|
|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
package com.biutag.lan.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Assert; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.biutag.core.PageResult; |
|
|
|
|
@ -12,6 +12,7 @@ import com.biutag.enums.RoleEnum;
|
|
|
|
|
import com.biutag.exception.OperateException; |
|
|
|
|
import com.biutag.lan.config.AdminThreadLocal; |
|
|
|
|
import com.biutag.lan.enums.PostEnums; |
|
|
|
|
import com.biutag.lan.mapper.PoliceUserMapper; |
|
|
|
|
import com.biutag.lan.service.IPermService; |
|
|
|
|
import com.biutag.lan.service.IPoliceUserService; |
|
|
|
|
import com.biutag.lan.validate.commons.PageValidate; |
|
|
|
|
@ -23,8 +24,14 @@ import com.biutag.lan.vo.system.PoliceUserDetailVo;
|
|
|
|
|
import com.biutag.lan.vo.system.PoliceUserInformVo; |
|
|
|
|
import com.biutag.lan.vo.system.PoliceUserListedVo; |
|
|
|
|
import com.biutag.lan.vo.system.PoliceUserSelvesVo; |
|
|
|
|
import com.biutag.mapper.system.*; |
|
|
|
|
import com.biutag.util.*; |
|
|
|
|
import com.biutag.mapper.system.MenuMapper; |
|
|
|
|
import com.biutag.mapper.system.PoliceDepartMapper; |
|
|
|
|
import com.biutag.mapper.system.PolicePositionMapper; |
|
|
|
|
import com.biutag.mapper.system.PoliceRoleMapper; |
|
|
|
|
import com.biutag.util.StringUtils; |
|
|
|
|
import com.biutag.util.TimeUtils; |
|
|
|
|
import com.biutag.util.ToolUtils; |
|
|
|
|
import com.biutag.util.UrlUtils; |
|
|
|
|
import com.github.yulichang.query.MPJQueryWrapper; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
@ -44,14 +51,6 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
|
|
|
|
|
@Resource |
|
|
|
|
MenuMapper menuMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
DeptMapper deptMapper; |
|
|
|
|
@Resource |
|
|
|
|
PostMapper postMapper; |
|
|
|
|
@Resource |
|
|
|
|
RoleMapper roleMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
PolicePositionMapper policePositionMapper; |
|
|
|
|
@Resource |
|
|
|
|
@ -74,94 +73,25 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
|
|
|
|
|
public PageResult<PoliceUserListedVo> list(PageValidate pageValidate, PoliceUserSearchValidate searchValidate) { |
|
|
|
|
Integer page = pageValidate.getPageNo(); |
|
|
|
|
Integer limit = pageValidate.getPageSize(); |
|
|
|
|
|
|
|
|
|
MPJQueryWrapper<PoliceUser> mpjQueryWrapper = new MPJQueryWrapper<>(); |
|
|
|
|
mpjQueryWrapper.select("t.id,t.name,t.emp_no, t.phone, t.username,t.nickname,t.avatar," + |
|
|
|
|
"t.post_ids as post,t.role_ids as role,t.dept_ids as dept,t.is_multipoint,t.mobile,t.id_code,t.job,t.job_type," + |
|
|
|
|
"t.is_disable,t.last_login_ip,t.last_login_time,t.create_time,t.update_time") |
|
|
|
|
.eq("t.is_delete", 0) |
|
|
|
|
.orderByDesc(Arrays.asList("t.id", "t.sort")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
policeUserMapper.setSearch(mpjQueryWrapper, searchValidate, new String[]{ |
|
|
|
|
"like:empNo@emp_no:str", |
|
|
|
|
"like:name:str", |
|
|
|
|
"like:mobile:str", |
|
|
|
|
"like:idCode@id_code:str" |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotNull(searchValidate.getRole())) { |
|
|
|
|
mpjQueryWrapper.in("role_ids", Collections.singletonList(searchValidate.getRole())); |
|
|
|
|
QueryWrapper<PoliceUser> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq(StrUtil.isNotBlank(searchValidate.getEmpNo()), "u.emp_no", searchValidate.getEmpNo()) |
|
|
|
|
.like(StrUtil.isNotBlank(searchValidate.getName()), "u.name", searchValidate.getName()) |
|
|
|
|
.like(StrUtil.isNotBlank(searchValidate.getIdCode()), "u.id_code", searchValidate.getIdCode()) |
|
|
|
|
.eq(Objects.nonNull(searchValidate.getRole()), "u.role_ids", searchValidate.getRole()) |
|
|
|
|
.eq(StrUtil.isNotBlank(searchValidate.getDeptId()), "u.dept_ids", searchValidate.getDeptId()); |
|
|
|
|
Integer roleId = AdminThreadLocal.getRoleId(); |
|
|
|
|
Integer deptId = AdminThreadLocal.getDeptId(); |
|
|
|
|
if (RoleEnum.SECOND_DEPT_CLASSES.getRoleId().equals(roleId)) { |
|
|
|
|
queryWrapper.and(query -> { |
|
|
|
|
query.eq("u.dept_ids", deptId).or().eq("d.pid", deptId); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNotEmpty(searchValidate.getDeptId())&&!"1".equals(searchValidate.getDeptId())) { |
|
|
|
|
//查询当前deptid下的所有机构id
|
|
|
|
|
List<String> ids = deptMapper.selectListById(searchValidate.getDeptId()); |
|
|
|
|
mpjQueryWrapper.in("dept_ids", ids); |
|
|
|
|
if (RoleEnum.THREE_DEPT_CLASSES.getRoleId().equals(roleId)) { |
|
|
|
|
queryWrapper.eq("u.dept_ids", deptId); |
|
|
|
|
} |
|
|
|
|
IPage<PoliceUserListedVo> iPage = policeUserMapper.selectJoinPage( |
|
|
|
|
new Page<>(page, limit), |
|
|
|
|
PoliceUserListedVo.class, |
|
|
|
|
mpjQueryWrapper); |
|
|
|
|
|
|
|
|
|
for (PoliceUserListedVo vo : iPage.getRecords()) { |
|
|
|
|
if (vo.getId().equals(1)) { |
|
|
|
|
vo.setRole("系统管理员"); |
|
|
|
|
} else { |
|
|
|
|
if(StringUtils.isNotNull(vo.getRole())) { |
|
|
|
|
List<String> role = new LinkedList<>(); |
|
|
|
|
List<Integer> roleIds = ListUtils.stringToListAsInt(vo.getRole(), ","); |
|
|
|
|
if (!roleIds.isEmpty()) { |
|
|
|
|
List<Role> roleList = roleMapper.selectList(new QueryWrapper<Role>() |
|
|
|
|
.select("id,name") |
|
|
|
|
.in("id", roleIds)); |
|
|
|
|
for (Role d : roleList) { |
|
|
|
|
role.add(d.getName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
vo.setRole(ListUtils.listToStringByStr(role, ",")); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNull(vo.getPost()) || vo.getPost().equals("")) { |
|
|
|
|
vo.setPost(""); |
|
|
|
|
}else { |
|
|
|
|
List<String> post = new LinkedList<>(); |
|
|
|
|
List<Integer> postIds = ListUtils.stringToListAsInt(vo.getPost(), ","); |
|
|
|
|
if (!postIds.isEmpty()) { |
|
|
|
|
List<Post> postList = postMapper.selectList(new QueryWrapper<Post>() |
|
|
|
|
.select("id,name") |
|
|
|
|
.in("id", postIds)); |
|
|
|
|
for (Post d : postList) { |
|
|
|
|
post.add(d.getName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
vo.setPost(ListUtils.listToStringByStr(post, ",")); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isNull(vo.getDept()) || vo.getDept().equals("")) { |
|
|
|
|
vo.setDept(""); |
|
|
|
|
} else { |
|
|
|
|
List<String> dept = new LinkedList<>(); |
|
|
|
|
List<Integer> deptIds = ListUtils.stringToListAsInt(vo.getDept(), ","); |
|
|
|
|
if (!deptIds.isEmpty()) { |
|
|
|
|
List<Dept> deptList = deptMapper.selectList(new QueryWrapper<Dept>() |
|
|
|
|
.select("id,name") |
|
|
|
|
.in("id", deptIds) |
|
|
|
|
.eq("is_delete", 0)); |
|
|
|
|
for (Dept d : deptList) { |
|
|
|
|
dept.add(d.getName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
vo.setDept(ListUtils.listToStringByStr(dept, ",")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vo.setAvatar(UrlUtils.toAbsoluteUrl(vo.getAvatar())); |
|
|
|
|
vo.setCreateTime(TimeUtils.timestampToDate(vo.getCreateTime())); |
|
|
|
|
vo.setUpdateTime(TimeUtils.timestampToDate(vo.getUpdateTime())); |
|
|
|
|
vo.setLastLoginTime(TimeUtils.timestampToDate(vo.getLastLoginTime())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return PageResult.iPageHandle(iPage); |
|
|
|
|
queryWrapper.orderByAsc("d.sort").orderByAsc("u.post_ids"); |
|
|
|
|
Page<PoliceUserListedVo> pages = policeUserMapper.selectPage(new Page<>(page, limit), queryWrapper); |
|
|
|
|
return PageResult.iPageHandle(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -247,9 +177,9 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
|
|
|
|
|
// 角色权限
|
|
|
|
|
List<String> auths = new LinkedList<>(); |
|
|
|
|
if (adminId > 1) { |
|
|
|
|
List<Integer> roleIds = ListUtils.stringToListAsInt(sysAdmin.getRoleIds(), ","); |
|
|
|
|
List<Integer> roleIds = Collections.singletonList(Integer.parseInt(sysAdmin.getRoleIds())); |
|
|
|
|
List<Integer> menuIds = iPermService.selectMenuIdsByRoleId(roleIds); |
|
|
|
|
if (menuIds.size() > 0) { |
|
|
|
|
if (!menuIds.isEmpty()) { |
|
|
|
|
List<Menu> Menus = menuMapper.selectList(new QueryWrapper<Menu>() |
|
|
|
|
.eq("is_disable", 0) |
|
|
|
|
.in("id", menuIds) |
|
|
|
|
@ -297,24 +227,16 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
|
|
|
|
|
.eq("id", id) |
|
|
|
|
.eq("is_delete", 0) |
|
|
|
|
.last("limit 1")); |
|
|
|
|
|
|
|
|
|
Assert.notNull(sysAdmin, "账号已不存在!"); |
|
|
|
|
|
|
|
|
|
PoliceUserDetailVo vo = new PoliceUserDetailVo(); |
|
|
|
|
BeanUtils.copyProperties(sysAdmin, vo); |
|
|
|
|
if(StringUtils.isNotNull(sysAdmin.getRoleIds())) { |
|
|
|
|
vo.setRoleIds(Integer.parseInt(sysAdmin.getRoleIds())); |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isNotNull(sysAdmin.getDeptIds())) { |
|
|
|
|
vo.setDeptIds(ListUtils.stringToListAsInt(sysAdmin.getDeptIds(), ",")); |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isNotNull(sysAdmin.getPostIds())) { |
|
|
|
|
vo.setPostIds(ListUtils.stringToListAsInt(sysAdmin.getPostIds(), ",")); |
|
|
|
|
} |
|
|
|
|
vo.setAvatar(UrlUtils.toAbsoluteUrl(sysAdmin.getAvatar())); |
|
|
|
|
vo.setCreateTime(TimeUtils.timestampToDate(sysAdmin.getCreateTime())); |
|
|
|
|
vo.setUpdateTime(TimeUtils.timestampToDate(sysAdmin.getUpdateTime())); |
|
|
|
|
vo.setLastLoginTime(TimeUtils.timestampToDate(sysAdmin.getLastLoginTime())); |
|
|
|
|
vo.setRoleIds(Integer.valueOf(sysAdmin.getRoleIds())); |
|
|
|
|
vo.setDeptIds(Integer.valueOf(sysAdmin.getDeptIds())); |
|
|
|
|
vo.setPostIds(Integer.valueOf(sysAdmin.getPostIds())); |
|
|
|
|
return vo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -353,12 +275,12 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
|
|
|
|
|
|
|
|
|
|
PoliceUser model = new PoliceUser(); |
|
|
|
|
|
|
|
|
|
model.setRoleIds(ListUtils.listToStringByInt(createValidate.getRoleIds(), ",")); |
|
|
|
|
this.batchSaveRoleByEmpNo(createValidate.getEmpNo(),createValidate.getRoleIds()); |
|
|
|
|
model.setDeptIds(ListUtils.listToStringByInt(createValidate.getDeptIds(), ",")); |
|
|
|
|
this.batchSaveDepartByEmpNo(createValidate.getEmpNo(),createValidate.getDeptIds()); |
|
|
|
|
model.setPostIds(ListUtils.listToStringByInt(createValidate.getPostIds(), ",")); |
|
|
|
|
this.batchSavePositionByEmpNo(createValidate.getEmpNo(),createValidate.getPostIds()); |
|
|
|
|
model.setRoleIds(createValidate.getRoleIds().toString()); |
|
|
|
|
this.batchSaveRoleByEmpNo(createValidate.getEmpNo(), Arrays.asList(createValidate.getRoleIds())); |
|
|
|
|
model.setDeptIds(createValidate.getDeptIds().toString()); |
|
|
|
|
this.batchSaveDepartByEmpNo(createValidate.getEmpNo(), Arrays.asList(createValidate.getDeptIds())); |
|
|
|
|
model.setPostIds(createValidate.getPostIds().toString()); |
|
|
|
|
this.batchSavePositionByEmpNo(createValidate.getEmpNo(), Arrays.asList(createValidate.getPostIds())); |
|
|
|
|
model.setEmpNo(createValidate.getEmpNo()); |
|
|
|
|
model.setName(createValidate.getName()); |
|
|
|
|
model.setAvatar(avatar); |
|
|
|
|
@ -394,8 +316,6 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
|
|
|
|
|
.eq("is_delete", 0) |
|
|
|
|
.last("limit 1")), "账号不存在了!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.isNull(policeUserMapper.selectOne(new QueryWrapper<PoliceUser>() |
|
|
|
|
.select(field) |
|
|
|
|
.eq("is_delete", 0) |
|
|
|
|
@ -419,15 +339,13 @@ public class PoliceUserServiceImpl implements IPoliceUserService {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(StringUtils.isNotNull(updateValidate.getDeptIds())) { |
|
|
|
|
model.setDeptIds(ListUtils.listToStringByInt(updateValidate.getDeptIds(), ",")); |
|
|
|
|
if(!policeUser.getDeptIds().equals(model.getDeptIds())){ |
|
|
|
|
this.batchSaveDepartByEmpNo(updateValidate.getEmpNo(),updateValidate.getDeptIds()); |
|
|
|
|
this.batchSaveDepartByEmpNo(updateValidate.getEmpNo(), Collections.singletonList(updateValidate.getDeptIds())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(StringUtils.isNotNull(updateValidate.getPostIds())) { |
|
|
|
|
model.setPostIds(ListUtils.listToStringByInt(updateValidate.getPostIds(), ",")); |
|
|
|
|
if(!policeUser.getPostIds().equals(model.getPostIds())){ |
|
|
|
|
this.batchSavePositionByEmpNo(updateValidate.getEmpNo(),updateValidate.getPostIds()); |
|
|
|
|
this.batchSavePositionByEmpNo(updateValidate.getEmpNo(), Collections.singletonList(updateValidate.getPostIds())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|