Commit b9118ca6 by 吴博

feat: [1003821] 购书申请列表

parent 87394ae4
......@@ -23,7 +23,7 @@ public interface BuyBookRequestBiz {
/**
* 分页查询
*/
PageBeanNew getList(Integer currentPage, Integer numPerPage);
PageBeanNew getList(Integer currentPage, Integer numPerPage, Long agentId);
/**
* 新增数据
......
......@@ -2,9 +2,14 @@ package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.biz.BuyBookRequestBiz;
import com.pcloud.book.applet.dao.BuyBookRequestDao;
import com.pcloud.book.applet.dto.BuyBookRequestDTO;
import com.pcloud.book.applet.dto.BuyBookRequetUserDTO;
import com.pcloud.book.applet.entity.BuyBookRequest;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.book.consumer.user.AgentConsr;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
......@@ -13,12 +18,14 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.readercenter.wechat.entity.WechatUser;
import org.apache.commons.collections.MapUtils;
import org.apache.regexp.RE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -38,6 +45,12 @@ public class BuyBookRequestBizImpl implements BuyBookRequestBiz {
private BuyBookRequestDao buyBookRequestDao;
@Autowired
private ReaderConsr readerConsr;
@Autowired
private BookBiz bookBiz;
@Autowired
private AgentConsr agentConsr;
@Autowired
private AdviserConsr adviserConsr;
@Override
@ParamLog("通过ID查询单条数据")
......@@ -47,17 +60,54 @@ public class BuyBookRequestBizImpl implements BuyBookRequestBiz {
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Integer currentPage, Integer numPerPage) {
PageBeanNew pageBeanNew = buyBookRequestDao.listPageNew(new PageParam(currentPage, numPerPage), null, "getList");
List recordList = pageBeanNew.getRecordList();
public PageBeanNew getList(Integer currentPage, Integer numPerPage, Long agentId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("agentId" , agentId);
PageBeanNew pageBeanNew = buyBookRequestDao.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "getList");
List<BuyBookRequestDTO> recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)) {
return pageBeanNew;
}
// 加载其它数据
fillAgentInfo(recordList);
return pageBeanNew;
}
private void fillAgentInfo(List<BuyBookRequestDTO> recordList) {
List<Long> bookIds = recordList.stream().map(e -> e.getBookId()).collect(Collectors.toList());
List<Long> agentIds = recordList.stream().map(e -> e.getAgentId()).collect(Collectors.toList());
List<Long> adviserIds = recordList.stream().map(e -> e.getAdviserId()).collect(Collectors.toList());
Map<Long, BookDto> bookDtoMap = new HashMap<>();
Map<Long, String> agentNameMap = new HashMap<>();
Map<Long, String> adviserNameMap = new HashMap<>();
if (!ListUtils.isEmpty(bookIds)) {
bookDtoMap = bookBiz.getListByIds(bookIds);
}
if (!ListUtils.isEmpty(agentIds)) {
agentNameMap = agentConsr.getNames(agentIds);
}
if (!ListUtils.isEmpty(agentIds)) {
adviserNameMap = adviserConsr.getNames(adviserIds);
}
for (BuyBookRequestDTO buyBookRequestDTO : recordList) {
if (null == buyBookRequestDTO) {
continue;
}
if (MapUtils.isNotEmpty(bookDtoMap) && null != bookDtoMap.get(buyBookRequestDTO.getBookId())) {
buyBookRequestDTO.setBookName(bookDtoMap.get(buyBookRequestDTO.getBookId()).getBookName());
buyBookRequestDTO.setCoverImg(bookDtoMap.get(buyBookRequestDTO.getBookId()).getCoverImg());
}
if (MapUtils.isNotEmpty(agentNameMap) && null != agentNameMap.get(buyBookRequestDTO.getAgentId())) {
buyBookRequestDTO.setAgentName(agentNameMap.get(buyBookRequestDTO.getAgentId()));
}
if (MapUtils.isNotEmpty(adviserNameMap) && null != adviserNameMap.get(buyBookRequestDTO.getAdviserId())) {
buyBookRequestDTO.setAdviserName(adviserNameMap.get(buyBookRequestDTO.getAdviserId()));
}
}
}
@Override
@ParamLog("新增")
public Long insert(BuyBookRequest buyBookRequest) {
......
package com.pcloud.book.applet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class BuyBookRequestDTO {
private Long id;
private Long bookId;
private String bookName;
private String coverImg;
private Long adviserId;
private String adviserName;
private Long channelId;
private Long agentId;
private String agentName;
private Long wechatUserId;
private String userName;
private String phone;
private String address;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
......@@ -45,10 +45,11 @@ public class BuyBookRequestFacade {
@GetMapping("getList")
public ResponseDto<?> getList(@RequestHeader("token") String token,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage,
@RequestParam(value = "agentId", required = false) Long agentId)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(buyBookRequestBiz.getList(currentPage, numPerPage));
return new ResponseDto<>(buyBookRequestBiz.getList(currentPage, numPerPage, agentId));
}
@ApiOperation("新增")
......
......@@ -16,6 +16,20 @@
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="BaseResultMap4DTO" type="com.pcloud.book.applet.dto.BuyBookRequestDTO">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<result column="adviser_id" property="adviserId" jdbcType="BIGINT"/>
<result column="channel_id" property="channelId" jdbcType="BIGINT"/>
<result column="agent_id" property="agentId" jdbcType="BIGINT"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="user_name" property="userName" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_id, adviser_id, channel_id, agent_id, wechat_user_id, user_name, phone, address, create_time, update_time
</sql>
......@@ -27,10 +41,16 @@
WHERE id = #{id}
</select>
<select id="getList" resultMap="BaseResultMap">
<select id="getList" resultMap="BaseResultMap4DTO">
SELECT
<include refid="Base_Column_List"/>
FROM buy_book_request
<where>
<if test="agentId != null">
agent_id = #{agentId}
</if>
</where>
order by create_time desc
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
......
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