操作日志模块新增机构 按照机构区分
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run

This commit is contained in:
lxd 2024-12-23 11:34:05 +08:00
parent 9c6906acf0
commit fadf46da04
6 changed files with 29 additions and 2 deletions

View File

@ -82,4 +82,5 @@ public class OperateLogCreateReqDTO {
@NotEmpty(message = "浏览器 UA 不能为空")
private String userAgent;
private String orgId;
}

View File

@ -6,7 +6,9 @@ import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogCreateReqDTO;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogPageReqDTO;
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogRespDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.fhs.core.trans.anno.TransMethodResult;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -14,6 +16,8 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/**
* 操作日志 API 实现类
*
@ -25,10 +29,15 @@ public class OperateLogApiImpl implements OperateLogApi {
@Resource
private OperateLogService operateLogService;
@Resource
private AdminUserService userService;
@Override
@Async
public void createOperateLog(OperateLogCreateReqDTO createReqDTO) {
//当前登陆用户
AdminUserDO user = userService.getUser(getLoginUserId());
createReqDTO.setOrgId(user.getOrgId());
operateLogService.createOperateLog(createReqDTO);
}

View File

@ -10,7 +10,9 @@ import cn.iocoder.yudao.framework.translate.core.TranslateUtils;
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.operatelog.OperateLogRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.logger.OperateLogService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
@ -27,6 +29,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - 操作日志")
@RestController
@ -36,11 +39,17 @@ public class OperateLogController {
@Resource
private OperateLogService operateLogService;
@Resource
private AdminUserService userService;
@GetMapping("/page")
@Operation(summary = "查看操作日志分页列表")
@PreAuthorize("@ss.hasPermission('system:operate-log:query')")
public CommonResult<PageResult<OperateLogRespVO>> pageOperateLog(@Valid OperateLogPageReqVO pageReqVO) {
//当前登陆用户
AdminUserDO user = userService.getUser(getLoginUserId());
pageReqVO.setOrgId(user.getOrgId());
PageResult<OperateLogDO> pageResult = operateLogService.getOperateLogPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, OperateLogRespVO.class));
}

View File

@ -31,5 +31,6 @@ public class OperateLogPageReqVO extends PageParam {
@Schema(description = "开始时间", example = "[2022-07-01 00:00:00,2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "机构ID")
private String orgId;
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.dal.dataobject.logger;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -82,4 +83,9 @@ public class OperateLogDO extends BaseDO {
*/
private String userAgent;
/**
* 机构ID
*/
@TableField("orgId")
private String orgId;
}

View File

@ -19,6 +19,7 @@ public interface OperateLogMapper extends BaseMapperX<OperateLogDO> {
.likeIfPresent(OperateLogDO::getSubType, pageReqDTO.getSubType())
.likeIfPresent(OperateLogDO::getAction, pageReqDTO.getAction())
.betweenIfPresent(OperateLogDO::getCreateTime, pageReqDTO.getCreateTime())
.eqIfPresent(OperateLogDO::getOrgId,pageReqDTO.getOrgId())
.orderByDesc(OperateLogDO::getId));
}