diff --git a/fuintAdmin_zt/src/api/setting/sysLog.js b/fuintAdmin_zt/src/api/setting/sysLog.js new file mode 100644 index 000000000..35570cee0 --- /dev/null +++ b/fuintAdmin_zt/src/api/setting/sysLog.js @@ -0,0 +1,37 @@ +import request from '@/utils/request' + +// 分页查询所有的订单信息 +export function getListApi(query) { + return request({ + url: 'sysLog', + method: 'get', + params: query + }) +} + +// +export function deleteApi(ids) { + return request({ + url: 'sysLog?idList=' + ids, + method: 'delete' + }) +} +// +export function saveApi(data) { + return request({ + url: 'sysLog', + method: 'post', + data: data + }) +} + +// 保存修改信息 +export function updateApi(data) { + return request({ + url: 'sysLog', + method: 'put', + data: data + }) +} + + diff --git a/fuintAdmin_zt/src/views/setting/sysLog.vue b/fuintAdmin_zt/src/views/setting/sysLog.vue index e69de29bb..06557258b 100644 --- a/fuintAdmin_zt/src/views/setting/sysLog.vue +++ b/fuintAdmin_zt/src/views/setting/sysLog.vue @@ -0,0 +1,366 @@ + + + + + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/CommissionRecordController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/CommissionRecordController.java index 38f939252..4c762ddec 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/CommissionRecordController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/CommissionRecordController.java @@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.commission.entity.CommissionRecord; import com.fuint.business.commission.service.CommissionRecordService; import com.fuint.business.commission.vo.CommissionRecordVo; +import com.fuint.business.setting.entity.SysLog; +import com.fuint.business.setting.service.SysLogService; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import io.lettuce.core.dynamic.annotation.Param; @@ -82,7 +85,8 @@ public class CommissionRecordController extends BaseController { */ @PostMapping public ResponseObject add(@RequestBody CommissionRecord commissionRecord) { - return getSuccessResult(this.commissionRecordService.insert(commissionRecord)); + CommissionRecord insert = this.commissionRecordService.insert(commissionRecord); + return getSuccessResult(insert); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/StaffCommissionController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/StaffCommissionController.java index 4d2147466..f2f77fa65 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/StaffCommissionController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/controller/StaffCommissionController.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.commission.entity.StaffCommission; import com.fuint.business.commission.service.StaffCommissionService; import com.fuint.business.commission.vo.StaffCommissionVo; +import com.fuint.business.setting.entity.SysLog; +import com.fuint.business.setting.service.SysLogService; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; import org.springframework.beans.factory.annotation.Autowired; @@ -19,6 +21,8 @@ import org.springframework.web.bind.annotation.*; public class StaffCommissionController extends BaseController { @Autowired private StaffCommissionService commissionService; + @Autowired + private SysLogService sysLogService; /** * 根据条件分页查询员工提成方案信息 @@ -64,6 +68,12 @@ public class StaffCommissionController extends BaseController { */ @DeleteMapping("/{id}") public ResponseObject remove(@PathVariable Integer id){ + StaffCommission staffCommission = commissionService.getById(id); + SysLog sysLog =new SysLog(); + sysLog.setSystemName("2"); + sysLog.setMoudle("短信模版"); + sysLog.setContent("删除了模版名称为"+staffCommission.getName()+"的数据"); + sysLogService.saveVo(sysLog); commissionService.deleteCommissionById(id); return getSuccessResult("操作成功"); } @@ -76,6 +86,11 @@ public class StaffCommissionController extends BaseController { @PostMapping public ResponseObject add(@Validated @RequestBody StaffCommission commission){ int row = commissionService.insertStaffCommission(commission); + SysLog sysLog =new SysLog(); + sysLog.setSystemName("2"); + sysLog.setMoudle("提成方案"); + sysLog.setContent("新增了一条数据"); + sysLogService.saveVo(sysLog); return getSuccessResult(row); } @@ -87,6 +102,11 @@ public class StaffCommissionController extends BaseController { @PutMapping public ResponseObject edit(@Validated @RequestBody StaffCommission commission){ int row = commissionService.updateStaffCommission(commission); + SysLog sysLog =new SysLog(); + sysLog.setSystemName("2"); + sysLog.setMoudle("提成方案"); + sysLog.setContent("修改了方案名称为"+commission.getName()+"的方案"); + sysLogService.saveVo(sysLog); return getSuccessResult(row); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/HardwareStoreController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/HardwareStoreController.java index 301c232b7..d0d4cceea 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/HardwareStoreController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/HardwareStoreController.java @@ -6,12 +6,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.setting.entity.HardwareStore; +import com.fuint.business.setting.entity.SysLog; import com.fuint.business.setting.service.HardwareStoreService; +import com.fuint.business.setting.service.SysLogService; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.StringUtils; import com.fuint.common.util.TokenUtil; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -32,6 +35,8 @@ public class HardwareStoreController extends BaseController { */ @Resource private HardwareStoreService hardwareStoreService; + @Autowired + private SysLogService sysLogService; /** * 分页查询所有数据 @@ -77,6 +82,11 @@ public class HardwareStoreController extends BaseController { //获取当前登录用户 AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); hardwareStore.setCreateName(nowAccountInfo.getRealName()); + SysLog sysLog =new SysLog(); + sysLog.setSystemName("1"); + sysLog.setMoudle("硬件商城"); + sysLog.setContent("新增了硬件名称为"+hardwareStore.getName()+"的数据"); + sysLogService.saveVo(sysLog); return getSuccessResult(this.hardwareStoreService.save(hardwareStore)); } @@ -88,6 +98,11 @@ public class HardwareStoreController extends BaseController { */ @PutMapping public ResponseObject update(@RequestBody HardwareStore hardwareStore) { + SysLog sysLog =new SysLog(); + sysLog.setSystemName("1"); + sysLog.setMoudle("硬件商城"); + sysLog.setContent("更新了硬件名称为"+hardwareStore.getName()+"的数据"); + sysLogService.saveVo(sysLog); return getSuccessResult(this.hardwareStoreService.updateById(hardwareStore)); } @@ -99,6 +114,15 @@ public class HardwareStoreController extends BaseController { */ @DeleteMapping public ResponseObject delete(@RequestParam("idList") List idList) { + for (Long aLong : idList) { + HardwareStore hardwareStore = hardwareStoreService.getById(aLong); + SysLog sysLog =new SysLog(); + sysLog.setSystemName("1"); + sysLog.setMoudle("硬件商城"); + sysLog.setContent("删除了硬件名称为"+hardwareStore.getName()+"的数据"); + sysLogService.saveVo(sysLog); + } + return getSuccessResult(this.hardwareStoreService.removeByIds(idList)); } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/MessageTemplateController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/MessageTemplateController.java index f0aaec1b4..0aa6517ca 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/MessageTemplateController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/MessageTemplateController.java @@ -5,11 +5,14 @@ package com.fuint.business.setting.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.setting.entity.MessageTemplate; +import com.fuint.business.setting.entity.SysLog; import com.fuint.business.setting.service.MessageTemplateService; +import com.fuint.business.setting.service.SysLogService; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -30,7 +33,8 @@ public class MessageTemplateController extends BaseController { */ @Resource private MessageTemplateService messageTemplateService; - + @Autowired + private SysLogService sysLogService; /** * 分页查询所有数据 * @@ -64,6 +68,11 @@ public class MessageTemplateController extends BaseController { public ResponseObject insert(@RequestBody MessageTemplate messageTemplate) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); messageTemplate.setCreateName(nowAccountInfo.getRealName()); + SysLog sysLog =new SysLog(); + sysLog.setSystemName("1"); + sysLog.setMoudle("短信模版"); + sysLog.setContent("新增了模版名称为"+messageTemplate.getName()+"的数据"); + sysLogService.saveVo(sysLog); return getSuccessResult(this.messageTemplateService.save(messageTemplate)); } @@ -75,6 +84,11 @@ public class MessageTemplateController extends BaseController { */ @PutMapping public ResponseObject update(@RequestBody MessageTemplate messageTemplate) { + SysLog sysLog =new SysLog(); + sysLog.setSystemName("1"); + sysLog.setMoudle("短信模版"); + sysLog.setContent("更新了模版名称为"+messageTemplate.getName()+"的数据"); + sysLogService.saveVo(sysLog); return getSuccessResult(this.messageTemplateService.updateById(messageTemplate)); } @@ -86,6 +100,14 @@ public class MessageTemplateController extends BaseController { */ @DeleteMapping public ResponseObject delete(@RequestParam("idList") List idList) { + for (Long aLong : idList) { + MessageTemplate messageTemplate = messageTemplateService.getById(aLong); + SysLog sysLog =new SysLog(); + sysLog.setSystemName("1"); + sysLog.setMoudle("短信模版"); + sysLog.setContent("删除了模版名称为"+messageTemplate.getName()+"的数据"); + sysLogService.saveVo(sysLog); + } return getSuccessResult(this.messageTemplateService.removeByIds(idList)); } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/SysLogController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/SysLogController.java index ecfdc5a4d..51d3640a5 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/SysLogController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/controller/SysLogController.java @@ -2,12 +2,17 @@ package com.fuint.business.setting.controller; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.fuint.business.setting.entity.HardwareStore; import com.fuint.business.setting.entity.SysLog; import com.fuint.business.setting.service.SysLogService; +import com.fuint.common.util.StringUtils; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; +import org.apache.commons.lang3.ObjectUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -38,7 +43,26 @@ public class SysLogController extends BaseController { */ @GetMapping public ResponseObject selectAll(Page page, SysLog sysLog) { - return getSuccessResult(this.sysLogService.page(page, new QueryWrapper<>(sysLog))); + LambdaQueryWrapper sysLogLambdaQueryWrapper = new LambdaQueryWrapper(); + if (!StringUtils.isEmpty(sysLog.getCreateName())){ + sysLogLambdaQueryWrapper.like(SysLog::getCreateName,sysLog.getCreateName()); + } + if (!StringUtils.isEmpty(sysLog.getDeptId())){ + sysLogLambdaQueryWrapper.eq(SysLog::getDeptId,sysLog.getDeptId()); + } + if (!StringUtils.isEmpty(sysLog.getMoudle())){ + sysLogLambdaQueryWrapper.like(SysLog::getMoudle,sysLog.getMoudle()); + } + if (!StringUtils.isEmpty(sysLog.getSystemName())){ + sysLogLambdaQueryWrapper.eq(SysLog::getSystemName,sysLog.getSystemName()); + } + if (!ObjectUtils.isEmpty(sysLog.getStartTime())){ + sysLogLambdaQueryWrapper.ge(SysLog::getCreateTime,sysLog.getStartTime()); + } + if (!ObjectUtils.isEmpty(sysLog.getEndTime())){ + sysLogLambdaQueryWrapper.le(SysLog::getCreateTime, DateUtil.format(sysLog.getEndTime(),"yyyy-MM-dd")+" 23:59:59"); + } + return getSuccessResult(this.sysLogService.page(page, sysLogLambdaQueryWrapper)); } /** diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/SysLog.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/SysLog.java index c85953385..f28da9fee 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/SysLog.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/entity/SysLog.java @@ -1,7 +1,15 @@ package com.fuint.business.setting.entity; import java.util.Date; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.extension.activerecord.Model; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + import java.io.Serializable; /** @@ -10,9 +18,9 @@ import java.io.Serializable; * @author makejava * @since 2024-07-18 15:37:16 */ -@SuppressWarnings("serial") +@Data public class SysLog extends Model { - + @TableId(type = IdType.AUTO) private Integer id; //ip地址 private String ipAddr; @@ -22,6 +30,8 @@ public class SysLog extends Model { private String moudle; //1中台端2油站端 private String systemName; + //机构主键 + private String deptId; //机构名称 private String deptName; //登录账户 @@ -29,6 +39,7 @@ public class SysLog extends Model { //创建人名称 private String createName; //创建时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date createTime; //创建人 private String createBy; @@ -36,112 +47,13 @@ public class SysLog extends Model { private Date updateTime; //更新人 private String updateBy; - - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getIpAddr() { - return ipAddr; - } - - public void setIpAddr(String ipAddr) { - this.ipAddr = ipAddr; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMoudle() { - return moudle; - } - - public void setMoudle(String moudle) { - this.moudle = moudle; - } - - public String getSystemName() { - return systemName; - } - - public void setSystemName(String systemName) { - this.systemName = systemName; - } - - public String getDeptName() { - return deptName; - } - - public void setDeptName(String deptName) { - this.deptName = deptName; - } - - public String getCreateAccount() { - return createAccount; - } - - public void setCreateAccount(String createAccount) { - this.createAccount = createAccount; - } - - public String getCreateName() { - return createName; - } - - public void setCreateName(String createName) { - this.createName = createName; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public String getCreateBy() { - return createBy; - } - - public void setCreateBy(String createBy) { - this.createBy = createBy; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - public String getUpdateBy() { - return updateBy; - } - - public void setUpdateBy(String updateBy) { - this.updateBy = updateBy; - } - - /** - * 获取主键值 - * - * @return 主键值 - */ - @Override - protected Serializable pkVal() { - return this.id; - } + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date startTime; + @TableField(exist = false) + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private Date endTime; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/SysLogService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/SysLogService.java index aa7f62b58..d4c27860a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/SysLogService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/SysLogService.java @@ -10,6 +10,7 @@ import com.fuint.business.setting.entity.SysLog; * @since 2024-07-18 15:37:16 */ public interface SysLogService extends IService { + void saveVo(SysLog sysLog); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/SysLogServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/SysLogServiceImpl.java index 30478f7a1..138f46d5b 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/SysLogServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/setting/service/impl/SysLogServiceImpl.java @@ -4,7 +4,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.fuint.business.setting.mapper.SysLogMapper; import com.fuint.business.setting.entity.SysLog; import com.fuint.business.setting.service.SysLogService; +import com.fuint.common.dto.AccountInfo; +import com.fuint.common.util.TokenUtil; +import com.fuint.system.dept.entity.SysDept; +import com.fuint.system.dept.service.ISysDeptService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; /** * (SysLog)表服务实现类 @@ -14,6 +24,31 @@ import org.springframework.stereotype.Service; */ @Service("sysLogService") public class SysLogServiceImpl extends ServiceImpl implements SysLogService { + @Autowired + private ISysDeptService deptService; + @Override + public void saveVo(SysLog sysLog) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String ipAddress = request.getHeader("X-Forwarded-For"); + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getHeader("WL-Proxy-Client-IP"); + } + if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) { + ipAddress = request.getRemoteAddr(); + } + sysLog.setIpAddr(ipAddress); + //获取当前登录用户 + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + sysLog.setCreateAccount(nowAccountInfo.getAccountName()); + sysLog.setCreateName(nowAccountInfo.getRealName()); + SysDept sysDept = deptService.selectDeptById(nowAccountInfo.getDeptId()); + sysLog.setDeptId(sysDept.getDeptId().toString()); + sysLog.setDeptName(sysDept.getDeptName()); + this.save(sysLog); + } }