update 修改框架中批量接口,改为原生mybatis执行foreach,改善性能
| | |
| | | */ |
| | | public List<Integer> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); |
| | | |
| | | /** |
| | | * 修改子元素关系 |
| | | * |
| | | * @param depts 子元素 |
| | | * @return 结果 |
| | | */ |
| | | public int updateDeptChildren(@Param("depts") List<SysDept> depts); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.core.page.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色与部门关联表 数据层 |
| | | * |
| | |
| | | */ |
| | | public interface SysRoleDeptMapper extends BaseMapperPlus<SysRoleDept> { |
| | | |
| | | /** |
| | | * 批量新增角色部门信息 |
| | | * |
| | | * @param roleDeptList 角色部门列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchRoleDept(List<SysRoleDept> roleDeptList); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.core.page.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色与菜单关联表 数据层 |
| | | * |
| | |
| | | */ |
| | | public interface SysRoleMenuMapper extends BaseMapperPlus<SysRoleMenu> { |
| | | |
| | | /** |
| | | * 批量新增角色菜单信息 |
| | | * |
| | | * @param roleMenuList 角色菜单列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchRoleMenu(List<SysRoleMenu> roleMenuList); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.core.page.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户与岗位关联表 数据层 |
| | | * |
| | |
| | | */ |
| | | public interface SysUserPostMapper extends BaseMapperPlus<SysUserPost> { |
| | | |
| | | /** |
| | | * 批量新增用户岗位信息 |
| | | * |
| | | * @param userPostList 用户角色列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchUserPost(List<SysUserPost> userPostList); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.common.core.page.BaseMapperPlus; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户与角色关联表 数据层 |
| | | * |
| | |
| | | */ |
| | | public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole> { |
| | | |
| | | /** |
| | | * 批量新增用户角色信息 |
| | | * |
| | | * @param userRoleList 用户角色列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchUserRole(List<SysUserRole> userRoleList); |
| | | |
| | | } |
| | |
| | | child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); |
| | | } |
| | | if (children.size() > 0) { |
| | | updateBatchById(children); |
| | | baseMapper.updateDeptChildren(children); |
| | | } |
| | | } |
| | | |
| | |
| | | list.add(rm); |
| | | } |
| | | if (list.size() > 0) { |
| | | for (SysRoleMenu sysRoleMenu : list) { |
| | | rows += roleMenuMapper.insert(sysRoleMenu); |
| | | } |
| | | rows = roleMenuMapper.batchRoleMenu(list); |
| | | } |
| | | return rows; |
| | | } |
| | |
| | | list.add(rd); |
| | | } |
| | | if (list.size() > 0) { |
| | | for (SysRoleDept sysRoleDept : list) { |
| | | rows += roleDeptMapper.insert(sysRoleDept); |
| | | } |
| | | rows = roleDeptMapper.batchRoleDept(list); |
| | | } |
| | | return rows; |
| | | } |
| | |
| | | list.add(ur); |
| | | } |
| | | if (list.size() > 0) { |
| | | for (SysUserRole sysUserRole : list) { |
| | | userRoleMapper.insert(sysUserRole); |
| | | } |
| | | userRoleMapper.batchUserRole(list); |
| | | } |
| | | } |
| | | } |
| | |
| | | list.add(up); |
| | | } |
| | | if (list.size() > 0) { |
| | | for (SysUserPost sysUserPost : list) { |
| | | userPostMapper.insert(sysUserPost); |
| | | } |
| | | userPostMapper.batchUserPost(list); |
| | | } |
| | | } |
| | | } |
| | |
| | | order by d.parent_id, d.order_num |
| | | </select> |
| | | |
| | | <update id="updateDeptChildren" parameterType="java.util.List"> |
| | | update sys_dept set ancestors = |
| | | <foreach collection="depts" item="item" index="index" |
| | | separator=" " open="case dept_id" close="end"> |
| | | when #{item.deptId} then #{item.ancestors} |
| | | </foreach> |
| | | where dept_id in |
| | | <foreach collection="depts" item="item" index="index" |
| | | separator="," open="(" close=")"> |
| | | #{item.deptId} |
| | | </foreach> |
| | | </update> |
| | | |
| | | </mapper> |
| | |
| | | <result property="deptId" column="dept_id"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | | <insert id="batchRoleDept"> |
| | | insert into sys_role_dept(role_id, dept_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.roleId},#{item.deptId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | <result property="menuId" column="menu_id"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | | <insert id="batchRoleMenu"> |
| | | insert into sys_role_menu(role_id, menu_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.roleId},#{item.menuId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | <result property="postId" column="post_id"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | | <insert id="batchUserPost"> |
| | | insert into sys_user_post(user_id, post_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.userId},#{item.postId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | <result property="roleId" column="role_id"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | | <insert id="batchUserRole"> |
| | | insert into sys_user_role(user_id, role_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.userId},#{item.roleId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |