refactor(logs): 将日志服务从设备模块迁移到系统模块

- 将 CsLogsPO 相关类从 cs-device 模块移动到 cs-system 模块
- 更新所有相关导入路径以指向新的包位置
- 修改 MqttMessageHandler 使用远程 Feign 客户端调用日志服务
- 清理不再使用的分页和日志 POJO 导入依赖
- 重命名相关 Mapper 和 Service 类以匹配新模块结构
This commit is contained in:
xy
2026-06-11 19:54:07 +08:00
parent 689f9ee51c
commit 95d9432298
16 changed files with 25 additions and 57 deletions

View File

@@ -0,0 +1,63 @@
package com.njcn.cssystem.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.cssystem.pojo.po.CsLogsPO;
import com.njcn.cssystem.service.CsLogsPOService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Description:
* Date: 2023/8/7 14:21【需求编号】
*
* @author clam
* @version V1.0.0
*/
@RestController
@Slf4j
@Api(tags = "日志管理")
@AllArgsConstructor
@RequestMapping("/cslog")
public class CsLogController extends BaseController {
private final CsLogsPOService csLogsPOService;
/**
* 插入审计日志
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
@PostMapping("/add")
@ApiOperation("插入设备日志")
@ApiImplicitParam(name = "deviceLogDTO", value = "插入日志参数", required = true)
public HttpResult addUserLog(@RequestBody DeviceLogDTO deviceLogDTO) {
String methodDescribe = getMethodDescribe("addUserLog");
csLogsPOService.addLog(deviceLogDTO);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryLog")
@ApiOperation("查询日志")
@ApiImplicitParam(name = "baseParam", value = "查询日志参数", required = true)
public HttpResult<IPage<CsLogsPO>> queryLog(@RequestBody BaseParam baseParam){
String methodDescribe = getMethodDescribe("queryLog");
IPage<CsLogsPO> list = csLogsPOService.queryPage(baseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -0,0 +1,15 @@
package com.njcn.cssystem.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.cssystem.pojo.po.CsLogsPO;
/**
*
* Description:
* Date: 2023/8/7 14:02【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsLogsPOMapper extends BaseMapper<CsLogsPO> {
}

View File

@@ -0,0 +1,22 @@
package com.njcn.cssystem.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.cssystem.pojo.po.CsLogsPO;
import com.njcn.web.pojo.param.BaseParam;
/**
*
* Description:
* Date: 2023/8/7 14:02【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsLogsPOService extends IService<CsLogsPO>{
void addLog(DeviceLogDTO deviceLogDTO);
IPage<CsLogsPO> queryPage(BaseParam baseParam);
}

View File

@@ -1,11 +1,9 @@
package com.njcn.cssystem.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.api.RoleEngineerDevFeignClient;
import com.njcn.csdevice.pojo.po.CsLogsPO;
import com.njcn.cssystem.mapper.CsFeedbackChatMapper;
import com.njcn.cssystem.mapper.CsFeedbackMapper;
import com.njcn.cssystem.pojo.param.CsFeedbackAddParm;
@@ -16,7 +14,6 @@ import com.njcn.cssystem.pojo.po.CsFeedbackPO;
import com.njcn.cssystem.pojo.po.CsFilePathPO;
import com.njcn.cssystem.pojo.vo.CsFeedbackDetailVO;
import com.njcn.cssystem.pojo.vo.CsFeedbackVO;
import com.njcn.cssystem.service.CsFeedbackChatService;
import com.njcn.cssystem.service.CsFeedbackService;
import com.njcn.cssystem.service.CsFilePathService;
import com.njcn.oss.constant.OssPath;

View File

@@ -0,0 +1,53 @@
package com.njcn.cssystem.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.cssystem.mapper.CsLogsPOMapper;
import com.njcn.cssystem.pojo.po.CsLogsPO;
import com.njcn.cssystem.service.CsLogsPOService;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
* Description:
* Date: 2023/8/7 14:02【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class CsLogsPOServiceImpl extends ServiceImpl<CsLogsPOMapper, CsLogsPO> implements CsLogsPOService {
@Override
public void addLog(DeviceLogDTO deviceLogDTO) {
CsLogsPO csPO = new CsLogsPO();
BeanUtils.copyProperties(deviceLogDTO,csPO);
csPO.setCreateBy(deviceLogDTO.getUserIndex());
csPO.setUpdateBy(deviceLogDTO.getUserIndex());
this.save(csPO);
}
@Override
public IPage<CsLogsPO> queryPage(BaseParam baseParam) {
Page<CsLogsPO> returnpage = new Page<> (baseParam.getPageNum ( ), baseParam.getPageSize ( ));
String username = RequestUtil.getUsername();
String userRole = RequestUtil.getUserRole();
List<String> strings = JSONArray.parseArray(userRole, String.class);
QueryWrapper<CsLogsPO> csLogsPOQueryWrapper = new QueryWrapper<>();
csLogsPOQueryWrapper.lambda()
.ge(StringUtils.isNotBlank(baseParam.getSearchBeginTime()),CsLogsPO::getCreateTime,baseParam.getSearchBeginTime()).
le(StringUtils.isNotBlank(baseParam.getSearchEndTime()),CsLogsPO::getCreateTime,baseParam.getSearchEndTime()).orderByDesc(CsLogsPO::getCreateTime);
IPage<CsLogsPO> list = this.getBaseMapper().selectPage(returnpage,csLogsPOQueryWrapper);
return list;
}
}