|
|
|
@ -7,7 +7,11 @@ import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil; |
|
|
|
import com.hxhq.business.domain.SystemLog; |
|
|
|
import com.hxhq.business.enums.dept.DeptTypeEnum; |
|
|
|
import com.hxhq.business.service.ISystemLogService; |
|
|
|
import com.hxhq.business.utils.ObjectCompareUtil; |
|
|
|
import com.hxhq.system.domain.SysMenu; |
|
|
|
import com.hxhq.system.domain.vo.TreeSelect; |
|
|
|
import com.hxhq.system.mapper.SysDeptMapper; |
|
|
|
import com.hxhq.system.mapper.SysRoleMapper; |
|
|
|
@ -40,6 +44,9 @@ public class SysDeptServiceImpl implements ISysDeptService |
|
|
|
@Autowired |
|
|
|
private SysRoleMapper roleMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ISystemLogService systemLogService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询部门管理数据 |
|
|
|
* |
|
|
|
@ -223,7 +230,10 @@ public class SysDeptServiceImpl implements ISysDeptService |
|
|
|
throw new ServiceException("部门停用,不允许新增"); |
|
|
|
} |
|
|
|
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); |
|
|
|
return deptMapper.insertDept(dept); |
|
|
|
|
|
|
|
int row = deptMapper.insertDept(dept); |
|
|
|
systemLogService.saveInfo(dept.getDeptName(),null,"新增部门","Create Department",null,null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),SecurityUtils.getUsername(),null); |
|
|
|
return row; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -251,6 +261,11 @@ public class SysDeptServiceImpl implements ISysDeptService |
|
|
|
// 如果该部门是启用状态,则启用该部门的所有上级部门 |
|
|
|
updateParentDeptStatusNormal(dept); |
|
|
|
} |
|
|
|
|
|
|
|
List<SystemLog> logList = getModifyLogList(dept,oldDept); |
|
|
|
if(logList.size()>0){ |
|
|
|
systemLogService.saveBatch(logList); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@ -295,7 +310,10 @@ public class SysDeptServiceImpl implements ISysDeptService |
|
|
|
@Override |
|
|
|
public int deleteDeptById(Long deptId) |
|
|
|
{ |
|
|
|
return deptMapper.deleteDeptById(deptId); |
|
|
|
SysDept sysDept = deptMapper.selectDeptById(deptId); |
|
|
|
int row = deptMapper.deleteDeptById(deptId); |
|
|
|
systemLogService.saveInfo(sysDept.getDeptName(),null,"删除部门","Remove Department",null,null,SecurityUtils.getUserId(),SecurityUtils.getNickName(),SecurityUtils.getUsername(),null); |
|
|
|
return row; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -368,4 +386,55 @@ public class SysDeptServiceImpl implements ISysDeptService |
|
|
|
{ |
|
|
|
return getChildList(list, t).size() > 0 ? true : false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取修改日志 |
|
|
|
* @param info |
|
|
|
* @param old |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<SystemLog> getModifyLogList(SysDept info, SysDept old){ |
|
|
|
List<SystemLog> list = new ArrayList<>(); |
|
|
|
|
|
|
|
List<ObjectCompareUtil.FieldChange> fieldChanges = ObjectCompareUtil.compareObjects(old, info); |
|
|
|
for (ObjectCompareUtil.FieldChange fieldChange : fieldChanges) { |
|
|
|
SystemLog log = getLogInfo(old); |
|
|
|
log.setJcnr(fieldChange.toString()); |
|
|
|
log.setJcnrEn(fieldChange.toEnString()); |
|
|
|
list.add(log); |
|
|
|
} |
|
|
|
if(!info.getType().equals(old.getType())){ |
|
|
|
SystemLog log = getLogInfo(old); |
|
|
|
log.setJcnr("[{\"name\":\"字段名\",\"value\":\"状态\"},{\"name\":\"原值\",\"value\":\""+(old.getType().equals(DeptTypeEnum.dept.getValue())?"部门":old.getType().equals(DeptTypeEnum.subject.getValue())?"学科":"小组")+"\"},{\"name\":\"新值\",\"value\":\""+(info.getType().equals(DeptTypeEnum.dept.getValue())?"部门":info.getType().equals(DeptTypeEnum.subject.getValue())?"学科":"小组")+"\"}]"); |
|
|
|
log.setJcnrEn("[{\"name\":\"Field\",\"value\":\"Status\"},{\"name\":\"Old Value\",\"value\":\""+(old.getType().equals(DeptTypeEnum.dept.getValue())?"Department":old.getType().equals(DeptTypeEnum.subject.getValue())?"Discipline":"Team")+"\"},{\"name\":\"New Value\",\"value\":\""+(info.getType().equals(DeptTypeEnum.dept.getValue())?"Department":info.getType().equals(DeptTypeEnum.subject.getValue())?"Discipline":"Team")+"\"}]"); |
|
|
|
list.add(log); |
|
|
|
} |
|
|
|
|
|
|
|
if(!info.getParentId().equals(old.getParentId())){ |
|
|
|
SysDept oldParent = deptMapper.selectDeptById(old.getParentId()); |
|
|
|
SysDept newParent = deptMapper.selectDeptById(info.getParentId()); |
|
|
|
|
|
|
|
SystemLog log = getLogInfo(old); |
|
|
|
log.setJcnr("[{\"name\":\"字段名\",\"value\":\"上级部门\"},{\"name\":\"原值\",\"value\":\""+oldParent.getDeptName()+"\"},{\"name\":\"新值\",\"value\":\""+newParent.getDeptName()+"\"}]"); |
|
|
|
log.setJcnrEn("[{\"name\":\"Field\",\"value\":\"Parent\"},{\"name\":\"Old Value\",\"value\":\""+oldParent.getDeptName()+"\"},{\"name\":\"New Value\",\"value\":\""+newParent.getDeptName()+"\"}]"); |
|
|
|
list.add(log); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取日志基础信息 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private SystemLog getLogInfo(SysDept sysDept){ |
|
|
|
SystemLog log = new SystemLog(); |
|
|
|
log.setName(sysDept.getDeptName()); |
|
|
|
log.setNameEn(sysDept.getDeptName()); |
|
|
|
log.setJcmc("编辑部门"); |
|
|
|
log.setJcmcEn("Edit Department"); |
|
|
|
log.setQmrId(SecurityUtils.getUserId()); |
|
|
|
log.setQmrMc(SecurityUtils.getNickName()); |
|
|
|
log.setQmrMcEn(SecurityUtils.getUsername()); |
|
|
|
return log; |
|
|
|
} |
|
|
|
} |