Commit 70ce8361 by 吴博

1002825 小程序配置读书计划

parent 8e45e3a6
...@@ -428,6 +428,11 @@ public class BookBizImpl implements BookBiz { ...@@ -428,6 +428,11 @@ public class BookBizImpl implements BookBiz {
BookDto bookDto = bookCache.getBookToRedis(bookId); BookDto bookDto = bookCache.getBookToRedis(bookId);
if (null == bookDto) { if (null == bookDto) {
bookDto = bookDao.getBaseById(bookId); bookDto = bookDao.getBaseById(bookId);
BookAdviserDto bookAdviserDto = bookAdviserBiz.getOneMainBook(bookId);
if (null != bookDto && null != bookAdviserDto){
bookDto.setTempletId(bookAdviserDto.getTempletId());
bookSet.setFirstTemplateName(bookDto);
}
// 将数据存入redis // 将数据存入redis
bookCache.setBookToRedis(bookDto); bookCache.setBookToRedis(bookDto);
} }
......
...@@ -1742,4 +1742,25 @@ public class BookSet { ...@@ -1742,4 +1742,25 @@ public class BookSet {
} }
} }
public void setFirstTemplateName(BookDto bookDto) {
LOGGER.info("设置一级模板名称【START】");
if (bookDto == null || bookDto.getTempletId() == null) {
return;
}
List<Long> templetIds = new ArrayList<>();
if (Objects.nonNull(bookDto.getTempletId())) {
templetIds.add(bookDto.getTempletId());
}
Map<Long, AssistTempletDTO> assistTempletMap = assistTempletConsr.mapByIds4Classify(templetIds);
if (MapUtils.isEmpty(assistTempletMap)) {
return;
}
if (Objects.nonNull(bookDto.getTempletId())) {
setBookDtoTempletInfo(assistTempletMap, bookDto, bookDto.getTempletId());
}
LOGGER.info("设置模板名称【END】");
}
} }
...@@ -50,4 +50,6 @@ public interface CustomPlanBiz { ...@@ -50,4 +50,6 @@ public interface CustomPlanBiz {
UserBookServiceVO getUserBookServiceById(Long userBookServiceId); UserBookServiceVO getUserBookServiceById(Long userBookServiceId);
List<PlanReadTypeDto> getPlanReadTypesByBookId(Long bookId); List<PlanReadTypeDto> getPlanReadTypesByBookId(Long bookId);
List<CustomPlan> listByCustomPlanIds(List<Long> customPlanIds);
} }
...@@ -536,4 +536,10 @@ public class CustomPlanBizImpl implements CustomPlanBiz { ...@@ -536,4 +536,10 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
List<PlanReadTypeDto> list=customPlanMapper.getPlanReadTypesByBookId(bookId); List<PlanReadTypeDto> list=customPlanMapper.getPlanReadTypesByBookId(bookId);
return list; return list;
} }
@Override
@ParamLog(value = "批量获取定制服务",isAfterReturn = false)
public List<CustomPlan> listByCustomPlanIds(List<Long> customPlanIds) {
return customPlanMapper.getCustomPlanByIds(customPlanIds);
}
} }
...@@ -39,4 +39,6 @@ public interface CustomPlanMapper { ...@@ -39,4 +39,6 @@ public interface CustomPlanMapper {
CustomPlan getLastCustomPlan(@Param("bookIds") List<Long> bookIds,@Param("readType") Integer readType); CustomPlan getLastCustomPlan(@Param("bookIds") List<Long> bookIds,@Param("readType") Integer readType);
CustomPlan getLastCustomPlanByBookIds(@Param("bookIds") List<Long> bookIds); CustomPlan getLastCustomPlanByBookIds(@Param("bookIds") List<Long> bookIds);
List<CustomPlan> getCustomPlanByIds(@Param("customPlanIds") List<Long> customPlanIds);
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.biz.impl; ...@@ -3,6 +3,7 @@ package com.pcloud.book.rightsSetting.biz.impl;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.appcenter.app.dto.AppDto; import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO; import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletNewsBiz; import com.pcloud.book.applet.biz.AppletNewsBiz;
...@@ -20,6 +21,9 @@ import com.pcloud.book.consumer.app.AppConsr; ...@@ -20,6 +21,9 @@ import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.app.AssistTempletConsr; import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr; import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.resource.ProductConsr; import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.custom.biz.CustomPlanBiz;
import com.pcloud.book.custom.entity.CustomPlan;
import com.pcloud.book.custom.mapper.CustomPlanMapper;
import com.pcloud.book.giftcoupon.dao.GiftReceiveDao; import com.pcloud.book.giftcoupon.dao.GiftReceiveDao;
import com.pcloud.book.group.biz.BookGroupBiz; import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.book.group.dto.BookServeDTO; import com.pcloud.book.group.dto.BookServeDTO;
...@@ -29,14 +33,18 @@ import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; ...@@ -29,14 +33,18 @@ import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.check.RightsSettingCheck; import com.pcloud.book.rightsSetting.check.RightsSettingCheck;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant; import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.dao.RightsItemGroupDao; import com.pcloud.book.rightsSetting.dao.RightsItemGroupDao;
import com.pcloud.book.rightsSetting.dao.RightsCustomRelationDao;
import com.pcloud.book.rightsSetting.dao.RightsNowItemDao; import com.pcloud.book.rightsSetting.dao.RightsNowItemDao;
import com.pcloud.book.rightsSetting.dao.RightsReadPlanDao;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO; import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao; import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO; import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto; import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify; import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsItemGroup; import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsCustomRelation;
import com.pcloud.book.rightsSetting.entity.RightsNowItem; import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsReadPlan;
import com.pcloud.book.rightsSetting.entity.RightsSetting; import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify; import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem; import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
...@@ -46,6 +54,7 @@ import com.pcloud.book.rightsSetting.enums.RightsNowItemType; ...@@ -46,6 +54,7 @@ import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum; import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper; import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.util.common.CommonUtils; import com.pcloud.book.util.common.CommonUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO; import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.vo.BookServeVO; import com.pcloud.channelcenter.wechat.vo.BookServeVO;
...@@ -56,13 +65,21 @@ import com.pcloud.common.utils.ListUtils; ...@@ -56,13 +65,21 @@ import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils; import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.resourcecenter.product.dto.ProductDto; import com.pcloud.resourcecenter.product.dto.ProductDto;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import io.swagger.annotations.ApiModelProperty;
import java.sql.SQLException;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -94,6 +111,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -94,6 +111,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Autowired @Autowired
private RightsNowItemDao rightsNowItemDao; private RightsNowItemDao rightsNowItemDao;
@Autowired @Autowired
private RightsReadPlanDao rightsReadPlanDao;
@Autowired
private RightsCustomRelationDao rightsCustomRelationDao;
@Autowired
private RightsSettingItemDao rightsSettingItemDao; private RightsSettingItemDao rightsSettingItemDao;
@Autowired @Autowired
private BookAdviserBiz bookAdviserBiz; private BookAdviserBiz bookAdviserBiz;
...@@ -117,6 +138,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -117,6 +138,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private RightsItemGroupDao rightsItemGroupDao; private RightsItemGroupDao rightsItemGroupDao;
@Autowired @Autowired
private BookGroupBiz bookGroupBiz; private BookGroupBiz bookGroupBiz;
private CustomPlanMapper customPlanMapper;
@Autowired
private CustomPlanBiz customPlanBiz;
@Override @Override
@ParamLog("新增权益设置") @ParamLog("新增权益设置")
...@@ -184,6 +209,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -184,6 +209,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override @Override
@ParamLog("更新权益设置") @ParamLog("更新权益设置")
@Transactional(rollbackFor= Exception.class)
public void updateRightsSetting(RightsSetting rightsSetting) { public void updateRightsSetting(RightsSetting rightsSetting) {
rightsSettingCheck.rightsSettingCheck(rightsSetting); rightsSettingCheck.rightsSettingCheck(rightsSetting);
if (null == rightsSetting.getId()) { if (null == rightsSetting.getId()) {
...@@ -199,6 +225,48 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -199,6 +225,48 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
updateRightNowItemByRightId(rightsSetting); updateRightNowItemByRightId(rightsSetting);
//新增/修改每周或长期权益 //新增/修改每周或长期权益
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingWeekItems(), rightsSetting.getId(), RightsTypeEnum.WEEK.value); this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingWeekItems(), rightsSetting.getId(), RightsTypeEnum.WEEK.value);
if (!ListUtils.isEmpty(rightsSetting.getRightsSettingWeekItems())){
for (RightsSettingItem rightsSettingItem : rightsSetting.getRightsSettingWeekItems()) {
rightsSettingItem.setUuid(StringUtil.getUUID());
}
}
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingWeekItems(), rightsSetting.getId(), RightsTypeEnum.WEEK.value);
//根据rightsSetting.getId(),RightsTypeEnum.WEEK.value 查询rightSettingItem
RightsSettingItem rightsSettingItem = new RightsSettingItem();
rightsSettingItem.setRightsSettingId(rightsSetting.getId());
rightsSettingItem.setRightsType(RightsTypeEnum.WEEK.value);
List<RightsSettingItem> list = rightsSettingItemDao.queryAll(rightsSettingItem);
List<RightsReadPlan> rightsReadPlans = new ArrayList<>();
List<RightsCustomRelation> rightsCustomRelations = new ArrayList<>();
if (!ListUtils.isEmpty(list)) {
HashMap<String, RightsSettingItem> map = Maps.newHashMap();
for (RightsSettingItem item : list) {
map.put(item.getUuid(), item);
}
for (RightsSettingItem itemVO : rightsSetting.getRightsSettingWeekItems()) {
RightsSettingItem vo = map.get(itemVO.getUuid());
if (Objects.isNull(vo) || !RightsNowItemType.ONLINE_REMIND.value.equals(vo.getRightsClassifyId().intValue())) {
continue;
}
RightsReadPlan rightsReadPlan = new RightsReadPlan();
rightsReadPlan.setRightsSettingItemId(vo.getId());
rightsReadPlan.setIsOpen(itemVO.getIsOpen());
rightsReadPlan.setServiceDesc(itemVO.getServiceDesc());
rightsReadPlans.add(rightsReadPlan);
if (ListUtils.isEmpty(itemVO.getCustomPlanList())){
continue;
}
for (CustomPlan plan : itemVO.getCustomPlanList()) {
RightsCustomRelation rightsCustomRelation = new RightsCustomRelation();
rightsCustomRelation.setCustomPlanId(Long.valueOf(plan.getId()));
rightsCustomRelation.setRightsSettingItemId(vo.getId());
rightsCustomRelations.add(rightsCustomRelation);
}
}
}
//批量插入rightsReadPlans和rightsCustomRelations
rightsReadPlanDao.insert(rightsReadPlans);
rightsCustomRelationDao.insert(rightsCustomRelations);
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingLongTermItems(), rightsSetting.getId(), RightsTypeEnum.LONG_TERM.value); this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingLongTermItems(), rightsSetting.getId(), RightsTypeEnum.LONG_TERM.value);
} }
...@@ -360,7 +428,48 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -360,7 +428,48 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
fillRightsNowItems(rightsSetting); fillRightsNowItems(rightsSetting);
rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(),null,null,null, false)); rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(),null,null,null, false));
fillGiftCouponPack(rightsSetting); fillGiftCouponPack(rightsSetting);
rightsSetting.setRightsSettingWeekItems(getItemsByRightsSettingId(id, RightsTypeEnum.WEEK.value)); List<RightsSettingItem> rightsItems = rightsSettingItemDao.getItemsByRightsSettingId4Read(id, RightsTypeEnum.WEEK.value);
List<Long> itemIdList = new ArrayList<>();
for (RightsSettingItem item : rightsItems) {
itemIdList.add(item.getId());
}
//获取集合对应的rightsCustomRelation
List<Long> customPlanIds = new ArrayList<>();
if (!ListUtils.isEmpty(itemIdList)) {
List<RightsCustomRelation> rightsCustomRelations = rightsCustomRelationDao.getCustomByItemIds(itemIdList);
for (RightsSettingItem item : rightsItems) {
List<CustomPlan> list = new ArrayList<>();
for (RightsCustomRelation rightsCustomRelation : rightsCustomRelations) {
if (item.getId().equals(rightsCustomRelation.getRightsSettingItemId())) {
CustomPlan customPlan = new CustomPlan();
customPlan.setId(Integer.valueOf(rightsCustomRelation.getCustomPlanId().toString()));
list.add(customPlan);
customPlanIds.add(rightsCustomRelation.getCustomPlanId());
}
}
item.setCustomPlanList(list);
}
}
List<CustomPlan> customPlanList = new ArrayList<>();
if (!ListUtils.isEmpty(customPlanIds)) {
customPlanList = customPlanMapper.getCustomPlanByIds(customPlanIds);
}
if (ListUtils.isEmpty(customPlanList)) {
Map<Integer, CustomPlan> appleMap = Optional
.ofNullable(customPlanList.stream().collect(Collectors.toMap(CustomPlan::getId, a -> a, (k1, k2) -> k1)))
.orElse(new HashMap<>());
for (RightsSettingItem item : rightsItems) {
List<CustomPlan> customPlanList1 = item.getCustomPlanList();
List<CustomPlan> customPlanList2 = new ArrayList<>();
for (CustomPlan customPlan : customPlanList1) {
CustomPlan customPlan1 = appleMap.get(customPlan.getId());
customPlanList2.add(customPlan1);
}
item.setCustomPlanList(customPlanList2);
}
}
rightsSetting.setRightsSettingWeekItems(rightsItems);
rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id, RightsTypeEnum.LONG_TERM.value)); rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id, RightsTypeEnum.LONG_TERM.value));
return rightsSetting; return rightsSetting;
} }
...@@ -805,6 +914,51 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -805,6 +914,51 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (ListUtils.isEmpty(list)) { if (ListUtils.isEmpty(list)) {
return new ArrayList<>(); return new ArrayList<>();
} }
//先获取阅读计划,若阅读计划为空则推资讯
List<Long> rightsSettingItemIds =
list.stream().filter(e -> YesOrNoEnums.YES.getValue().equals(e.getIsOpen())).map(e -> e.getId()).collect(Collectors.toList());
if (!ListUtils.isEmpty(rightsSettingItemIds)) {
List<RightsCustomRelation> rightsCustomRelations = rightsCustomRelationDao.getCustomByItemIds(rightsSettingItemIds);
list = setReadPlan4Week(rightsCustomRelations, list);
} else {
list = setAppletNews4Week(rightsSettingId, rightsType, wechatUserId, list);
}
return list;
}
private List<RightsSettingItem> setReadPlan4Week(List<RightsCustomRelation> rightsCustomRelations, List<RightsSettingItem> list) {
log.info("为每周权益设置读书计划");
if (ListUtils.isEmpty(list) || ListUtils.isEmpty(rightsCustomRelations)) {
return list;
}
List<Long> customPlanIds = rightsCustomRelations.stream().map(e -> e.getCustomPlanId()).collect(Collectors.toList());
if (ListUtils.isEmpty(customPlanIds)) {
return list;
}
Map<Long, List<RightsCustomRelation>> rightsCustomRelationMap =
rightsCustomRelations.stream().collect(Collectors.groupingBy(RightsCustomRelation::getRightsSettingItemId));
List<CustomPlan> customPlans = customPlanMapper.getCustomPlanByIds(customPlanIds);
if (ListUtils.isEmpty(customPlans)) {
return list;
}
Map<Integer, CustomPlan> customPlanMap = customPlans.stream().collect(Collectors.toMap(CustomPlan::getId, a -> a, (k1, k2) -> k1));
for (RightsSettingItem item : list) {
List<CustomPlan> customPlans4ReadPlan = new ArrayList<>();
List<RightsCustomRelation> customRelations = rightsCustomRelationMap.get(item.getId());
if (ListUtils.isEmpty(customRelations)) {
continue;
}
for (RightsCustomRelation rightsCustomRelation : customRelations) {
if (customPlanMap.containsKey(rightsCustomRelation.getCustomPlanId().intValue())) {
customPlans4ReadPlan.add(customPlanMap.get(rightsCustomRelation.getCustomPlanId().intValue()));
}
}
item.setCustomPlanList(customPlans4ReadPlan);
}
return list;
}
private List<RightsSettingItem> setAppletNews4Week(Long rightsSettingId, String rightsType, Long wechatUserId, List<RightsSettingItem> list) {
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId); RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取 if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId()); BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId());
......
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.rightsSetting.entity.RightsCustomRelation;
import com.pcloud.book.rightsSetting.entity.RightsReadPlan;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @Description
* @Author zengpo
* @Date 2020/4/27 17:44
**/
public interface RightsCustomRelationDao extends BaseDao<RightsCustomRelation> {
List<RightsCustomRelation> getCustomByItemIds(List<Long> itemIdList);
}
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.rightsSetting.entity.RightsReadPlan;
import com.pcloud.common.core.dao.BaseDao;
/**
* @Description
* @Author zengpo
* @Date 2020/4/27 17:44
**/
public interface RightsReadPlanDao extends BaseDao<RightsReadPlan> {
}
...@@ -39,4 +39,7 @@ public interface RightsSettingItemDao extends BaseDao<RightsSettingItem>{ ...@@ -39,4 +39,7 @@ public interface RightsSettingItemDao extends BaseDao<RightsSettingItem>{
*/ */
List<RightsSettingClassify>getAllRightsClassify(String rightsType); List<RightsSettingClassify>getAllRightsClassify(String rightsType);
List<RightsSettingItem> getItemByRightsIdAndType(Long rightsSettingId, String rightsType);
List<RightsSettingItem> getItemsByRightsSettingId4Read(Long rightsSettingId, String rightsType);
} }
\ No newline at end of file
package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.rightsSetting.dao.RightsCustomRelationDao;
import com.pcloud.book.rightsSetting.dao.RightsReadPlanDao;
import com.pcloud.book.rightsSetting.entity.RightsCustomRelation;
import com.pcloud.book.rightsSetting.entity.RightsReadPlan;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Description
* @Author zengpo
* @Date 2020/4/27 17:44
**/
@Component("rightsCustomRelationDao")
public class RightsCustomRelationDaoImpl extends BaseDaoImpl<RightsCustomRelation> implements RightsCustomRelationDao {
@Override
public List<RightsCustomRelation> getCustomByItemIds(List<Long> itemIdList) {
return getSqlSession().selectList(getStatement("getCustomByItemIds"),itemIdList);
}
}
package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.rightsSetting.dao.RightsReadPlanDao;
import com.pcloud.book.rightsSetting.entity.RightsReadPlan;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
/**
* @Description
* @Author zengpo
* @Date 2020/4/27 17:44
**/
@Component("rightsReadPlanDao")
public class RightsReadPlanDaoImpl extends BaseDaoImpl<RightsReadPlan> implements RightsReadPlanDao {
}
...@@ -38,4 +38,20 @@ public class RightsSettingItemDaoImpl extends BaseDaoImpl<RightsSettingItem> imp ...@@ -38,4 +38,20 @@ public class RightsSettingItemDaoImpl extends BaseDaoImpl<RightsSettingItem> imp
map.put("rightsType",rightsType); map.put("rightsType",rightsType);
return getSessionTemplate().selectList(getStatement("getAllRightsClassify"), map); return getSessionTemplate().selectList(getStatement("getAllRightsClassify"), map);
} }
@Override
public List<RightsSettingItem> getItemByRightsIdAndType(Long rightsSettingId, String rightsType) {
Map<String,Object> map = new HashMap<>();
map.put("rightsSettingId",rightsSettingId);
map.put("rightsType",rightsType);
return getSessionTemplate().selectList(getStatement("getItemByRightsIdAndType"), map);
}
@Override
public List<RightsSettingItem> getItemsByRightsSettingId4Read(Long rightsSettingId, String rightsType) {
Map<String,Object> map = new HashMap<>();
map.put("rightsSettingId",rightsSettingId);
map.put("rightsType",rightsType);
return getSessionTemplate().selectList(getStatement("getItemsByRightsSettingId4Read"), map);
}
} }
package com.pcloud.book.rightsSetting.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Description
* @Author zengpo
* @Date 2020/4/27 17:41
**/
@Data
public class RightsCustomRelation extends BaseEntity {
@ApiModelProperty("定制服务方案id")
private Long customPlanId;
@ApiModelProperty("权益内容id")
private Long rightsSettingItemId;
}
package com.pcloud.book.rightsSetting.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Description
* @Author zengpo
* @Date 2020/4/27 17:41
**/
@Data
public class RightsReadPlan extends BaseEntity {
@ApiModelProperty("主键")
private Long id;
@ApiModelProperty("权益内容id")
private Long rightsSettingItemId;
@ApiModelProperty("本书阅读计划开关 0关闭 1开启")
private Integer isOpen;
@ApiModelProperty("服务说明")
private String serviceDesc;
}
...@@ -2,12 +2,14 @@ package com.pcloud.book.rightsSetting.entity; ...@@ -2,12 +2,14 @@ package com.pcloud.book.rightsSetting.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.book.applet.dto.AppletNewsDTO; import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.custom.entity.CustomPlan;
import com.pcloud.common.entity.BaseEntity; import com.pcloud.common.entity.BaseEntity;
import java.util.Date; import java.util.Date;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
/** /**
...@@ -54,4 +56,17 @@ public class RightsSettingItem extends BaseEntity { ...@@ -54,4 +56,17 @@ public class RightsSettingItem extends BaseEntity {
* 资讯 * 资讯
*/ */
private List<AppletNewsDTO> appletNewsDTOS; private List<AppletNewsDTO> appletNewsDTOS;
@ApiModelProperty("本书阅读计划开关 0关闭 1开启")
private Integer isOpen;
@ApiModelProperty("服务说明")
private String serviceDesc;
@ApiModelProperty("定制服务方案集合")
private List<CustomPlan> customPlanList;
@ApiModelProperty("唯一键")
private String uuid;
} }
\ No newline at end of file
...@@ -27,11 +27,13 @@ public enum RightsNowItemType { ...@@ -27,11 +27,13 @@ public enum RightsNowItemType {
/** /**
* 6 配套资料 * 6 配套资料
*/ */
SERVES(6); SERVES(6),
/** /**
* * 7线上学习/阅读提醒
*/ */
ONLINE_REMIND(7);
public final Integer value; public final Integer value;
RightsNowItemType(Integer value) { RightsNowItemType(Integer value) {
......
...@@ -261,4 +261,14 @@ ...@@ -261,4 +261,14 @@
ORDER BY id DESC ORDER BY id DESC
LIMIT 1 LIMIT 1
</select> </select>
<select id="getCustomPlanByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from custom_plan
where id IN
<foreach collection="customPlanIds" item="item" separator="," open="(" close=")">
${item}
</foreach>
ORDER BY id DESC
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.rightsSetting.dao.impl.RightsCustomRelationDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsCustomRelation">
<result property="rightsSettingItemId" column="rights_setting_item_id" jdbcType="BIGINT"/>
<result property="customPlanId" column="custom_plan_id" jdbcType="BIGINT"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
rights_setting_item_id, custom_plan_id, create_time, update_time
</sql>
<!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into book.rights_custom_relation (
rights_setting_item_id, custom_plan_id, create_time, update_time
)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.rightsSettingItemId},
#{item.customPlanId},
NOW(),
NOW()
)
</foreach>
</insert>
<select id="getCustomByItemIds" parameterType="java.util.List" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from rights_custom_relation where 1=1 and
rights_setting_item_id IN
<foreach collection="list" item="item" separator="," open="(" close=")">
${item}
</foreach>
</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" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.rightsSetting.dao.impl.RightsReadPlanDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsReadPlan">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="rightsSettingItemId" column="rights_setting_item_id" jdbcType="BIGINT"/>
<result property="isOpen" column="is_open" jdbcType="INTEGER"/>
<result property="serviceDesc" column="service_desc" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, rights_setting_item_id, is_open, service_desc, create_time, update_time
</sql>
<!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into book.rights_read_plan (
rights_setting_item_id, is_open, service_desc, create_time, update_time
)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.rightsSettingItemId},
#{item.isOpen},
#{item.serviceDesc},
NOW(),
NOW()
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<result property="description" column="description" jdbcType="VARCHAR"/> <result property="description" column="description" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="title" column="title" jdbcType="VARCHAR"/> <result property="title" column="title" jdbcType="VARCHAR"/>
<result property="uuid" column="uuid" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<!--通过实体作为筛选条件查询--> <!--通过实体作为筛选条件查询-->
...@@ -17,8 +18,9 @@ ...@@ -17,8 +18,9 @@
select select
i.id, i.rights_setting_id rightsSettingId, i.id, i.rights_setting_id rightsSettingId,
i.rights_type rightsType, i.rights_classify_id rightsClassifyId, i.rights_type rightsType, i.rights_classify_id rightsClassifyId,
i.description, i.create_time createTime, i.title i.description, i.create_time createTime, i.title,i.uuid,IFNULL(p.is_open,0) isOpen,p.service_desc serviceDesc
from book.rights_setting_item i from book.rights_setting_item i
left join book.rights_read_plan p on i.id=p.rights_setting_item_id
<where> <where>
<if test="id != null"> <if test="id != null">
and i.id = #{id} and i.id = #{id}
...@@ -38,8 +40,8 @@ ...@@ -38,8 +40,8 @@
<!--新增所有列--> <!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true"> <insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.rights_setting_item(rights_setting_id, rights_type, rights_classify_id, description, create_time,title) insert into book.rights_setting_item(rights_setting_id, rights_type, rights_classify_id, description, create_time,title,uuid)
values (#{rightsSettingId}, #{rightsType}, #{rightsClassifyId}, #{description}, NOW(), #{title}) values (#{rightsSettingId}, #{rightsType}, #{rightsClassifyId}, #{description}, NOW(), #{title},#{uuid})
</insert> </insert>
<!--通过权益主键删除--> <!--通过权益主键删除-->
...@@ -54,7 +56,7 @@ ...@@ -54,7 +56,7 @@
<!--批量新增--> <!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List"> <insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into book.rights_setting_item ( insert into book.rights_setting_item (
rights_setting_id, rights_type, rights_classify_id, description, create_time,title rights_setting_id, rights_type, rights_classify_id, description, create_time,title,uuid
) )
values values
<foreach collection="list" item="item" index="index" separator="," > <foreach collection="list" item="item" index="index" separator="," >
...@@ -64,7 +66,8 @@ ...@@ -64,7 +66,8 @@
#{item.rightsClassifyId,jdbcType=VARCHAR}, #{item.rightsClassifyId,jdbcType=VARCHAR},
#{item.description,jdbcType=VARCHAR}, #{item.description,jdbcType=VARCHAR},
NOW(), NOW(),
#{item.title} #{item.title},
#{item.uuid}
) )
</foreach> </foreach>
</insert> </insert>
...@@ -78,4 +81,22 @@ ...@@ -78,4 +81,22 @@
</if> </if>
</select> </select>
<select id="getItemsByRightsSettingId4Read" parameterType="map" resultType="com.pcloud.book.rightsSetting.entity.RightsSettingItem">
select
i.id, i.rights_setting_id rightsSettingId,
i.rights_type rightsType, i.rights_classify_id rightsClassifyId,
i.description, i.create_time createTime, i.title,i.uuid,IFNULL(p.is_open,0) isOpen,p.service_desc serviceDesc
from book.rights_setting_item i
left join book.rights_read_plan p on i.id=p.rights_setting_item_id
<where>
<if test="rightsSettingId != null">
and i.rights_setting_id = #{rightsSettingId}
</if>
<if test="rightsType != null and rightsType != ''">
and i.rights_type = #{rightsType}
</if>
</where>
order by i.id asc
</select>
</mapper> </mapper>
\ No newline at end of file
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