| | |
| | | EntityWrapper<Role> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("name", condition); |
| | | // 上下级管理 |
| | | List<Long> leaderIds = new ArrayList<>(); |
| | | |
| | | if (9527 != getUserId()) { |
| | | Long roleId = getUser().getRoleId(); |
| | | Role role = roleService.selectById(roleId); |
| | | Long leaderId = role.getLeader(); |
| | | if (null != leaderId) { |
| | | List<Long> leaderIds = new ArrayList<>(); |
| | | while (leaderId != null) { |
| | | Role leader = roleService.selectById(leaderId); |
| | | leaderIds.add(leader.getId()); |
| | |
| | | // } |
| | | } |
| | | |
| | | Page<Role> page = roleService.selectPage(new Page<>(0, 10), wrapper); |
| | | // Page<Role> page = roleService.selectPage(new Page<>(0, 10), wrapper); |
| | | |
| | | List<Role> roleList = roleService.selectRoleList((Cools.isEmpty(leaderIds) || leaderIds.isEmpty())? null : leaderIds,0,10); |
| | | Page<Role> page = new Page<Role>(0,10).setRecords(roleList); |
| | | page.setTotal(roleService.selectRoleListTotal((Cools.isEmpty(leaderIds) || leaderIds.isEmpty())? null : leaderIds)); |
| | | |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Role role : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | convert(param, wrapper); |
| | | wrapper.orderBy("id", false); |
| | | if (9527 == getUserId()) { |
| | | return R.ok(userService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | List<User> userList = userService.selectUserList(null,curr,limit); |
| | | Page<User> page = new Page<User>(curr,limit).setRecords(userList); |
| | | page.setTotal(userService.selectUserListTotal(null)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | Long roleId = getUser().getRoleId(); |
| | | Role role = roleService.selectById(roleId); |
| | | Long leaderId = role.getLeader(); |
| | | if (null != leaderId) { |
| | | List<Long> leaderIds = new ArrayList<>(); |
| | | if (null != leaderId) { |
| | | leaderIds.add(role.getId()); |
| | | while (leaderId != null) { |
| | | Role leader = roleService.selectById(leaderId); |
| | | leaderIds.add(leader.getId()); |
| | | leaderId = leader.getLeader(); |
| | | } |
| | | wrapper.notIn("role_id", leaderIds); |
| | | } |
| | | |
| | | return R.ok(userService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | List<User> userList = userService.selectUserList(leaderIds,curr,limit); |
| | | Page<User> page = new Page<User>(curr,limit).setRecords(userList); |
| | | page.setTotal(userService.selectUserListTotal(leaderIds)); |
| | | return R.ok(page); |
| | | } |
| | | |
| | | private void convert(Map<String, Object> map, EntityWrapper wrapper){ |
| | |
| | | @RequestMapping(value = "/user/add/auth") |
| | | @ManagerAuth(memo = "系统用户添加") |
| | | public R add(User user) { |
| | | user.setStatus(1); |
| | | userService.insert(user); |
| | | return R.ok(); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.mapper.BaseMapper; |
| | | import com.zy.system.entity.User; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface UserMapper extends BaseMapper<User> { |
| | | |
| | | |
| | | List<User> selectUserList(@Param("leaderIdList") List<Long> leaderIdList, |
| | | @Param("pageNumber") Integer curr, |
| | | @Param("pageSize") Integer limit); |
| | | |
| | | Long selectUserListTotal(@Param("leaderIdList") List<Long> leaderIdList); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.zy.system.entity.User; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface UserService extends IService<User> { |
| | | |
| | | List<User> selectUserList(List<Long> leaderIdList, Integer curr, Integer limit); |
| | | |
| | | Long selectUserListTotal(List<Long> leaderIdList); |
| | | } |
| | |
| | | import com.zy.system.service.UserService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Service("userService") |
| | | public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { |
| | | @Override |
| | | public List<User> selectUserList(List<Long> leaderIdList, Integer curr, Integer limit){ |
| | | return this.baseMapper.selectUserList(leaderIdList,curr,limit); |
| | | }; |
| | | |
| | | @Override |
| | | public Long selectUserListTotal(List<Long> leaderIdList){ |
| | | return this.baseMapper.selectUserListTotal(leaderIdList); |
| | | }; |
| | | |
| | | } |
| | |
| | | |
| | | </resultMap> |
| | | |
| | | <sql id="batchSeq"> |
| | | <if test="id != null and id != 0"> |
| | | and a.ID = #{id} |
| | | </if> |
| | | <if test="name != null and name != ''"> |
| | | and a.NAME = #{name} |
| | | </if> |
| | | </sql> |
| | | |
| | | <select id="selectRoleList" resultMap="BaseResultMap"> |
| | | SELECT * FROM "SOURCE"."sys_role" |
| | | WHERE 1=1 |
| | |
| | | </select> |
| | | |
| | | <select id="selectRoleListTotal" resultType="Long"> |
| | | SELECT count(1) FROM "SOURCE"."wcs_api_config" |
| | | SELECT count(1) FROM "SOURCE"."sys_role" |
| | | WHERE 1=1 |
| | | <if test="leaderIdList != null and leaderIdList != ''"> |
| | | and ID not in |
| | |
| | | |
| | | </resultMap> |
| | | |
| | | <select id="selectUserList" resultMap="BaseResultMap"> |
| | | SELECT * FROM "SOURCE"."sys_user" |
| | | WHERE 1=1 |
| | | <if test="leaderIdList != null and leaderIdList != ''"> |
| | | and ID not in |
| | | <foreach collection="leaderIdList" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | ORDER BY ID DESC |
| | | LIMIT #{pageSize} OFFSET ((#{pageNumber} - 1) * #{pageSize}); |
| | | </select> |
| | | |
| | | <select id="selectUserListTotal" resultType="Long"> |
| | | SELECT count(1) FROM "SOURCE"."sys_user" |
| | | WHERE 1=1 |
| | | <if test="leaderIdList != null and leaderIdList != ''"> |
| | | and ID not in |
| | | <foreach collection="leaderIdList" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |