Commit 82827cc2 by 田超

Merge branch 'feature/1003353' into 'master'

feat: [1003353] 小睿书刊分类添加版本标签

See merge request rays/pcloud-book!860
parents 6fdaf590 f457f41b
......@@ -40,12 +40,12 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import java.util.Arrays;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
......@@ -108,6 +108,7 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
@Override
public PageBeanNew<AppletUserBookcaseDTO> listByWechatUserId(Long wechatUserId, Integer currentPage, Integer numPerPage) {
//缓存中查
String key = AppletConstants.USER_BOOK_CASE + wechatUserId;
String field = currentPage + "-" + numPerPage;
String countKey = AppletConstants.USER_BOOK_CASE_COUNT + wechatUserId;
......@@ -117,9 +118,22 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
if (!StringUtil.isEmpty(countStr)) {
count = Integer.valueOf(countStr);
}
if (!ListUtils.isEmpty(bookcaseDTOS) && count > 0) {
//首页数据是否正确
Boolean correct = true;
if (0 == currentPage && 1 == numPerPage && !ListUtils.isEmpty(bookcaseDTOS)) {
AppletUserBookcaseDTO appletUserBookcase = bookcaseDTOS.get(0);
Long settingId = appletUserBookcase.getRightsSettingId() == null ? 0L : appletUserBookcase.getRightsSettingId();
RightsSettingDto rightsSettingDto = rightsSettingBiz.getRightsSettingByBookId4AppletHome(appletUserBookcase.getBookId(), appletUserBookcase.getAdviserId(), appletUserBookcase.getChannelId());
Long actualSettingId = rightsSettingDto.getId() == null ? 0L : rightsSettingDto.getId();
if (!actualSettingId.equals(settingId)) {
correct = false;
appletUserBookcaseDao.updateRightsSettingId(actualSettingId > 0 ? actualSettingId : null, appletUserBookcase.getBookId(), appletUserBookcase.getAdviserId(), appletUserBookcase.getChannelId());
}
}
if (!ListUtils.isEmpty(bookcaseDTOS) && count > 0 && correct) {
return new PageBeanNew<>(currentPage, numPerPage, count, bookcaseDTOS);
}
//数据库查询
Map<String, Object> map = new HashMap<>();
map.put("wechatUserId", wechatUserId);
PageBeanNew<AppletUserBookcaseDTO> pageBeanNew = appletUserBookcaseDao.listPageNew(
......
......@@ -897,7 +897,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
BookAdviserDto adviserDto = bookAdviserDao.getBase(bookId,channelId,adviserId);
if (null!=adviserDto){
RightsSettingDto rightsSettingDto = rightsSettingBiz.getByLabel(adviserDto.getTempletId(),
adviserDto.getSecondTempletId(),adviserDto.getGraLabelId(),adviserDto.getSubLabelId(), adviserDto.getVolLabelId());
adviserDto.getSecondTempletId(),adviserDto.getGraLabelId(),adviserDto.getSubLabelId(), adviserDto.getVolLabelId(), adviserDto.getVerLabelId());
if (null!= rightsSettingDto){
bookRightsSettingDTO.setRightsSettingDetail(rightsSettingDto.getDetail());
bookRightsSettingDTO.setRightsSettingIntroduce(rightsSettingDto.getIntroduce());
......
......@@ -27,7 +27,7 @@ public interface RightsSettingBiz {
PageBeanNew<RightsSettingDto> listRightsSettingPage(Integer currentPage, Integer numPerPage, RightsSetting rightsSetting);
RightsSettingDto getByLabel(Long firstClassify,Long secondClassify,Long gradeLabelId,Long subjectLabelId, Long volLabelId);
RightsSettingDto getByLabel(Long firstClassify,Long secondClassify,Long gradeLabelId,Long subjectLabelId, Long volLabelId, Long verLabelId);
Integer getUserCount();
......
package com.pcloud.book.rightsSetting.biz.impl;
import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
......@@ -14,7 +14,6 @@ import com.pcloud.book.applet.dto.AppletGroupStatementDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.dto.AppletNewsServeDTO;
import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletNewsServe;
import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.applet.enums.AppletNewsServeTypeEnum;
import com.pcloud.book.base.exception.BookBizException;
......@@ -95,9 +94,7 @@ import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import java.util.Arrays;
import java.util.Comparator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
......@@ -107,6 +104,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
......@@ -120,6 +118,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz {
......@@ -267,6 +268,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (!ArrayUtils.contains(RightsSettingConstant.K12_VOLUME_ID, baseTempletClassify.getFirstClassify())) {
baseTempletClassify.setVolLabelId(null);
}
if (!ArrayUtils.contains(RightsSettingConstant.K12_VERSION_ID, baseTempletClassify.getFirstClassify())) {
baseTempletClassify.setVerLabelId(null);
}
}
/**
......@@ -294,6 +298,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
paramMap.put("gradeLabelId", rightsSetting.getGradeLabelId());
paramMap.put("subjectLabelId", rightsSetting.getSubjectLabelId());
paramMap.put("volLabelId", rightsSetting.getVolLabelId());
paramMap.put("verLabelId", rightsSetting.getVerLabelId());
}
List<RightsSettingDto> list = rightsSettingDAO.listRightsSettingPage(paramMap);
count = list.size();
......@@ -1456,6 +1461,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
paramMap.put("gradeLabelId", rightsSetting.getGradeLabelId());
paramMap.put("subjectLabelId", rightsSetting.getSubjectLabelId());
paramMap.put("volLabelId", rightsSetting.getVolLabelId());
paramMap.put("verLabelId", rightsSetting.getVerLabelId());
rightsSettingDtoPageBeanNew = rightsSettingDAO
.listPageNew(new PageParam(currentPage, numPerPage), paramMap, "listRightsSettingPage");
}
......@@ -1521,6 +1527,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (null != rightsSettingDto.getVolLabelId()) {
labelIds.add(rightsSettingDto.getVolLabelId());
}
if (null != rightsSettingDto.getVerLabelId()){
labelIds.add(rightsSettingDto.getVerLabelId());
}
}
Map<Long, AssistTempletDTO> classifyMap = new HashMap<>();
Map<Long, BookLabel> labelMap = new HashMap<>();
......@@ -1546,11 +1555,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getVolLabelId())) {
rightsSettingDto.setVolLabelContent(labelMap.get(rightsSettingDto.getVolLabelId()).getName());
}
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getVerLabelId())){
rightsSettingDto.setVerLabelContent(labelMap.get(rightsSettingDto.getVerLabelId()).getName());
}
}
}
@Override
public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId) {
public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId,
Long verLabelId) {
//医疗保健分类校验
if (ArrayUtils.contains(RightsSettingConstant.MEDICAL_INSURANCE_TEMPLET_ID, firstClassify)) {
subjectLabelId = null;
......@@ -1570,7 +1583,16 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (!ArrayUtils.contains(RightsSettingConstant.K12_VOLUME_ID, firstClassify)) {
volLabelId = null;
}
RightsSettingDto dto = rightsSettingDAO.getByLabel(firstClassify, secondClassify, gradeLabelId, subjectLabelId, volLabelId);
//版本标签校验
if (!ArrayUtils.contains(RightsSettingConstant.K12_VERSION_ID, firstClassify)){
verLabelId = null;
}
RightsSettingDto dto = rightsSettingDAO.getByLabel(firstClassify, secondClassify, gradeLabelId, subjectLabelId, volLabelId, verLabelId);
//有版本筛选但权益未配置
if (null == dto && verLabelId > 0) {
Long commonLabelId = bookLabelDao.getByNameType("通用版",3);
dto = rightsSettingDAO.getByLabel(firstClassify, secondClassify, gradeLabelId, subjectLabelId, volLabelId, commonLabelId);
}
return dto;
}
......@@ -1628,14 +1650,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (null != rightsSettingDto) {
rightsSettingDto
.setRightsSettingBookRelations(rightsSettingBookRelationMapper.selectByRithsSettingId(rightsSettingDto.getId()));
;
}
if (null == rightsSettingDto) {
//根据分类获取权益
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
if (null != adviserDto) {
rightsSettingDto = getByLabel(adviserDto.getTempletId(), adviserDto.getSecondTempletId(), adviserDto.getGraLabelId(),
adviserDto.getSubLabelId(), adviserDto.getVolLabelId());
adviserDto.getSubLabelId(), adviserDto.getVolLabelId(), adviserDto.getVerLabelId());
}
}
if (null == rightsSettingDto) {
......@@ -2311,7 +2332,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
if (null != adviserDto) {
rightsSettingDto = getByLabel(adviserDto.getTempletId(), adviserDto.getSecondTempletId(), adviserDto.getGraLabelId(),
adviserDto.getSubLabelId(), adviserDto.getVolLabelId());
adviserDto.getSubLabelId(), adviserDto.getVolLabelId(), adviserDto.getVerLabelId());
if (null == rightsSettingDto) {
log.error("该书没有匹配的分类权益,bookId=" + bookId);
return new RightsSettingDto();
......@@ -2454,7 +2475,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
//根据分类获取权益
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
return getByLabel(adviserDto.getTempletId(), adviserDto.getSecondTempletId(), adviserDto.getGraLabelId(),
adviserDto.getSubLabelId(), adviserDto.getVolLabelId());
adviserDto.getSubLabelId(), adviserDto.getVolLabelId(), adviserDto.getVerLabelId());
}
@Override
......
......@@ -18,6 +18,10 @@ public class RightsSettingConstant {
*/
public static final Long[] K12_VOLUME_ID = {48L, 59L, 46L, 40L, 65L};
/**
* 所属k12教育/学前教育的书刊分类id---有版本分类
*/
public static final Long[] K12_VERSION_ID = {48L, 59L, 46L, 40L, 65L, 73L};
/**
* 医疗保健编辑书刊分类id
*/
public static final Long[] MEDICAL_INSURANCE_TEMPLET_ID = {63L};
......
......@@ -16,7 +16,7 @@ public interface RightsSettingDAO extends BaseDao<RightsSetting> {
int updateByPrimaryKey(RightsSetting record);
RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId);
RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId, Long verLabelId);
RightsSettingDto getByBookId(Long bookId);
......
......@@ -33,13 +33,14 @@ public class RightsSettingDAOImpl extends BaseDaoImpl<RightsSetting> implement
}
@Override
public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId) {
public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId, Long volLabelId, Long verLabelId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("firstClassify",firstClassify);
paramMap.put("secondClassify",secondClassify);
paramMap.put("gradeLabelId",gradeLabelId);
paramMap.put("subjectLabelId",subjectLabelId);
paramMap.put("volLabelId", volLabelId);
paramMap.put("verLabelId", verLabelId);
return getSessionTemplate().selectOne(getStatement("getByLabel"),paramMap);
}
......
......@@ -28,4 +28,6 @@ public class RightsSettingDto extends RightsSetting {
private Integer chooseReadType;
private String volLabelContent;
private String verLabelContent;
}
......@@ -21,4 +21,6 @@ public class BaseTempletClassify extends BaseEntity {
private Long subjectLabelId;
@ApiModelProperty("上下册标签id")
private Long volLabelId;
@ApiModelProperty("版本标签")
private Long verLabelId;
}
......@@ -141,6 +141,9 @@ public class RightsSetting extends BaseTempletClassify {
@ApiModelProperty("小程序对象")
private AppletNewsServeDTO guideAppletServe;
@ApiModelProperty("版本标签")
private Long verLabelId;
public RightsSetting() {
}
......
......@@ -80,7 +80,8 @@ public class RightsSettingFacede {
@RequestParam(value = "gradeLabelId", required = false) Long gradeLabelId,
@RequestParam(value = "subjectLabelId", required = false) Long subjectLabelId, @RequestParam(value = "rightsSettingType", required = false, defaultValue = "1") Integer rightsSettingType,
@RequestParam(value = "bookQuery", required = false) String bookQuery,
@RequestParam(value = "volLabelId", required = false) Long volLabelId
@RequestParam(value = "volLabelId", required = false) Long volLabelId,
@RequestParam(value = "verLabelId", required = false) Long verLabelId
) throws PermissionException {
SessionUtil.getToken4Redis(token);
......@@ -92,6 +93,7 @@ public class RightsSettingFacede {
rightsSetting.setRightsSettingType(rightsSettingType);
rightsSetting.setBookQuery(bookQuery);
rightsSetting.setVolLabelId(volLabelId);
rightsSetting.setVerLabelId(verLabelId);
return new ResponseDto<PageBeanNew<RightsSettingDto>>(rightsSettingBiz.listRightsSettingPage(currentPage, numPerPage, rightsSetting));
}
......
......@@ -25,6 +25,7 @@
<result column="guide_type" property="guideType" jdbcType="VARCHAR" />
<result column="guide_id" property="guideId" jdbcType="BIGINT" />
<result column="guide_pic" property="guidePic" jdbcType="VARCHAR" />
<result column="ver_label_id" property="verLabelId" jdbcType="BIGINT" />
</resultMap>
<resultMap id="DtoResultMap" type="com.pcloud.book.rightsSetting.dto.RightsSettingDto">
......@@ -47,6 +48,7 @@
<result column="draw_open" property="drawNowOpen" jdbcType="BOOLEAN" />
<result column="read_type_title" property="readTypeTitle" jdbcType="VARCHAR" />
<result column="vol_label_id" property="volLabelId" jdbcType="BIGINT" />
<result column="ver_label_id" property="verLabelId" jdbcType="BIGINT" />
</resultMap>
<resultMap id="DtoResultMap4Book" type="com.pcloud.book.rightsSetting.dto.RightsSettingDto" extends="DtoResultMap">
......@@ -58,13 +60,13 @@
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,
reading_guide,guide_title,guide_type,guide_id,guide_pic
reading_guide,guide_title,guide_type,guide_id,guide_pic,ver_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,r.vol_label_id
,r.online_course_open,r.learning_tool_open,r.draw_open,r.read_type_title,r.vol_label_id,r.ver_label_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
......@@ -83,13 +85,13 @@
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,
reading_guide,guide_title,guide_type,guide_id,guide_pic)
reading_guide,guide_title,guide_type,guide_id,guide_pic,ver_label_id)
values ( #{introduce,jdbcType=VARCHAR}, #{detail,jdbcType=VARCHAR},
#{count,jdbcType=INTEGER}, #{firstClassify,jdbcType=BIGINT}, #{secondClassify,jdbcType=BIGINT},
#{gradeLabelId,jdbcType=BIGINT}, #{subjectLabelId,jdbcType=BIGINT}, now(),
#{updateTime,jdbcType=TIMESTAMP}, #{enableGroupService}, #{rightsSettingType}, #{bookId},
#{onlineCourseOpen},#{learningToolOpen},#{drawNowOpen},#{readTypeTitle}, #{volLabelId},
#{guideIsOpen},#{guideTitle},#{guideType},#{guideId},#{guidePic})
#{guideIsOpen},#{guideTitle},#{guideType},#{guideId},#{guidePic}, #{verLabelId})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsSetting" >
update rights_setting
......@@ -155,7 +157,10 @@
guide_id = #{guideId,jdbcType=BIGINT},
</if>
<if test="guidePic != null" >
guide_pic = #{guidePic,jdbcType=VARCHAR}
guide_pic = #{guidePic,jdbcType=VARCHAR},
</if>
<if test="verLabelId != null" >
ver_label_id = #{verLabelId,jdbcType=BIGINT}
</if>
</set>
where id = #{id,jdbcType=BIGINT}
......@@ -181,7 +186,8 @@
guide_title = #{guideTitle,jdbcType=VARCHAR},
guide_type = #{guideType,jdbcType=VARCHAR},
guide_id = #{guideId,jdbcType=BIGINT},
guide_pic = #{guidePic,jdbcType=VARCHAR}
guide_pic = #{guidePic,jdbcType=VARCHAR},
ver_label_id = #{verLabelId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
......@@ -219,6 +225,9 @@
<if test="volLabelId != null" >
and vol_label_id = #{volLabelId}
</if>
<if test="verLabelId != null" >
and r.ver_label_id = #{verLabelId,jdbcType=BIGINT}
</if>
</where>
order by r.create_time desc
</select>
......@@ -226,7 +235,8 @@
<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
r.create_time, r.update_time, r.enable_group_service, r.rights_setting_type, r.book_id, b.BOOK_NAME, r.vol_label_id,
r.ver_label_id
from
rights_setting r
left join rights_setting_book_relation s on r.id = s.rights_setting_id
......@@ -262,6 +272,9 @@
<if test="volLabelId != null" >
and vol_label_id = #{volLabelId}
</if>
<if test="verLabelId != null" >
and ver_label_id = #{verLabelId,jdbcType=BIGINT}
</if>
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