Commit ceca2bdd by 裴大威

Merge branch 'feat_wb_1002932_new' into 'master'

wb_1002932 权益关联书刊

See merge request rays/pcloud-book!738
parents e8aeb914 0126342b
......@@ -652,4 +652,6 @@ public interface BookBiz {
void updateIsOpenRobotProcess(Long adviserId, UpdateBookRobotProcessDto robotProcessDto);
void updateIsOpenRobotProcess4Now(Long adviserId, UpdateBookRobotProcessDto robotProcessDto);
PageBeanNew<BookDto> getAdviserBooks4Rights(String keyword, Long agentId, Long templetId, Long secondTempletId, String typeCode, Integer currentPage, Integer numPerPage);
}
......@@ -56,6 +56,7 @@ import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.entity.BookAppletScene;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.mq.producer.BookMQProducer;
import com.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.vo.BookServeVO;
......@@ -170,12 +171,8 @@ public class BookBizImpl implements BookBiz {
@Autowired
private WechatConsr wechatConsr;
@Autowired
private RightsSettingBookRelationMapper rightsSettingBookRelationMapper;
/**
......@@ -2258,6 +2255,38 @@ public class BookBizImpl implements BookBiz {
}
}
@Override
public PageBeanNew<BookDto> getAdviserBooks4Rights(String keyword, Long agentId, Long templetId, Long secondTempletId, String typeCode,
Integer currentPage, Integer numPerPage) {
Map<String,Object> map=new HashMap<>();
map.put("keyword",keyword);
map.put("templetId",templetId);
map.put("secondTempletId",secondTempletId);
map.put("typeCode",typeCode);
if (agentId != null){
List<Long> adviserIds = adviserConsr.getIdsByNameAndAgentId(agentId, null);
if (ListUtils.isEmpty(adviserIds)){
map.put("adviserIds", Collections.singletonList(-1L));
}else {
map.put("adviserIds",adviserIds);
}
}
if(!StringUtil.isEmpty(keyword)) {
// 模糊匹配编辑名称
List<Long> adviserIds = adviserConsr.getAdviserIdsByName(keyword);
map.put("adviserIds4Name", adviserIds);
}
//获取已被权益选择的书刊
List<Long> bookIds = rightsSettingBookRelationMapper.getAllBookIds();
if (!ListUtils.isEmpty(bookIds)){
map.put("ignoreBookIds", bookIds);
}
PageBeanNew<BookDto> page = bookDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getAdviserBooks4Rights");
fillBookInfo(page.getRecordList());
return page;
}
public void createBookGroupAppletUrl(Long bookId, Long channelId, Long adviserId,List<Long> sceneIds){
BookAdviserDto bookAdviserDto = bookAdviserDao.getBase(bookId,channelId,adviserId);
Long raysClassifyId = bookRaysClassifyDao.getClassifyIdByBookTemplateId(bookAdviserDto.getTempletId());
......
......@@ -1051,4 +1051,22 @@ public class BookFacadeImpl implements BookFacade {
return new ResponseDto<>();
}
@GetMapping("getAdviserBooks4Rights")
public ResponseDto<?> getAdviserBooks4Rights(
@RequestHeader("token") String token,
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "agentId", required = false) Long agentId,
@RequestParam(value = "templetId", required = false) Long templetId,
@RequestParam(value = "secondTempletId", required = false) Long secondTempletId,
@RequestParam(value = "typeCode", required = false) String typeCode,
@RequestParam(value = "currentPage") Integer currentPage,
@RequestParam(value = "numPerPage") Integer numPerPage
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (currentPage == null || numPerPage == null || currentPage < 0 || numPerPage < 0) {
throw BookBizException.PAGE_PARAM_DELETION;
}
return new ResponseDto<>(bookBiz.getAdviserBooks4Rights(keyword, agentId, templetId, secondTempletId, typeCode, currentPage, numPerPage));
}
}
\ No newline at end of file
......@@ -38,8 +38,8 @@ public class RightsSettingCheck {
if (null==rightsSetting.getRightsSettingType()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益类型为空!");
}
if (rightsSetting.getRightsSettingType()==2 && null==rightsSetting.getBookId()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"bookId为空!");
if (ListUtils.isEmpty(rightsSetting.getRightsSettingBookRelations())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"RightsSettingBookRelations不能为空!");
}
if (rightsSetting.getRightsSettingType()==1 && null == rightsSetting.getFirstClassify()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!");
......
......@@ -70,6 +70,9 @@ public class RightsSetting extends BaseTempletClassify {
@ApiModelProperty("书刊id")
private Long bookId;
@ApiModelProperty("书刊ids")
private List<RightsSettingBookRelation> rightsSettingBookRelations;
/**
* 书或isbn查询
*/
......
package com.pcloud.book.rightsSetting.entity;
import java.util.Date;
import lombok.Data;
@Data
public class RightsSettingBookRelation {
private Long id;
private Long rightsSettingId;
private Long bookId;
private Date createTime;
private Date updateTime;
private String bookName;
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.mapper;
import com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RightsSettingBookRelationMapper {
int deleteByPrimaryKey(Long id);
int insert(RightsSettingBookRelation record);
int insertSelective(RightsSettingBookRelation record);
RightsSettingBookRelation selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(RightsSettingBookRelation record);
int updateByPrimaryKey(RightsSettingBookRelation record);
void batchInsert(List<RightsSettingBookRelation> rightsSettingBookRelations);
void deleteByRightsSettingId(Long rightsSettingId);
List<RightsSettingBookRelation> selectByRithsSettingId(Long rightsSettingId);
List<RightsSettingBookRelation> selectBookByRithsSettingId(Long rightsSettingId);
List<Long> getAllBookIds();
}
\ No newline at end of file
......@@ -2379,4 +2379,58 @@
and is_delete=0
</update>
<select id="getAdviserBooks4Rights" resultMap="bookMap" parameterType="map">
SELECT
A.BOOK_ID, A.CHANNEL_ID, A.ADVISER_ID, A.IS_MAIN_EDITOR, T.TYPE_CODE, T.TYPE_NAME, B.ISBN, B.BOOK_NAME, B.REMARK,
B.AUTHOR, B.PUBLISH, B.PUBLISH_DATE, B.COVER_IMG, B.ORIGIN_NAME, B.BOOK_PRICE, B.ISSN, B.BOOK_NUM, B.SERIAL_NUMBER,
A.TEMPLET_ID,A.SECOND_TEMPLET_ID,A.LAST_MODIFIED_DATE LAST_MODIFIED_DATE,A.BOOK_ADVISER_ID,CONCAT('BK',A.BOOK_ID) uniqueNumber
FROM
BOOK_ADVISER A
INNER JOIN BOOK B ON A.BOOK_ID = B.BOOK_ID AND A.IS_DELETE = 0 AND B.IS_DELETE = 0
LEFT JOIN BOOK_TYPE T ON B.TYPE_CODE = T.TYPE_CODE
WHERE
1=1
AND A.IS_MAIN_EDITOR = 1
<if test="typeCode!=null">
AND
B.TYPE_CODE = #{typeCode}
</if>
<if test="keyword != null">
AND (B.BOOK_NAME LIKE CONCAT('%', #{keyword}, '%')
OR B.ISBN LIKE CONCAT(#{keyword},'%')
OR CONCAT('BK',A.BOOK_ID) = #{keyword}
<if test="adviserIds4Name!=null and adviserIds4Name.size()>0">
OR
A.ADVISER_ID in
<foreach collection="adviserIds4Name" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>)
</if>
<if test="templetId != null">
AND
A.TEMPLET_ID = #{templetId}
</if>
<if test="secondTempletId!=null ">
AND
A.SECOND_TEMPLET_ID=#{secondTempletId}
</if>
<if test="adviserIds!=null and adviserIds.size()>0">
AND
A.ADVISER_ID in
<foreach collection="adviserIds" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
<if test="ignoreBookIds != null">
and
A.BOOK_ID not in
<foreach collection="ignoreBookIds" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
GROUP BY A.BOOK_ID, A.CHANNEL_ID
ORDER BY
A.LAST_MODIFIED_DATE DESC
</select>
</mapper>
\ No newline at end of file
<?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.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT" />
<result column="book_id" property="bookId" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, rights_setting_id, book_id, create_time, update_time
</sql>
<sql id="Base_Column_List_owm" >
r.id, r.rights_setting_id, r.book_id, r.create_time, r.update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from rights_setting_book_relation
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectByRithsSettingId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from rights_setting_book_relation
where rights_setting_id = #{rightsSettingId,jdbcType=BIGINT}
</select>
<select id="getAllBookIds" resultType="java.lang.Long">
select book_id
from
rights_setting_book_relation
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from rights_setting_book_relation
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByRightsSettingId" parameterType="long">
delete from rights_setting_book_relation
where rights_setting_id = #{rightsSettingId,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation" >
insert into rights_setting_book_relation (id, rights_setting_id, book_id,
create_time, update_time)
values (#{id,jdbcType=BIGINT}, #{rightsSettingId,jdbcType=BIGINT}, #{bookId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation" >
insert into rights_setting_book_relation
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="rightsSettingId != null" >
rights_setting_id,
</if>
<if test="bookId != null" >
book_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="rightsSettingId != null" >
#{rightsSettingId,jdbcType=BIGINT},
</if>
<if test="bookId != null" >
#{bookId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation">
insert into rights_setting_book_relation (rights_setting_id, book_id,
create_time, update_time)
values
<foreach collection="list" index="index" item="item" separator=",">
(#{item.rightsSettingId,jdbcType=BIGINT}, #{item.bookId,jdbcType=BIGINT},
now(),now())
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation" >
update rights_setting_book_relation
<set >
<if test="rightsSettingId != null" >
rights_setting_id = #{rightsSettingId,jdbcType=BIGINT},
</if>
<if test="bookId != null" >
book_id = #{bookId,jdbcType=BIGINT},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation" >
update rights_setting_book_relation
set rights_setting_id = #{rightsSettingId,jdbcType=BIGINT},
book_id = #{bookId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectBookByRithsSettingId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List_owm" />,b.book_name
from rights_setting_book_relation r
left join book b on r.book_id = b.book_Id
where rights_setting_id = #{_parameter}
</select>
</mapper>
\ No newline at end of file
......@@ -43,11 +43,24 @@
<result column="read_type_title" property="readTypeTitle" jdbcType="VARCHAR" />
<result column="vol_label_id" property="volLabelId" jdbcType="BIGINT" />
</resultMap>
<resultMap id="DtoResultMap4Book" type="com.pcloud.book.rightsSetting.dto.RightsSettingDto" extends="DtoResultMap">
<collection property="rightsSettingBookRelations" ofType="com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation"
column="id" select="com.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper.selectBookByRithsSettingId">
</collection>
</resultMap>
<sql id="Base_Column_List" >
id, introduce, detail, count, first_classify, second_classify, grade_label_id, subject_label_id,
create_time, update_time, enable_group_service, rights_setting_type, book_id
,online_course_open,learning_tool_open,draw_open,read_type_title, vol_label_id
</sql>
<sql id="Base_Column_List_own" >
r.id, r.introduce, r.detail, r.count, r.first_classify, r.second_classify, r.grade_label_id, r.subject_label_id,
r.create_time, r.update_time, r.enable_group_service, r.rights_setting_type, r.book_id
,r.online_course_open,r.learning_tool_open,r.draw_open,r.read_type_title
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
......@@ -146,9 +159,10 @@
<select id="listRightsSettingPage" parameterType="map" resultMap="DtoResultMap">
select
<include refid="Base_Column_List"/>
<include refid="Base_Column_List_own"/>
from
rights_setting
rights_setting r
left join rights_setting_book_relation b on r.id = b.rights_setting_id
<where>
<if test="firstClassify != null">
first_classify = #{firstClassify}
......@@ -165,30 +179,36 @@
<if test="rightsSettingType !=null">
and rights_setting_type = #{rightsSettingType}
</if>
<if test="bookId!=null">
and book_id=#{bookId}
<if test="bookIds != null and bookIds.size() > 0">
and b.book_id in
<foreach collection="bookIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="exceptId!=null">
and id != #{exceptId}
and r.id != #{exceptId}
</if>
<if test="volLabelId != null" >
and vol_label_id = #{volLabelId}
</if>
</where>
order by create_time desc
order by r.create_time desc
</select>
<select id="listBookRightsSettingPage" parameterType="map" resultMap="DtoResultMap">
<select id="listBookRightsSettingPage" parameterType="map" resultMap="DtoResultMap4Book">
select
r.id, r.introduce, r.detail, r.count, r.first_classify, r.second_classify, r.grade_label_id, r.subject_label_id,
r.create_time, r.update_time, r.enable_group_service, r.rights_setting_type, r.book_id, b.BOOK_NAME, r.vol_label_id
from
rights_setting r LEFT JOIN book b ON r.book_id=b.BOOK_ID
rights_setting r
left join rights_setting_book_relation s on r.id = s.rights_setting_id
LEFT JOIN book b ON s.book_id=b.BOOK_ID
WHERE
r.rights_setting_type = 2
<if test="bookQuery !=null">
AND (b.BOOK_NAME LIKE CONCAT("%",#{bookQuery},"%") OR b.ISBN LIKE CONCAT("%",#{bookQuery},"%"))
</if>
group by r.id
order by r.create_time desc
</select>
......@@ -219,10 +239,11 @@
<select id="getByBookId" parameterType="map" resultMap="DtoResultMap">
select
<include refid="Base_Column_List"/>
<include refid="Base_Column_List_own"/>
from
rights_setting
WHERE book_id = #{bookId}
rights_setting r
left join rights_setting_book_relation b on r.id = b.rights_setting_id
WHERE b.book_id = #{bookId}
and rights_setting_type = 2
limit 1
</select>
......
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