Commit 8acd20e4 by liyanlin

增加分页

parent 12f83ea0
package com.blt.other.module.cost.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blt.other.module.cost.dto.request.ApprovalHistoryReq;
import com.blt.other.module.cost.dto.response.ApprovalHistoryResult;
import com.blt.other.module.cost.service.ApprovalHistoryService;
......@@ -29,16 +31,7 @@ public class ApprovalHistoryController {
@ApiOperation("获取审批历史列表")
@GetMapping
public ApprovalHistoryResult get(ApprovalHistoryReq req) {
ApprovalHistoryResult result = new ApprovalHistoryResult();
try {
List<ApprovalHistoryVo> list = approvalHistoryService.getApprovalHistoryList(req);
result.setSuccess(true);
result.setList(list);
} catch (Exception ex) {
result.setSuccess(false);
result.setMsg(ex.getMessage());
}
return result;
public Page<ApprovalHistoryVo> get(ApprovalHistoryReq req) {
return approvalHistoryService.getApprovalHistoryList(req);
}
}
package com.blt.other.module.cost.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.blt.other.module.cost.dto.request.ApprovalHistoryReq;
import com.blt.other.module.cost.model.ApprovalHistoryDomain;
import com.blt.other.module.cost.vo.ApprovalHistoryVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -15,5 +17,5 @@ import java.util.List;
*/
public interface ApprovalHistoryMapper extends BaseMapper<ApprovalHistoryDomain> {
List<ApprovalHistoryVo> getApprovalHistoryList(ApprovalHistoryReq req);
IPage<ApprovalHistoryVo> getApprovalHistoryList(@Param("page") IPage<ApprovalHistoryVo> page, @Param("req")ApprovalHistoryReq req);
}
package com.blt.other.module.cost.dto.request;
import com.bailuntec.common.base.BaseRequest;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.checkerframework.common.value.qual.IntRange;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
......@@ -16,7 +18,7 @@ import java.time.LocalDateTime;
*/
@Data
@ApiModel("审批请求Model")
public class ApprovalHistoryReq {
public class ApprovalHistoryReq extends BaseRequest {
@ApiModelProperty(value = "审批时间-起始时间", required = true, example = "2021-08-25 00:00:00")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
......
package com.blt.other.module.cost.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.blt.other.module.cost.dao.ApprovalHistoryMapper;
import com.blt.other.module.cost.dto.request.ApprovalHistoryReq;
......@@ -21,5 +23,5 @@ public interface ApprovalHistoryService extends IService<ApprovalHistoryDomain>
* @param req
* @return
*/
List<ApprovalHistoryVo> getApprovalHistoryList(ApprovalHistoryReq req);
Page<ApprovalHistoryVo> getApprovalHistoryList(ApprovalHistoryReq req);
}
package com.blt.other.module.cost.service.impl;
import com.bailuntec.common.exception.BizException;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blt.other.module.cost.dao.ApprovalHistoryMapper;
import com.blt.other.module.cost.dto.request.ApprovalHistoryReq;
......@@ -25,13 +27,14 @@ public class ApprovalHistoryServiceImpl extends ServiceImpl<ApprovalHistoryMappe
ApprovalHistoryMapper approvalHistoryMapper;
@Override
public List<ApprovalHistoryVo> getApprovalHistoryList(ApprovalHistoryReq req) {
public Page<ApprovalHistoryVo> getApprovalHistoryList(ApprovalHistoryReq req) {
IPage<ApprovalHistoryVo> page = new Page<>(req.getPageNum(), req.getPageSize());
if(req.getStartTime() == null || req.getEndTime() == null){
throw new BizException("查询时间不可为空");
}
if(req.getStartTime().isAfter(req.getEndTime())){
throw new BizException("查询起始时间不可大于查询结束时间");
}
return approvalHistoryMapper.getApprovalHistoryList(req);
return (Page<ApprovalHistoryVo>)approvalHistoryMapper.getApprovalHistoryList(page, req);
}
}
......@@ -3,7 +3,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.blt.other.module.cost.dao.ApprovalHistoryMapper">
<select id="getApprovalHistoryList" parameterType="com.blt.other.module.cost.dto.request.ApprovalHistoryReq"
<select id="getApprovalHistoryList"
resultType="com.blt.other.module.cost.vo.ApprovalHistoryVo">
select ah.id, ah.cost_no as costNo ,c.cost_form as costFrom,c.is_lend as isLend, s2.statusvalue as costStatus
,ah.is_passed as isPassed ,ah.approval_time as approvalTime ,c.type_name as typeName,u.username
......@@ -11,10 +11,10 @@
left join cost c on c.cost_no = ah.cost_no
left join `user` u on u.userid = ah.approval_user_id
left join status s2 on s2.statusname = 'cost_status' and s2.statuskey = ah.cost_status
where ah.approval_time between #{startTime} and #{endTime}
<if test="costStatus != null">and ah.cost_status = #{costStatus}</if>
<if test="typeNo != null and typeNo != ''">and c.type_no = #{typeNo}</if>
<if test="userId != null and userId != ''">and ah.approval_user_id = #{userId}</if>
<if test="costNo != null and costNo != ''">and ah.cost_no like concat('%',#{costNo},'%')</if>
where ah.approval_time between #{req.startTime} and #{req.endTime}
<if test="req.costStatus != null">and ah.cost_status = #{costStatus}</if>
<if test="req.typeNo != null and req.typeNo != ''">and c.type_no = #{req.typeNo}</if>
<if test="req.userId != null and req.userId != ''">and ah.approval_user_id = #{req.userId}</if>
<if test="req.costNo != null and req.costNo != ''">and ah.cost_no like concat('%',#{req.costNo},'%')</if>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment