From c89af8f426d603f87f2fcf6a75b241b9f5c397b4 Mon Sep 17 00:00:00 2001 From: rentaiming <806181062@qq.com> Date: 星期四, 25 七月 2024 15:27:31 +0800 Subject: [PATCH] 森林防火 供应商管理 --- ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/LogFallbackFactory.java | 42 ++++++++++ ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 2 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java | 82 +++++++++++++++++++- ruoyi-modules/ruoyi-system/target/classes/mapper/system/SysOperLogMapper.xml | 11 -- ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java | 55 ++----------- ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/LogClient.java | 17 ++++ ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml | 11 -- ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java | 1 8 files changed, 148 insertions(+), 73 deletions(-) diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java index 525eda3..5757d50 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/RemoteLogService.java @@ -29,6 +29,7 @@ @PostMapping("/operlog") public R<Boolean> saveLog(@RequestBody SysOperLog sysOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception; + /** * 保存访问记录 * diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java index 36f7c7d..5bb4183 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysOperLog.java @@ -1,6 +1,9 @@ package com.ruoyi.system.api.domain; import java.util.Date; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel.ColumnType; @@ -13,77 +16,35 @@ * @author ruoyi */ @Data -public class SysOperLog extends BaseEntity +public class SysOperLog { private static final long serialVersionUID = 1L; /** 日志主键 */ @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) + @TableField(value = "oper_id") private Long operId; /** 操作模块 */ @Excel(name = "操作模块") private String title; - /** 业务类型(0其它 1新增 2修改 3删除) */ - @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") - private Integer businessType; - - /** 业务类型数组 */ - private Integer[] businessTypes; - - /** 请求方法 */ - @Excel(name = "请求方法") - private String method; - - /** 请求方式 */ - @Excel(name = "请求方式") - private String requestMethod; - - /** 操作类别(0其它 1后台用户 2手机端用户) */ - @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") - private Integer operatorType; - /** 操作人员 */ @Excel(name = "操作人员") + @TableField(value = "oper_name") private String operName; /** 部门名称 */ @Excel(name = "部门名称") + @TableField(value = "dept_name") private String deptName; - - /** 请求url */ - @Excel(name = "请求地址") - private String operUrl; - - /** 操作地址 */ - @Excel(name = "操作地址") - private String operIp; - - /** 请求参数 */ - @Excel(name = "请求参数") - private String operParam; - - /** 返回参数 */ - @Excel(name = "返回参数") - private String jsonResult; - - /** 操作状态(0正常 1异常) */ - @Excel(name = "状态", readConverterExp = "0=正常,1=异常") - private Integer status; - - /** 错误消息 */ - @Excel(name = "错误消息") - private String errorMsg; /** 操作时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + @TableField(value = "oper_time") private Date operTime; - /** 消耗时间 */ - @Excel(name = "消耗时间", suffix = "毫秒") - private Long costTime; @Excel(name = "电话") private String phone; diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/LogFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/LogFallbackFactory.java new file mode 100644 index 0000000..dda771a --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/LogFallbackFactory.java @@ -0,0 +1,42 @@ +package com.ruoyi.system.api.factory; + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.api.RemoteLogService; +import com.ruoyi.system.api.domain.SysLogininfor; +import com.ruoyi.system.api.domain.SysOperLog; +import com.ruoyi.system.api.feignClient.LogClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +/** + * 日志服务降级处理 + * + * @author ruoyi + */ +@Component +public class LogFallbackFactory implements FallbackFactory<LogClient> +{ + private static final Logger log = LoggerFactory.getLogger(LogFallbackFactory.class); + + @Override + public LogClient create(Throwable throwable) + { + log.error("日志服务调用失败:{}", throwable.getMessage()); + return new LogClient() + { + + @Override + public R savelong() { + return null; + } + + @Override + public R savelong1() { + return null; + } + }; + + } +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/LogClient.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/LogClient.java new file mode 100644 index 0000000..2ec6050 --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/feignClient/LogClient.java @@ -0,0 +1,17 @@ +package com.ruoyi.system.api.feignClient; + +import com.ruoyi.common.core.constant.ServiceNameConstants; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.api.factory.SysUserFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +@FeignClient(contextId = "LogClient", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = SysUserFallbackFactory.class) +public interface LogClient { + @PostMapping("/operlog/savelong") + R savelong(); + + @PostMapping("/operlog/savelong1") + R savelong1(); +} diff --git a/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 4918e8c..be546b4 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/ruoyi-api/ruoyi-api-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -2,3 +2,5 @@ com.ruoyi.system.api.factory.RemoteLogFallbackFactory com.ruoyi.system.api.factory.RemoteFileFallbackFactory com.ruoyi.system.api.factory.SysUserFallbackFactory +com.ruoyi.system.api.factory.LogFallbackFactory + diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java index 6ff43c4..96c93bc 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysOperlogController.java @@ -1,5 +1,9 @@ package com.ruoyi.system.controller; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Objects; @@ -8,12 +12,22 @@ import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.security.utils.SecurityUtils; +import com.ruoyi.system.api.domain.SysUser; +import com.ruoyi.system.domain.dto.SupplierDTO; +import com.ruoyi.system.mapper.SysOperLogMapper; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.system.query.SysOperLogQuery; +import com.ruoyi.system.service.ISysUserRoleService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -43,15 +57,75 @@ public class SysOperlogController extends BaseController { @Resource - private ISysOperLogService operLogService; + private SysOperLogMapper operLogService; + + @Autowired + private SysUserMapper sysUserMapper; @ApiOperation(value = "操作日志查询") @PostMapping("/list") - public R<List<SysOperLog>> list(@RequestBody SysOperLogQuery gy) + public R<Page<SysOperLog>> list(@RequestBody SysOperLogQuery gy) { - List<SysOperLog> list = operLogService.list(); - return R.ok(list); + Page<SysOperLog> page = new Page<>(); + page.setSize(gy.getPageSize()); + page.setCurrent(gy.getPageCurr()); + + LambdaQueryWrapper<SysOperLog> wrapper= Wrappers.lambdaQuery(); + if (gy.getOperName()!=null){ + wrapper.like(SysOperLog::getOperName,gy.getOperName()); + } + if (gy.getPhone()!=null){ + wrapper.like(SysOperLog::getPhone,gy.getPhone()); + } + if (gy.getTitle()!=null){ + wrapper.like(SysOperLog::getTitle,gy.getTitle()); + } + if (gy.getTitle()!=null){ + wrapper.like(SysOperLog::getTitle,gy.getTitle()); + } + + if(gy.getBeginTime()!=null){ + wrapper.le(SysOperLog::getOperTime, gy.getBeginTime()); + } + + if(gy.getEndTime()!=null){ + wrapper.gt(SysOperLog::getOperTime, gy.getEndTime()); + } + + + Page<SysOperLog> sysOperLogPage = operLogService.selectPage(page, wrapper); + return R.ok(sysOperLogPage); + } + + @Log(title = "操作完成入库", businessType = BusinessType.UPDATE) + @ApiOperation(value = "操作完成入库", notes = "操作完成入库") + @PostMapping("/savelong") + public R<?> savelong() { + Long userid = SecurityUtils.getUserId(); + SysUser user = sysUserMapper.selectById(userid); + SysOperLog sysOperLog=new SysOperLog(); + sysOperLog.setOperTime(new Date()); + sysOperLog.setTitle("完成入库"); + sysOperLog.setOperName(user.getNickName()); + sysOperLog.setPhone(user.getPhonenumber()); + operLogService.insert(sysOperLog); + return R.ok(); + } + + @Log(title = "操作完成出库", businessType = BusinessType.UPDATE) + @ApiOperation(value = "操作完成出库", notes = "操作完成出库") + @PostMapping("/savelong1") + public R<?> savelong1() { + Long userid = SecurityUtils.getUserId(); + SysUser user = sysUserMapper.selectById(userid); + SysOperLog sysOperLog=new SysOperLog(); + sysOperLog.setOperTime(new Date()); + sysOperLog.setTitle("完成出库"); + sysOperLog.setOperName(user.getNickName()); + sysOperLog.setPhone(user.getPhonenumber()); + operLogService.insert(sysOperLog); + return R.ok(); } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml index a6c5d52..5a60db5 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -7,20 +7,9 @@ <resultMap type="com.ruoyi.system.api.domain.SysOperLog" id="SysOperLogResult"> <id property="operId" column="oper_id" /> <result property="title" column="title" /> - <result property="businessType" column="business_type" /> - <result property="method" column="method" /> - <result property="requestMethod" column="request_method" /> <result property="operatorType" column="operator_type" /> <result property="operName" column="oper_name" /> - <result property="deptName" column="dept_name" /> - <result property="operUrl" column="oper_url" /> - <result property="operIp" column="oper_ip" /> - <result property="operParam" column="oper_param" /> - <result property="jsonResult" column="json_result" /> - <result property="status" column="status" /> - <result property="errorMsg" column="error_msg" /> <result property="operTime" column="oper_time" /> - <result property="costTime" column="cost_time" /> </resultMap> <sql id="selectOperLogVo"> diff --git a/ruoyi-modules/ruoyi-system/target/classes/mapper/system/SysOperLogMapper.xml b/ruoyi-modules/ruoyi-system/target/classes/mapper/system/SysOperLogMapper.xml index a6c5d52..5a60db5 100644 --- a/ruoyi-modules/ruoyi-system/target/classes/mapper/system/SysOperLogMapper.xml +++ b/ruoyi-modules/ruoyi-system/target/classes/mapper/system/SysOperLogMapper.xml @@ -7,20 +7,9 @@ <resultMap type="com.ruoyi.system.api.domain.SysOperLog" id="SysOperLogResult"> <id property="operId" column="oper_id" /> <result property="title" column="title" /> - <result property="businessType" column="business_type" /> - <result property="method" column="method" /> - <result property="requestMethod" column="request_method" /> <result property="operatorType" column="operator_type" /> <result property="operName" column="oper_name" /> - <result property="deptName" column="dept_name" /> - <result property="operUrl" column="oper_url" /> - <result property="operIp" column="oper_ip" /> - <result property="operParam" column="oper_param" /> - <result property="jsonResult" column="json_result" /> - <result property="status" column="status" /> - <result property="errorMsg" column="error_msg" /> <result property="operTime" column="oper_time" /> - <result property="costTime" column="cost_time" /> </resultMap> <sql id="selectOperLogVo"> -- Gitblit v1.7.1