日志模块
This commit is contained in:
parent
d0c6c6691c
commit
875483cd93
@ -176,4 +176,8 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode LOG_INSTANCE_NOT_EXISTS = new ErrorCode(1_009_010_002, "日志实例的拓展不存在");
|
ErrorCode LOG_INSTANCE_NOT_EXISTS = new ErrorCode(1_009_010_002, "日志实例的拓展不存在");
|
||||||
|
|
||||||
ErrorCode LOG_RULE_NOT_EXISTS = new ErrorCode(1_009_010_003, "日志规则不存在");
|
ErrorCode LOG_RULE_NOT_EXISTS = new ErrorCode(1_009_010_003, "日志规则不存在");
|
||||||
|
|
||||||
|
ErrorCode LOG_RULE_NOT_FIND = new ErrorCode(1_009_010_004, "该模板没配置规则");
|
||||||
|
|
||||||
|
ErrorCode LOG_USE_NOT_EXISTS = new ErrorCode(1_009_010_005, "模板不存在");
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,16 @@ public class UserController {
|
|||||||
return success(UserConvert.INSTANCE.convert(user, dept, post));
|
return success(UserConvert.INSTANCE.convert(user, dept, post));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getByDeptIds")
|
||||||
|
@Operation(summary = "获得用户详情")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:user:query')")
|
||||||
|
public CommonResult<List<UserRespVO>> getUserByDeptIds(@RequestBody Collection<Long> deptIds) {
|
||||||
|
|
||||||
|
List<UserRespVO> user = userService.getUserByDeptIds(deptIds);
|
||||||
|
|
||||||
|
return success(user);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
@Operation(summary = "导出用户")
|
@Operation(summary = "导出用户")
|
||||||
@PreAuthorize("@ss.hasPermission('system:user:export')")
|
@PreAuthorize("@ss.hasPermission('system:user:export')")
|
||||||
|
@ -41,14 +41,14 @@ public class LogInstanceController {
|
|||||||
private LogInstanceService logInstanceService;
|
private LogInstanceService logInstanceService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建日志实例的拓展")
|
@Operation(summary = "创建日志实例")
|
||||||
@PreAuthorize("@ss.hasPermission('system:log-instance:create')")
|
@PreAuthorize("@ss.hasPermission('system:log-instance:create')")
|
||||||
public CommonResult<Long> createLogInstance(@Valid @RequestBody LogInstanceSaveReqVO createReqVO) {
|
public CommonResult<Long> createLogInstance(@Valid @RequestBody LogInstanceSaveReqVO createReqVO) {
|
||||||
return success(logInstanceService.createLogInstance(createReqVO));
|
return success(logInstanceService.createLogInstance(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新日志实例的拓展")
|
@Operation(summary = "更新日志实例")
|
||||||
@PreAuthorize("@ss.hasPermission('system:log-instance:update')")
|
@PreAuthorize("@ss.hasPermission('system:log-instance:update')")
|
||||||
public CommonResult<Boolean> updateLogInstance(@Valid @RequestBody LogInstanceSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateLogInstance(@Valid @RequestBody LogInstanceSaveReqVO updateReqVO) {
|
||||||
logInstanceService.updateLogInstance(updateReqVO);
|
logInstanceService.updateLogInstance(updateReqVO);
|
||||||
@ -56,7 +56,7 @@ public class LogInstanceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除日志实例的拓展")
|
@Operation(summary = "删除日志实例")
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('system:log-instance:delete')")
|
@PreAuthorize("@ss.hasPermission('system:log-instance:delete')")
|
||||||
public CommonResult<Boolean> deleteLogInstance(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> deleteLogInstance(@RequestParam("id") Long id) {
|
||||||
@ -65,7 +65,7 @@ public class LogInstanceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get")
|
||||||
@Operation(summary = "获得日志实例的拓展")
|
@Operation(summary = "获得日志实例")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('system:log-instance:query')")
|
@PreAuthorize("@ss.hasPermission('system:log-instance:query')")
|
||||||
public CommonResult<LogInstanceRespVO> getLogInstance(@RequestParam("id") Long id) {
|
public CommonResult<LogInstanceRespVO> getLogInstance(@RequestParam("id") Long id) {
|
||||||
@ -82,7 +82,7 @@ public class LogInstanceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得日志实例的拓展分页")
|
@Operation(summary = "获得我收到的日志分页列表")
|
||||||
@PreAuthorize("@ss.hasPermission('system:view-log:query')")
|
@PreAuthorize("@ss.hasPermission('system:view-log:query')")
|
||||||
public CommonResult<PageResult<LogInstanceRespVO>> getLogInstancePage(@Valid LogInstancePageReqVO pageReqVO) {
|
public CommonResult<PageResult<LogInstanceRespVO>> getLogInstancePage(@Valid LogInstancePageReqVO pageReqVO) {
|
||||||
PageResult<LogInstanceDO> pageResult = logInstanceService.getLogInstancePage(pageReqVO);
|
PageResult<LogInstanceDO> pageResult = logInstanceService.getLogInstancePage(pageReqVO);
|
||||||
|
@ -38,9 +38,6 @@ public class LogInstancePageReqVO extends PageParam {
|
|||||||
@Schema(description = "模板值")
|
@Schema(description = "模板值")
|
||||||
private Map<String, Object> formVariables;
|
private Map<String, Object> formVariables;
|
||||||
|
|
||||||
@Schema(description = "日志阅读状态", example = "2")
|
|
||||||
private Map<String, Object> readStatus;
|
|
||||||
|
|
||||||
@Schema(description = "附件信息")
|
@Schema(description = "附件信息")
|
||||||
private List<UploadUserFile> fileItems ;
|
private List<UploadUserFile> fileItems ;
|
||||||
|
|
||||||
|
@ -35,9 +35,6 @@ public class LogInstanceRespVO {
|
|||||||
@Schema(description = "模板值")
|
@Schema(description = "模板值")
|
||||||
private Map<String, Object> formVariables;
|
private Map<String, Object> formVariables;
|
||||||
|
|
||||||
@Schema(description = "日志阅读状态", example = "2")
|
|
||||||
private Map<String, Object> readStatus;
|
|
||||||
|
|
||||||
@Schema(description = "附件信息")
|
@Schema(description = "附件信息")
|
||||||
private List<UploadUserFile> fileItems ;
|
private List<UploadUserFile> fileItems ;
|
||||||
|
|
||||||
|
@ -15,12 +15,10 @@ public class LogInstanceSaveReqVO {
|
|||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20649")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20649")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "日志发起人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24292")
|
@Schema(description = "日志发起人的用户编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "24292")
|
||||||
@NotNull(message = "发起日志的用户编号不能为空")
|
|
||||||
private Long startUserId;
|
private Long startUserId;
|
||||||
|
|
||||||
@Schema(description = "日志发起人的部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24292")
|
@Schema(description = "日志发起人的部门编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "24292")
|
||||||
@NotNull(message = "发起日志的用户编号不能为空")
|
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
@Schema(description = "日志实例的名字", example = "张三")
|
@Schema(description = "日志实例的名字", example = "张三")
|
||||||
@ -35,9 +33,6 @@ public class LogInstanceSaveReqVO {
|
|||||||
@Schema(description = "模板值")
|
@Schema(description = "模板值")
|
||||||
private Map<String, Object> formVariables;
|
private Map<String, Object> formVariables;
|
||||||
|
|
||||||
@Schema(description = "日志阅读状态", example = "2")
|
|
||||||
private Map<String, Object> readStatus;
|
|
||||||
|
|
||||||
@Schema(description = "附件信息")
|
@Schema(description = "附件信息")
|
||||||
private List<UploadUserFile> fileItems ;
|
private List<UploadUserFile> fileItems ;
|
||||||
|
|
||||||
|
@ -17,9 +17,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class LogRulePageReqVO extends PageParam {
|
public class LogRulePageReqVO extends PageParam {
|
||||||
|
|
||||||
@Schema(description = "模板使用部门组")
|
|
||||||
private String deptIds;
|
|
||||||
|
|
||||||
@Schema(description = "日志类型 字典值 详情参考work_log_type", example = "2")
|
@Schema(description = "日志类型 字典值 详情参考work_log_type", example = "2")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
|
@ -16,10 +16,6 @@ public class LogRuleRespVO {
|
|||||||
@ExcelProperty("编号")
|
@ExcelProperty("编号")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "模板使用部门组", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@ExcelProperty("模板使用部门组")
|
|
||||||
private Long deptIds;
|
|
||||||
|
|
||||||
@Schema(description = "日志类型 字典值 详情参考work_log_type", example = "2")
|
@Schema(description = "日志类型 字典值 详情参考work_log_type", example = "2")
|
||||||
@ExcelProperty("日志类型")
|
@ExcelProperty("日志类型")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
@ -12,10 +12,6 @@ public class LogRuleSaveReqVO {
|
|||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21181")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21181")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "模板使用部门组", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
||||||
@NotNull(message = "模板使用部门组不能为空")
|
|
||||||
private String deptIds;
|
|
||||||
|
|
||||||
@Schema(description = "日志类型", example = "2")
|
@Schema(description = "日志类型", example = "2")
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
|
@ -61,12 +61,6 @@ public class LogInstanceDO extends BaseDO {
|
|||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private Map<String, Object> formVariables;
|
private Map<String, Object> formVariables;
|
||||||
|
|
||||||
/**
|
|
||||||
* 日志阅读状态
|
|
||||||
*/
|
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
|
||||||
private Map<String, Object> readStatus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 附件基本信息
|
* 附件基本信息
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.dataobject.worklog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志查看状态 DO
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@TableName("work_log_read")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class LogReadDo extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志实例编号
|
||||||
|
*/
|
||||||
|
private Long logInstanceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日这发起人的用户编号
|
||||||
|
*/
|
||||||
|
private Long startUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志查看人的用户编号
|
||||||
|
*/
|
||||||
|
private Long readUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志查看状态
|
||||||
|
* 0:未读
|
||||||
|
* 1:已读
|
||||||
|
*/
|
||||||
|
private Integer readStatus;
|
||||||
|
}
|
@ -24,10 +24,6 @@ public class LogRuleDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
|
||||||
* 模板使用部门组
|
|
||||||
*/
|
|
||||||
private String deptIds;
|
|
||||||
/**
|
/**
|
||||||
* 日志类型
|
* 日志类型
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.dataobject.worklog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志模板使用者 DO
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@TableName("work_log_use")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class LogUseDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板编号
|
||||||
|
*/
|
||||||
|
private Long formId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则编号
|
||||||
|
*/
|
||||||
|
private Long ruleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用者编号
|
||||||
|
*/
|
||||||
|
private Long useUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用者部门编号
|
||||||
|
*/
|
||||||
|
private Long useUserDept;
|
||||||
|
}
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserRespVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@ -53,4 +54,8 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void emptyOpenId(@Param("openId") String openId);
|
void emptyOpenId(@Param("openId") String openId);
|
||||||
|
|
||||||
|
List<AdminUserDO> selectListByRoleId(@Param("roleId") Long roleId);
|
||||||
|
|
||||||
|
List<UserRespVO> selectByDeptIds(@Param("deptIds") Collection<Long> deptIds);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.system.dal.mysql.worklog;
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstancePageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstancePageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogInstanceDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogInstanceDO;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,22 +23,22 @@ public interface LogInstanceMapper extends BaseMapperX<LogInstanceDO> {
|
|||||||
.likeIfPresent(LogInstanceDO::getName, reqVO.getName())
|
.likeIfPresent(LogInstanceDO::getName, reqVO.getName())
|
||||||
.eqIfPresent(LogInstanceDO::getFormId, reqVO.getFormId())
|
.eqIfPresent(LogInstanceDO::getFormId, reqVO.getFormId())
|
||||||
.eqIfPresent(LogInstanceDO::getFormVariables, reqVO.getFormVariables())
|
.eqIfPresent(LogInstanceDO::getFormVariables, reqVO.getFormVariables())
|
||||||
.eqIfPresent(LogInstanceDO::getReadStatus, reqVO.getReadStatus())
|
|
||||||
.eqIfPresent(LogInstanceDO::getFileItems, reqVO.getFileItems())
|
.eqIfPresent(LogInstanceDO::getFileItems, reqVO.getFileItems())
|
||||||
.betweenIfPresent(LogInstanceDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(LogInstanceDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(LogInstanceDO::getId));
|
.orderByDesc(LogInstanceDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default PageResult<LogInstanceDO> selectMyPage(Long userId, LogInstancePageReqVO reqVO) {
|
default PageResult<LogInstanceDO> selectMyPage(Long userId, LogInstancePageReqVO reqVO) {
|
||||||
|
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<LogInstanceDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<LogInstanceDO>()
|
||||||
.eqIfPresent(LogInstanceDO::getStartUserId, userId)
|
.eqIfPresent(LogInstanceDO::getStartUserId, userId)
|
||||||
.likeIfPresent(LogInstanceDO::getName, reqVO.getName())
|
.likeIfPresent(LogInstanceDO::getName, reqVO.getName())
|
||||||
.eqIfPresent(LogInstanceDO::getFormId, reqVO.getFormId())
|
.eqIfPresent(LogInstanceDO::getFormId, reqVO.getFormId())
|
||||||
.eqIfPresent(LogInstanceDO::getFormVariables, reqVO.getFormVariables())
|
.eqIfPresent(LogInstanceDO::getFormVariables, reqVO.getFormVariables())
|
||||||
.eqIfPresent(LogInstanceDO::getReadStatus, reqVO.getReadStatus())
|
|
||||||
.eqIfPresent(LogInstanceDO::getFileItems, reqVO.getFileItems())
|
.eqIfPresent(LogInstanceDO::getFileItems, reqVO.getFileItems())
|
||||||
.betweenIfPresent(LogInstanceDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(LogInstanceDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(LogInstanceDO::getId));
|
.orderByDesc(LogInstanceDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -4,7 +4,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.rule.LogRulePageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.rule.LogRulePageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogFormDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogInstanceDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogRuleDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogRuleDO;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,10 +21,8 @@ public interface LogRuleMapper extends BaseMapperX<LogRuleDO> {
|
|||||||
|
|
||||||
default PageResult<LogRuleDO> selectPage(LogRulePageReqVO reqVO) {
|
default PageResult<LogRuleDO> selectPage(LogRulePageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<LogRuleDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<LogRuleDO>()
|
||||||
.eqIfPresent(LogRuleDO::getDeptIds, reqVO.getDeptIds())
|
|
||||||
.eqIfPresent(LogRuleDO::getType, reqVO.getType())
|
.eqIfPresent(LogRuleDO::getType, reqVO.getType())
|
||||||
.betweenIfPresent(LogRuleDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(LogRuleDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(LogRuleDO::getId));
|
.orderByDesc(LogRuleDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.mysql.worklog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogUseDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志模板使用者 Mapper
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface LogUseMapper extends BaseMapperX<LogUseDO> {
|
||||||
|
}
|
@ -5,10 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -148,6 +145,14 @@ public interface AdminUserService {
|
|||||||
*/
|
*/
|
||||||
List<AdminUserDO> getUserListByDeptIds(Collection<Long> deptIds);
|
List<AdminUserDO> getUserListByDeptIds(Collection<Long> deptIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定岗位的用户数组
|
||||||
|
*
|
||||||
|
* @param deptIds 岗位数组
|
||||||
|
* @return 用户数组
|
||||||
|
*/
|
||||||
|
List<UserRespVO> getUserByDeptIds(Collection<Long> deptIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得指定岗位的用户数组
|
* 获得指定岗位的用户数组
|
||||||
*
|
*
|
||||||
|
@ -15,10 +15,7 @@ import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
|
|||||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportExcelVO;
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserImportRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
@ -251,6 +248,14 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
return userMapper.selectListByDeptIds(deptIds);
|
return userMapper.selectListByDeptIds(deptIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<UserRespVO> getUserByDeptIds(Collection<Long> deptIds) {
|
||||||
|
if (CollUtil.isEmpty(deptIds)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return userMapper.selectByDeptIds(deptIds);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AdminUserDO> getUserListByPostIds(Collection<Long> postIds) {
|
public List<AdminUserDO> getUserListByPostIds(Collection<Long> postIds) {
|
||||||
if (CollUtil.isEmpty(postIds)) {
|
if (CollUtil.isEmpty(postIds)) {
|
||||||
|
@ -6,26 +6,23 @@ import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.Lo
|
|||||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.worklog.vo.loginstance.LogInstanceSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.convert.worklog.LogInstanceConvert;
|
import cn.iocoder.yudao.module.system.convert.worklog.LogInstanceConvert;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogFormDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogInstanceDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogInstanceDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper;
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogRuleDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogInstanceMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.worklog.LogInstanceMapper;
|
||||||
import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum;
|
import cn.iocoder.yudao.module.system.service.dict.DictDataService;
|
||||||
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||||
import cn.iocoder.yudao.module.system.service.permission.MenuService;
|
|
||||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
|
||||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.LOG_INSTANCE_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.LOG_INSTANCE_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.LOG_RULE_NOT_FIND;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志实例的拓展 Service 实现类
|
* 日志实例的拓展 Service 实现类
|
||||||
@ -40,90 +37,108 @@ public class LogInstanceServiceImpl implements LogInstanceService {
|
|||||||
private LogInstanceMapper logInstanceMapper;
|
private LogInstanceMapper logInstanceMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MenuService menuService;
|
private DictDataService dictDataService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PermissionService permissionService;
|
private LogRuleService logRuleService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RoleService roleService;
|
private LogFormService logFormService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserRoleMapper userRoleMapper;
|
private AdminUserService adminUserService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AdminUserMapper adminUserMapper;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DeptService deptService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createLogInstance(LogInstanceSaveReqVO createReqVO) {
|
public Long createLogInstance(LogInstanceSaveReqVO createReqVO) {
|
||||||
// 插入
|
|
||||||
LogInstanceDO logInstance = BeanUtils.toBean(createReqVO, LogInstanceDO.class);
|
LogInstanceDO logInstance = BeanUtils.toBean(createReqVO, LogInstanceDO.class);
|
||||||
|
|
||||||
|
//获取日志类型
|
||||||
|
LogFormDO logFormDo = logFormService.getForm(createReqVO.getFormId());
|
||||||
|
LogRuleDO logRuleDO = logRuleService.getLogRule(logFormDo.getRuleId());
|
||||||
|
if (logRuleDO == null) {
|
||||||
|
throw exception(LOG_RULE_NOT_FIND);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取部门信息
|
||||||
|
AdminUserDO adminUserDO = adminUserService.getUser(getLoginUserId());
|
||||||
|
|
||||||
|
//获取字典值
|
||||||
|
DictDataDO dictDataDO = dictDataService.getDictData("work_log_type", String.valueOf(logRuleDO.getType()));
|
||||||
|
|
||||||
|
//设置发起人用户编号
|
||||||
|
logInstance.setStartUserId(getLoginUserId());
|
||||||
|
//设置发起人部门编号
|
||||||
|
logInstance.setDeptId(adminUserDO.getDeptId());
|
||||||
|
//设置日志类型
|
||||||
|
logInstance.setType(logRuleDO.getType());
|
||||||
|
//设置日志名称
|
||||||
|
logInstance.setName(adminUserDO.getNickname() + "的" + dictDataDO.getLabel());
|
||||||
|
|
||||||
|
// 插入
|
||||||
logInstanceMapper.insert(logInstance);
|
logInstanceMapper.insert(logInstance);
|
||||||
|
|
||||||
//根据查询权限获取menuID
|
// //根据查询权限获取menuID
|
||||||
List<Long> menuIds = menuService.getMenuIdListByPermissionFromCache("system:view-log:query");
|
// List<Long> menuIds = menuService.getMenuIdListByPermissionFromCache("system:view-log:query");
|
||||||
if (menuIds != null && !menuIds.isEmpty()) {
|
// if (menuIds != null && !menuIds.isEmpty()) {
|
||||||
|
//
|
||||||
Map<String, String> readStatus = new HashMap<>();
|
// Map<String, String> readStatus = new HashMap<>();
|
||||||
List<Long> roles = new ArrayList<>();
|
// List<Long> roles = new ArrayList<>();
|
||||||
|
//
|
||||||
//根据menuID 获取 roleIds
|
// //根据menuID 获取 roleIds
|
||||||
Set<Long> roleIds = permissionService.getMenuRoleIdListByMenuIdFromCache(menuIds.get(0));
|
// Set<Long> roleIds = permissionService.getMenuRoleIdListByMenuIdFromCache(menuIds.get(0));
|
||||||
|
//
|
||||||
List<RoleDO> roleDOS = roleService.getRoleList(roleIds);
|
// List<RoleDO> roleDOS = roleService.getRoleList(roleIds);
|
||||||
for (RoleDO roleDo : roleDOS) {
|
// for (RoleDO roleDo : roleDOS) {
|
||||||
|
//
|
||||||
if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.ALL.getScope())) { //数据权限是全部时
|
// if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.ALL.getScope())) { //数据权限是全部时
|
||||||
|
//
|
||||||
roles.add(roleDo.getId());
|
// roles.add(roleDo.getId());
|
||||||
}else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_CUSTOM.getScope())) { //数据权限是指定部门
|
// }else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_CUSTOM.getScope())) { //数据权限是指定部门
|
||||||
|
//
|
||||||
//指定部门组里存在 发起人的部门
|
// //指定部门组里存在 发起人的部门
|
||||||
if (roleDo.getDataScopeDeptIds().contains(createReqVO.getDeptId())) {
|
// if (roleDo.getDataScopeDeptIds().contains(createReqVO.getDeptId())) {
|
||||||
|
//
|
||||||
roles.add(roleDo.getId());
|
// roles.add(roleDo.getId());
|
||||||
}
|
// }
|
||||||
}else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_ONLY.getScope())) { //数据权限是本部门
|
// }else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_ONLY.getScope())) { //数据权限是本部门
|
||||||
|
//
|
||||||
List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
|
// List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
|
||||||
for (AdminUserDO userDO : userDos) {
|
// for (AdminUserDO userDO : userDos) {
|
||||||
|
//
|
||||||
//权限部门与发起人部门一致时
|
// //权限部门与发起人部门一致时
|
||||||
if (Objects.equals(userDO.getDeptId(), createReqVO.getDeptId())) {
|
// if (Objects.equals(userDO.getDeptId(), createReqVO.getDeptId())) {
|
||||||
|
//
|
||||||
readStatus.put(String.valueOf(userDO.getId()), "0");
|
// readStatus.put(String.valueOf(userDO.getId()), "0");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_AND_CHILD.getScope())) { //数据权限是本部门及一下
|
// }else if (Objects.equals(roleDo.getDataScope(), DataScopeEnum.DEPT_AND_CHILD.getScope())) { //数据权限是本部门及一下
|
||||||
|
//
|
||||||
//根据规则ID 查询用户信息
|
// //根据规则ID 查询用户信息
|
||||||
List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
|
// List<AdminUserDO> userDos = adminUserMapper.selectListByRoleId(roleDo.getId());
|
||||||
for (AdminUserDO userDO : userDos) {
|
// for (AdminUserDO userDO : userDos) {
|
||||||
|
//
|
||||||
Set<Long> deptIds = deptService.getChildDeptIdListFromCache(userDO.getDeptId());
|
// Set<Long> deptIds = deptService.getChildDeptIdListFromCache(userDO.getDeptId());
|
||||||
//权限部门与发起人部门一致时
|
// //权限部门与发起人部门一致时
|
||||||
if (deptIds.contains(createReqVO.getDeptId())) {
|
// if (deptIds.contains(createReqVO.getDeptId())) {
|
||||||
|
//
|
||||||
readStatus.put(String.valueOf(userDO.getId()), "0");
|
// readStatus.put(String.valueOf(userDO.getId()), "0");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//通过满足条件的roleId 查询所有用户信息
|
// //通过满足条件的roleId 查询所有用户信息
|
||||||
List<UserRoleDO> userRoleDOS = userRoleMapper.selectListByRoleIds(roles);
|
// List<UserRoleDO> userRoleDOS = userRoleMapper.selectListByRoleIds(roles);
|
||||||
for (UserRoleDO userRoleDO : userRoleDOS) {
|
// for (UserRoleDO userRoleDO : userRoleDOS) {
|
||||||
|
//
|
||||||
readStatus.put(String.valueOf(userRoleDO.getUserId()), "0");
|
// readStatus.put(String.valueOf(userRoleDO.getUserId()), "0");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
LogInstanceDO updateObj = new LogInstanceDO();
|
// LogInstanceDO updateObj = new LogInstanceDO();
|
||||||
// updateObj.setReadStatus(JsonObject.);
|
// updateObj.setReadStatus();
|
||||||
// logInstanceMapper.updateById();
|
//// logInstanceMapper.updateById();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 返回
|
// 返回
|
||||||
return logInstance.getId();
|
return logInstance.getId();
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.worklog;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.worklog.LogUseDO;
|
||||||
|
import cn.iocoder.yudao.module.system.service.worklog.dto.LogUseSaveReqDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志模板使用者 Service 接口
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
public interface LogUseService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建日志模板使用者
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createLogUse(LogUseSaveReqDTO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新日志模板使用者
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateLogUse(LogUseSaveReqDTO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得日志模板使用者
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 日志模板使用者
|
||||||
|
*/
|
||||||
|
LogUseDO getLogUse(Long id);
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.worklog;
|
||||||
|
|
||||||
|
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 org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.LOG_USE_NOT_EXISTS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志模板使用者 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 符溶馨
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class LogUseServiceImpl implements LogUseService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LogUseMapper logUseMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createLogUse(LogUseSaveReqDTO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
LogUseDO logUse = BeanUtils.toBean(createReqVO, LogUseDO.class);
|
||||||
|
logUseMapper.insert(logUse);
|
||||||
|
// 返回
|
||||||
|
return logUse.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLogUse(LogUseSaveReqDTO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateLogUseExists(updateReqVO.getFormId());
|
||||||
|
// 更新
|
||||||
|
LogUseDO updateObj = BeanUtils.toBean(updateReqVO, LogUseDO.class);
|
||||||
|
logUseMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateLogUseExists(Long formId) {
|
||||||
|
if (logUseMapper.selectCount(LogUseDO::getFormId, formId) == 0L) {
|
||||||
|
throw exception(LOG_USE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LogUseDO getLogUse(Long id) {
|
||||||
|
return logUseMapper.selectById(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.worklog.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志可查看用户 Response DTO
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LogReadUserRespDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可查看日志的用户编号
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.worklog.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志模板使用者新增/修改 Request DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LogUseSaveReqDTO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志模板编号
|
||||||
|
*/
|
||||||
|
private Long formId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板规则编号
|
||||||
|
*/
|
||||||
|
private Long ruleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用模板用户编号
|
||||||
|
*/
|
||||||
|
private Long useUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用模板用户部门编号
|
||||||
|
*/
|
||||||
|
private Long useUserDept;
|
||||||
|
}
|
@ -47,7 +47,7 @@ spring:
|
|||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: 123456
|
||||||
# username: sa
|
# username: sa
|
||||||
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
||||||
slave: # 模拟从库,可根据自己需要修改
|
slave: # 模拟从库,可根据自己需要修改
|
||||||
@ -58,7 +58,7 @@ spring:
|
|||||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
# url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例
|
||||||
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
|
# url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例
|
||||||
username: root
|
username: root
|
||||||
password: root
|
password: 123456
|
||||||
# username: sa
|
# username: sa
|
||||||
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
# password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ spring:
|
|||||||
|
|
||||||
profiles:
|
profiles:
|
||||||
active: local #local
|
active: local #local
|
||||||
|
# active: dev
|
||||||
# active: prod
|
# active: prod
|
||||||
|
|
||||||
server:
|
server:
|
||||||
|
@ -14,4 +14,20 @@
|
|||||||
set open_id = null
|
set open_id = null
|
||||||
where open_id = #{openId}
|
where open_id = #{openId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="selectListByRoleId">
|
||||||
|
select A.* FROM system_users A, system_user_role B, system_role C
|
||||||
|
where A.id = C.user_id
|
||||||
|
and C.role_id = B.id
|
||||||
|
and C.role_id = #{roleId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByDeptIds">
|
||||||
|
select A.*, B.name deptName FROM system_users A, system_dept B
|
||||||
|
where A.dept_id = B.id
|
||||||
|
and A.dept_id in
|
||||||
|
<foreach collection="list" item="deptIds" open="(" close=")" separator=",">
|
||||||
|
#{deptIds}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.system.dal.mysql.worklog.LogInstanceMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
<select id="selectRaedUser">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
user.id,
|
||||||
|
user.dept_id,
|
||||||
|
user.nickname,
|
||||||
|
read_user.*,
|
||||||
|
CASE
|
||||||
|
read_user.data_scope
|
||||||
|
WHEN 1 THEN
|
||||||
|
'all' -- 全部数据权限
|
||||||
|
|
||||||
|
WHEN 2 THEN
|
||||||
|
read_user.data_scope_dept_ids -- 指定部门数据权限
|
||||||
|
|
||||||
|
WHEN 3 THEN
|
||||||
|
user.dept_id -- 本部门数据权限
|
||||||
|
|
||||||
|
WHEN 4 THEN
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
GROUP_CONCAT( id SEPARATOR ', ' ) AS ids
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
t1.id,
|
||||||
|
t1.NAME,
|
||||||
|
IF
|
||||||
|
( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
|
||||||
|
FROM
|
||||||
|
( SELECT id, parent_id, NAME FROM system_dept t ORDER BY parent_id, id ) t1,
|
||||||
|
( SELECT @pids := user.dept_id ) t2
|
||||||
|
) t3
|
||||||
|
WHERE
|
||||||
|
ischild != 0
|
||||||
|
OR id = user.dept_id
|
||||||
|
) -- read_user.data_scope_dept_ids -- 本部门及以下数据权限
|
||||||
|
|
||||||
|
END AS ids
|
||||||
|
FROM
|
||||||
|
system_users user
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
u_role.user_id,
|
||||||
|
u_role.role_id,
|
||||||
|
role_id.data_scope,
|
||||||
|
role_id.data_scope_dept_ids
|
||||||
|
FROM
|
||||||
|
system_user_role u_role
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT
|
||||||
|
role.id, role.data_scope, role.data_scope_dept_ids
|
||||||
|
FROM
|
||||||
|
( SELECT role_id FROM system_role_menu a LEFT JOIN system_menu role ON a.menu_id = role.id WHERE role.permission = 'system:view-log:query' ) menu
|
||||||
|
LEFT JOIN system_role role on role.id = menu.role_id
|
||||||
|
) role_id ON u_role.role_id = role_id.id
|
||||||
|
WHERE u_role.deleted = 0
|
||||||
|
ORDER BY
|
||||||
|
u_role.role_id
|
||||||
|
) read_user ON user.id = read_user.user_id
|
||||||
|
WHERE
|
||||||
|
user.deleted = 0
|
||||||
|
AND read_user.data_scope != 5
|
||||||
|
) result
|
||||||
|
WHERE
|
||||||
|
1= 1
|
||||||
|
and ( LOCATE(#{deptId},result.ids) and result.data_scope = 4 )
|
||||||
|
or ( LOCATE(#{deptId},result.ids) and result.data_scope = 2 )
|
||||||
|
or ( result.dept_id = #{deptId} and result.data_scope = 3 )
|
||||||
|
or result.data_scope = 1
|
||||||
|
</select>
|
||||||
|
</mapper>
|
@ -3,9 +3,11 @@ CREATE TABLE IF NOT EXISTS "system_dept" (
|
|||||||
"name" varchar(30) NOT NULL DEFAULT '',
|
"name" varchar(30) NOT NULL DEFAULT '',
|
||||||
"parent_id" bigint NOT NULL DEFAULT '0',
|
"parent_id" bigint NOT NULL DEFAULT '0',
|
||||||
"sort" int NOT NULL DEFAULT '0',
|
"sort" int NOT NULL DEFAULT '0',
|
||||||
|
"level" int(11) NOT NULL DEFAULT '0',
|
||||||
"leader_user_id" bigint DEFAULT NULL,
|
"leader_user_id" bigint DEFAULT NULL,
|
||||||
"phone" varchar(11) DEFAULT NULL,
|
"phone" varchar(11) DEFAULT NULL,
|
||||||
"email" varchar(50) DEFAULT NULL,
|
"email" varchar(50) DEFAULT NULL,
|
||||||
|
"flag" varchar(255) NOT NULL,
|
||||||
"status" tinyint NOT NULL,
|
"status" tinyint NOT NULL,
|
||||||
"creator" varchar(64) DEFAULT '',
|
"creator" varchar(64) DEFAULT '',
|
||||||
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
@ -248,6 +250,7 @@ CREATE TABLE IF NOT EXISTS "system_users" (
|
|||||||
"update_time" timestamp not null default current_timestamp,
|
"update_time" timestamp not null default current_timestamp,
|
||||||
"deleted" bit not null default false,
|
"deleted" bit not null default false,
|
||||||
"tenant_id" bigint not null default '0',
|
"tenant_id" bigint not null default '0',
|
||||||
|
"open_id" varchar(255) DEFAULT NULL,
|
||||||
primary key ("id")
|
primary key ("id")
|
||||||
) comment '用户信息表';
|
) comment '用户信息表';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user