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

添加用户类型修改

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