feat(department): 完善部门管理功能并优化用户关联逻辑
- 新增部门子级数据结构定义,包括DepartmentChildItemVO和DepartmentChildVO - 在AppUserForAdminVO和AppUserVO中添加部门名称字段用于显示 - 实现部门与用户的关联查询,在多处服务层添加部门名称映射 - 重构部门控制器中的删除验证逻辑,改为检查子级和管理员用户 - 添加获取部门绑定用户和子级部门的接口方法 - 优化部门启用禁用功能,支持批量操作和状态更新 - 修复用户更新时的部门变更处理逻辑,确保部门管理员状态正确更新 - 重构部门服务层的hasManager字段更新逻辑,提高数据一致性
This commit is contained in:
parent
6f845e50ae
commit
2823430d31
|
|
@ -17,6 +17,7 @@ import com.nflg.mobilebroken.common.pojo.vo.TitleSimpleVO;
|
||||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
import com.nflg.mobilebroken.repository.entity.AdminUser;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.nflg.mobilebroken.repository.service.IAdminUserService;
|
import com.nflg.mobilebroken.repository.service.IAdminUserService;
|
||||||
import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService;
|
import com.nflg.mobilebroken.repository.service.IDictionaryItemTranslateService;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
|
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
|
||||||
|
|
@ -134,8 +135,16 @@ public class AdminUserController extends ControllerBase {
|
||||||
@PostMapping("updateAccount")
|
@PostMapping("updateAccount")
|
||||||
@MethodInfoMark(value = "更新账号", menuName = "账号管理")
|
@MethodInfoMark(value = "更新账号", menuName = "账号管理")
|
||||||
@ApiMark(moduleName = "账号管理", apiName = "更新账号")
|
@ApiMark(moduleName = "账号管理", apiName = "更新账号")
|
||||||
public ApiResult<Void> updateAccount(@Valid @RequestBody AccountUpdateRequest request) throws MessagingException {
|
public ApiResult<Void> updateAccount(@Valid @RequestBody AccountUpdateRequest request) {
|
||||||
AdminUser user=adminUserService.getById(request.getId());
|
AdminUser user=adminUserService.getById(request.getId());
|
||||||
|
if (!Objects.equals(user.getDepartmentId(), request.getDepartmentId())) {
|
||||||
|
departmentService.updateHasManager(user.getDepartmentId());
|
||||||
|
departmentService.lambdaUpdate()
|
||||||
|
.set(TBaseDepartment::isHasManager, true)
|
||||||
|
.eq(TBaseDepartment::isHasManager, false)
|
||||||
|
.eq(TBaseDepartment::getId, request.getDepartmentId())
|
||||||
|
.update();
|
||||||
|
}
|
||||||
user.setUserCode(request.getUserCode())
|
user.setUserCode(request.getUserCode())
|
||||||
.setUserName(request.getUserName())
|
.setUserName(request.getUserName())
|
||||||
.setAvatar(request.getAvatar())
|
.setAvatar(request.getAvatar())
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
import com.nflg.mobilebroken.repository.entity.AppUser;
|
import com.nflg.mobilebroken.repository.entity.AppUser;
|
||||||
import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
|
import com.nflg.mobilebroken.repository.entity.AppUserApplyfor;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
import com.nflg.mobilebroken.repository.entity.TBaseCustomer;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.nflg.mobilebroken.repository.service.*;
|
import com.nflg.mobilebroken.repository.service.*;
|
||||||
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||||
import com.nflg.mobilebroken.starter.service.EmailService;
|
import com.nflg.mobilebroken.starter.service.EmailService;
|
||||||
|
|
@ -78,6 +79,9 @@ public class AppUserController extends ControllerBase {
|
||||||
@Resource
|
@Resource
|
||||||
private IAdminMessageService adminMessageService;
|
private IAdminMessageService adminMessageService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITBaseDepartmentService departmentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取公司列表
|
* 获取公司列表
|
||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
|
|
@ -206,6 +210,16 @@ public class AppUserController extends ControllerBase {
|
||||||
@ApiMark(moduleName = "代理商管理", apiName = "更新代理商账号")
|
@ApiMark(moduleName = "代理商管理", apiName = "更新代理商账号")
|
||||||
public ApiResult<Void> updateAppUser(@Valid @RequestBody AppUserUpdateRequest request) {
|
public ApiResult<Void> updateAppUser(@Valid @RequestBody AppUserUpdateRequest request) {
|
||||||
AppUser user=appUserService.getById(request.getId());
|
AppUser user=appUserService.getById(request.getId());
|
||||||
|
if (!Objects.equals(user.getDepartmentId(), request.getDepartmentId())) {
|
||||||
|
if (Objects.nonNull(user.getDepartmentId())) {
|
||||||
|
departmentService.updateHasManager(user.getDepartmentId());
|
||||||
|
}
|
||||||
|
departmentService.lambdaUpdate()
|
||||||
|
.set(TBaseDepartment::isHasManager, true)
|
||||||
|
.eq(TBaseDepartment::isHasManager, false)
|
||||||
|
.eq(TBaseDepartment::getId, request.getDepartmentId())
|
||||||
|
.update();
|
||||||
|
}
|
||||||
user.setExpireTime(user.getExpireTime().plusDays(1));
|
user.setExpireTime(user.getExpireTime().plusDays(1));
|
||||||
if (user.getIsPrimary()){
|
if (user.getIsPrimary()){
|
||||||
updatePrimaryAppUser(user,request);
|
updatePrimaryAppUser(user,request);
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
package com.nflg.mobilebroken.admin.controller;
|
package com.nflg.mobilebroken.admin.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||||
import com.nflg.mobilebroken.admin.constant.Constant;
|
import com.nflg.mobilebroken.admin.constant.Constant;
|
||||||
import com.nflg.mobilebroken.admin.pojo.dto.DepartmentDTO;
|
import com.nflg.mobilebroken.admin.pojo.dto.DepartmentDTO;
|
||||||
import com.nflg.mobilebroken.admin.pojo.query.DepartmentQuery;
|
import com.nflg.mobilebroken.admin.pojo.query.DepartmentQuery;
|
||||||
import com.nflg.mobilebroken.admin.pojo.vo.BaseDepartmentVO;
|
import com.nflg.mobilebroken.admin.pojo.vo.BaseDepartmentVO;
|
||||||
import com.nflg.mobilebroken.admin.service.AdminDepartmentService;
|
import com.nflg.mobilebroken.admin.service.AdminDepartmentService;
|
||||||
import com.nflg.mobilebroken.common.constant.STATE;
|
|
||||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
|
||||||
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildVO;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
||||||
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
import com.nflg.mobilebroken.common.util.AdminUserUtil;
|
||||||
import com.nflg.mobilebroken.common.util.UniqueSequenceGenerator;
|
import com.nflg.mobilebroken.common.util.UniqueSequenceGenerator;
|
||||||
import com.nflg.mobilebroken.common.util.VUtils;
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
|
|
@ -26,6 +27,8 @@ import javax.validation.Valid;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门管理
|
* 部门管理
|
||||||
|
|
@ -47,9 +50,9 @@ public class DepartmentController extends ControllerBase {
|
||||||
*/
|
*/
|
||||||
@PostMapping("getList")
|
@PostMapping("getList")
|
||||||
@ApiMark(moduleName = "部门管理", apiName = "获取部门列表")
|
@ApiMark(moduleName = "部门管理", apiName = "获取部门列表")
|
||||||
public ApiResult<PageData<BaseDepartmentVO>> getList(@RequestBody DepartmentQuery query){
|
public ApiResult<PageData<BaseDepartmentVO>> getList(@RequestBody DepartmentQuery query) {
|
||||||
|
|
||||||
return adminDepartmentService.getList(query);
|
return adminDepartmentService.getList(query);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +64,7 @@ public class DepartmentController extends ControllerBase {
|
||||||
*/
|
*/
|
||||||
@GetMapping("getChild")
|
@GetMapping("getChild")
|
||||||
@ApiMark(moduleName = "部门管理", apiName = "获取子级")
|
@ApiMark(moduleName = "部门管理", apiName = "获取子级")
|
||||||
public ApiResult<List<TBaseDepartment>> getChild(@RequestParam("parentId") Long parentId ){
|
public ApiResult<List<TBaseDepartment>> getChild(@RequestParam("parentId") Long parentId) {
|
||||||
|
|
||||||
return ApiResult.success(departmentService.getChildByParentId(parentId));
|
return ApiResult.success(departmentService.getChildByParentId(parentId));
|
||||||
}
|
}
|
||||||
|
|
@ -72,20 +75,19 @@ public class DepartmentController extends ControllerBase {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("add")
|
@PostMapping("add")
|
||||||
@MethodInfoMark(value = "新增" ,menuName = "部门管理")
|
@MethodInfoMark(value = "新增", menuName = "部门管理")
|
||||||
@ApiMark(moduleName = "部门管理", apiName = "新增")
|
@ApiMark(moduleName = "部门管理", apiName = "新增")
|
||||||
public ApiResult<Boolean> add(@Valid @RequestBody DepartmentDTO departmentDTO){
|
public ApiResult<Boolean> add(@Valid @RequestBody DepartmentDTO departmentDTO) {
|
||||||
|
|
||||||
// List<TBaseDepartment> checkCode = departmentService.lambdaQuery().eq(TBaseDepartment::getDeptCode, departmentDTO.getDeptCode()).list();
|
// List<TBaseDepartment> checkCode = departmentService.lambdaQuery().eq(TBaseDepartment::getDeptCode, departmentDTO.getDeptCode()).list();
|
||||||
//新增
|
//新增
|
||||||
TBaseDepartment dept = Convert.convert(TBaseDepartment.class, departmentDTO);
|
TBaseDepartment dept = Convert.convert(TBaseDepartment.class, departmentDTO);
|
||||||
if(null==departmentDTO.getId() || departmentDTO.getId()==0){
|
if (null == departmentDTO.getId() || departmentDTO.getId() == 0) {
|
||||||
dept.setDeptCode(UniqueSequenceGenerator.generateCode(Constant.DeptCodePrefix));
|
dept.setDeptCode(UniqueSequenceGenerator.generateCode(Constant.DeptCodePrefix));
|
||||||
dept.setDataCreateUserNo(AdminUserUtil.getUserNo());
|
dept.setDataCreateUserNo(AdminUserUtil.getUserNo());
|
||||||
dept.setDataCreateUserName(AdminUserUtil.getUserName());
|
dept.setDataCreateUserName(AdminUserUtil.getUserName());
|
||||||
dept.setDataCreateTime(LocalDateTime.now());
|
dept.setDataCreateTime(LocalDateTime.now());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
dept.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
dept.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
||||||
dept.setDataModifyUserName(AdminUserUtil.getUserName());
|
dept.setDataModifyUserName(AdminUserUtil.getUserName());
|
||||||
dept.setDataModifyTime(LocalDateTime.now());
|
dept.setDataModifyTime(LocalDateTime.now());
|
||||||
|
|
@ -101,23 +103,33 @@ public class DepartmentController extends ControllerBase {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("del")
|
@PostMapping("del")
|
||||||
@MethodInfoMark(value = "删除",menuName = "部门管理")
|
@MethodInfoMark(value = "删除", menuName = "部门管理")
|
||||||
@ApiMark(moduleName = "部门管理", apiName = "删除")
|
@ApiMark(moduleName = "部门管理", apiName = "删除")
|
||||||
public ApiResult<Boolean> add(@RequestBody List<Long> ids ){
|
public ApiResult<Boolean> del(@RequestBody List<Long> ids) {
|
||||||
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要删除的数据");
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要删除的数据");
|
||||||
List<TBaseDepartment> delDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
List<TBaseDepartment> delDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
||||||
List<String> hasChildDeptNames=new ArrayList<>();
|
// List<String> hasChildDeptNames=new ArrayList<>();
|
||||||
List<Long> childIds=new ArrayList<>();
|
// List<Long> childIds=new ArrayList<>();
|
||||||
for (TBaseDepartment dept :delDepartments) {
|
// for (TBaseDepartment dept :delDepartments) {
|
||||||
childIds.clear();
|
// childIds.clear();
|
||||||
adminDepartmentService.getAllChildIds(dept,childIds);
|
// adminDepartmentService.getAllChildIds(dept,childIds);
|
||||||
if(CollUtil.isNotEmpty(childIds)){
|
// if(CollUtil.isNotEmpty(childIds)){
|
||||||
hasChildDeptNames.add(dept.getDeptName());
|
// hasChildDeptNames.add(dept.getDeptName());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if(CollUtil.isNotEmpty(hasChildDeptNames)){
|
// if(CollUtil.isNotEmpty(hasChildDeptNames)){
|
||||||
throw new NflgException(STATE.ParamErr, StrUtil.join(",", hasChildDeptNames)+" 存在子集,请先删除子级");
|
// throw new NflgException(STATE.ParamErr, StrUtil.join(",", hasChildDeptNames)+" 存在子集,请先删除子级");
|
||||||
}
|
// }
|
||||||
|
List<TBaseDepartment> errors = delDepartments.stream()
|
||||||
|
.filter(TBaseDepartment::isHasChild)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(errors))
|
||||||
|
.throwMessage("以下部门存在下级,不能删除:" + errors.stream().map(TBaseDepartment::getDeptName).collect(Collectors.joining(",")));
|
||||||
|
errors = delDepartments.stream()
|
||||||
|
.filter(TBaseDepartment::isHasManager)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
VUtils.trueThrowBusinessError(CollectionUtil.isNotEmpty(errors))
|
||||||
|
.throwMessage("以下部门存在用户,不能删除:" + errors.stream().map(TBaseDepartment::getDeptName).collect(Collectors.joining(",")));
|
||||||
departmentService.del(ids);
|
departmentService.del(ids);
|
||||||
return ApiResult.success(true);
|
return ApiResult.success(true);
|
||||||
}
|
}
|
||||||
|
|
@ -129,18 +141,18 @@ public class DepartmentController extends ControllerBase {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("enable")
|
@PostMapping("enable")
|
||||||
@MethodInfoMark(value = "启用",menuName = "部门管理")
|
@MethodInfoMark(value = "启用", menuName = "部门管理")
|
||||||
@ApiMark(moduleName = "部门管理", apiName = "启用")
|
@ApiMark(moduleName = "部门管理", apiName = "启用")
|
||||||
public ApiResult<Boolean> enable(@RequestBody List<Long> ids ){
|
public ApiResult<Boolean> enable(@RequestBody List<Long> ids) {
|
||||||
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
|
||||||
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
||||||
tBaseDepartments.forEach(u->{
|
tBaseDepartments.forEach(u -> {
|
||||||
u.setDeptStatus(1);
|
u.setDeptStatus(1);
|
||||||
u.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
u.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
||||||
u.setDataModifyUserName(AdminUserUtil.getUserName());
|
u.setDataModifyUserName(AdminUserUtil.getUserName());
|
||||||
u.setDataModifyTime(LocalDateTime.now());
|
u.setDataModifyTime(LocalDateTime.now());
|
||||||
});
|
});
|
||||||
if(CollUtil.isNotEmpty(tBaseDepartments)){
|
if (CollUtil.isNotEmpty(tBaseDepartments)) {
|
||||||
departmentService.updateBatchById(tBaseDepartments);
|
departmentService.updateBatchById(tBaseDepartments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,37 +166,86 @@ public class DepartmentController extends ControllerBase {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("disable")
|
@PostMapping("disable")
|
||||||
@MethodInfoMark(value = "禁用",menuName = "部门管理")
|
@MethodInfoMark(value = "禁用", menuName = "部门管理")
|
||||||
@ApiMark(moduleName = "部门管理", apiName = "禁用")
|
@ApiMark(moduleName = "部门管理", apiName = "禁用")
|
||||||
public ApiResult<Boolean> disable(@RequestBody List<Long> ids ){
|
public ApiResult<Boolean> disable(@RequestBody List<Long> ids) {
|
||||||
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要启用的数据");
|
||||||
|
|
||||||
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
List<TBaseDepartment> tBaseDepartments = departmentService.getBaseMapper().selectByIds(ids);
|
||||||
List<Long> childIds=new ArrayList<>();
|
List<Long> childIds = new ArrayList<>();
|
||||||
childIds.addAll(ids);
|
childIds.addAll(ids);
|
||||||
for (TBaseDepartment tBaseDepartment : tBaseDepartments) {
|
for (TBaseDepartment tBaseDepartment : tBaseDepartments) {
|
||||||
adminDepartmentService.getAllChildIds(tBaseDepartment, childIds);
|
adminDepartmentService.getAllChildIds(tBaseDepartment, childIds);
|
||||||
}
|
}
|
||||||
tBaseDepartments = departmentService.getBaseMapper().selectByIds(childIds);
|
tBaseDepartments = departmentService.getBaseMapper().selectByIds(childIds);
|
||||||
tBaseDepartments.forEach(u->{
|
tBaseDepartments.forEach(u -> {
|
||||||
u.setDeptStatus(0);
|
u.setDeptStatus(0);
|
||||||
u.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
u.setDataModifyUserNo(AdminUserUtil.getUserNo());
|
||||||
u.setDataModifyUserName(AdminUserUtil.getUserName());
|
u.setDataModifyUserName(AdminUserUtil.getUserName());
|
||||||
u.setDataModifyTime(LocalDateTime.now());
|
u.setDataModifyTime(LocalDateTime.now());
|
||||||
});
|
});
|
||||||
if(CollUtil.isNotEmpty(tBaseDepartments)){
|
if (CollUtil.isNotEmpty(tBaseDepartments)) {
|
||||||
departmentService.updateBatchById(tBaseDepartments);
|
departmentService.updateBatchById(tBaseDepartments);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ApiResult.success(true);
|
return ApiResult.success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取绑定的用户和子级部门
|
||||||
|
* @param id 部门id
|
||||||
|
*/
|
||||||
|
@GetMapping("getChildren")
|
||||||
|
public ApiResult<DepartmentChildVO> getChildren(@RequestParam Long id) {
|
||||||
|
List<TBaseDepartment> departments = departmentService.lambdaQuery().eq(TBaseDepartment::getDataValidStatus, 1).list();
|
||||||
|
TBaseDepartment department = departments.stream().filter(u -> u.getId().equals(id)).findFirst().orElse(null);
|
||||||
|
VUtils.trueThrowBusinessError(Objects.isNull(department)).throwMessage("部门不存在");
|
||||||
|
List<DepartmentChildItemVO> itemVOS = new ArrayList<>();
|
||||||
|
List<DepartmentChildItemVO> users = departmentService.getUsers(id);
|
||||||
|
if (CollUtil.isNotEmpty(users)) {
|
||||||
|
itemVOS.addAll(users);
|
||||||
|
}
|
||||||
|
List<TBaseDepartment> childs = departments.stream()
|
||||||
|
.filter(di -> Objects.equals(di.getDeptParentId(), id))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if (CollUtil.isNotEmpty(childs)) {
|
||||||
|
itemVOS.addAll(
|
||||||
|
childs.stream().map(c -> new DepartmentChildItemVO()
|
||||||
|
.setId(c.getId())
|
||||||
|
.setName(c.getDeptName())
|
||||||
|
.setType(0)
|
||||||
|
.setState(c.getDeptStatus())
|
||||||
|
.setCreateBy(c.getDataCreateUserName())
|
||||||
|
.setCreateTime(c.getDataCreateTime())
|
||||||
|
.setUpdateBy(c.getDataModifyUserName())
|
||||||
|
.setUpdateTime(c.getDataModifyTime())
|
||||||
|
)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<DepartmentSimpleVO> paths = new ArrayList<>();
|
||||||
|
paths.add(new DepartmentSimpleVO()
|
||||||
|
.setId(department.getId())
|
||||||
|
.setName(department.getDeptName())
|
||||||
|
);
|
||||||
|
bindParent(paths, department, departments);
|
||||||
|
return ApiResult.success(new DepartmentChildVO()
|
||||||
|
.setPaths(paths)
|
||||||
|
.setItems(itemVOS)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindParent(List<DepartmentSimpleVO> paths, TBaseDepartment department, List<TBaseDepartment> departments) {
|
||||||
|
TBaseDepartment parent = departments.stream()
|
||||||
|
.filter(di -> Objects.equals(di.getId(), department.getDeptParentId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (Objects.nonNull(parent)) {
|
||||||
|
paths.add(0, new DepartmentSimpleVO()
|
||||||
|
.setId(parent.getId())
|
||||||
|
.setName(parent.getDeptName())
|
||||||
|
);
|
||||||
|
bindParent(paths, parent, departments);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,11 @@ public class AppUserForAdminVO {
|
||||||
*/
|
*/
|
||||||
private Long departmentId;
|
private Long departmentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
private String departmentName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地域类型,字典id
|
* 地域类型,字典id
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -106,4 +106,14 @@ public class AppUserVO {
|
||||||
|
|
||||||
//平台,app或者admin
|
//平台,app或者admin
|
||||||
private String platform="app";
|
private String platform="app";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门id
|
||||||
|
*/
|
||||||
|
private Long departmentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
private String departmentName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.nflg.mobilebroken.common.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class DepartmentChildItemVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0:部门 1:用户
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0:代理商,1:终端用户;2:内部用户
|
||||||
|
*/
|
||||||
|
private Integer userType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新人
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.nflg.mobilebroken.common.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class DepartmentChildVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 路径
|
||||||
|
*/
|
||||||
|
private List<DepartmentSimpleVO> paths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子级
|
||||||
|
*/
|
||||||
|
private List<DepartmentChildItemVO> items;
|
||||||
|
}
|
||||||
|
|
@ -15,6 +15,16 @@ public class DepartmentSimpleVO {
|
||||||
//部门名称
|
//部门名称
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有下级
|
||||||
|
*/
|
||||||
|
private boolean hasChild;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已设置管理者
|
||||||
|
*/
|
||||||
|
private boolean hasManager;
|
||||||
|
|
||||||
//下级
|
//下级
|
||||||
private List<DepartmentSimpleVO> children;
|
private List<DepartmentSimpleVO> children;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package com.nflg.mobilebroken.repository.mapper;
|
package com.nflg.mobilebroken.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -21,4 +22,8 @@ public interface TBaseDepartmentMapper extends BaseMapper<TBaseDepartment> {
|
||||||
Page<TBaseDepartment> selectListByPage(@Param("page") Page<PageBaseQuery> page,@Param("query") PageBaseQuery query );
|
Page<TBaseDepartment> selectListByPage(@Param("page") Page<PageBaseQuery> page,@Param("query") PageBaseQuery query );
|
||||||
|
|
||||||
void del(@Param("ids") List<Long> ids);
|
void del(@Param("ids") List<Long> ids);
|
||||||
|
|
||||||
|
void updateHasManager(Long departmentId);
|
||||||
|
|
||||||
|
List<DepartmentChildItemVO> getUsers(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.nflg.mobilebroken.repository.service;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -34,4 +35,8 @@ public interface ITBaseDepartmentService extends IService<TBaseDepartment> {
|
||||||
|
|
||||||
|
|
||||||
Set<Long> getAllChildrenIds(Long departmentId);
|
Set<Long> getAllChildrenIds(Long departmentId);
|
||||||
|
|
||||||
|
void updateHasManager(Long departmentId);
|
||||||
|
|
||||||
|
List<DepartmentChildItemVO> getUsers(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,11 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
|
||||||
.setCreateTime(LocalDateTime.now());
|
.setCreateTime(LocalDateTime.now());
|
||||||
save(user);
|
save(user);
|
||||||
}
|
}
|
||||||
|
departmentService.lambdaUpdate()
|
||||||
|
.set(TBaseDepartment::isHasManager, true)
|
||||||
|
.eq(TBaseDepartment::isHasManager, false)
|
||||||
|
.eq(TBaseDepartment::getId, user.getDepartmentId())
|
||||||
|
.update();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,9 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
||||||
@Resource
|
@Resource
|
||||||
private ITBaseAreaService baseAreaService;
|
private ITBaseAreaService baseAreaService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITBaseDepartmentService departmentService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AppUserApplyfor add(AddUserRequest request) {
|
public AppUserApplyfor add(AddUserRequest request) {
|
||||||
VUtils.trueThrowBusinessError(appUserService.lambdaQuery().eq(AppUser::getEmail, request.getEmail()).exists())
|
VUtils.trueThrowBusinessError(appUserService.lambdaQuery().eq(AppUser::getEmail, request.getEmail()).exists())
|
||||||
|
|
@ -223,6 +226,11 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
||||||
.setExpireTime(appUser.getExpireTime())
|
.setExpireTime(appUser.getExpireTime())
|
||||||
.setSalesUserName(appUser.getSalesUserName());
|
.setSalesUserName(appUser.getSalesUserName());
|
||||||
appUserService.save(user);
|
appUserService.save(user);
|
||||||
|
departmentService.lambdaUpdate()
|
||||||
|
.set(TBaseDepartment::isHasManager, true)
|
||||||
|
.eq(TBaseDepartment::isHasManager, false)
|
||||||
|
.eq(TBaseDepartment::getId, user.getDepartmentId())
|
||||||
|
.update();
|
||||||
} else if (applyfor.getType() == AppUserApplyforType.ENABLE.getState().byteValue()) {
|
} else if (applyfor.getType() == AppUserApplyforType.ENABLE.getState().byteValue()) {
|
||||||
//账号启用
|
//账号启用
|
||||||
AppUser appUser = appUserService.getById(applyfor.getUserId());
|
AppUser appUser = appUserService.getById(applyfor.getUserId());
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,9 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
@Resource
|
@Resource
|
||||||
private ITBaseAreaService baseAreaService;
|
private ITBaseAreaService baseAreaService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITBaseDepartmentService departmentService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AppUser getUser(String userName, String password) {
|
public AppUser getUser(String userName, String password) {
|
||||||
AppUser user = lambdaQuery()
|
AppUser user = lambdaQuery()
|
||||||
|
|
@ -198,6 +201,11 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.setExpireTime(LocalDate.of(LocalDateTime.now().getYear() + 1, 1, 1));
|
.setExpireTime(LocalDate.of(LocalDateTime.now().getYear() + 1, 1, 1));
|
||||||
save(user);
|
save(user);
|
||||||
}
|
}
|
||||||
|
departmentService.lambdaUpdate()
|
||||||
|
.set(TBaseDepartment::isHasManager, true)
|
||||||
|
.eq(TBaseDepartment::isHasManager, false)
|
||||||
|
.eq(TBaseDepartment::getId, user.getDepartmentId())
|
||||||
|
.update();
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,12 +247,13 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
AppUser primaryUser = getById(id);
|
AppUser primaryUser = getById(id);
|
||||||
List<Integer> companyIds = Arrays.stream(primaryUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
List<Integer> companyIds = Arrays.stream(primaryUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
||||||
List<CompanyVO> datas = new ArrayList<>();
|
List<CompanyVO> datas = new ArrayList<>();
|
||||||
|
List<TBaseDepartment> departments = departmentService.list();
|
||||||
for (Integer companyId : companyIds) {
|
for (Integer companyId : companyIds) {
|
||||||
TBaseCustomer customer = customerService.getById(companyId);
|
TBaseCustomer customer = customerService.getById(companyId);
|
||||||
CompanyVO companyVO = new CompanyVO()
|
CompanyVO companyVO = new CompanyVO()
|
||||||
.setId(customer.getId())
|
.setId(customer.getId())
|
||||||
.setName(customer.getAgencyCompanyName())
|
.setName(customer.getAgencyCompanyName())
|
||||||
.setUsers(getByCompanyId(companyId));
|
.setUsers(getByCompanyId(companyId, departments));
|
||||||
datas.add(companyVO);
|
datas.add(companyVO);
|
||||||
}
|
}
|
||||||
return datas;
|
return datas;
|
||||||
|
|
@ -423,6 +432,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
List<AppUserForAdminVO> subs = datas.stream()
|
List<AppUserForAdminVO> subs = datas.stream()
|
||||||
.filter(d -> Objects.nonNull(d.getIsPrimary()) && !d.getIsPrimary())
|
.filter(d -> Objects.nonNull(d.getIsPrimary()) && !d.getIsPrimary())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
List<TBaseDepartment> departments = departmentService.list();
|
||||||
subs.forEach(d -> {
|
subs.forEach(d -> {
|
||||||
AppUserForAdminVO primary = primarys.stream()
|
AppUserForAdminVO primary = primarys.stream()
|
||||||
.filter(p -> Objects.nonNull(p.getIsPrimary()) && Arrays.stream(p.getCompanyId().split(",")).anyMatch(c -> c.equals(d.getCompanyId())))
|
.filter(p -> Objects.nonNull(p.getIsPrimary()) && Arrays.stream(p.getCompanyId().split(",")).anyMatch(c -> c.equals(d.getCompanyId())))
|
||||||
|
|
@ -457,7 +467,14 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.setSalesUserName(appUser.getSalesUserName())
|
.setSalesUserName(appUser.getSalesUserName())
|
||||||
.setTitleId(appUser.getTitleId())
|
.setTitleId(appUser.getTitleId())
|
||||||
.setTitle(positionService.getById(appUser.getTitleId()).getPositionName())
|
.setTitle(positionService.getById(appUser.getTitleId()).getPositionName())
|
||||||
.setState(appUser.getExpireTime().isAfter(LocalDate.now()) ? 1 : 2);
|
.setState(appUser.getExpireTime().isAfter(LocalDate.now()) ? 1 : 2)
|
||||||
|
.setDepartmentId(appUser.getDepartmentId())
|
||||||
|
.setDepartmentName(departments.stream()
|
||||||
|
.filter(dept -> dept.getId().equals(appUser.getDepartmentId()))
|
||||||
|
.findFirst()
|
||||||
|
.map(TBaseDepartment::getDeptName)
|
||||||
|
.orElse("")
|
||||||
|
);
|
||||||
AppUserApplyfor applyFor = appUserApplyforService.lambdaQuery()
|
AppUserApplyfor applyFor = appUserApplyforService.lambdaQuery()
|
||||||
.eq(AppUserApplyfor::getUserId, appUser.getId())
|
.eq(AppUserApplyfor::getUserId, appUser.getId())
|
||||||
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||||
|
|
@ -748,12 +765,13 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
companyIds.addAll(userCompanyIds);
|
companyIds.addAll(userCompanyIds);
|
||||||
}
|
}
|
||||||
|
List<TBaseDepartment> departments = departmentService.list();
|
||||||
companyIds.forEach(id -> {
|
companyIds.forEach(id -> {
|
||||||
TBaseCustomer customer = customerService.getById(id);
|
TBaseCustomer customer = customerService.getById(id);
|
||||||
CompanyVO companyVO = new CompanyVO()
|
CompanyVO companyVO = new CompanyVO()
|
||||||
.setId(customer.getId())
|
.setId(customer.getId())
|
||||||
.setName(customer.getAgencyCompanyName())
|
.setName(customer.getAgencyCompanyName())
|
||||||
.setUsers(getByCompanyId(id));
|
.setUsers(getByCompanyId(id, departments));
|
||||||
datas.add(companyVO);
|
datas.add(companyVO);
|
||||||
});
|
});
|
||||||
return datas;
|
return datas;
|
||||||
|
|
@ -834,7 +852,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
return getBaseMapper().selectOne(queryWrapper);
|
return getBaseMapper().selectOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AppUserVO> getByCompanyId(Integer companyId) {
|
private List<AppUserVO> getByCompanyId(Integer companyId, List<TBaseDepartment> departments) {
|
||||||
return lambdaQuery()
|
return lambdaQuery()
|
||||||
.eq(AppUser::getIsDel, false)
|
.eq(AppUser::getIsDel, false)
|
||||||
.eq(AppUser::getCompanyId, companyId.toString())
|
.eq(AppUser::getCompanyId, companyId.toString())
|
||||||
|
|
@ -842,7 +860,18 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
||||||
.eq(AppUser::getIsPrimary, false)
|
.eq(AppUser::getIsPrimary, false)
|
||||||
.list()
|
.list()
|
||||||
.stream()
|
.stream()
|
||||||
.map(u -> new AppUserVO().setId(u.getId()).setName(u.getName()))
|
.map(u -> new AppUserVO()
|
||||||
|
.setId(u.getId())
|
||||||
|
.setName(u.getName())
|
||||||
|
.setDepartmentId(u.getDepartmentId())
|
||||||
|
.setDepartmentName(
|
||||||
|
departments.stream()
|
||||||
|
.filter(d -> Objects.equals(d.getId(), u.getDepartmentId()))
|
||||||
|
.findFirst()
|
||||||
|
.map(TBaseDepartment::getDeptName)
|
||||||
|
.orElse("")
|
||||||
|
)
|
||||||
|
)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO;
|
||||||
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
import com.nflg.mobilebroken.common.pojo.vo.DepartmentSimpleVO;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper;
|
import com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper;
|
||||||
|
|
@ -72,6 +73,16 @@ public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMappe
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateHasManager(Long departmentId) {
|
||||||
|
baseMapper.updateHasManager(departmentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DepartmentChildItemVO> getUsers(Long id) {
|
||||||
|
return baseMapper.getUsers(id);
|
||||||
|
}
|
||||||
|
|
||||||
private void getChildrenIds(Set<Long> ids, List<TBaseDepartment> departments, Long departmentId) {
|
private void getChildrenIds(Set<Long> ids, List<TBaseDepartment> departments, Long departmentId) {
|
||||||
Set<Long> cids = departments.stream()
|
Set<Long> cids = departments.stream()
|
||||||
.filter(d -> Objects.equals(d.getDeptParentId(), departmentId))
|
.filter(d -> Objects.equals(d.getDeptParentId(), departmentId))
|
||||||
|
|
@ -96,7 +107,12 @@ public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMappe
|
||||||
|
|
||||||
private List<DepartmentSimpleVO> convert(List<TBaseDepartment> datas) {
|
private List<DepartmentSimpleVO> convert(List<TBaseDepartment> datas) {
|
||||||
return datas.stream()
|
return datas.stream()
|
||||||
.map(d -> new DepartmentSimpleVO().setId(d.getId()).setName(d.getDeptName()))
|
.map(d -> new DepartmentSimpleVO()
|
||||||
|
.setId(d.getId())
|
||||||
|
.setName(d.getDeptName())
|
||||||
|
.setHasChild(d.isHasChild())
|
||||||
|
.setHasManager(d.isHasManager())
|
||||||
|
)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,12 +123,14 @@
|
||||||
,au.expire_time,IF(aua.id IS NOT NULL,0
|
,au.expire_time,IF(aua.id IS NOT NULL,0
|
||||||
,IF(CONVERT_TZ(NOW(), @@session.time_zone, '+00:00') < au.expire_time,1,2)) AS 'state',au.create_by
|
,IF(CONVERT_TZ(NOW(), @@session.time_zone, '+00:00') < au.expire_time,1,2)) AS 'state',au.create_by
|
||||||
,au.create_time,au.update_by,au.update_time,au.last_login_time,au.is_primary,au.company_id,au.phone,au.area_id
|
,au.create_time,au.update_by,au.update_time,au.last_login_time,au.is_primary,au.company_id,au.phone,au.area_id
|
||||||
,au.language_code,p.position_name AS
|
,au.language_code,p.position_name AS 'title',au.title_id,au.type,au.customer_name,au.department_id,d.dept_name
|
||||||
'title',au.title_id,au.type,au.customer_name,au.department_id,au.region_type_id
|
as 'departmentName'
|
||||||
|
,au.region_type_id
|
||||||
FROM app_user au
|
FROM app_user au
|
||||||
LEFT JOIN app_area aa ON au.area_id=aa.id
|
LEFT JOIN app_area aa ON au.area_id=aa.id
|
||||||
LEFT JOIN app_user_applyfor aua ON aua.user_id=au.id AND aua.state=0
|
LEFT JOIN app_user_applyfor aua ON aua.user_id=au.id AND aua.state=0
|
||||||
LEFT JOIN t_base_position p ON au.title_id=p.id
|
LEFT JOIN t_base_position p ON au.title_id=p.id
|
||||||
|
LEFT JOIN t_base_department d ON au.department_id=d.id
|
||||||
WHERE au.is_del=0
|
WHERE au.is_del=0
|
||||||
<if test="loginName!=null and loginName!=''">
|
<if test="loginName!=null and loginName!=''">
|
||||||
AND au.login_name LIKE concat('%', #{loginName}, '%')
|
AND au.login_name LIKE concat('%', #{loginName}, '%')
|
||||||
|
|
@ -158,12 +160,14 @@
|
||||||
,IF(aua.is_primary,fun_getPrimaryUserArea(aua.company_id),aa.`name`) AS 'areaName'
|
,IF(aua.is_primary,fun_getPrimaryUserArea(aua.company_id),aa.`name`) AS 'areaName'
|
||||||
,null AS 'userState',null AS 'expireTime',0 AS 'state',au.name AS 'createBy',aua.create_time,null AS 'updateBy'
|
,null AS 'userState',null AS 'expireTime',0 AS 'state',au.name AS 'createBy',aua.create_time,null AS 'updateBy'
|
||||||
,null AS 'updateTime',null AS 'lastLoginTime',aua.is_primary,aua.company_id,aua.user_phone AS 'phone',aua.area_id
|
,null AS 'updateTime',null AS 'lastLoginTime',aua.is_primary,aua.company_id,aua.user_phone AS 'phone',aua.area_id
|
||||||
,aua.language_code,p.position_name AS
|
,aua.language_code,p.position_name AS 'title',aua.title_id,au.type,au.customer_name,au.department_id,d.dept_name
|
||||||
'title',aua.title_id,au.type,au.customer_name,au.department_id,au.region_type_id
|
as 'departmentName'
|
||||||
|
,au.region_type_id
|
||||||
FROM app_user_applyfor aua
|
FROM app_user_applyfor aua
|
||||||
LEFT JOIN app_user au ON au.id=aua.create_by
|
LEFT JOIN app_user au ON au.id=aua.create_by
|
||||||
LEFT JOIN app_area aa ON aua.area_id=aa.id
|
LEFT JOIN app_area aa ON aua.area_id=aa.id
|
||||||
LEFT JOIN t_base_position p ON aua.title_id=p.id
|
LEFT JOIN t_base_position p ON aua.title_id=p.id
|
||||||
|
LEFT JOIN t_base_department d ON au.department_id=d.id
|
||||||
WHERE aua.type=0 AND aua.state=0
|
WHERE aua.type=0 AND aua.state=0
|
||||||
<if test="loginName!=null and loginName!=''">
|
<if test="loginName!=null and loginName!=''">
|
||||||
AND aua.user_email LIKE concat('%', #{loginName}, '%')
|
AND aua.user_email LIKE concat('%', #{loginName}, '%')
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,19 @@
|
||||||
</if>
|
</if>
|
||||||
<include refid="whr"/>
|
<include refid="whr"/>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getUsers" resultType="com.nflg.mobilebroken.common.pojo.vo.DepartmentChildItemVO">
|
||||||
|
SELECT id,
|
||||||
|
user_name as 'name',
|
||||||
|
1 as 'type',
|
||||||
|
type as 'userType',
|
||||||
|
state,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time
|
||||||
|
FROM v_all_user
|
||||||
|
WHERE department_id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
<delete id="del">
|
<delete id="del">
|
||||||
delete from t_base_department where id in
|
delete from t_base_department where id in
|
||||||
|
|
@ -25,4 +38,9 @@
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
<update id="updateHasManager">
|
||||||
|
UPDATE t_base_department p
|
||||||
|
SET has_manager=EXISTS(SELECT * FROM v_all_user WHERE department_id = p.id)
|
||||||
|
WHERE id = #{departmentId}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue