refactor(system): 更新用户部门时同步更新日志使用人部门- 在 AdminUserServiceImpl 中添加更新日志使用人部门的逻辑- 在 LogUseService 接口中新增 updateUseDeptId 方法
- 在 LogUseServiceImpl 中实现 updateUseDeptId 方法 - 优化 LogInstanceServiceImpl 中的日志实例导出查询,支持查询所有下级部门
This commit is contained in:
parent
cdb4d79822
commit
57838d91dd
@ -41,6 +41,7 @@ import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
||||
import cn.iocoder.yudao.module.system.service.dept.PostService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
||||
import cn.iocoder.yudao.module.system.service.worklog.LogUseService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@ -100,6 +101,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@Resource
|
||||
private LogUseService logUseService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateUserOpenId(Long id, String openId) {
|
||||
@ -155,9 +159,14 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
userMapper.updateById(updateObj);
|
||||
// 更新岗位
|
||||
updateUserPost(updateReqVO, updateObj);
|
||||
|
||||
// 更新日志使用人信息
|
||||
logUseService.updateUseDeptId(updateObj.getId(), updateObj.getDeptId());
|
||||
|
||||
}
|
||||
|
||||
private void updateUserPost(UserSaveReqVO reqVO, AdminUserDO updateObj) {
|
||||
|
||||
Long userId = reqVO.getId();
|
||||
Set<Long> dbPostIds = convertSet(userPostMapper.selectListByUserId(userId), UserPostDO::getPostId);
|
||||
// 计算新增和删除的岗位编号
|
||||
|
@ -450,8 +450,11 @@ public class LogInstanceServiceImpl implements LogInstanceService {
|
||||
|
||||
@Override
|
||||
public List<LogExportExcelVO> getLogInstanceExport(LogExportVO reqVO) {
|
||||
// 获取所有部门及下级部门信息
|
||||
List<DeptDO> deptDOS = deptService.getChildDept(reqVO.getCompanyDeptId());
|
||||
|
||||
List<LogInstanceDO> list = logInstanceMapper.selectList(new LambdaQueryWrapperX<LogInstanceDO>()
|
||||
.eqIfPresent(LogInstanceDO::getDeptId, reqVO.getCompanyDeptId())
|
||||
.inIfPresent(LogInstanceDO::getDeptId, convertList(deptDOS, DeptDO::getId))
|
||||
.eqIfPresent(LogInstanceDO::getFormId, reqVO.getFormId())
|
||||
.betweenIfPresent(LogInstanceDO::getTime, reqVO.getTime()));
|
||||
|
||||
|
@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogFormMapper;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogRuleMapper;
|
||||
import cn.iocoder.yudao.module.system.service.worklog.dto.LogUseSaveReqDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -132,5 +133,4 @@ public class LogRuleServiceImpl implements LogRuleService {
|
||||
return logRuleMapper.selectOne(new LambdaQueryWrapper<LogRuleDO>()
|
||||
.eq(LogRuleDO::getFormId, formId));
|
||||
}
|
||||
|
||||
}
|
@ -74,4 +74,11 @@ public interface LogUseService {
|
||||
* @return 模版列表
|
||||
*/
|
||||
List<Long> getFormIdList(List<Long> deptIds);
|
||||
|
||||
/**
|
||||
* 更新日志规则使用部门id
|
||||
* @param userId 用户编号
|
||||
* @param deptId 部门编号
|
||||
*/
|
||||
void updateUseDeptId(Long userId, Long deptId);
|
||||
}
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogUseDO;
|
||||
import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogUseMapper;
|
||||
import cn.iocoder.yudao.module.system.service.worklog.dto.LogUseSaveReqDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -106,4 +107,12 @@ public class LogUseServiceImpl implements LogUseService {
|
||||
List<LogUseDO> logUseDOS = logUseMapper.selectList(LogUseDO::getUseUserDept, deptIds);
|
||||
return logUseDOS.stream().map(LogUseDO::getFormId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUseDeptId(Long userId, Long deptId) {
|
||||
|
||||
logUseMapper.update(null, new LambdaUpdateWrapper<LogUseDO>()
|
||||
.set(LogUseDO::getUseUserDept, deptId)
|
||||
.eq(LogUseDO::getUseUserId, userId));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user