Commit 3c56c2ba by 裴大威

Merge branch 'feat-1002712' into 'master'

1002712

See merge request rays/pcloud-book!620
parents 60879852 f9389f97
......@@ -87,6 +87,29 @@ public class BookAdviserDto extends BaseDto {
* 是否已经被删除 1是 0否
*/
private Integer isDelete;
/**
* 第二级类型
*/
private Long secondTempletId;
/**
* 年级标签id
*/
private Long graLabelId;
/**
* 科目标签id
*/
private Long subLabelId;
/**
* 版本标签id
*/
private Long verLabelId;
/**
* 地域标签id
*/
private Long areaLabelId;
public Integer getCount() {
return count;
......@@ -216,6 +239,46 @@ public class BookAdviserDto extends BaseDto {
this.templetId = templetId;
}
public Long getSecondTempletId() {
return secondTempletId;
}
public void setSecondTempletId(Long secondTempletId) {
this.secondTempletId = secondTempletId;
}
public Long getGraLabelId() {
return graLabelId;
}
public void setGraLabelId(Long graLabelId) {
this.graLabelId = graLabelId;
}
public Long getSubLabelId() {
return subLabelId;
}
public void setSubLabelId(Long subLabelId) {
this.subLabelId = subLabelId;
}
public Long getVerLabelId() {
return verLabelId;
}
public void setVerLabelId(Long verLabelId) {
this.verLabelId = verLabelId;
}
public Long getAreaLabelId() {
return areaLabelId;
}
public void setAreaLabelId(Long areaLabelId) {
this.areaLabelId = areaLabelId;
}
@Override
public String toString() {
return "BookAdviserDto{" +
......@@ -226,6 +289,7 @@ public class BookAdviserDto extends BaseDto {
", adviserId=" + adviserId +
", adviserName='" + adviserName + '\'' +
", channelId=" + channelId +
", templetId=" + templetId +
", channelName='" + channelName + '\'' +
", count=" + count +
", isMainEditor=" + isMainEditor +
......@@ -233,6 +297,11 @@ public class BookAdviserDto extends BaseDto {
", agentName='" + agentName + '\'' +
", bookDto=" + bookDto +
", isDelete=" + isDelete +
", secondTempletId=" + secondTempletId +
", graLabelId=" + graLabelId +
", subLabelId=" + subLabelId +
", verLabelId=" + verLabelId +
", areaLabelId=" + areaLabelId +
'}';
}
}
package com.pcloud.book.book.dto;
import com.pcloud.common.dto.BaseDto;
import lombok.Data;
/**
* 书刊小睿品牌介绍页权益
*/
@Data
public class BookRightsSettingDTO extends BaseDto {
/**
* 权益介绍
*/
private String rightsSettingIntroduce;
/**
*权益详情
*/
private String rightsSettingDetail;
/**
*权益数量
*/
private Integer rightsSettingCount;
}
......@@ -126,4 +126,10 @@ public interface BookAdviserService {
ResponseEntity<ResponseDto<String>> refactorData(@RequestParam("parentId") Long parentId,
@RequestParam("originTempletId") Long originTempletId,
@RequestParam(value = "secondTempletId",required = false) Long secondTempletId) throws BizException ;
@ApiOperation("获取书刊小睿品牌介绍页权益")
@GetMapping("getBookRightsSetting")
ResponseEntity<ResponseDto<BookRightsSettingDTO>>getBookRightsSetting(
@RequestParam("bookId") Long bookId, @RequestParam("channelId") Long channelId,
@RequestParam("adviserId") Long adviserId);
}
......@@ -211,4 +211,8 @@ public interface BookGroupService {
@ApiOperation("根据用户和社群书id获取个人号信息")
@GetMapping("getSelfRobotBookGroupInfoByUser")
ResponseEntity<ResponseDto<SelfRobotBookGroupDTO>> getSelfRobotBookGroupInfoByUser(@RequestParam("wxUserId") String wxUserId, @RequestParam("bookGroupId") Long bookGroupId);
@ApiOperation("每天增加小程序权益读者数量")
@GetMapping("addUserCount4RightsSetting")
void addUserCount4RightsSetting();
}
......@@ -4,6 +4,7 @@ import com.pcloud.book.advertising.biz.AdvertisingSpaceBiz;
import com.pcloud.book.advertising.biz.GroupTagBiz;
import com.pcloud.book.advertising.biz.LinkRevertBiz;
import com.pcloud.book.advertising.service.AdvertisingSpaceService;
import com.pcloud.book.group.service.BookGroupService;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
......@@ -42,6 +43,8 @@ public class AdvertisingSpaceServiceImpl implements AdvertisingSpaceService {
private GroupTagBiz groupTagBiz;
@Autowired
private LinkRevertBiz linkRevertBiz;
@Autowired
private BookGroupService bookGroupService;
/**
* 每日凌晨计算昨日广告位收益
......@@ -52,6 +55,8 @@ public class AdvertisingSpaceServiceImpl implements AdvertisingSpaceService {
advertisingSpaceBiz.calculateAdvertisingIncomeYesterday();
//统计昨日链接发送次数
linkRevertBiz.addYesterdaySendStatistic();
//新增读者数量
bookGroupService.addUserCount4RightsSetting();
}
@ApiOperation("发送广告计划")
......
......@@ -196,4 +196,13 @@ public interface BookAdviserBiz {
* @throws BizException
*/
void setIsPrint(BookAdviser bookAdviser) throws BizException;
/**
* 获取书刊小睿品牌介绍页权益
* @param bookId
* @param channelId
* @param adviserId
* @return
*/
BookRightsSettingDTO getBookRightsSetting(Long bookId, Long channelId, Long adviserId);
}
......@@ -7,6 +7,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.pcloud.book.book.dto.BookRightsSettingDTO;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -104,6 +108,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
@Autowired
private BookGroupDao bookGroupDao;
@Autowired
private RightsSettingBiz rightsSettingBiz;
@Override
public List<BookDto> listByAdviserId(Long adviserId) {
......@@ -810,4 +816,20 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
}
bookAdviserDao.setIsPrint(bookAdviser);
}
@Override
public BookRightsSettingDTO getBookRightsSetting(Long bookId, Long channelId, Long adviserId) {
BookRightsSettingDTO bookRightsSettingDTO = new BookRightsSettingDTO();
BookAdviserDto adviserDto = bookAdviserDao.getBase(bookId,channelId,adviserId);
if (null!=adviserDto){
RightsSettingDto rightsSettingDto = rightsSettingBiz.getByLabel(adviserDto.getTempletId(),
adviserDto.getSecondTempletId(),adviserDto.getGraLabelId(),adviserDto.getSubLabelId());
if (null!= rightsSettingDto){
bookRightsSettingDTO.setRightsSettingDetail(rightsSettingDto.getDetail());
bookRightsSettingDTO.setRightsSettingIntroduce(rightsSettingDto.getIntroduce());
bookRightsSettingDTO.setRightsSettingCount(rightsSettingDto.getCount());
}
}
return bookRightsSettingDTO;
}
}
......@@ -124,4 +124,13 @@ public class BookAdviserServiceImpl implements BookAdviserService {
bookAdviserBiz.refactorData(parentId,originTempletId,secondTempletId);
return ResponseHandleUtil.toResponse("ok");
}
@Override
@GetMapping("getBookRightsSetting")
public ResponseEntity<ResponseDto<BookRightsSettingDTO>>getBookRightsSetting(
@RequestParam("bookId") Long bookId, @RequestParam("channelId") Long channelId,
@RequestParam("adviserId") Long adviserId) {
BookRightsSettingDTO bookRightsSettingDTO = bookAdviserBiz.getBookRightsSetting(bookId,channelId,adviserId);
return ResponseHandleUtil.toResponse(bookRightsSettingDTO);
}
}
......@@ -71,4 +71,30 @@ public class AssistTempletConsr {
}
return ids;
}
/**
* 获取模板基本信息
*
* @return
*/
public Map<Long, AssistTempletDTO> mapByIds4Classify(List<Long> assistTempletIds) {
LOGGER.info("获取模板基本信息[assistTempletService.mapByIds4Classify],参数列表[assistTempletIds]:" + assistTempletIds);
Map<Long, AssistTempletDTO> assistTempletDTOs = new HashMap<>();
if (ListUtils.isEmpty(assistTempletIds)) {
return assistTempletDTOs;
}
try {
assistTempletDTOs = ResponseHandleUtil.parseMapResponse(assistTempletService.mapByIds4Classify(assistTempletIds),
Long.class, AssistTempletDTO.class);
} catch (BizException e) {
LOGGER.warn("获取模板基本信息[assistTempletService.mapByIds4Classify]:" + e.getMessage(), e);
throw new BizException(e.getCode(), e.getMessage());
} catch (Exception e) {
LOGGER.error("获取模板基本信息[assistTempletService.mapByIds4Classify]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_APP_ERROR, "获取模板基本信息失败~!");
}
return assistTempletDTOs;
}
}
......@@ -77,6 +77,8 @@ import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.push.enums.AltTypeEnum;
import com.pcloud.book.reading.dao.ReadingUserDao;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.base.constants.ChannelConstants;
import com.pcloud.channelcenter.qrcode.dto.GroupQrcodeVO;
......@@ -299,6 +301,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
private WechatConsr wechatConsr;
@Autowired
private BookAppletSceneDao bookAppletSceneDao;
@Autowired
private RightsSettingBiz rightsSettingBiz;
private static final ThreadPoolExecutor PLATFORM_STATISTICS_EXPORT_THREAD = new ThreadPoolExecutor(2, 2,
0, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
......@@ -4441,8 +4445,19 @@ public class BookGroupBizImpl implements BookGroupBiz {
if (null != bookAppletScene){
BeanUtils.copyProperties(bookAppletScene,dto);
}
BookGroupDTO bookGroupDTO = bookGroupDao.getBookBaseInfoById(bookGroupId);
BookGroupDTO bookGroupDTO = bookGroupDao. getBookBaseInfoById(bookGroupId);
dto.setBookName(StringUtil.addBracket(bookGroupDTO.getBookName()));
//权益
BookAdviserDto adviserDto = bookAdviserDao.getBase(bookGroupDTO.getBookId(),bookGroupDTO.getChannelId(),bookGroupDTO.getCreateUser());
if (null!=adviserDto){
RightsSettingDto rightsSettingDto = rightsSettingBiz.getByLabel(adviserDto.getTempletId(),
adviserDto.getSecondTempletId(),adviserDto.getGraLabelId(),adviserDto.getSubLabelId());
if (null!= rightsSettingDto){
dto.setRightsSettingDetail(rightsSettingDto.getDetail());
dto.setRightsSettingIntroduce(rightsSettingDto.getIntroduce());
dto.setRightsSettingCount(rightsSettingDto.getCount());
}
}
return dto;
}
......
......@@ -36,5 +36,18 @@ public class BookAppletSceneDTO extends BaseDto {
* 书名
*/
private String bookName;
/**
* 权益介绍
*/
private String rightsSettingIntroduce;
/**
*权益详情
*/
private String rightsSettingDetail;
/**
*权益数量
*/
private Integer rightsSettingCount;
}
......@@ -3,11 +3,14 @@ package com.pcloud.book.group.handler;
import com.pcloud.book.group.biz.BookGroupBiz;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Random;
import lombok.extern.slf4j.Slf4j;
......
......@@ -22,9 +22,12 @@ import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.dto.StoreFlowInfoDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -36,8 +39,10 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
......@@ -359,4 +364,15 @@ public class BookGroupServiceImpl implements BookGroupService {
SelfRobotBookGroupDTO selfRobotBookGroupDTO = bookGroupBiz.getSelfRobotBookGroupInfoByUser(wxUserId, bookGroupId);
return ResponseHandleUtil.toResponse(selfRobotBookGroupDTO);
}
@Override
public void addUserCount4RightsSetting() {
//每天增加读者数
String key="BOOK:APPLET:RIGHTS_SETTING_USER_COUNT";
String value = JedisClusterUtils.get(key);
if (!StringUtil.isEmpty(value)){
Integer count =Integer.valueOf(value)+new Random().nextInt(10)+20;
JedisClusterUtils.set(key,count.toString(),36*3600);
}
}
}
package com.pcloud.book.rightsSetting.biz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
public interface RightsSettingBiz {
Long addRightsSetting(RightsSetting rightsSetting);
void deleteRightsSetting(Long id);
void updateRightsSetting(RightsSetting rightsSetting);
RightsSetting getRightsSetting(Long id);
PageBeanNew<RightsSettingDto> listRightsSettingPage(Integer currentPage, Integer numPerPage, RightsSetting rightsSetting);
RightsSettingDto getByLabel(Long firstClassify,Long secondClassify,Long gradeLabelId,Long subjectLabelId);
Integer getUserCount();
}
package com.pcloud.book.rightsSetting.biz.impl;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.constants.RightsSettingConstant;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dao.check.RightsSettingCheck;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz {
@Autowired
private RightsSettingDAO rightsSettingDAO;
@Autowired
private RightsSettingCheck rightsSettingCheck;
@Autowired
private BookLabelDao bookLabelDao;
@Autowired
private AssistTempletConsr assistTempletConsr;
@Value("${system.env}")
private String envStr;
@Override
@ParamLog("新增权益设置")
public Long addRightsSetting(RightsSetting rightsSetting) {
rightsSettingCheck.rightsSettingCheck(rightsSetting);
setClassifyAndLabel(rightsSetting);
RightsSettingDto rightsSettingDto = getByLabel(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),
rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId());
if (null != rightsSettingDto){
throw new BookBizException(BookBizException.ERROR,"已存在相同的权益设置");
}
return rightsSettingDAO.insert(rightsSetting);
}
private void setClassifyAndLabel(RightsSetting rightsSetting) {
log.info("对于某些特殊分类做处理");
Boolean contain4K12 = false;
Boolean contain4Medical = false;
if ("test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID_TEST,rightsSetting.getFirstClassify())){
contain4K12 = true;
}else if (!"test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID,rightsSetting.getFirstClassify())){
contain4K12 = true;
}
if (!ArrayUtils.contains(RightsSettingConstant.MEDICAL_INSURANCE_TEMPLET_ID,rightsSetting.getFirstClassify())){
rightsSetting.setSecondClassify(null);
}
if (!contain4K12){
rightsSetting.setGradeLabelId(null);
rightsSetting.setSubjectLabelId(null);
}
}
@Override
@ParamLog("删除权益设置")
public void deleteRightsSetting(Long id) {
rightsSettingDAO.deleteByPrimaryKey(id);
}
@Override
@ParamLog("更新权益设置")
public void updateRightsSetting(RightsSetting rightsSetting) {
rightsSettingCheck.rightsSettingCheck(rightsSetting);
setClassifyAndLabel(rightsSetting);
RightsSettingDto rightsSettingDto = getByLabel(rightsSetting.getFirstClassify(),rightsSetting.getSecondClassify(),
rightsSetting.getGradeLabelId(), rightsSetting.getSubjectLabelId());
if (null != rightsSettingDto && !rightsSettingDto.getId().equals(rightsSetting.getId())){
throw new BookBizException(BookBizException.ERROR,"已存在相同的权益设置");
}
rightsSetting.setUpdateTime(new Date());
rightsSettingDAO.updateByPrimaryKeySelective(rightsSetting);
}
@Override
@ParamLog("获取权益设置")
public RightsSetting getRightsSetting(Long id) {
return rightsSettingDAO.selectByPrimaryKey(id);
}
@Override
@ParamLog(value = "获取权益分类分页列表",isAfterReturn = false)
public PageBeanNew<RightsSettingDto> listRightsSettingPage(Integer currentPage, Integer numPerPage, RightsSetting rightsSetting) {
Map<String,Object> paramMap = new HashMap<>();
if (null != rightsSetting.getFirstClassify()){
setClassifyAndLabel(rightsSetting);
}
paramMap.put("firstClassify",rightsSetting.getFirstClassify());
paramMap.put("secondClassify",rightsSetting.getSecondClassify());
paramMap.put("gradeLabelId",rightsSetting.getGradeLabelId());
paramMap.put("subjectLabelId",rightsSetting.getSubjectLabelId());
PageBeanNew<RightsSettingDto> rightsSettingDtoPageBeanNew = rightsSettingDAO.listPageNew(new PageParam(currentPage,numPerPage),paramMap,"listRightsSettingPage");
if (null != rightsSettingDtoPageBeanNew && !ListUtils.isEmpty(rightsSettingDtoPageBeanNew.getRecordList())){
List<RightsSettingDto> rightsSettingDtos = rightsSettingDtoPageBeanNew.getRecordList();
setLabelContent(rightsSettingDtos);
}
return rightsSettingDtoPageBeanNew;
}
private void setLabelContent(List<RightsSettingDto> rightsSettingDtos) {
log.info("权益设置标签具体内容");
if (ListUtils.isEmpty(rightsSettingDtos)){
return;
}
List<Long> firstClassifyIds = new ArrayList<>();
List<Long> secondClassifyIds = new ArrayList<>();
List<Long> classifyIds = new ArrayList<>();
List<Long> gradeLabelIds = new ArrayList<>();
List<Long> subjectLabelIds = new ArrayList<>();
List<Long> labelIds = new ArrayList<>();
firstClassifyIds = rightsSettingDtos.stream().map(e -> e.getFirstClassify()).collect(Collectors.toList());
secondClassifyIds = rightsSettingDtos.stream().map(e -> e.getSecondClassify()).collect(Collectors.toList());
gradeLabelIds = rightsSettingDtos.stream().map(e -> e.getGradeLabelId()).collect(Collectors.toList());
subjectLabelIds = rightsSettingDtos.stream().map(e -> e.getSubjectLabelId()).collect(Collectors.toList());
if (!ListUtils.isEmpty(firstClassifyIds)){
classifyIds.addAll(firstClassifyIds);
}
if (!ListUtils.isEmpty(secondClassifyIds)){
classifyIds.addAll(secondClassifyIds);
}
if (!ListUtils.isEmpty(gradeLabelIds)){
labelIds.addAll(gradeLabelIds);
}
if (!ListUtils.isEmpty(subjectLabelIds)){
labelIds.addAll(subjectLabelIds);
}
Map<Long, AssistTempletDTO> classifyMap = new HashMap<>();
Map<Long, BookLabel> labelMap= new HashMap<>();
if (!ListUtils.isEmpty(classifyIds)){
classifyMap = assistTempletConsr.mapByIds4Classify(classifyIds);
}
if (!ListUtils.isEmpty(labelIds)){
labelMap = bookLabelDao.getMapByIds(labelIds);
}
for (RightsSettingDto rightsSettingDto : rightsSettingDtos){
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getFirstClassify())){
rightsSettingDto.setFirstClassifyContent(classifyMap.get(rightsSettingDto.getFirstClassify()).getTempletName());
}
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getSecondClassify())){
rightsSettingDto.setSecondClassifyContent(classifyMap.get(rightsSettingDto.getSecondClassify()).getTempletName());
}
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getGradeLabelId())){
rightsSettingDto.setGradeLabelIdContent(labelMap.get(rightsSettingDto.getGradeLabelId()).getName());
}
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getSubjectLabelId())){
rightsSettingDto.setSubjectLabelIdContent(labelMap.get(rightsSettingDto.getSubjectLabelId()).getName());
}
}
}
@Override
public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId) {
//医疗保健分类校验
if (ArrayUtils.contains(RightsSettingConstant.MEDICAL_INSURANCE_TEMPLET_ID,firstClassify)){
subjectLabelId=null;
gradeLabelId=null;
}
//k12教育分类校验
else if ("test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID_TEST,firstClassify)){
secondClassify=null;
}else if (!"test".equals(envStr) && ArrayUtils.contains(RightsSettingConstant.K12_TEMPLET_ID,firstClassify)){
secondClassify=null;
}
else {
secondClassify=null;
subjectLabelId=null;
gradeLabelId=null;
}
RightsSettingDto dto = rightsSettingDAO.getByLabel(firstClassify,secondClassify,gradeLabelId,subjectLabelId);
return dto;
}
@Override
public Integer getUserCount() {
Integer userCount = 102336;
String key="BOOK:APPLET:RIGHTS_SETTING_USER_COUNT";
String value = JedisClusterUtils.get(key);
if (StringUtil.isEmpty(value)){
JedisClusterUtils.set(key,userCount.toString(),24*3600);
}else {
userCount = Integer.valueOf(value);
}
return userCount;
}
}
package com.pcloud.book.rightsSetting.constants;
public class RightsSettingConstant {
/**
* 所属k12教育的编辑书刊分类id--生产uat
*/
public static final Long[] K12_TEMPLET_ID = {48L, 59L, 46L, 40L, 65L, 60L, 131L};
/**
* 所属k12教育的编辑书刊分类id--测试环境
*/
public static final Long[] K12_TEMPLET_ID_TEST = {48L, 59L, 46L, 40L, 65L, 60L, 136L};
/**
* 医疗保健编辑书刊分类id
*/
public static final Long[] MEDICAL_INSURANCE_TEMPLET_ID = {63L};
}
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.core.dao.BaseDao;
public interface RightsSettingDAO extends BaseDao<RightsSetting> {
int deleteByPrimaryKey(Long id);
RightsSetting selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(RightsSetting record);
int updateByPrimaryKey(RightsSetting record);
RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId);
}
package com.pcloud.book.rightsSetting.dao;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
public interface RightsSettingMapper {
int deleteByPrimaryKey(Long id);
int insert(RightsSetting record);
int insertSelective(RightsSetting record);
RightsSetting selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(RightsSetting record);
int updateByPrimaryKey(RightsSetting record);
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.dao.check;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.utils.string.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Component("权益设置参数校验")
@Slf4j
public class RightsSettingCheck {
public void rightsSettingCheck(RightsSetting rightsSetting) {
log.info("新增权益设置参数校验");
if (null == rightsSetting){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数为空!");
}
if (StringUtil.isEmpty(rightsSetting.getIntroduce())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益介绍为空!");
}
if (StringUtil.isEmpty(rightsSetting.getDetail())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益详情为空!");
}
if (null == rightsSetting.getCount()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"权益个数为空!");
}
if (null == rightsSetting.getFirstClassify()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"分类为空!");
}
}
}
package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class RightsSettingDAOImpl extends BaseDaoImpl<RightsSetting> implements RightsSettingDAO{
@Override
public int deleteByPrimaryKey(Long id) {
return super.getSqlSession().delete(getStatement("deleteByPrimaryKey"),id);
}
@Override
public RightsSetting selectByPrimaryKey(Long id) {
return super.getSqlSession().selectOne(getStatement("selectByPrimaryKey"),id);
}
@Override
public int updateByPrimaryKeySelective(RightsSetting record) {
return super.getSqlSession().update(getStatement("updateByPrimaryKeySelective"),record);
}
@Override
public int updateByPrimaryKey(RightsSetting record) {
return super.getSqlSession().update(getStatement("updateByPrimaryKeySelective"),record);
}
@Override
public RightsSettingDto getByLabel(Long firstClassify, Long secondClassify, Long gradeLabelId, Long subjectLabelId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("firstClassify",firstClassify);
paramMap.put("secondClassify",secondClassify);
paramMap.put("gradeLabelId",gradeLabelId);
paramMap.put("subjectLabelId",subjectLabelId);
return getSessionTemplate().selectOne(getStatement("getByLabel"),paramMap);
}
}
package com.pcloud.book.rightsSetting.dto;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import lombok.Data;
@Data
public class RightsSettingDto extends RightsSetting {
private String firstClassifyContent;
private String secondClassifyContent;
private String gradeLabelIdContent;
private String subjectLabelIdContent;
}
package com.pcloud.book.rightsSetting.entity;
import com.pcloud.common.entity.BaseEntity;
import lombok.Data;
@Data
public class RightsSetting extends BaseEntity {
private String introduce;
private String detail;
private Integer count;
private Long firstClassify;
private Long secondClassify;
private Long gradeLabelId;
private Long subjectLabelId;
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.facade;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RequestMapping("rightsSetting")
@RestController("rightsSettingFacede")
public class RightsSettingFacede {
@Autowired
private RightsSettingBiz rightsSettingBiz;
@PostMapping("addRightsSetting")
public ResponseDto<Long> addRightsSetting(@RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting) throws PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<Long>(rightsSettingBiz.addRightsSetting(rightsSetting));
}
@GetMapping("deleteRightsSetting")
public ResponseDto<?> deleteRightsSetting(@RequestHeader("token") String token, @RequestParam("id") Long id) throws PermissionException {
SessionUtil.getToken4Redis(token);
rightsSettingBiz.deleteRightsSetting(id);
return new ResponseDto<>();
}
@PostMapping("updateRightsSetting")
public ResponseDto<?> updateRightsSetting(@RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting) throws PermissionException {
SessionUtil.getToken4Redis(token);
rightsSettingBiz.updateRightsSetting(rightsSetting);
return new ResponseDto<>();
}
@GetMapping("getRightsSetting")
public ResponseDto<RightsSetting> getRightsSetting(@RequestHeader("token") String token, @RequestParam("id") Long id) throws PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<RightsSetting>(rightsSettingBiz.getRightsSetting(id));
}
@GetMapping("listRightsSettingPage")
public ResponseDto<PageBeanNew<RightsSettingDto>> listRightsSettingPage(@RequestHeader("token") String token,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage,
@RequestParam(value = "firstClassify", required = false) Long firstClassify,
@RequestParam(value = "secondClassify", required = false) Long secondClassify,
@RequestParam(value = "gradeLabelId", required = false) Long gradeLabelId,
@RequestParam(value = "subjectLabelId", required = false) Long subjectLabelId) throws PermissionException {
SessionUtil.getToken4Redis(token);
RightsSetting rightsSetting = new RightsSetting();
rightsSetting.setFirstClassify(firstClassify);
rightsSetting.setSecondClassify(secondClassify);
rightsSetting.setGradeLabelId(gradeLabelId);
rightsSetting.setSubjectLabelId(subjectLabelId);
return new ResponseDto<PageBeanNew<RightsSettingDto>>(rightsSettingBiz.listRightsSettingPage(currentPage, numPerPage, rightsSetting));
}
@ApiOperation("获取读者数量-每天自增")
@GetMapping("getUserCount")
public ResponseDto<Integer> getUserCount(){
return new ResponseDto<>(rightsSettingBiz.getUserCount());
}
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
<generatorConfiguration>
<classPathEntry
location="C:\work\repository\mysql\mysql-connector-java\5.1.44\mysql-connector-java-5.1.44.jar"/>
location="E:\work\respository\mysql\mysql-connector-java\5.1.44\mysql-connector-java-5.1.44.jar"/>
<context id="my" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="false"/>
......@@ -16,19 +16,19 @@
connectionURL="jdbc:mysql://192.168.92.41:3306/book" userId="root"
password="LGSC2016.lgsc"/>
<javaModelGenerator targetPackage="com.pcloud.book"
targetProject="C:\project\rays\个人中心\pcloud-book\pcloud-service-book\src\main\resource">
<javaModelGenerator targetPackage="com.pcloud.book.rightsSetting.entity"
targetProject="src\main\java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.pcloud.book"
targetProject="C:\project\rays\个人中心\pcloud-book\pcloud-service-book\src\main\resource">
<sqlMapGenerator targetPackage="mapper.rightssetting"
targetProject="src\main\resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator targetPackage="com.pcloud.book"
targetProject="C:\project\rays\个人中心\pcloud-book\pcloud-service-book\src\main\resource" type="XMLMAPPER">
<javaClientGenerator targetPackage="com.pcloud.book.rightsSetting.dao"
targetProject="src\main\java" type="XMLMAPPER">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
......@@ -38,7 +38,7 @@
selectByExampleQueryId="false">
</table>-->
<table tableName="mini_user_classify" domainObjectName="MiniUserClassify"
<table tableName="rights_setting" domainObjectName="RightsSetting"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
......
......@@ -16,6 +16,10 @@
<result column="IS_MAIN_EDITOR" property="isMainEditor" jdbcType="BIT" />
<result column="IS_DELETE" property="isDelete" jdbcType="BIT" />
<result column="SECOND_TEMPLET_ID" property="secondTempletId" jdbcType="BIGINT" />
<result column="GRA_LABEL_ID" property="graLabelId" jdbcType="BIGINT" />
<result column="SUB_LABEL_ID" property="subLabelId" jdbcType="BIGINT" />
<result column="VER_LABEL_ID" property="verLabelId" jdbcType="BIGINT" />
<result column="AREA_LABEL_ID" property="areaLabelId" jdbcType="BIGINT" />
</resultMap>
<resultMap id="manageAdviserMap" type="adviserManageDto" >
......@@ -113,7 +117,9 @@
<!-- 批量获取书籍信息 -->
<select id="getBase" resultMap="bookAdviserMap" parameterType="map">
SELECT
BOOK_ADVISER_ID, BOOK_ID, TEMPLET_ID, CHANNEL_ID, ADVISER_ID, IS_DELETE
BOOK_ADVISER_ID, BOOK_ID, TEMPLET_ID, CHANNEL_ID, ADVISER_ID, IS_DELETE,
TEMPLET_ID,SECOND_TEMPLET_ID,
GRA_LABEL_ID,SUB_LABEL_ID,VER_LABEL_ID,AREA_LABEL_ID
FROM
BOOK_ADVISER
WHERE
......
......@@ -459,7 +459,9 @@
bg.is_invite_group,
b.book_name,
b.cover_img book_img,
b.isbn
b.isbn,
bg.channel_id,
bg.create_user
FROM
book_group bg
LEFT JOIN book b ON bg.book_id = b.BOOK_ID
......
<?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.dao.impl.RightsSettingDAOImpl" >
<resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsSetting" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="introduce" property="introduce" jdbcType="VARCHAR" />
<result column="detail" property="detail" jdbcType="VARCHAR" />
<result column="count" property="count" jdbcType="INTEGER" />
<result column="first_classify" property="firstClassify" jdbcType="BIGINT" />
<result column="second_classify" property="secondClassify" jdbcType="BIGINT" />
<result column="grade_label_id" property="gradeLabelId" jdbcType="BIGINT" />
<result column="subject_label_id" property="subjectLabelId" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<resultMap id="DtoResultMap" type="com.pcloud.book.rightsSetting.dto.RightsSettingDto">
<id column="id" property="id" jdbcType="BIGINT" />
<result column="introduce" property="introduce" jdbcType="VARCHAR" />
<result column="detail" property="detail" jdbcType="VARCHAR" />
<result column="count" property="count" jdbcType="INTEGER" />
<result column="first_classify" property="firstClassify" jdbcType="BIGINT" />
<result column="second_classify" property="secondClassify" jdbcType="BIGINT" />
<result column="grade_label_id" property="gradeLabelId" jdbcType="BIGINT" />
<result column="subject_label_id" property="subjectLabelId" 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, introduce, detail, count, first_classify, second_classify, grade_label_id, subject_label_id,
create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from rights_setting
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from rights_setting
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSetting" >
insert into rights_setting (id, introduce, detail,
count, first_classify, second_classify,
grade_label_id, subject_label_id, create_time,
update_time)
values (#{id,jdbcType=BIGINT}, #{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})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsSetting" >
update rights_setting
<set >
<if test="introduce != null" >
introduce = #{introduce,jdbcType=VARCHAR},
</if>
<if test="detail != null" >
detail = #{detail,jdbcType=VARCHAR},
</if>
<if test="count != null" >
count = #{count,jdbcType=INTEGER},
</if>
<if test="firstClassify != null" >
first_classify = #{firstClassify,jdbcType=BIGINT},
</if>
<if test="secondClassify != null" >
second_classify = #{secondClassify,jdbcType=BIGINT},
</if>
<if test="gradeLabelId != null" >
grade_label_id = #{gradeLabelId,jdbcType=BIGINT},
</if>
<if test="subjectLabelId != null" >
subject_label_id = #{subjectLabelId,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.RightsSetting" >
update rights_setting
set introduce = #{introduce,jdbcType=VARCHAR},
detail = #{detail,jdbcType=VARCHAR},
count = #{count,jdbcType=INTEGER},
first_classify = #{firstClassify,jdbcType=BIGINT},
second_classify = #{secondClassify,jdbcType=BIGINT},
grade_label_id = #{gradeLabelId,jdbcType=BIGINT},
subject_label_id = #{subjectLabelId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="listRightsSettingPage" parameterType="map" resultMap="DtoResultMap">
select
<include refid="Base_Column_List"/>
from
rights_setting
<where>
<if test="firstClassify != null">
first_classify = #{firstClassify}
</if>
<if test="secondClassify != null">
and second_classify = #{secondClassify}
</if>
<if test="gradeLabelId != null">
and grade_label_id = #{gradeLabelId}
</if>
<if test="subjectLabelId != null">
and subject_label_id = #{subjectLabelId}
</if>
</where>
order by create_time desc
</select>
<select id="getByLabel" parameterType="map" resultMap="DtoResultMap">
select
<include refid="Base_Column_List"/>
from
rights_setting
where 1=1
<if test="firstClassify != null">
and first_classify = #{firstClassify}
</if>
<if test="secondClassify != null">
and second_classify = #{secondClassify}
</if>
<if test="gradeLabelId != null">
and grade_label_id = #{gradeLabelId}
</if>
<if test="subjectLabelId != null">
and subject_label_id = #{subjectLabelId}
</if>
limit 1
</select>
</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