src/main/java/com/yssh/controller/XlsReportController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/mapper/XlsReportMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/yssh/utils/Result.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/XlsReportMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/yssh/controller/XlsReportController.java
@@ -53,9 +53,10 @@ pageIndex = null == pageIndex || pageIndex < 1 ? 1 : pageIndex; Integer offset = pageSize * (pageIndex - 1); List<XlsReport> list = xlsReportMapper.selectReportByPage(type, strStart, strEnd, pageSize, offset); Integer count = xlsReportMapper.selectReportCount(type, strStart, strEnd, pageSize, offset); List<XlsReport> list = 0 == count ? null : xlsReportMapper.selectReportByPage(type, strStart, strEnd, pageSize, offset); return Result.OK(list); return Result.OK(count, list); } @ApiOperationSupport(order = 2) src/main/java/com/yssh/mapper/XlsReportMapper.java
@@ -15,6 +15,11 @@ @Mapper public interface XlsReportMapper { /** * 查询报告记录数 */ Integer selectReportCount(@Param("type") String type, @Param("start") String start, @Param("end") String end, @Param("limit") Integer limit, @Param("offset") Integer offset); /** * 分页查询报告 */ List<XlsReport> selectReportByPage(@Param("type") String type, @Param("start") String start, @Param("end") String end, @Param("limit") Integer limit, @Param("offset") Integer offset); src/main/java/com/yssh/utils/Result.java
@@ -44,6 +44,9 @@ @ApiModelProperty(value = "数据对象") private T result; @ApiModelProperty(value = "记录数") private Integer count = 0; /** * 时间戳 */ @@ -72,7 +75,7 @@ @Deprecated public static Result<Object> ok(String msg) { Result<Object> r = new Result<Object>(); Result<Object> r = new Result<>(); r.setSuccess(true); r.setCode(CommonConstant.SC_OK_200); r.setMessage(msg); @@ -81,14 +84,21 @@ @Deprecated public static Result<Object> ok(Object data) { Result<Object> r = new Result<Object>(); Result<Object> r = new Result<>(); r.setSuccess(true); r.setCode(CommonConstant.SC_OK_200); r.setResult(data); return r; } public static<T> Result<T> OK() { public static Result<Object> OK(Integer count, Object data) { Result<Object> r = ok(data); r.setCount(count); return r; } public static <T> Result<T> OK() { Result<T> r = new Result<T>(); r.setSuccess(true); r.setCode(CommonConstant.SC_OK_200); @@ -96,7 +106,7 @@ return r; } public static<T> Result<T> OK(T data) { public static <T> Result<T> OK(T data) { Result<T> r = new Result<T>(); r.setSuccess(true); r.setCode(CommonConstant.SC_OK_200); @@ -104,7 +114,7 @@ return r; } public static<T> Result<T> OK(String msg, T data) { public static <T> Result<T> OK(String msg, T data) { Result<T> r = new Result<T>(); r.setSuccess(true); r.setCode(CommonConstant.SC_OK_200); @@ -113,7 +123,7 @@ return r; } public static<T> Result<T> error(String msg, T data) { public static <T> Result<T> error(String msg, T data) { Result<T> r = new Result<T>(); r.setSuccess(false); r.setCode(CommonConstant.SC_INTERNAL_SERVER_ERROR_500); @@ -140,6 +150,7 @@ this.success = false; return this; } /** * 无权限访问返回结果 */ @@ -147,8 +158,51 @@ return error(CommonConstant.SC_JEECG_NO_AUTHZ, msg); } @JsonIgnore private String onlTable; public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public T getResult() { return result; } public void setResult(T result) { this.result = result; } public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } public long getTimestamp() { return timestamp; } public void setTimestamp(long timestamp) { this.timestamp = timestamp; } } src/main/resources/mapper/XlsReportMapper.xml
@@ -1,6 +1,23 @@ <?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.yssh.mapper.XlsReportMapper"> <select id="selectReportCount" resultType="java.lang.Integer"> select count(*) from xls_report <where> 1 = 1 <if test="type != null"> and type = #{type} </if> <if test="start != null"> and create_time >= #{start} </if> <if test="end != null"> and create_time <= #{end} </if> </where> </select> <!-- 分页查询报告 --> <select id="selectReportByPage" resultType="com.yssh.entity.xls.XlsReport"> select *