谐波模块sql语句换成InfluxDBPublicParam
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
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.system.pojo.param.AuditParam;
|
||||
import com.njcn.system.pojo.vo.AuditLogVO;
|
||||
import com.njcn.system.service.AuditService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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.validation.annotation.Validated;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/07/11 19:00
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/audit")
|
||||
@Api(tags = "审计管理")
|
||||
@AllArgsConstructor
|
||||
public class AuditController extends BaseController {
|
||||
|
||||
private final AuditService auditService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getAuditLog")
|
||||
@ApiOperation("审计日志列表")
|
||||
@ApiImplicitParam(name = "auditParam", value = "审计日志参数", required = true)
|
||||
public HttpResult<Page<AuditLogVO>> getAuditLog(@RequestBody @Validated AuditParam auditParam){
|
||||
String methodDescribe = getMethodDescribe("getAuditLog");
|
||||
Page<AuditLogVO> result = auditService.getAuditLog(auditParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,result,methodDescribe);
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
// @GetMapping("/insetAuditLog")
|
||||
// @ApiOperation("添加审计日志")
|
||||
// public HttpResult insetAuditLog(){
|
||||
// String methodDescribe = getMethodDescribe("insetAuditLog");
|
||||
// auditService.insetAuditLog();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,null,methodDescribe);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,20 +1,25 @@
|
||||
package com.njcn.system.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.system.service.IUserLogService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.*;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
@@ -25,28 +30,30 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/userLog")
|
||||
@Api(tags = "行政区域管理")
|
||||
@Api(tags = "用户日志管理")
|
||||
@AllArgsConstructor
|
||||
public class UserLogController extends BaseController {
|
||||
|
||||
private final IUserLogService userLogService;
|
||||
|
||||
|
||||
/**
|
||||
* 插入审计日志
|
||||
*/
|
||||
@ApiIgnore
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("插入审计日志")
|
||||
public void addUserLog(@RequestBody LogInfoDTO logInfoDTO) {
|
||||
|
||||
System.out.println(logInfoDTO.toString());
|
||||
|
||||
// userLogService.addUserLog(logInfoDTO);
|
||||
@ApiImplicitParam(name = "logInfoDTO", value = "插入日志参数", required = true)
|
||||
public HttpResult addUserLog(@RequestBody LogInfoDTO logInfoDTO) {
|
||||
String methodDescribe = getMethodDescribe("addUserLog");
|
||||
boolean res = userLogService.addUserLog(logInfoDTO);
|
||||
if (res) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,null,methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL,null,methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.system.mapper;
|
||||
|
||||
import com.njcn.system.pojo.param.AuditParam;
|
||||
import com.njcn.system.pojo.po.UserLog;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/07/11 21:06
|
||||
*/
|
||||
public interface AuditMapper {
|
||||
/**
|
||||
* 获取审计日志列表
|
||||
*/
|
||||
List<UserLog> selectAuditLog(@Param("auditParam") AuditParam auditParam);
|
||||
|
||||
int getCount(@Param("auditParam") AuditParam auditParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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="com.njcn.system.mapper.AuditMapper">
|
||||
|
||||
<select id="selectAuditLog" resultType="UserLog">
|
||||
SELECT
|
||||
id,
|
||||
user_name userName,
|
||||
ip,
|
||||
operate,
|
||||
operate_type operateType,
|
||||
result,
|
||||
level,
|
||||
type,
|
||||
service_name serviceName,
|
||||
state,
|
||||
create_by createBy,
|
||||
create_time createTime,
|
||||
update_by updateBy,
|
||||
update_time updateTime
|
||||
FROM
|
||||
sys_user_log
|
||||
WHERE update_time >= #{auditParam.searchBeginTime}
|
||||
AND #{auditParam.searchEndTime} >= update_time
|
||||
<!-- <if test="auditParam.userName!=null">-->
|
||||
<!-- and update_by = #{auditParam.userName}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="auditParam.type!=null">-->
|
||||
<!-- and type = #{auditParam.type}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="auditParam.operate!=null">-->
|
||||
<!-- and operate_type = #{auditParam.operate}-->
|
||||
<!-- </if>-->
|
||||
AND id >= (select id from sys_user_log order by id limit #{auditParam.pageNum}, 1) limit #{auditParam.pageSize}
|
||||
</select>
|
||||
|
||||
<select id="getCount" resultType="int">
|
||||
SELECT count(id)
|
||||
FROM sys_user_log
|
||||
WHERE update_time >= #{auditParam.searchBeginTime}
|
||||
AND #{auditParam.searchEndTime} >= update_time
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.system.pojo.param.AuditParam;
|
||||
import com.njcn.system.pojo.vo.AuditLogVO;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/07/11 19:59
|
||||
*/
|
||||
public interface AuditService {
|
||||
/**
|
||||
* 获取审计日志列表
|
||||
* @param auditParam
|
||||
*/
|
||||
Page<AuditLogVO> getAuditLog(AuditParam auditParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.njcn.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.system.mapper.AuditMapper;
|
||||
import com.njcn.system.pojo.param.AuditParam;
|
||||
import com.njcn.system.pojo.po.UserLog;
|
||||
import com.njcn.system.pojo.vo.AuditLogVO;
|
||||
import com.njcn.system.service.AuditService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/07/11 20:56
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AuditServiceImpl implements AuditService {
|
||||
|
||||
|
||||
private final AuditMapper auditMapper;
|
||||
|
||||
@Override
|
||||
public Page<AuditLogVO> getAuditLog(AuditParam auditParam) {
|
||||
List<AuditLogVO> auditLogVOS = new ArrayList<>();
|
||||
|
||||
Page<AuditLogVO> page = new Page<>();
|
||||
page.setSize(auditParam.getPageSize());
|
||||
page.setCurrent(auditParam.getPageNum());
|
||||
|
||||
//待分页数据总量
|
||||
int count = auditMapper.getCount(auditParam);
|
||||
page.setTotal(count);
|
||||
//分页总页数
|
||||
int pages = (int)Math.ceil(count*1.0/auditParam.getPageSize());
|
||||
page.setPages(pages);
|
||||
|
||||
auditParam.setPageNum(auditParam.getPageSize()*(auditParam.getPageNum()-1));
|
||||
List<UserLog> userLogs = auditMapper.selectAuditLog(auditParam);
|
||||
for (UserLog userLog: userLogs) {
|
||||
AuditLogVO auditLogVO = new AuditLogVO();
|
||||
String ip = userLog.getIp();
|
||||
auditLogVO.setIp(userLog.getIp());
|
||||
String updateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(userLog.getUpdateTime());
|
||||
auditLogVO.setTime(updateTime);
|
||||
auditLogVO.setUserName(userLog.getUserName());
|
||||
auditLogVO.setOperate(userLog.getOperate());
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(userLog.getUserName()).append(userLog.getUpdateBy()).append("在")
|
||||
.append(userLog.getOperateType());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//当前页数据
|
||||
// page.setRecords();
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void insetAuditLog() {
|
||||
// Audit audit = new Audit();
|
||||
// String userId = IdUtil.simpleUUID();
|
||||
// audit.setId(userId);
|
||||
// audit.setIp("225.225.225.2");
|
||||
// audit.setOperate("查询稳态趋势对比");
|
||||
// audit.setType(0);
|
||||
// audit.setResult("成功");
|
||||
// audit.setLevel("普通");
|
||||
// audit.setUserLogDescribe("正式用户组yfyw2在2022-07-12 10:38在49.72.16.99执行了查询稳态趋势对比,结果为成功");
|
||||
// audit.setUpdateBy("e9e2251e3149462aaea6c73cbda5eaa3");
|
||||
// audit.setUpdateTime(LocalDateTime.now());
|
||||
// audit.setState(0);
|
||||
// auditMapper.insert(audit);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user