Commit 07c454fe authored by 赵啸非's avatar 赵啸非

添加用户类型修改

parent 3cbf9bc6
......@@ -4,12 +4,12 @@ import java.util.LinkedHashMap;
import java.util.Map;
/**
* 启用状态 (0.停止,1.启用)枚举类
*
* @author zxfei
*/
* 启用状态 (0.停止,1.启用)枚举类
*
* @author zxfei
*/
public enum EnabledEnum {
(0, "停止"),
(0, "停用"),
启用(1, "启用");
private Integer value;
private String desc;
......
package com.mortals.xhx.module.dept.service.impl;
import com.mortals.xhx.common.code.EnableEnum;
import com.mortals.xhx.common.code.EnabledEnum;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
......@@ -7,7 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.common.code.DeptStatusEnum;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.module.dept.dao.DeptDao;
import com.mortals.xhx.module.dept.model.DeptEntity;
......@@ -34,13 +35,13 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
@Override
protected void saveBefore(DeptEntity entity, Context context) throws AppException {
if(ObjectUtils.isEmpty(entity.getParentId())){
if (ObjectUtils.isEmpty(entity.getParentId())) {
//如果父节点为空,默认挂载到根目录
entity.setParentId(0L);
}
DeptEntity parentDeptEntity = this.get(entity.getParentId());
if (!ObjectUtils.isEmpty(parentDeptEntity) && DeptStatusEnum.停用.getValue() == parentDeptEntity.getDeptStatus()) {
if (!ObjectUtils.isEmpty(parentDeptEntity) && EnabledEnum.停用.getValue() == parentDeptEntity.getDeptStatus()) {
throw new AppException("部门信息停用,不允许新增");
}
......@@ -56,7 +57,7 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
DeptEntity newParentEntity = this.get(entity.getParentId());
DeptEntity oldEntity = this.get(entity.getId());
if (!ObjectUtils.isEmpty(newParentEntity) && !ObjectUtils.isEmpty(oldEntity)) {
String newAncestors = newParentEntity.getAncestors() + "," +entity.getId();
String newAncestors = newParentEntity.getAncestors() + "," + entity.getId();
String oldAncestors = oldEntity.getAncestors();
entity.setAncestors(newAncestors);
updateDeptChildren(entity.getId(), newAncestors, oldAncestors, context);
......@@ -67,7 +68,7 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
@Override
protected void updateAfter(DeptEntity entity, Context context) throws AppException {
if (DeptStatusEnum.启用.getValue() == entity.getDeptStatus()) {
if (EnabledEnum.启用.getValue() == entity.getDeptStatus()) {
updateParentDeptStatus(entity, context);
}
super.updateAfter(entity, context);
......@@ -80,10 +81,10 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
*/
private void updateParentDeptStatus(DeptEntity dept, Context context) {
DeptEntity deptEntity = this.get(dept.getParentId());
if(!ObjectUtils.isEmpty(deptEntity)){
deptEntity.setDeptStatus(DeptStatusEnum.启用.getValue());
if (!ObjectUtils.isEmpty(deptEntity)) {
deptEntity.setDeptStatus(EnabledEnum.启用.getValue());
deptEntity.setUpdateTime(new Date());
deptEntity.setUpdateUser(context==null?"admin":context.getUser().getLoginName());
deptEntity.setUpdateUser(context == null ? "admin" : context.getUser().getLoginName());
DeptEntity condition = new DeptEntity();
condition.setId(deptEntity.getId());
this.updateBatch(deptEntity, condition, context);
......@@ -138,12 +139,12 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
for (Iterator<DeptEntity> iterator = list.iterator(); iterator.hasNext(); ) {
DeptEntity deptEntity = iterator.next();
List<StaffEntity> staffEntities = staffService.find(new StaffQuery().deptId(deptEntity.getId()));
List<Map<String,Object>> personList = new ArrayList<>();
staffEntities.forEach(item->{
Map<String,Object> map= new HashMap<>();
map.put("staffId",item.getId());
map.put("staffName",item.getName());
map.put("deptId",item.getDeptId());
List<Map<String, Object>> personList = new ArrayList<>();
staffEntities.forEach(item -> {
Map<String, Object> map = new HashMap<>();
map.put("staffId", item.getId());
map.put("staffName", item.getName());
map.put("deptId", item.getDeptId());
personList.add(map);
});
deptEntity.setPersonList(personList);
......@@ -208,6 +209,4 @@ public class DeptServiceImpl extends AbstractCRUDServiceImpl<DeptDao, DeptEntity
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment