feat(operatorsLog): 添加压桶修改日志导出功能

- 在AdminOperatorsLogController中新增operatorsLogListExcel接口用于导出功能
- 集成EasyPoi实现Excel导出功能并添加相关依赖导入
- 在OperatorsLog实体类中为各个字段添加@Excel注解以支持导出映射
- 为响应对象添加HttpServletResponse参数支持文件下载
- 实现分页数据获取并转换为Excel格式导出的完整流程
This commit is contained in:
wxys233 2026-02-07 14:59:46 +08:00
parent 6badf1652b
commit 469ff37b8e
2 changed files with 24 additions and 0 deletions

View file

@ -2,14 +2,19 @@ package com.sqx.modules.operatorsLog.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sqx.common.utils.Result; import com.sqx.common.utils.Result;
import com.sqx.modules.operatorsLog.entity.OperatorsLog; import com.sqx.modules.operatorsLog.entity.OperatorsLog;
import com.sqx.modules.operatorsLog.service.OperatorsLogService; import com.sqx.modules.operatorsLog.service.OperatorsLogService;
import com.sqx.modules.pay.entity.PayDetails;
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
/** /**
* <p> * <p>
* 前端控制器 * 前端控制器
@ -31,6 +36,13 @@ public class AdminOperatorsLogController {
return Result.success().put("data", operatorsLogService.getOperatorsLogList(page, limit, operatorsLog)); return Result.success().put("data", operatorsLogService.getOperatorsLogList(page, limit, operatorsLog));
} }
@GetMapping("/operatorsLogListExcel")
@ApiOperation("压桶修改日志列表导出")
public void operatorsLogListExcel(Integer page, Integer limit, OperatorsLog operatorsLog, HttpServletResponse response) throws Exception {
IPage<OperatorsLog> operatorsLogList = operatorsLogService.getOperatorsLogList(page, limit, operatorsLog);
ExcelUtils.exportExcel(operatorsLogList.getRecords(), "押桶记录", "押桶记录", OperatorsLog.class, "押桶记录", response);
}
@RequestMapping(value = "deleteLogById") @RequestMapping(value = "deleteLogById")
@ApiOperation("根据id删除日志") @ApiOperation("根据id删除日志")
public Result deleteLogById(Long logId) { public Result deleteLogById(Long logId) {

View file

@ -1,5 +1,6 @@
package com.sqx.modules.operatorsLog.entity; package com.sqx.modules.operatorsLog.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.SqlCondition; import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
@ -27,6 +28,7 @@ public class OperatorsLog implements Serializable {
* 日志id * 日志id
*/ */
@TableId(value = "log_id", type = IdType.AUTO) @TableId(value = "log_id", type = IdType.AUTO)
@Excel(name = "日志id")
private Long logId; private Long logId;
/** /**
@ -42,11 +44,13 @@ public class OperatorsLog implements Serializable {
/** /**
* 修改人昵称 * 修改人昵称
*/ */
@Excel(name = "修改人")
@TableField(condition = SqlCondition.LIKE) @TableField(condition = SqlCondition.LIKE)
private String updateUserName; private String updateUserName;
/** /**
* 修改人手机号码 * 修改人手机号码
*/ */
@Excel(name = "修改人手机号码")
private String updateUserPhone; private String updateUserPhone;
/** /**
* 用户id * 用户id
@ -56,40 +60,48 @@ public class OperatorsLog implements Serializable {
/** /**
* 用户昵称 * 用户昵称
*/ */
@Excel(name = "用户昵称")
@TableField(condition = SqlCondition.LIKE) @TableField(condition = SqlCondition.LIKE)
private String userName; private String userName;
/** /**
* 用户手机号码 * 用户手机号码
*/ */
@Excel(name = "用户手机号码")
private String userPhone; private String userPhone;
/** /**
* 用户上一次压桶数 * 用户上一次压桶数
*/ */
@Excel(name = "用户上一次压桶数")
private Integer lastBucket; private Integer lastBucket;
/** /**
* 1增加 2减少 * 1增加 2减少
*/ */
@Excel(name = "操作类型")
private Integer operator; private Integer operator;
/** /**
* 修改数量 * 修改数量
*/ */
@Excel(name = "修改数量")
private Integer operatorNum; private Integer operatorNum;
/** /**
* 0待审核 1已通过 2已拒绝 * 0待审核 1已通过 2已拒绝
*/ */
@Excel(name = "操作状态")
private Integer status; private Integer status;
/** /**
* 修改后的压桶数 * 修改后的压桶数
*/ */
@Excel(name = "修改后的压桶数")
private Integer nextBucket; private Integer nextBucket;
/** /**
* 修改时间 * 修改时间
*/ */
@Excel(name = "修改时间")
private Date updateTime; private Date updateTime;