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 { ...@@ -652,4 +652,6 @@ public interface BookBiz {
void updateIsOpenRobotProcess(Long adviserId, UpdateBookRobotProcessDto robotProcessDto); void updateIsOpenRobotProcess(Long adviserId, UpdateBookRobotProcessDto robotProcessDto);
void updateIsOpenRobotProcess4Now(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; ...@@ -56,6 +56,7 @@ import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.entity.BookAppletScene; import com.pcloud.book.group.entity.BookAppletScene;
import com.pcloud.book.group.enums.JoinGroupTypeEnum; import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.mq.producer.BookMQProducer; import com.pcloud.book.mq.producer.BookMQProducer;
import com.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper;
import com.pcloud.book.util.common.ThreadPoolUtils; import com.pcloud.book.util.common.ThreadPoolUtils;
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;
...@@ -170,12 +171,8 @@ public class BookBizImpl implements BookBiz { ...@@ -170,12 +171,8 @@ public class BookBizImpl implements BookBiz {
@Autowired @Autowired
private WechatConsr wechatConsr; private WechatConsr wechatConsr;
@Autowired
private RightsSettingBookRelationMapper rightsSettingBookRelationMapper;
/** /**
...@@ -2258,6 +2255,38 @@ public class BookBizImpl implements BookBiz { ...@@ -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){ public void createBookGroupAppletUrl(Long bookId, Long channelId, Long adviserId,List<Long> sceneIds){
BookAdviserDto bookAdviserDto = bookAdviserDao.getBase(bookId,channelId,adviserId); BookAdviserDto bookAdviserDto = bookAdviserDao.getBase(bookId,channelId,adviserId);
Long raysClassifyId = bookRaysClassifyDao.getClassifyIdByBookTemplateId(bookAdviserDto.getTempletId()); Long raysClassifyId = bookRaysClassifyDao.getClassifyIdByBookTemplateId(bookAdviserDto.getTempletId());
......
...@@ -1051,4 +1051,22 @@ public class BookFacadeImpl implements BookFacade { ...@@ -1051,4 +1051,22 @@ public class BookFacadeImpl implements BookFacade {
return new ResponseDto<>(); 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
...@@ -58,6 +58,7 @@ import com.pcloud.book.rightsSetting.entity.RightsNowPic; ...@@ -58,6 +58,7 @@ import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsReadPlan; import com.pcloud.book.rightsSetting.entity.RightsReadPlan;
import com.pcloud.book.rightsSetting.entity.RightsReadType; import com.pcloud.book.rightsSetting.entity.RightsReadType;
import com.pcloud.book.rightsSetting.entity.RightsSetting; import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingBookRelation;
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;
import com.pcloud.book.rightsSetting.entity.RightsSettingItemDetail; import com.pcloud.book.rightsSetting.entity.RightsSettingItemDetail;
...@@ -67,6 +68,7 @@ import com.pcloud.book.rightsSetting.enums.RightsNowItemType; ...@@ -67,6 +68,7 @@ import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.enums.RightsServeTypeEnum; import com.pcloud.book.rightsSetting.enums.RightsServeTypeEnum;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum; import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.rightsSetting.mapper.RightsReadTypeMapper; import com.pcloud.book.rightsSetting.mapper.RightsReadTypeMapper;
import com.pcloud.book.rightsSetting.mapper.RightsSettingBookRelationMapper;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper; import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz; import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao; import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
...@@ -172,6 +174,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -172,6 +174,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private RightsReadTypeMapper rightsReadTypeMapper; private RightsReadTypeMapper rightsReadTypeMapper;
@Autowired @Autowired
private AppletUserBookcaseBiz appletUserBookcaseBiz; private AppletUserBookcaseBiz appletUserBookcaseBiz;
@Autowired
private RightsSettingBookRelationMapper rightsSettingBookRelationMapper;
@Override @Override
@ParamLog("新增权益设置") @ParamLog("新增权益设置")
...@@ -192,6 +196,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -192,6 +196,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsReadTypes.forEach(e -> e.setRightsSettingId(rightsSettingId)); rightsReadTypes.forEach(e -> e.setRightsSettingId(rightsSettingId));
rightsReadTypeMapper.batchInsert(rightsReadTypes); rightsReadTypeMapper.batchInsert(rightsReadTypes);
} }
//新增关联书刊
List<RightsSettingBookRelation> rightsSettingBookRelations = rightsSetting.getRightsSettingBookRelations();
if (ListUtils.isEmpty(rightsSettingBookRelations)){
return rightsSettingId;
}
rightsSettingBookRelations.forEach(e -> e.setRightsSettingId(rightsSettingId));
rightsSettingBookRelationMapper.batchInsert(rightsSettingBookRelations);
return rightsSetting.getId(); return rightsSetting.getId();
} }
...@@ -225,7 +236,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -225,7 +236,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
paramMap.put("rightsSettingType", rightsSetting.getRightsSettingType()); paramMap.put("rightsSettingType", rightsSetting.getRightsSettingType());
paramMap.put("exceptId", rightsSetting.getId()); paramMap.put("exceptId", rightsSetting.getId());
if (rightsSetting.getRightsSettingType() == 2) { if (rightsSetting.getRightsSettingType() == 2) {
paramMap.put("bookId", rightsSetting.getBookId()); List<Long> bookIds = new ArrayList<>();
if (!ListUtils.isEmpty(rightsSetting.getRightsSettingBookRelations())){
bookIds = rightsSetting.getRightsSettingBookRelations().stream().map(e -> e.getBookId()).collect(Collectors.toList());
}
if (!ListUtils.isEmpty(bookIds)){
paramMap.put("bookIds", bookIds);
}
} else if (rightsSetting.getRightsSettingType() == 1) { } else if (rightsSetting.getRightsSettingType() == 1) {
setClassifyAndLabel(rightsSetting); setClassifyAndLabel(rightsSetting);
paramMap.put("firstClassify", rightsSetting.getFirstClassify()); paramMap.put("firstClassify", rightsSetting.getFirstClassify());
...@@ -249,6 +266,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -249,6 +266,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsNowItemDao.deleteByRightsSettingId(id); rightsNowItemDao.deleteByRightsSettingId(id);
rightsSettingItemDao.deleteByRightsSettingId(id, null); rightsSettingItemDao.deleteByRightsSettingId(id, null);
rightsItemGroupDao.deleteByRightsSettingId(id); rightsItemGroupDao.deleteByRightsSettingId(id);
rightsSettingBookRelationMapper.deleteByRightsSettingId(id);
} }
@Override @Override
...@@ -273,12 +291,23 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -273,12 +291,23 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsReadTypes.forEach(e -> e.setRightsSettingId(rightsSettingId)); rightsReadTypes.forEach(e -> e.setRightsSettingId(rightsSettingId));
rightsReadTypeMapper.batchInsert(rightsReadTypes); rightsReadTypeMapper.batchInsert(rightsReadTypes);
} }
//更新关联书刊
updateRelationBook(rightsSetting, rightsSettingId);
//更新即享权益 //更新即享权益
updateRightNowItemByRightId(rightsSetting); updateRightNowItemByRightId(rightsSetting);
// 更新每周、长期权益 // 更新每周、长期权益
updateRightsWeekOrLongTerm(rightsSetting); updateRightsWeekOrLongTerm(rightsSetting);
} }
private void updateRelationBook(RightsSetting rightsSetting, Long rightsSettingId) {
rightsSettingBookRelationMapper.deleteByRightsSettingId(rightsSettingId);
List<RightsSettingBookRelation> rightsSettingBookRelations = rightsSetting.getRightsSettingBookRelations();
if (!ListUtils.isEmpty(rightsSettingBookRelations)){
rightsSettingBookRelations.forEach(e -> e.setRightsSettingId(rightsSettingId));
rightsSettingBookRelationMapper.batchInsert(rightsSettingBookRelations);
}
}
private void updateRightsWeekOrLongTerm(RightsSetting rightsSetting) { private void updateRightsWeekOrLongTerm(RightsSetting rightsSetting) {
// 设置uuid,批量更新使用 // 设置uuid,批量更新使用
setRightsSettingItemUuid(rightsSetting); setRightsSettingItemUuid(rightsSetting);
...@@ -561,10 +590,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -561,10 +590,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
if (null == rightsSetting) { if (null == rightsSetting) {
return new RightsSetting(); return new RightsSetting();
} }
if (rightsSetting.getRightsSettingType() == 2 && null != rightsSetting.getBookId()) { //书刊分类关联书刊
BookDto bookDto = bookBiz.getBaseById(rightsSetting.getBookId()); fillBookName(id, rightsSetting);
rightsSetting.setBookName(bookDto == null ? "" : bookDto.getBookName());
}
fillRightsNowItems(rightsSetting); fillRightsNowItems(rightsSetting);
rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(),null,null,null, false, null)); rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(),null,null,null, false, null));
fillGiftCouponPack(rightsSetting,null); fillGiftCouponPack(rightsSetting,null);
...@@ -574,6 +601,28 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -574,6 +601,28 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
return rightsSetting; return rightsSetting;
} }
private void fillBookName(Long id, RightsSetting rightsSetting) {
if (rightsSetting.getRightsSettingType() != 2) {
return;
}
List<RightsSettingBookRelation> rightsSettingBookRelations = rightsSettingBookRelationMapper.selectByRithsSettingId(id);
if (ListUtils.isEmpty(rightsSettingBookRelations)) {
return;
}
List<Long> bookIds = rightsSettingBookRelations.stream().map(e -> e.getBookId()).collect(Collectors.toList());
Map<Long, BookDto> bookDtoMap = bookBiz.getListByIds(bookIds);
if (MapUtils.isEmpty(bookDtoMap)) {
return;
}
rightsSettingBookRelations.forEach(rightsSettingBookRelation -> {
if (bookDtoMap.containsKey(rightsSettingBookRelation.getBookId()) && null != bookDtoMap
.get(rightsSettingBookRelation.getBookId())) {
rightsSettingBookRelation.setBookName(bookDtoMap.get(rightsSettingBookRelation.getBookId()).getBookName());
}
});
rightsSetting.setRightsSettingBookRelations(rightsSettingBookRelations);
}
private void setReadType(RightsSetting rightsSetting) { private void setReadType(RightsSetting rightsSetting) {
List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSetting.getId()); List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSetting.getId());
rightsSetting.setRightsReadTypes(ListUtils.isEmpty(rightsReadTypes) ? new ArrayList<>() : rightsReadTypes); rightsSetting.setRightsReadTypes(ListUtils.isEmpty(rightsReadTypes) ? new ArrayList<>() : rightsReadTypes);
...@@ -1047,6 +1096,36 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1047,6 +1096,36 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
return rightsSettingDtoPageBeanNew; return rightsSettingDtoPageBeanNew;
} }
private void setRelationBooks(List<RightsSettingDto> rightsSettingDtos) {
List<RightsSettingBookRelation> rightsSettingBookRelations = new ArrayList<>();
rightsSettingDtos.forEach(rightsSettingDto -> {
if(!ListUtils.isEmpty(rightsSettingDto.getRightsSettingBookRelations())){
rightsSettingBookRelations.addAll(rightsSettingDto.getRightsSettingBookRelations());
}
});
if (ListUtils.isEmpty(rightsSettingBookRelations)){
return;
}
List<Long> bookIds = rightsSettingBookRelations.stream().map(e -> e.getBookId()).collect(Collectors.toList());
if (ListUtils.isEmpty(bookIds)){
return;
}
Map<Long, BookDto> bookDtoMap = bookBiz.getListByIds(bookIds);
if (MapUtils.isEmpty(bookDtoMap)){
return;
}
rightsSettingDtos.forEach(rightsSettingDto -> {
if(ListUtils.isEmpty(rightsSettingDto.getRightsSettingBookRelations())){
return;
}
rightsSettingDto.getRightsSettingBookRelations().forEach(rightsSettingBookRelation -> {
if (bookDtoMap.containsKey(rightsSettingBookRelation.getBookId()) && null != bookDtoMap.get(rightsSettingBookRelation.getBookId())){
rightsSettingBookRelation.setBookName(bookDtoMap.get(rightsSettingBookRelation.getBookId()).getBookName());
}
});
});
}
private void setLabelContent(List<RightsSettingDto> rightsSettingDtos) { private void setLabelContent(List<RightsSettingDto> rightsSettingDtos) {
log.info("权益设置标签具体内容"); log.info("权益设置标签具体内容");
...@@ -1172,6 +1251,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1172,6 +1251,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
public RightsSettingDto getRightsSettingByBookId4AppletHome(Long bookId, Long adviserId, Long channelId) { public RightsSettingDto getRightsSettingByBookId4AppletHome(Long bookId, Long adviserId, Long channelId) {
//根据书获取权益 //根据书获取权益
RightsSettingDto rightsSettingDto = rightsSettingDAO.getByBookId(bookId); RightsSettingDto rightsSettingDto = rightsSettingDAO.getByBookId(bookId);
if (null != rightsSettingDto){
rightsSettingDto.setRightsSettingBookRelations(rightsSettingBookRelationMapper.selectByRithsSettingId(rightsSettingDto.getId()));;
}
if (null == rightsSettingDto) { if (null == rightsSettingDto) {
//根据分类获取权益 //根据分类获取权益
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId); BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
...@@ -1331,7 +1413,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1331,7 +1413,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private List<RightsSettingItem> setAppletNews4Week(Long rightsSettingId, String rightsType, Long wechatUserId, List<RightsSettingItem> 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()); List<RightsSettingBookRelation> rightsSettingBookRelations =
rightsSettingBookRelationMapper.selectByRithsSettingId(rightsSettingId);
if (ListUtils.isEmpty(rightsSettingBookRelations)){
return new ArrayList<>();
}
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSettingBookRelations.get(0).getBookId());
rightsSetting.setFirstClassify(adviserDto.getTempletId()); rightsSetting.setFirstClassify(adviserDto.getTempletId());
rightsSetting.setSecondClassify(adviserDto.getSecondTempletId()); rightsSetting.setSecondClassify(adviserDto.getSecondTempletId());
rightsSetting.setGradeLabelId(adviserDto.getGraLabelId()); rightsSetting.setGradeLabelId(adviserDto.getGraLabelId());
...@@ -1474,7 +1561,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1474,7 +1561,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
Long subjectLabelId = rightsSetting.getSubjectLabelId(); Long subjectLabelId = rightsSetting.getSubjectLabelId();
Long volLabelId = rightsSetting.getVolLabelId(); Long volLabelId = rightsSetting.getVolLabelId();
if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取 if (rightsSetting.getRightsSettingType() == 2) {//书刊权益,分类标签从编辑书刊取
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSetting.getBookId()); List<RightsSettingBookRelation> rightsSettingBookRelations =
rightsSettingBookRelationMapper.selectByRithsSettingId(rightsSettingId);
if (ListUtils.isEmpty(rightsSettingBookRelations)){
return fill;
}
BookAdviserDto adviserDto = bookAdviserBiz.getOneMainBook(rightsSettingBookRelations.get(0).getBookId());
firstClassify = adviserDto.getTempletId(); firstClassify = adviserDto.getTempletId();
secondClassify = adviserDto.getSecondTempletId(); secondClassify = adviserDto.getSecondTempletId();
gradeLabelId = adviserDto.getGraLabelId(); gradeLabelId = adviserDto.getGraLabelId();
...@@ -1613,6 +1705,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz { ...@@ -1613,6 +1705,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
appletUserBookcase.getReadType(); appletUserBookcase.getReadType();
if (null != rightsSettingDto) { if (null != rightsSettingDto) {
Long rightsSettingId = rightsSettingDto.getId(); Long rightsSettingId = rightsSettingDto.getId();
rightsSettingDto.setRightsSettingBookRelations(rightsSettingBookRelationMapper.selectByRithsSettingId(rightsSettingDto.getId()));;
List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSettingId); List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSettingId);
ReadTypeCountDTO readTypeCountDTO = new ReadTypeCountDTO(); ReadTypeCountDTO readTypeCountDTO = new ReadTypeCountDTO();
readTypeCountDTO.setRightsSettingId(rightsSettingId); readTypeCountDTO.setRightsSettingId(rightsSettingId);
......
...@@ -38,8 +38,8 @@ public class RightsSettingCheck { ...@@ -38,8 +38,8 @@ public class RightsSettingCheck {
if (null==rightsSetting.getRightsSettingType()){ if (null==rightsSetting.getRightsSettingType()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益类型为空!"); throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益类型为空!");
} }
if (rightsSetting.getRightsSettingType()==2 && null==rightsSetting.getBookId()){ if (ListUtils.isEmpty(rightsSetting.getRightsSettingBookRelations())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"bookId为空!"); throw new BookBizException(BookBizException.PARAM_IS_NULL,"RightsSettingBookRelations不能为空!");
} }
if (rightsSetting.getRightsSettingType()==1 && null == rightsSetting.getFirstClassify()){ if (rightsSetting.getRightsSettingType()==1 && null == rightsSetting.getFirstClassify()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!"); throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!");
......
...@@ -70,6 +70,9 @@ public class RightsSetting extends BaseTempletClassify { ...@@ -70,6 +70,9 @@ public class RightsSetting extends BaseTempletClassify {
@ApiModelProperty("书刊id") @ApiModelProperty("书刊id")
private Long bookId; private Long bookId;
@ApiModelProperty("书刊ids")
private List<RightsSettingBookRelation> rightsSettingBookRelations;
/** /**
* 书或isbn查询 * 书或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 @@ ...@@ -2379,4 +2379,58 @@
and is_delete=0 and is_delete=0
</update> </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> </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 @@ ...@@ -43,11 +43,24 @@
<result column="read_type_title" property="readTypeTitle" jdbcType="VARCHAR" /> <result column="read_type_title" property="readTypeTitle" jdbcType="VARCHAR" />
<result column="vol_label_id" property="volLabelId" jdbcType="BIGINT" /> <result column="vol_label_id" property="volLabelId" jdbcType="BIGINT" />
</resultMap> </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" > <sql id="Base_Column_List" >
id, introduce, detail, count, first_classify, second_classify, grade_label_id, subject_label_id, 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 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 ,online_course_open,learning_tool_open,draw_open,read_type_title, vol_label_id
</sql> </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 id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
...@@ -146,9 +159,10 @@ ...@@ -146,9 +159,10 @@
<select id="listRightsSettingPage" parameterType="map" resultMap="DtoResultMap"> <select id="listRightsSettingPage" parameterType="map" resultMap="DtoResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List_own"/>
from from
rights_setting rights_setting r
left join rights_setting_book_relation b on r.id = b.rights_setting_id
<where> <where>
<if test="firstClassify != null"> <if test="firstClassify != null">
first_classify = #{firstClassify} first_classify = #{firstClassify}
...@@ -165,30 +179,36 @@ ...@@ -165,30 +179,36 @@
<if test="rightsSettingType !=null"> <if test="rightsSettingType !=null">
and rights_setting_type = #{rightsSettingType} and rights_setting_type = #{rightsSettingType}
</if> </if>
<if test="bookId!=null"> <if test="bookIds != null and bookIds.size() > 0">
and book_id=#{bookId} and b.book_id in
<foreach collection="bookIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</if> </if>
<if test="exceptId!=null"> <if test="exceptId!=null">
and id != #{exceptId} and r.id != #{exceptId}
</if> </if>
<if test="volLabelId != null" > <if test="volLabelId != null" >
and vol_label_id = #{volLabelId} and vol_label_id = #{volLabelId}
</if> </if>
</where> </where>
order by create_time desc order by r.create_time desc
</select> </select>
<select id="listBookRightsSettingPage" parameterType="map" resultMap="DtoResultMap"> <select id="listBookRightsSettingPage" parameterType="map" resultMap="DtoResultMap4Book">
select select
r.id, r.introduce, r.detail, r.count, r.first_classify, r.second_classify, r.grade_label_id, r.subject_label_id, 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
from 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 WHERE
r.rights_setting_type = 2 r.rights_setting_type = 2
<if test="bookQuery !=null"> <if test="bookQuery !=null">
AND (b.BOOK_NAME LIKE CONCAT("%",#{bookQuery},"%") OR b.ISBN LIKE CONCAT("%",#{bookQuery},"%")) AND (b.BOOK_NAME LIKE CONCAT("%",#{bookQuery},"%") OR b.ISBN LIKE CONCAT("%",#{bookQuery},"%"))
</if> </if>
group by r.id
order by r.create_time desc order by r.create_time desc
</select> </select>
...@@ -219,10 +239,11 @@ ...@@ -219,10 +239,11 @@
<select id="getByBookId" parameterType="map" resultMap="DtoResultMap"> <select id="getByBookId" parameterType="map" resultMap="DtoResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List_own"/>
from from
rights_setting rights_setting r
WHERE book_id = #{bookId} left join rights_setting_book_relation b on r.id = b.rights_setting_id
WHERE b.book_id = #{bookId}
and rights_setting_type = 2 and rights_setting_type = 2
limit 1 limit 1
</select> </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