mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-10-09 05:36:41 +08:00
id替换以及结构调整
This commit is contained in:
parent
db96d1f1be
commit
2ace49012b
@ -1,7 +1,10 @@
|
|||||||
package net.lab1024.smartadmin.service.common.util;
|
package net.lab1024.smartadmin.service.common.util;
|
||||||
|
|
||||||
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
import net.lab1024.smartadmin.service.common.enumeration.BaseEnum;
|
||||||
|
import net.lab1024.smartadmin.service.module.support.idgenerator.constant.IdGeneratorRuleTypeEnum;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
@ -16,6 +19,8 @@ import java.util.stream.Stream;
|
|||||||
*/
|
*/
|
||||||
public class SmartBaseEnumUtil {
|
public class SmartBaseEnumUtil {
|
||||||
|
|
||||||
|
private Object e;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验参数与枚举类比较是否合法
|
* 校验参数与枚举类比较是否合法
|
||||||
*
|
*
|
||||||
@ -98,6 +103,16 @@ public class SmartBaseEnumUtil {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static <T extends BaseEnum> T getEnumByName(String name, Class<T> enumClass) {
|
||||||
|
return Stream.of(enumClass.getEnumConstants())
|
||||||
|
.filter(e->StringUtils.equalsIgnoreCase(e.toString(), name))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据lambda getter/setter 注入
|
* 根据lambda getter/setter 注入
|
||||||
*
|
*
|
||||||
|
@ -22,7 +22,7 @@ public class DepartmentEntity {
|
|||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long departmentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门名称
|
* 部门名称
|
||||||
@ -56,10 +56,5 @@ public class DepartmentEntity {
|
|||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入标识
|
|
||||||
*/
|
|
||||||
private Boolean importFlag;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package net.lab1024.smartadmin.service.module.system.department.domain.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 部门实体类
|
|
||||||
* t_department 数据表
|
|
||||||
*
|
|
||||||
* @author listen
|
|
||||||
* @date 2017/12/19 10:45
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName(value = "t_department_third")
|
|
||||||
public class DepartmentThirdEntity {
|
|
||||||
|
|
||||||
private Long departmentId;
|
|
||||||
/**
|
|
||||||
* {@link net.lab1024.smartadmin.mq.constant.XmfCrmPlatformEnum}
|
|
||||||
*/
|
|
||||||
private Integer platformType;
|
|
||||||
/**
|
|
||||||
* 第三方平台部门id
|
|
||||||
*/
|
|
||||||
private Long thirdDepartmentId;
|
|
||||||
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
}
|
|
@ -20,6 +20,6 @@ public class DepartmentUpdateForm extends DepartmentAddForm {
|
|||||||
|
|
||||||
@ApiModelProperty("部门id")
|
@ApiModelProperty("部门id")
|
||||||
@NotNull(message = "部门id不能为空")
|
@NotNull(message = "部门id不能为空")
|
||||||
private Long id;
|
private Long departmentId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import lombok.Data;
|
|||||||
public class DepartmentVO {
|
public class DepartmentVO {
|
||||||
|
|
||||||
@ApiModelProperty("部门id")
|
@ApiModelProperty("部门id")
|
||||||
private Long id;
|
private Long departmentId;
|
||||||
|
|
||||||
@ApiModelProperty("部门名称")
|
@ApiModelProperty("部门名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -19,19 +19,4 @@ import java.util.List;
|
|||||||
public class DepartmentManager extends ServiceImpl<DepartmentDao, DepartmentEntity> {
|
public class DepartmentManager extends ServiceImpl<DepartmentDao, DepartmentEntity> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加 编辑
|
|
||||||
*
|
|
||||||
* @param insertDepartmentList
|
|
||||||
* @param updateDepartmentList
|
|
||||||
*/
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void batchInsertUpdate(List<DepartmentEntity> insertDepartmentList, List<DepartmentEntity> updateDepartmentList) {
|
|
||||||
if(!CollectionUtils.isEmpty(insertDepartmentList)){
|
|
||||||
saveBatch(insertDepartmentList);
|
|
||||||
}
|
|
||||||
if(!CollectionUtils.isEmpty(updateDepartmentList)){
|
|
||||||
updateBatchById(updateDepartmentList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import net.lab1024.smartadmin.service.constant.CacheModuleConst;
|
|||||||
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||||
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -129,7 +131,7 @@ public class DepartmentCacheService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private DepartmentVO findSchoolDepartmentId(List<DepartmentVO> departmentList, Long departmentId, Long schoolParentDepartmentId) {
|
private DepartmentVO findSchoolDepartmentId(List<DepartmentVO> departmentList, Long departmentId, Long schoolParentDepartmentId) {
|
||||||
Optional<DepartmentVO> findRes = departmentList.stream().filter(e -> e.getId().equals(departmentId)).findFirst();
|
Optional<DepartmentVO> findRes = departmentList.stream().filter(e -> e.getDepartmentId().equals(departmentId)).findFirst();
|
||||||
// 如果查询不到 或者自己本身为最顶级 返回null
|
// 如果查询不到 或者自己本身为最顶级 返回null
|
||||||
if (!findRes.isPresent()) {
|
if (!findRes.isPresent()) {
|
||||||
return null;
|
return null;
|
||||||
@ -150,12 +152,12 @@ public class DepartmentCacheService {
|
|||||||
@Cacheable(CacheModuleConst.Department.DEPARTMENT_ROUTE_CACHE)
|
@Cacheable(CacheModuleConst.Department.DEPARTMENT_ROUTE_CACHE)
|
||||||
public Map<Long, String> departmentRouteCache() {
|
public Map<Long, String> departmentRouteCache() {
|
||||||
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
List<DepartmentVO> departmentVOList = departmentDao.listAll();
|
||||||
Map<Long, DepartmentVO> departmentMap = departmentVOList.stream().collect(Collectors.toMap(DepartmentVO::getId, Function.identity()));
|
Map<Long, DepartmentVO> departmentMap = departmentVOList.stream().collect(Collectors.toMap(DepartmentVO::getDepartmentId, Function.identity()));
|
||||||
|
|
||||||
Map<Long, String> routeNameMap = Maps.newHashMap();
|
Map<Long, String> routeNameMap = Maps.newHashMap();
|
||||||
for (DepartmentVO departmentVO : departmentVOList) {
|
for (DepartmentVO departmentVO : departmentVOList) {
|
||||||
String routeName = this.buildRoutePath(departmentVO, departmentMap);
|
String routeName = this.buildRoutePath(departmentVO, departmentMap);
|
||||||
routeNameMap.put(departmentVO.getId(), routeName);
|
routeNameMap.put(departmentVO.getDepartmentId(), routeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return routeNameMap;
|
return routeNameMap;
|
||||||
@ -168,7 +170,7 @@ public class DepartmentCacheService {
|
|||||||
* @param departmentMap
|
* @param departmentMap
|
||||||
*/
|
*/
|
||||||
private String buildRoutePath(DepartmentVO departmentVO, Map<Long, DepartmentVO> departmentMap) {
|
private String buildRoutePath(DepartmentVO departmentVO, Map<Long, DepartmentVO> departmentMap) {
|
||||||
if (departmentVO.getParentId() == DepartmentService.DEFAULT_PARENT_ID) {
|
if (Objects.equals(departmentVO.getParentId(), NumberUtils.LONG_ZERO)) {
|
||||||
return departmentVO.getName();
|
return departmentVO.getName();
|
||||||
}
|
}
|
||||||
//父节点
|
//父节点
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.lab1024.smartadmin.service.module.system.department.service;
|
package net.lab1024.smartadmin.service.module.system.department.service;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||||
@ -8,21 +7,13 @@ import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao
|
|||||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentAddForm;
|
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentAddForm;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentUpdateForm;
|
import net.lab1024.smartadmin.service.module.system.department.domain.form.DepartmentUpdateForm;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentEmployeeTreeVO;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.springframework.aop.framework.AopContext;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门管理
|
* 部门管理
|
||||||
@ -32,8 +23,6 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
public class DepartmentService {
|
public class DepartmentService {
|
||||||
|
|
||||||
static final long DEFAULT_PARENT_ID = 0L;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DepartmentDao departmentDao;
|
private DepartmentDao departmentDao;
|
||||||
|
|
||||||
@ -65,77 +54,6 @@ public class DepartmentService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递归构建每部门的员工信息
|
|
||||||
*
|
|
||||||
* @param treeVOList
|
|
||||||
* @param employeeMap
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<DepartmentEmployeeTreeVO> buildTreeEmployee(List<DepartmentTreeVO> treeVOList, Map<Long, List<EmployeeVO>> employeeMap) {
|
|
||||||
List<DepartmentEmployeeTreeVO> departmentEmployeeTreeVOList = Lists.newArrayList();
|
|
||||||
for (DepartmentTreeVO departmentTreeVO : treeVOList) {
|
|
||||||
DepartmentEmployeeTreeVO departmentEmployeeTreeVO = SmartBeanUtil.copy(departmentTreeVO, DepartmentEmployeeTreeVO.class);
|
|
||||||
departmentEmployeeTreeVO.setEmployees(employeeMap.getOrDefault(departmentEmployeeTreeVO.getId(), Lists.newArrayList()));
|
|
||||||
List<DepartmentTreeVO> children = departmentTreeVO.getChildren();
|
|
||||||
if (CollectionUtils.isEmpty(children)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
List<DepartmentEmployeeTreeVO> childrenList = this.buildTreeEmployee(children, employeeMap);
|
|
||||||
departmentEmployeeTreeVO.setChildren(childrenList);
|
|
||||||
departmentEmployeeTreeVOList.add(departmentEmployeeTreeVO);
|
|
||||||
}
|
|
||||||
return departmentEmployeeTreeVOList;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 过滤部门名称,获取过滤后的结果
|
|
||||||
*
|
|
||||||
* @author lidoudou
|
|
||||||
* @date 2019/4/28 20:17
|
|
||||||
*/
|
|
||||||
private List<DepartmentVO> filterDepartment(List<DepartmentVO> departmentVOList, String departmentName) {
|
|
||||||
Map<Long, DepartmentVO> departmentMap = new HashMap<>(departmentVOList.size());
|
|
||||||
departmentVOList.forEach(item -> {
|
|
||||||
if (!item.getName().contains(departmentName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 当前部门包含关键字
|
|
||||||
departmentMap.put(item.getId(), item);
|
|
||||||
Long parentId = item.getParentId();
|
|
||||||
if (null != parentId) {
|
|
||||||
List<DepartmentVO> filterResult = new ArrayList<>();
|
|
||||||
getParentDepartment(departmentVOList, parentId, filterResult);
|
|
||||||
for (DepartmentVO dto : filterResult) {
|
|
||||||
if (!departmentMap.containsKey(dto.getId())) {
|
|
||||||
departmentMap.put(dto.getId(), dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return new ArrayList<>(departmentMap.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递归获取部门的所有上级元素
|
|
||||||
*
|
|
||||||
* @param departmentVOList
|
|
||||||
* @param parentId
|
|
||||||
* @param result
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private List<DepartmentVO> getParentDepartment(List<DepartmentVO> departmentVOList, Long parentId, List<DepartmentVO> result) {
|
|
||||||
List<DepartmentVO> deptList = departmentVOList.stream().filter(e -> e.getId().equals(parentId)).collect(Collectors.toList());
|
|
||||||
for (DepartmentVO item : deptList) {
|
|
||||||
result.add(item);
|
|
||||||
if (item.getParentId() != DEFAULT_PARENT_ID && item.getParentId() != null) {
|
|
||||||
result.addAll(getParentDepartment(departmentVOList, item.getParentId(), result));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增添加部门
|
* 新增添加部门
|
||||||
*
|
*
|
||||||
@ -145,7 +63,6 @@ public class DepartmentService {
|
|||||||
|
|
||||||
public ResponseDTO<String> addDepartment(DepartmentAddForm departmentAddForm) {
|
public ResponseDTO<String> addDepartment(DepartmentAddForm departmentAddForm) {
|
||||||
DepartmentEntity departmentEntity = SmartBeanUtil.copy(departmentAddForm, DepartmentEntity.class);
|
DepartmentEntity departmentEntity = SmartBeanUtil.copy(departmentAddForm, DepartmentEntity.class);
|
||||||
DepartmentService departmentService = (DepartmentService) AopContext.currentProxy();
|
|
||||||
departmentDao.insert(departmentEntity);
|
departmentDao.insert(departmentEntity);
|
||||||
this.clearCache();
|
this.clearCache();
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
@ -162,7 +79,7 @@ public class DepartmentService {
|
|||||||
if (updateDTO.getParentId() == null) {
|
if (updateDTO.getParentId() == null) {
|
||||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "父级部门id不能为空");
|
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "父级部门id不能为空");
|
||||||
}
|
}
|
||||||
DepartmentEntity entity = departmentDao.selectById(updateDTO.getId());
|
DepartmentEntity entity = departmentDao.selectById(updateDTO.getDepartmentId());
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
|||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentTreeVO;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -27,7 +28,7 @@ public class DepartmentTreeService {
|
|||||||
if (CollectionUtils.isEmpty(voList)) {
|
if (CollectionUtils.isEmpty(voList)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
List<DepartmentVO> rootList = voList.stream().filter(e -> e.getParentId() == null || Objects.equals(e.getParentId(), DepartmentService.DEFAULT_PARENT_ID)).collect(Collectors.toList());
|
List<DepartmentVO> rootList = voList.stream().filter(e -> e.getParentId() == null || Objects.equals(e.getParentId(), NumberUtils.LONG_ZERO)).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isEmpty(rootList)) {
|
if (CollectionUtils.isEmpty(rootList)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
@ -49,10 +50,10 @@ public class DepartmentTreeService {
|
|||||||
int nextIndex = i + 1;
|
int nextIndex = i + 1;
|
||||||
DepartmentTreeVO node = nodeList.get(i);
|
DepartmentTreeVO node = nodeList.get(i);
|
||||||
if (preIndex > -1) {
|
if (preIndex > -1) {
|
||||||
node.setPreId(nodeList.get(preIndex).getId());
|
node.setPreId(nodeList.get(preIndex).getDepartmentId());
|
||||||
}
|
}
|
||||||
if (nextIndex < nodeSize) {
|
if (nextIndex < nodeSize) {
|
||||||
node.setNextId(nodeList.get(nextIndex).getId());
|
node.setNextId(nodeList.get(nextIndex).getDepartmentId());
|
||||||
}
|
}
|
||||||
buildTree(node, voList);
|
buildTree(node, voList);
|
||||||
}
|
}
|
||||||
@ -65,7 +66,7 @@ public class DepartmentTreeService {
|
|||||||
* @param voList
|
* @param voList
|
||||||
*/
|
*/
|
||||||
private void buildTree(DepartmentTreeVO node, List<DepartmentVO> voList) {
|
private void buildTree(DepartmentTreeVO node, List<DepartmentVO> voList) {
|
||||||
List<DepartmentTreeVO> children = getChildren(node.getId(), voList);
|
List<DepartmentTreeVO> children = getChildren(node.getDepartmentId(), voList);
|
||||||
if (CollectionUtils.isNotEmpty(children)) {
|
if (CollectionUtils.isNotEmpty(children)) {
|
||||||
node.setChildren(children);
|
node.setChildren(children);
|
||||||
this.buildTree(children, voList);
|
this.buildTree(children, voList);
|
||||||
@ -104,7 +105,7 @@ public class DepartmentTreeService {
|
|||||||
if (CollectionUtils.isEmpty(children)) {
|
if (CollectionUtils.isEmpty(children)) {
|
||||||
return selfAndChildrenIdList;
|
return selfAndChildrenIdList;
|
||||||
}
|
}
|
||||||
List<Long> childrenIdList = children.stream().map(DepartmentTreeVO::getId).collect(Collectors.toList());
|
List<Long> childrenIdList = children.stream().map(DepartmentTreeVO::getDepartmentId).collect(Collectors.toList());
|
||||||
selfAndChildrenIdList.addAll(childrenIdList);
|
selfAndChildrenIdList.addAll(childrenIdList);
|
||||||
for (Long childId : childrenIdList) {
|
for (Long childId : childrenIdList) {
|
||||||
this.selfAndChildrenRecursion(selfAndChildrenIdList, childId, voList);
|
this.selfAndChildrenRecursion(selfAndChildrenIdList, childId, voList);
|
||||||
@ -124,7 +125,7 @@ public class DepartmentTreeService {
|
|||||||
if (CollectionUtils.isEmpty(children)) {
|
if (CollectionUtils.isEmpty(children)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Long> childrenIdList = children.stream().map(DepartmentTreeVO::getId).collect(Collectors.toList());
|
List<Long> childrenIdList = children.stream().map(DepartmentTreeVO::getDepartmentId).collect(Collectors.toList());
|
||||||
selfAndChildrenIdList.addAll(childrenIdList);
|
selfAndChildrenIdList.addAll(childrenIdList);
|
||||||
for (Long childId : childrenIdList) {
|
for (Long childId : childrenIdList) {
|
||||||
this.selfAndChildrenRecursion(selfAndChildrenIdList, childId, voList);
|
this.selfAndChildrenRecursion(selfAndChildrenIdList, childId, voList);
|
||||||
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
import net.lab1024.smartadmin.service.common.controller.SystemBaseController;
|
||||||
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
import net.lab1024.smartadmin.service.common.domain.PageResult;
|
||||||
import net.lab1024.smartadmin.service.common.util.SmartRequestUtil;
|
import net.lab1024.smartadmin.service.common.util.SmartRequestUtil;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.employee.service.EmployeeService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import net.lab1024.smartadmin.service.common.annoation.NoValidPrivilege;
|
import net.lab1024.smartadmin.service.common.annoation.NoValidPrivilege;
|
||||||
|
@ -42,10 +42,10 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
|||||||
/**
|
/**
|
||||||
* 更新单个
|
* 更新单个
|
||||||
*
|
*
|
||||||
* @param id
|
* @param employeeId
|
||||||
* @param disabledFlag
|
* @param disabledFlag
|
||||||
*/
|
*/
|
||||||
void updateDisableFlag(@Param("id") Long id, @Param("disabledFlag") Boolean disabledFlag);
|
void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +100,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
|||||||
* @param employeeIds
|
* @param employeeIds
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<EmployeeVO> getEmployeeByIds(@Param("ids") Collection<Long> employeeIds);
|
List<EmployeeVO> getEmployeeByIds(@Param("employeeIds") Collection<Long> employeeIds);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,7 +109,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
|||||||
* @param employeeId
|
* @param employeeId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
EmployeeVO getEmployeeById(@Param("id") Long employeeId);
|
EmployeeVO getEmployeeById(@Param("employeeId") Long employeeId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,7 @@ import java.time.LocalDateTime;
|
|||||||
public class EmployeeEntity {
|
public class EmployeeEntity {
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long employeeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录账号
|
* 登录账号
|
||||||
|
@ -17,5 +17,5 @@ public class EmployeeUpdateForm extends EmployeeAddForm {
|
|||||||
|
|
||||||
@ApiModelProperty("员工id")
|
@ApiModelProperty("员工id")
|
||||||
@NotNull(message = "员工id不能为空")
|
@NotNull(message = "员工id不能为空")
|
||||||
private Long id;
|
private Long employeeId;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
public class EmployeeVO {
|
public class EmployeeVO {
|
||||||
|
|
||||||
@ApiModelProperty("主键id")
|
@ApiModelProperty("主键id")
|
||||||
private Long id;
|
private Long employeeId;
|
||||||
|
|
||||||
@ApiModelProperty("登录账号")
|
@ApiModelProperty("登录账号")
|
||||||
private String loginName;
|
private String loginName;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package net.lab1024.smartadmin.service.module.system.employee;
|
package net.lab1024.smartadmin.service.module.system.employee.manager;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -39,7 +40,7 @@ public class EmployeeManager extends ServiceImpl<EmployeeDao, EmployeeEntity> {
|
|||||||
employeeDao.insert(employee);
|
employeeDao.insert(employee);
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(roleIdList)) {
|
if (CollectionUtils.isNotEmpty(roleIdList)) {
|
||||||
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getId())).collect(Collectors.toList());
|
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getEmployeeId())).collect(Collectors.toList());
|
||||||
roleEmployeeManager.saveBatch(roleEmployeeList);
|
roleEmployeeManager.saveBatch(roleEmployeeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,8 +56,8 @@ public class EmployeeManager extends ServiceImpl<EmployeeDao, EmployeeEntity> {
|
|||||||
employeeDao.updateById(employee);
|
employeeDao.updateById(employee);
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(roleIdList)) {
|
if (CollectionUtils.isNotEmpty(roleIdList)) {
|
||||||
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getId())).collect(Collectors.toList());
|
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getEmployeeId())).collect(Collectors.toList());
|
||||||
this.updateEmployeeRole(employee.getId(),roleEmployeeList);
|
this.updateEmployeeRole(employee.getEmployeeId(),roleEmployeeList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
package net.lab1024.smartadmin.service.module.system.employee;
|
package net.lab1024.smartadmin.service.module.system.employee.service;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.smartadmin.service.constant.CacheModuleConst;
|
import net.lab1024.smartadmin.service.constant.CacheModuleConst;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.compress.utils.Lists;
|
import org.apache.commons.compress.utils.Lists;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.smartadmin.service.module.system.employee;
|
package net.lab1024.smartadmin.service.module.system.employee.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -11,9 +11,11 @@ import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao
|
|||||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
import net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.service.DepartmentCacheService;
|
import net.lab1024.smartadmin.service.module.system.department.service.DepartmentCacheService;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.domain.form.*;
|
import net.lab1024.smartadmin.service.module.system.employee.domain.form.*;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.employee.manager.EmployeeManager;
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.LoginUserDetail;
|
import net.lab1024.smartadmin.service.module.system.login.domain.LoginUserDetail;
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.RequestEmployee;
|
import net.lab1024.smartadmin.service.module.system.login.domain.RequestEmployee;
|
||||||
import net.lab1024.smartadmin.service.module.system.menu.service.MenuEmployeeService;
|
import net.lab1024.smartadmin.service.module.system.menu.service.MenuEmployeeService;
|
||||||
@ -116,7 +118,7 @@ public class EmployeeService {
|
|||||||
return ResponseDTO.ok(PageResult);
|
return ResponseDTO.ok(PageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> employeeIdList = employeeList.stream().map(EmployeeVO::getId).collect(Collectors.toList());
|
List<Long> employeeIdList = employeeList.stream().map(EmployeeVO::getEmployeeId).collect(Collectors.toList());
|
||||||
// 查询员工角色
|
// 查询员工角色
|
||||||
List<RoleEmployeeVO> roleEmployeeEntityList = roleEmployeeDao.selectRoleByEmployeeIdList(employeeIdList);
|
List<RoleEmployeeVO> roleEmployeeEntityList = roleEmployeeDao.selectRoleByEmployeeIdList(employeeIdList);
|
||||||
Map<Long, List<Long>> employeeRoleIdListMap = roleEmployeeEntityList.stream().collect(Collectors.groupingBy(RoleEmployeeVO::getEmployeeId, Collectors.mapping(RoleEmployeeVO::getRoleId, Collectors.toList())));
|
Map<Long, List<Long>> employeeRoleIdListMap = roleEmployeeEntityList.stream().collect(Collectors.groupingBy(RoleEmployeeVO::getEmployeeId, Collectors.mapping(RoleEmployeeVO::getRoleId, Collectors.toList())));
|
||||||
@ -125,8 +127,8 @@ public class EmployeeService {
|
|||||||
Map<Long, String> departmentNameMap = departmentCacheService.departmentRouteCache();
|
Map<Long, String> departmentNameMap = departmentCacheService.departmentRouteCache();
|
||||||
|
|
||||||
employeeList.forEach(e -> {
|
employeeList.forEach(e -> {
|
||||||
e.setRoleIdList(employeeRoleIdListMap.getOrDefault(e.getId(), Lists.newArrayList()));
|
e.setRoleIdList(employeeRoleIdListMap.getOrDefault(e.getEmployeeId(), Lists.newArrayList()));
|
||||||
e.setRoleNameList(employeeRoleNameListMap.getOrDefault(e.getId(), Lists.newArrayList()));
|
e.setRoleNameList(employeeRoleNameListMap.getOrDefault(e.getEmployeeId(), Lists.newArrayList()));
|
||||||
e.setDepartmentName(departmentNameMap.getOrDefault(e.getDepartmentId(), ""));
|
e.setDepartmentName(departmentNameMap.getOrDefault(e.getDepartmentId(), ""));
|
||||||
});
|
});
|
||||||
PageResult<EmployeeVO> PageResult = SmartPageUtil.convert2PageResult(pageParam, employeeList);
|
PageResult<EmployeeVO> PageResult = SmartPageUtil.convert2PageResult(pageParam, employeeList);
|
||||||
@ -181,7 +183,7 @@ public class EmployeeService {
|
|||||||
*/
|
*/
|
||||||
public synchronized ResponseDTO<String> updateEmployee(EmployeeUpdateForm employeeUpdateForm) {
|
public synchronized ResponseDTO<String> updateEmployee(EmployeeUpdateForm employeeUpdateForm) {
|
||||||
|
|
||||||
Long employeeId = employeeUpdateForm.getId();
|
Long employeeId = employeeUpdateForm.getEmployeeId();
|
||||||
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
EmployeeEntity employeeEntity = employeeDao.selectById(employeeId);
|
||||||
if (null == employeeEntity) {
|
if (null == employeeEntity) {
|
||||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
@ -196,12 +198,12 @@ public class EmployeeService {
|
|||||||
|
|
||||||
|
|
||||||
EmployeeEntity existEntity = employeeDao.getByLoginName(employeeUpdateForm.getLoginName(), false);
|
EmployeeEntity existEntity = employeeDao.getByLoginName(employeeUpdateForm.getLoginName(), false);
|
||||||
if (null != existEntity && !Objects.equals(existEntity.getId(), employeeId)) {
|
if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) {
|
||||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "登录名重复");
|
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "登录名重复");
|
||||||
}
|
}
|
||||||
|
|
||||||
existEntity = employeeDao.getByPhone(employeeUpdateForm.getPhone(), false);
|
existEntity = employeeDao.getByPhone(employeeUpdateForm.getPhone(), false);
|
||||||
if (null != existEntity && !Objects.equals(existEntity.getId(), employeeId)) {
|
if (null != existEntity && !Objects.equals(existEntity.getEmployeeId(), employeeId)) {
|
||||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "手机号已存在");
|
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "手机号已存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +240,6 @@ public class EmployeeService {
|
|||||||
if (null == employeeEntity) {
|
if (null == employeeEntity) {
|
||||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
employeeDao.updateDisableFlag(employeeId, !employeeEntity.getDisabledFlag());
|
employeeDao.updateDisableFlag(employeeId, !employeeEntity.getDisabledFlag());
|
||||||
|
|
||||||
employeeCacheService.clearCacheByEmployeeId(employeeId);
|
employeeCacheService.clearCacheByEmployeeId(employeeId);
|
||||||
@ -259,11 +260,10 @@ public class EmployeeService {
|
|||||||
if (employeeIdList.size() != employeeEntityList.size()) {
|
if (employeeIdList.size() != employeeEntityList.size()) {
|
||||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
// 更新
|
||||||
List<EmployeeEntity> updateList = employeeIdList.stream().map(e -> {
|
List<EmployeeEntity> updateList = employeeIdList.stream().map(e -> {
|
||||||
// 更新删除
|
|
||||||
EmployeeEntity updateEmployee = new EmployeeEntity();
|
EmployeeEntity updateEmployee = new EmployeeEntity();
|
||||||
updateEmployee.setId(e);
|
updateEmployee.setEmployeeId(e);
|
||||||
updateEmployee.setDepartmentId(batchUpdateDepartmentForm.getDepartmentId());
|
updateEmployee.setDepartmentId(batchUpdateDepartmentForm.getDepartmentId());
|
||||||
return updateEmployee;
|
return updateEmployee;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
@ -271,7 +271,7 @@ public class EmployeeService {
|
|||||||
|
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
employeeEntityList.forEach(e -> {
|
employeeEntityList.forEach(e -> {
|
||||||
employeeCacheService.clearCacheByEmployeeId(e.getId());
|
employeeCacheService.clearCacheByEmployeeId(e.getEmployeeId());
|
||||||
employeeCacheService.clearCacheByDepartmentId(e.getDepartmentId());
|
employeeCacheService.clearCacheByDepartmentId(e.getDepartmentId());
|
||||||
});
|
});
|
||||||
employeeCacheService.clearCacheByDepartmentId(batchUpdateDepartmentForm.getDepartmentId());
|
employeeCacheService.clearCacheByDepartmentId(batchUpdateDepartmentForm.getDepartmentId());
|
||||||
@ -305,7 +305,7 @@ public class EmployeeService {
|
|||||||
|
|
||||||
// 更新密码
|
// 更新密码
|
||||||
EmployeeEntity updateEntity = new EmployeeEntity();
|
EmployeeEntity updateEntity = new EmployeeEntity();
|
||||||
updateEntity.setId(employeeId);
|
updateEntity.setEmployeeId(employeeId);
|
||||||
updateEntity.setLoginPwd(getEncryptPwd(newPassword));
|
updateEntity.setLoginPwd(getEncryptPwd(newPassword));
|
||||||
employeeDao.updateById(updateEntity);
|
employeeDao.updateById(updateEntity);
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ public class EmployeeService {
|
|||||||
}
|
}
|
||||||
// 获取部门
|
// 获取部门
|
||||||
List<DepartmentVO> departmentList = departmentCacheService.departmentCache();
|
List<DepartmentVO> departmentList = departmentCacheService.departmentCache();
|
||||||
Optional<DepartmentVO> departmentVO = departmentList.stream().filter(e -> e.getId().equals(departmentId)).findFirst();
|
Optional<DepartmentVO> departmentVO = departmentList.stream().filter(e -> e.getDepartmentId().equals(departmentId)).findFirst();
|
||||||
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
||||||
return ResponseDTO.ok(Collections.emptyList());
|
return ResponseDTO.ok(Collections.emptyList());
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ import io.jsonwebtoken.Claims;
|
|||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeService;
|
import net.lab1024.smartadmin.service.module.system.employee.service.EmployeeService;
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.LoginUserDetail;
|
import net.lab1024.smartadmin.service.module.system.login.domain.LoginUserDetail;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -10,7 +10,7 @@ import net.lab1024.smartadmin.service.module.support.captcha.domain.CaptchaVO;
|
|||||||
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
import net.lab1024.smartadmin.service.module.system.employee.EmployeeDao;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeService;
|
import net.lab1024.smartadmin.service.module.system.employee.service.EmployeeService;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
import net.lab1024.smartadmin.service.module.system.employee.domain.entity.EmployeeEntity;
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.LoginForm;
|
import net.lab1024.smartadmin.service.module.system.login.domain.LoginForm;
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.LoginResultVO;
|
import net.lab1024.smartadmin.service.module.system.login.domain.LoginResultVO;
|
||||||
@ -90,21 +90,21 @@ public class LoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 生成 登录token
|
// 生成 登录token
|
||||||
String token = jwtService.generateJwtToken(employeeEntity.getId());
|
String token = jwtService.generateJwtToken(employeeEntity.getEmployeeId());
|
||||||
// 获取前端菜单以及功能权限
|
// 获取前端菜单以及功能权限
|
||||||
MenuLoginBO menuLoginBORespDTO = menuEmployeeService.queryMenuTreeByEmployeeId(employeeEntity.getId());
|
MenuLoginBO menuLoginBORespDTO = menuEmployeeService.queryMenuTreeByEmployeeId(employeeEntity.getEmployeeId());
|
||||||
// 查询部门
|
// 查询部门
|
||||||
DepartmentEntity departmentEntity = departmentDao.selectById(employeeEntity.getDepartmentId());
|
DepartmentEntity departmentEntity = departmentDao.selectById(employeeEntity.getDepartmentId());
|
||||||
// 返回登录结果
|
// 返回登录结果
|
||||||
LoginResultVO loginResultDTO = SmartBeanUtil.copy(employeeEntity, LoginResultVO.class);
|
LoginResultVO loginResultDTO = SmartBeanUtil.copy(employeeEntity, LoginResultVO.class);
|
||||||
loginResultDTO.setEmployeeId(employeeEntity.getId());
|
loginResultDTO.setEmployeeId(employeeEntity.getEmployeeId());
|
||||||
loginResultDTO.setMenuTree(menuLoginBORespDTO.getMenuTree());
|
loginResultDTO.setMenuTree(menuLoginBORespDTO.getMenuTree());
|
||||||
loginResultDTO.setMenuList(menuLoginBORespDTO.getMenuList());
|
loginResultDTO.setMenuList(menuLoginBORespDTO.getMenuList());
|
||||||
loginResultDTO.setAllMenuList(menuLoginBORespDTO.getAllMenuList());
|
loginResultDTO.setAllMenuList(menuLoginBORespDTO.getAllMenuList());
|
||||||
loginResultDTO.setPointsList(menuLoginBORespDTO.getPointsList());
|
loginResultDTO.setPointsList(menuLoginBORespDTO.getPointsList());
|
||||||
loginResultDTO.setDepartmentName(null == departmentEntity ? StringConst.EMPTY_STR : departmentEntity.getName());
|
loginResultDTO.setDepartmentName(null == departmentEntity ? StringConst.EMPTY_STR : departmentEntity.getName());
|
||||||
loginResultDTO.setToken(token);
|
loginResultDTO.setToken(token);
|
||||||
loginResultDTO.setIsSuperMan(menuEmployeeService.isSuperman(employeeEntity.getId()));
|
loginResultDTO.setIsSuperMan(menuEmployeeService.isSuperman(employeeEntity.getEmployeeId()));
|
||||||
|
|
||||||
return ResponseDTO.ok(loginResultDTO);
|
return ResponseDTO.ok(loginResultDTO);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package net.lab1024.smartadmin.service.module.system.menu.service;
|
|||||||
|
|
||||||
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
import com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap;
|
||||||
import net.lab1024.smartadmin.service.common.util.SmartStringUtil;
|
import net.lab1024.smartadmin.service.common.util.SmartStringUtil;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeService;
|
import net.lab1024.smartadmin.service.module.system.employee.service.EmployeeService;
|
||||||
import net.lab1024.smartadmin.service.module.system.login.domain.RequestEmployee;
|
import net.lab1024.smartadmin.service.module.system.login.domain.RequestEmployee;
|
||||||
import net.lab1024.smartadmin.service.module.system.menu.constant.MenuTypeEnum;
|
import net.lab1024.smartadmin.service.module.system.menu.constant.MenuTypeEnum;
|
||||||
import net.lab1024.smartadmin.service.module.system.menu.domain.bo.MenuLoginBO;
|
import net.lab1024.smartadmin.service.module.system.menu.domain.bo.MenuLoginBO;
|
||||||
|
@ -20,7 +20,11 @@ import net.lab1024.smartadmin.service.module.system.role.domain.entity.RoleEntit
|
|||||||
@Component
|
@Component
|
||||||
public interface RoleDao extends BaseMapper<RoleEntity> {
|
public interface RoleDao extends BaseMapper<RoleEntity> {
|
||||||
|
|
||||||
|
/**
|
||||||
RoleEntity getByRoleName(@Param("roleName") String name);
|
* 根据角色名称查询
|
||||||
|
* @param roleName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
RoleEntity getByRoleName(@Param("roleName") String roleName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,4 @@ public interface RoleDataScopeDao extends BaseMapper<RoleDataScopeEntity> {
|
|||||||
*/
|
*/
|
||||||
void deleteByRoleId(@Param("roleId") Long roleId);
|
void deleteByRoleId(@Param("roleId") Long roleId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量添加设置信息
|
|
||||||
* @param list
|
|
||||||
*/
|
|
||||||
void batchInsert(@Param("list")List<RoleDataScopeEntity> list);
|
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,11 @@ import lombok.Data;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* [ 角色 ]
|
* [ 角色 ]
|
||||||
*
|
*
|
||||||
* @author yandanyang
|
* @author 罗伊
|
||||||
* @version 1.0
|
* @date
|
||||||
* @company 1024lab.net
|
|
||||||
* @copyright (c) 2018 1024lab.netInc. All rights reserved.
|
|
||||||
* @date 2019/3/27 0027 下午 13:01
|
|
||||||
* @since JDK1.8
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("t_role")
|
@TableName("t_role")
|
||||||
@ -24,7 +21,7 @@ public class RoleEntity {
|
|||||||
* 主键id
|
* 主键id
|
||||||
*/
|
*/
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long id;
|
private Long roleId;
|
||||||
|
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class RoleUpdateForm extends RoleAddForm {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("角色id")
|
@ApiModelProperty("角色id")
|
||||||
@NotNull(message = "角色id不能为空")
|
@NotNull(message = "角色id不能为空")
|
||||||
protected Long id;
|
protected Long roleId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import lombok.Data;
|
|||||||
public class RoleVO {
|
public class RoleVO {
|
||||||
|
|
||||||
@ApiModelProperty("角色ID")
|
@ApiModelProperty("角色ID")
|
||||||
private Long id;
|
private Long roleId;
|
||||||
|
|
||||||
@ApiModelProperty("角色名称")
|
@ApiModelProperty("角色名称")
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
package net.lab1024.smartadmin.service.module.system.role.manager;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||||
|
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.dao.RoleDataScopeDao;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.entity.RoleDataScopeEntity;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.form.RoleDataScopeUpdateForm;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.vo.RoleDataScopeVO;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* [ ]
|
||||||
|
*
|
||||||
|
* @author yandanyang
|
||||||
|
* @date
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RoleDataScopeManager extends ServiceImpl<RoleDataScopeDao,RoleDataScopeEntity> {
|
||||||
|
|
||||||
|
}
|
@ -1,17 +1,17 @@
|
|||||||
package net.lab1024.smartadmin.service.module.system.role.service;
|
package net.lab1024.smartadmin.service.module.system.role.service;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||||
|
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.entity.RoleDataScopeEntity;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.form.RoleDataScopeUpdateForm;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.vo.RoleDataScopeVO;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.manager.RoleDataScopeManager;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
|
||||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.domain.entity.RoleDataScopeEntity;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleDataScopeDao;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.domain.form.RoleDataScopeUpdateForm;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.domain.vo.RoleDataScopeVO;
|
|
||||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
public class RoleDataScopeService {
|
public class RoleDataScopeService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoleDataScopeDao roleDataScopeDao;
|
private RoleDataScopeManager roleDataScopeManager;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +33,7 @@ public class RoleDataScopeService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<List<RoleDataScopeVO>> getRoleDataScopeList(Long roleId) {
|
public ResponseDTO<List<RoleDataScopeVO>> getRoleDataScopeList(Long roleId) {
|
||||||
List<RoleDataScopeEntity> roleDataScopeEntityList = roleDataScopeDao.listByRoleId(roleId);
|
List<RoleDataScopeEntity> roleDataScopeEntityList = roleDataScopeManager.getBaseMapper().listByRoleId(roleId);
|
||||||
if (CollectionUtils.isEmpty(roleDataScopeEntityList)) {
|
if (CollectionUtils.isEmpty(roleDataScopeEntityList)) {
|
||||||
return ResponseDTO.ok(Lists.newArrayList());
|
return ResponseDTO.ok(Lists.newArrayList());
|
||||||
}
|
}
|
||||||
@ -55,8 +55,8 @@ public class RoleDataScopeService {
|
|||||||
}
|
}
|
||||||
List<RoleDataScopeEntity> roleDataScopeEntityList = SmartBeanUtil.copyList(batchSetList, RoleDataScopeEntity.class);
|
List<RoleDataScopeEntity> roleDataScopeEntityList = SmartBeanUtil.copyList(batchSetList, RoleDataScopeEntity.class);
|
||||||
roleDataScopeEntityList.forEach(e -> e.setRoleId(roleDataScopeUpdateForm.getRoleId()));
|
roleDataScopeEntityList.forEach(e -> e.setRoleId(roleDataScopeUpdateForm.getRoleId()));
|
||||||
roleDataScopeDao.deleteByRoleId(roleDataScopeUpdateForm.getRoleId());
|
roleDataScopeManager.getBaseMapper().deleteByRoleId(roleDataScopeUpdateForm.getRoleId());
|
||||||
roleDataScopeDao.batchInsert(roleDataScopeEntityList);
|
roleDataScopeManager.saveBatch(roleDataScopeEntityList);
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
|||||||
import net.lab1024.smartadmin.service.common.util.SmartPageUtil;
|
import net.lab1024.smartadmin.service.common.util.SmartPageUtil;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
import net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao;
|
||||||
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
import net.lab1024.smartadmin.service.module.system.department.domain.entity.DepartmentEntity;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.EmployeeCacheService;
|
import net.lab1024.smartadmin.service.module.system.employee.service.EmployeeCacheService;
|
||||||
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
import net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO;
|
||||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleDao;
|
import net.lab1024.smartadmin.service.module.system.role.dao.RoleDao;
|
||||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleEmployeeDao;
|
import net.lab1024.smartadmin.service.module.system.role.dao.RoleEmployeeDao;
|
||||||
@ -39,13 +39,10 @@ public class RoleEmployeeService {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoleEmployeeDao roleEmployeeDao;
|
private RoleEmployeeDao roleEmployeeDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoleDao roleDao;
|
private RoleDao roleDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DepartmentDao departmentDao;
|
private DepartmentDao departmentDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoleEmployeeManager roleEmployeeManager;
|
private RoleEmployeeManager roleEmployeeManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -63,7 +60,7 @@ public class RoleEmployeeService {
|
|||||||
List<Long> departmentIdList = employeeDTOS.stream().filter(e -> e.getDepartmentId() != null).map(EmployeeVO::getDepartmentId).collect(Collectors.toList());
|
List<Long> departmentIdList = employeeDTOS.stream().filter(e -> e.getDepartmentId() != null).map(EmployeeVO::getDepartmentId).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(departmentIdList)) {
|
if (CollectionUtils.isNotEmpty(departmentIdList)) {
|
||||||
List<DepartmentEntity> departmentEntities = departmentDao.selectBatchIds(departmentIdList);
|
List<DepartmentEntity> departmentEntities = departmentDao.selectBatchIds(departmentIdList);
|
||||||
Map<Long, String> departmentIdNameMap = departmentEntities.stream().collect(Collectors.toMap(DepartmentEntity::getId, DepartmentEntity::getName));
|
Map<Long, String> departmentIdNameMap = departmentEntities.stream().collect(Collectors.toMap(DepartmentEntity::getDepartmentId, DepartmentEntity::getName));
|
||||||
employeeDTOS.forEach(e -> {
|
employeeDTOS.forEach(e -> {
|
||||||
e.setDepartmentName(departmentIdNameMap.getOrDefault(e.getDepartmentId(), StringConst.EMPTY_STR));
|
e.setDepartmentName(departmentIdNameMap.getOrDefault(e.getDepartmentId(), StringConst.EMPTY_STR));
|
||||||
});
|
});
|
||||||
@ -141,7 +138,7 @@ public class RoleEmployeeService {
|
|||||||
List<Long> roleIds = roleEmployeeDao.selectRoleIdByEmployeeId(employeeId);
|
List<Long> roleIds = roleEmployeeDao.selectRoleIdByEmployeeId(employeeId);
|
||||||
List<RoleEntity> roleList = roleDao.selectList(null);
|
List<RoleEntity> roleList = roleDao.selectList(null);
|
||||||
List<RoleSelectedVO> result = SmartBeanUtil.copyList(roleList, RoleSelectedVO.class);
|
List<RoleSelectedVO> result = SmartBeanUtil.copyList(roleList, RoleSelectedVO.class);
|
||||||
result.stream().forEach(item -> item.setSelected(roleIds.contains(item.getId())));
|
result.stream().forEach(item -> item.setSelected(roleIds.contains(item.getRoleId())));
|
||||||
return ResponseDTO.ok(result);
|
return ResponseDTO.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package net.lab1024.smartadmin.service.module.system.role.service;
|
package net.lab1024.smartadmin.service.module.system.role.service;
|
||||||
|
|
||||||
|
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
||||||
|
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
||||||
|
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.dao.RoleDao;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.dao.RoleEmployeeDao;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.dao.RoleMenuDao;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.entity.RoleEntity;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.form.RoleAddForm;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.form.RoleUpdateForm;
|
||||||
|
import net.lab1024.smartadmin.service.module.system.role.domain.vo.RoleVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import net.lab1024.smartadmin.service.common.code.UserErrorCode;
|
|
||||||
import net.lab1024.smartadmin.service.common.domain.ResponseDTO;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleDao;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.domain.form.RoleAddForm;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.domain.form.RoleUpdateForm;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.domain.entity.RoleEntity;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.domain.vo.RoleVO;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleEmployeeDao;
|
|
||||||
import net.lab1024.smartadmin.service.module.system.role.dao.RoleMenuDao;
|
|
||||||
import net.lab1024.smartadmin.service.common.util.SmartBeanUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ public class RoleService {
|
|||||||
* @return ResponseDTO
|
* @return ResponseDTO
|
||||||
*/
|
*/
|
||||||
public ResponseDTO addRole(RoleAddForm roleAddForm) {
|
public ResponseDTO addRole(RoleAddForm roleAddForm) {
|
||||||
RoleEntity employeeRoleEntity = roleDao.getByRoleName(roleAddForm.getRoleName());
|
RoleEntity existRoleEntity = roleDao.getByRoleName(roleAddForm.getRoleName());
|
||||||
if (null != employeeRoleEntity) {
|
if (null != existRoleEntity) {
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST, "角色名称重复");
|
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "角色名称重复");
|
||||||
}
|
}
|
||||||
RoleEntity roleEntity = SmartBeanUtil.copy(roleAddForm, RoleEntity.class);
|
RoleEntity roleEntity = SmartBeanUtil.copy(roleAddForm, RoleEntity.class);
|
||||||
roleDao.insert(roleEntity);
|
roleDao.insert(roleEntity);
|
||||||
@ -76,11 +76,11 @@ public class RoleService {
|
|||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ResponseDTO<String> updateRole(RoleUpdateForm roleUpdateForm) {
|
public ResponseDTO<String> updateRole(RoleUpdateForm roleUpdateForm) {
|
||||||
if (null == roleDao.selectById(roleUpdateForm.getId())) {
|
if (null == roleDao.selectById(roleUpdateForm.getRoleId())) {
|
||||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||||
}
|
}
|
||||||
RoleEntity employeeRoleEntity = roleDao.getByRoleName(roleUpdateForm.getRoleName());
|
RoleEntity existRoleEntity = roleDao.getByRoleName(roleUpdateForm.getRoleName());
|
||||||
if (null != employeeRoleEntity && !employeeRoleEntity.getId().equals(roleUpdateForm.getId())) {
|
if (null != existRoleEntity && !existRoleEntity.getRoleId().equals(roleUpdateForm.getRoleId())) {
|
||||||
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "角色名称重复");
|
return ResponseDTO.error(UserErrorCode.PARAM_ERROR, "角色名称重复");
|
||||||
}
|
}
|
||||||
RoleEntity roleEntity = SmartBeanUtil.copy(roleUpdateForm, RoleEntity.class);
|
RoleEntity roleEntity = SmartBeanUtil.copy(roleUpdateForm, RoleEntity.class);
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao">
|
<mapper namespace="net.lab1024.smartadmin.service.module.system.department.dao.DepartmentDao">
|
||||||
|
|
||||||
<sql id="baseSql">
|
|
||||||
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="listAll" resultType="net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO">
|
<select id="listAll" resultType="net.lab1024.smartadmin.service.module.system.department.domain.vo.DepartmentVO">
|
||||||
SELECT
|
SELECT
|
||||||
@ -13,8 +10,8 @@
|
|||||||
pd.`name` as parentName
|
pd.`name` as parentName
|
||||||
FROM
|
FROM
|
||||||
t_department d
|
t_department d
|
||||||
left join t_employee e on d.manager_id= e.id
|
left join t_employee e on d.manager_id= e.employee_id
|
||||||
left join t_department pd on d.parent_id = pd.id
|
left join t_department pd on d.parent_id = pd.department_id
|
||||||
order by sort desc
|
order by sort desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
e.*,
|
e.*,
|
||||||
d.name AS departmentName
|
d.name AS departmentName
|
||||||
FROM t_employee e
|
FROM t_employee e
|
||||||
LEFT JOIN t_department d ON d.id = e.department_id
|
LEFT JOIN t_department d ON d.department_id = e.department_id
|
||||||
<where>
|
<where>
|
||||||
<if test="queryForm.keyword != null and queryForm.keyword != ''">
|
<if test="queryForm.keyword != null and queryForm.keyword != ''">
|
||||||
AND (
|
AND (
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<update id="updateDisableFlag">
|
<update id="updateDisableFlag">
|
||||||
UPDATE t_employee
|
UPDATE t_employee
|
||||||
SET disabled_flag = #{disabledFlag}
|
SET disabled_flag = #{disabledFlag}
|
||||||
WHERE id = #{id}
|
WHERE employee_id = #{employeeId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +113,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getEmployeeIdByDepartmentIdList" resultType="java.lang.Long">
|
<select id="getEmployeeIdByDepartmentIdList" resultType="java.lang.Long">
|
||||||
SELECT id
|
SELECT employee_id
|
||||||
FROM t_employee
|
FROM t_employee
|
||||||
<where>
|
<where>
|
||||||
department_id IN
|
department_id IN
|
||||||
@ -129,7 +129,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<select id="getEmployeeId" resultType="java.lang.Long">
|
<select id="getEmployeeId" resultType="java.lang.Long">
|
||||||
SELECT id
|
SELECT employee_id
|
||||||
FROM t_employee
|
FROM t_employee
|
||||||
<where>
|
<where>
|
||||||
<if test="disabledFlag != null">
|
<if test="disabledFlag != null">
|
||||||
@ -139,7 +139,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getEmployeeIdByDepartmentId" resultType="java.lang.Long">
|
<select id="getEmployeeIdByDepartmentId" resultType="java.lang.Long">
|
||||||
SELECT id
|
SELECT employee_id
|
||||||
FROM t_employee
|
FROM t_employee
|
||||||
<where>
|
<where>
|
||||||
department_id = #{departmentId}
|
department_id = #{departmentId}
|
||||||
@ -152,8 +152,8 @@
|
|||||||
|
|
||||||
<select id="getEmployeeByIds" resultType="net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO">
|
<select id="getEmployeeByIds" resultType="net.lab1024.smartadmin.service.module.system.employee.domain.vo.EmployeeVO">
|
||||||
SELECT * FROM t_employee
|
SELECT * FROM t_employee
|
||||||
where id IN
|
where employee_id IN
|
||||||
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
<foreach collection="employeeIds" item="item" open="(" close=")" separator=",">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
ORDER BY create_time DESC
|
ORDER BY create_time DESC
|
||||||
@ -164,14 +164,14 @@
|
|||||||
SELECT e.*,
|
SELECT e.*,
|
||||||
d.name AS departmentName
|
d.name AS departmentName
|
||||||
FROM t_employee e
|
FROM t_employee e
|
||||||
LEFT JOIN t_department d ON d.id = e.department_id
|
LEFT JOIN t_department d ON d.department_id = e.department_id
|
||||||
where e.id = #{id}
|
where e.employee_id = #{employeeId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updatePassword">
|
<update id="updatePassword">
|
||||||
UPDATE t_employee
|
UPDATE t_employee
|
||||||
SET login_pwd = #{password}
|
SET login_pwd = #{password}
|
||||||
WHERE id = #{employeeId}
|
WHERE employee_id = #{employeeId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,17 +20,5 @@
|
|||||||
WHERE role_id = #{roleId}
|
WHERE role_id = #{roleId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<insert id="batchInsert" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List">
|
|
||||||
INSERT INTO t_role_data_scope (data_scope_type,view_type,role_id,update_time,create_time) VALUES
|
|
||||||
<foreach collection="list" item="item" separator=",">
|
|
||||||
(
|
|
||||||
#{item.dataScopeType},
|
|
||||||
#{item.viewType},
|
|
||||||
#{item.roleId},
|
|
||||||
now(),
|
|
||||||
now()
|
|
||||||
)
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user