Commit 9ce628b4 by zhuyajie

1002907小程序首页改版

parent 38b91486
......@@ -133,6 +133,8 @@ public class BookConstant {
public static final Random RANDOM = new Random();
public static final Integer zero = 0;
/**
* 微信群默认头像
*/
......
......@@ -71,7 +71,7 @@ public interface AppletBooklistBiz {
* @param numPerPage
* @return
*/
PageBeanNew<AppletBooklistDTO> listBooklist(Integer currentPage, Integer numPerPage, String name);
PageBeanNew<AppletBooklistDTO> listBooklist(Integer currentPage, Integer numPerPage, String name, Long classifyId);
/**
* 书单添加图书
......@@ -107,7 +107,7 @@ public interface AppletBooklistBiz {
* @param numPerPage
* @return
*/
PageBeanNew<AppletBooklistDTO> listBooklist4Wechat(Long classifyId, Integer currentPage, Integer numPerPage);
PageBeanNew<AppletBooklistDTO> listBooklist4Wechat(Long classifyId, Integer currentPage, Integer numPerPage, Long wechatUserId);
/**
* 客户端根据id获取书单
......@@ -124,4 +124,26 @@ public interface AppletBooklistBiz {
* @return
*/
BookDTO4Booklist getByBookIdAdviserChannel(Long adviserId, Long channelId, Long bookId);
/**
* 用户选择书单栏目
* @author:zhuyajie
* @date:2020/5/14 11:21
* * @param null
*/
void addUserBooklistClassify(List<Long> classifyIds, Long wechatUserId);
/**
* 所有书单栏目列表+用户选择的书单栏目
* @author:zhuyajie
* @date:2020/5/14 11:21
* * @param null
*/
List<AppletBooklistClassifyDTO> getAllBooklistClassify4Wechat(Long wechatUserId);
/**
* 用户选择的书单栏目
* @author:zhuyajie
* @date:2020/5/14 11:21
* * @param null
*/
List<AppletBooklistClassifyDTO> getBooklistClassifyByUser(Long wechatUserId);
}
......@@ -74,7 +74,7 @@ public interface AppletNewsBiz {
*/
PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name,
Long firstClassify,Long secondClassify,Long gradeLabelId,
Long subjectLabelId,Long rightsClassifyId,String source);
Long subjectLabelId,Long rightsClassifyId,String source, Long newsClassifyId);
/**
* 获取所有资讯栏目
......@@ -89,7 +89,7 @@ public interface AppletNewsBiz {
* @param newsClassifyId
* @return
*/
PageBeanNew<AppletNewsDTO> listAppletNews4Wechat(Integer currentPage, Integer numPerPage, Long newsClassifyId);
PageBeanNew<AppletNewsDTO> listAppletNews4Wechat(Integer currentPage, Integer numPerPage, Long newsClassifyId, Long wechatUserId);
/**
* 添加资讯评论
......@@ -171,6 +171,27 @@ public interface AppletNewsBiz {
* * @param null
*/
String getUrlNumberByUrl(String jumpUrl);
/**
* 用户选择资讯栏目
* @author:zhuyajie
* @date:2020/5/14 11:21
* * @param null
*/
void addUserNewsClassify(List<Long> newsClassifyIds, Long wechatUserId);
/**
* 所有资讯栏目列表+用户选择的资讯栏目
* @author:zhuyajie
* @date:2020/5/14 11:21
* * @param null
*/
List<AppletNewsClassifyDTO> getAllNewsClassify4Wechat(Long wechatUserId);
/**
* 用户选择的资讯栏目
* @author:zhuyajie
* @date:2020/5/14 11:21
* * @param null
*/
List<AppletNewsClassifyDTO> getNewsClassifyByUser(Long wechatUserId);
/**
* 资讯统计分析
......
......@@ -53,4 +53,28 @@ public interface AppletUserBookcaseBiz {
* * @param null
*/
void deleteByIds(List<Long> ids, Long wechatUserId);
/**
* 更新读者关于本书的阅读方式
* @param appletUserBookcase
*/
void updateUserReadType(AppletUserBookcase appletUserBookcase);
/**
* 获取读者关于本书的阅读方式
* @param wechatUserId
* @param bookId
* @param adviserId
* @param channelId
* @return
*/
AppletUserBookcase getUserReadType(Long wechatUserId, Long bookId, Long adviserId, Long channelId);
/**
* 已读书刊随机换一本书展示
* @author:zhuyajie
* @date:2020/5/15 14:49
* * @param null
*/
void randomChangeBook(Long wechatUserId);
}
......@@ -10,16 +10,19 @@ import com.pcloud.book.applet.dto.AppletBooklistDTO;
import com.pcloud.book.applet.dto.BookDTO4Booklist;
import com.pcloud.book.applet.entity.AppletBooklist;
import com.pcloud.book.applet.entity.AppletBooklistClassify;
import com.pcloud.book.applet.entity.AppletBooklistClassifyUser;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dao.BookRaysClassifyDao;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.user.AdviserConsr;
import com.pcloud.common.constant.CacheConstant;
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.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -40,6 +43,8 @@ import java.util.stream.Collectors;
@Component
public class AppletBooklistBizImpl implements AppletBooklistBiz {
private static final String BOOKLIST_BOOK = CacheConstant.BOOK+"APPLET:listBooklist4Wechat_";
@Autowired
private AppletBooklistClassifyDao appletBooklistClassifyDao;
@Autowired
......@@ -100,7 +105,7 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
appletBooklistDao.deleteById(id);
appletBooklistDao.deleteConfigByBooklistId(id);
//删除客户端缓存
JedisClusterUtils.del("BOOK:APPLET:listBooklist4Wechat_"+id);
JedisClusterUtils.del(BOOKLIST_BOOK+id);
}
@Override
......@@ -122,9 +127,10 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
}
@Override
public PageBeanNew<AppletBooklistDTO> listBooklist(Integer currentPage, Integer numPerPage, String name) {
public PageBeanNew<AppletBooklistDTO> listBooklist(Integer currentPage, Integer numPerPage, String name, Long classifyId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("name", name);
paramMap.put("classifyId", classifyId);
PageBeanNew<AppletBooklistDTO> pageBeanNew = appletBooklistDao.listPageNew(
new PageParam(currentPage,numPerPage), paramMap,"listBooklist");
if(null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())){
......@@ -156,7 +162,7 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
appletBooklistDao.deleteConfigByBooklistId(booklistId);
appletBooklistDao.addBooklistConfig(configDTOS);
//删除客户端缓存
JedisClusterUtils.del("BOOK:APPLET:listBooklist4Wechat_"+booklistId);
JedisClusterUtils.del(BOOKLIST_BOOK+booklistId);
}
@Override
......@@ -217,28 +223,36 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
}
@Override
public PageBeanNew<AppletBooklistDTO> listBooklist4Wechat(Long classifyId, Integer currentPage, Integer numPerPage){
if (null == classifyId){//没有栏目id取第一个
List<AppletBooklistClassifyDTO> classifyDTOS = getAllBooklistClassify(true);
if (ListUtils.isEmpty(classifyDTOS)){
throw new BookBizException(BookBizException.ERROR,"没有书单栏目");
public PageBeanNew<AppletBooklistDTO> listBooklist4Wechat(Long classifyId, Integer currentPage, Integer numPerPage, Long wechatUserId) {
Map<String, Object> map = new HashMap<>();
if (null == classifyId) {//首页书单推荐
List<Long> classifyIds = appletBooklistClassifyDao.getClassifyIdsByUserId(wechatUserId);
if (ListUtils.isEmpty(classifyIds)) {//没有栏目id取第一个
List<AppletBooklistClassifyDTO> classifyDTOS = getAllBooklistClassify(true);
if (ListUtils.isEmpty(classifyDTOS)) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
classifyId = classifyDTOS.get(0).getId();
classifyIds.add(classifyId);
}
classifyId = classifyDTOS.get(0).getId();
map.put("classifyIdList", classifyIds);
map.put("order", 1);
} else {
map.put("classifyId", classifyId);
}
Map<String,Object> map = new HashMap<>();
map.put("classifyId", classifyId);
PageBeanNew<AppletBooklistDTO> pageBeanNew = appletBooklistDao.listPageNew(
new PageParam(currentPage, numPerPage), map, "listBooklist4Wechat");
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())){
return new PageBeanNew<>(currentPage,numPerPage,0,new ArrayList<>());
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
for (AppletBooklistDTO booklistDTO : pageBeanNew.getRecordList()){
for (AppletBooklistDTO booklistDTO : pageBeanNew.getRecordList()) {
Long booklistId = booklistDTO.getId();
String key = "BOOK:APPLET:listBooklist4Wechat_"+booklistId;
List<BookDTO4Booklist> bookList = JedisClusterUtils.getJsonList(key,BookDTO4Booklist.class);
if (ListUtils.isEmpty(bookList)){
bookList=appletBooklistDao.getBookBaseByBooklistId(booklistId, 0,3);
JedisClusterUtils.setJson(key,bookList);
String key = BOOKLIST_BOOK + booklistId;
List<BookDTO4Booklist> bookList = JedisClusterUtils.getJsonList(key, BookDTO4Booklist.class);
if (ListUtils.isEmpty(bookList)) {
bookList = appletBooklistDao.getBookBaseByBooklistId(booklistId, 0, 3);
JedisClusterUtils.setJson(key, bookList);
JedisClusterUtils.expire(key, 3600);
}
booklistDTO.setBookDTO4Booklists(bookList);
}
......@@ -268,4 +282,52 @@ public class AppletBooklistBizImpl implements AppletBooklistBiz {
}
return bookDTO4Booklist;
}
@Override
public void addUserBooklistClassify(List<Long> classifyIds, Long wechatUserId) {
if (null == wechatUserId){
return;
}
appletBooklistClassifyDao.deleteClassifyByWechatUesrId(wechatUserId);
if (ListUtils.isEmpty(classifyIds)){
List<AppletBooklistClassifyDTO> classifyDTOS = getAllBooklistClassify(true);
if (ListUtils.isEmpty(classifyDTOS)){
return;
}
classifyIds.add(classifyDTOS.get(0).getId());
}
List<AppletBooklistClassifyUser> addList = new ArrayList<>();
for (Long classifyId : classifyIds){
AppletBooklistClassifyUser classifyUser = new AppletBooklistClassifyUser();
classifyUser.setClassifyId(classifyId);
classifyUser.setWechatUserId(wechatUserId);
addList.add(classifyUser);
}
appletBooklistClassifyDao.batchInsertUserBooklistClassify(addList);
}
@Override
public List<AppletBooklistClassifyDTO> getAllBooklistClassify4Wechat(Long wechatUserId) {
List<AppletBooklistClassifyDTO> list = appletBooklistClassifyDao.getAllBooklistClassify(true);
if (ListUtils.isEmpty(list)) {
return new ArrayList<>();
}
List<Long> chooseIds = appletBooklistClassifyDao.getClassifyIdsByUserId(wechatUserId);
if (ListUtils.isEmpty(chooseIds)) {
chooseIds.add(list.get(0).getId());
}
for (AppletBooklistClassifyDTO appletNewsClassifyDTO : list) {
if (!ListUtils.isEmpty(chooseIds) && chooseIds.contains(appletNewsClassifyDTO.getId())) {
appletNewsClassifyDTO.setChoose(true);
} else {
appletNewsClassifyDTO.setChoose(false);
}
}
return list;
}
@Override
public List<AppletBooklistClassifyDTO> getBooklistClassifyByUser(Long wechatUserId) {
return appletBooklistClassifyDao.getClassifysByUserId(wechatUserId);
}
}
......@@ -14,6 +14,7 @@ import com.pcloud.book.applet.dto.PvuvDTO;
import com.pcloud.book.applet.entity.AppletLinkClick;
import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletNewsClassify;
import com.pcloud.book.applet.entity.AppletNewsClassifyUser;
import com.pcloud.book.applet.entity.AppletNewsComment;
import com.pcloud.book.applet.enums.DataRecordTypeEnum;
import com.pcloud.book.applet.enums.DataTypeEnum;
......@@ -147,11 +148,12 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
@Override
public PageBeanNew<AppletNewsDTO> listAppletNews(Integer currentPage, Integer numPerPage, String name,
Long firstClassify,Long secondClassify,Long gradeLabelId,
Long subjectLabelId,Long rightsClassifyId,String source) {
Long subjectLabelId,Long rightsClassifyId,String source, Long newsClassifyId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("name", name);
paramMap.put("rightsClassifyId", rightsClassifyId);
paramMap.put("source", source);
paramMap.put("newsClassifyId", newsClassifyId);
//处理分类
if (null!=firstClassify){
BaseTempletClassify classify = new BaseTempletClassify();
......@@ -270,23 +272,28 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
}
@Override
public PageBeanNew<AppletNewsDTO> listAppletNews4Wechat(Integer currentPage, Integer numPerPage, Long newsClassifyId) {
if (null == newsClassifyId){//没有栏目id取第一个
List<AppletNewsClassifyDTO> classifyDTOS = getAllNewsClassify(true);
if (ListUtils.isEmpty(classifyDTOS)){
throw new BookBizException(BookBizException.ERROR,"没有资讯栏目");
public PageBeanNew<AppletNewsDTO> listAppletNews4Wechat(Integer currentPage, Integer numPerPage, Long newsClassifyId, Long wechatUserId) {
Map<String, Object> paramMap = new HashMap<>();
if (null == newsClassifyId) {//首页资讯
List<Long> classifyIds = appletNewsClassifyDao.getClassifyIdsByUserId(wechatUserId);
if (ListUtils.isEmpty(classifyIds)) {//没有栏目id取第一个
List<AppletNewsClassifyDTO> classifyDTOS = getAllNewsClassify(true);
if (ListUtils.isEmpty(classifyDTOS)) {
return new PageBeanNew<>(currentPage, numPerPage, new ArrayList<>());
}
newsClassifyId = classifyDTOS.get(0).getId();
classifyIds.add(newsClassifyId);
}
newsClassifyId = classifyDTOS.get(0).getId();
paramMap.put("newsClassifyIdList", classifyIds);
paramMap.put("order", 1);
} else {//栏目下的资讯
paramMap.put("newsClassifyId", newsClassifyId);
}
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("newsClassifyId", newsClassifyId);
paramMap.put("showState",true);
PageBeanNew<AppletNewsDTO> pageBeanNew = appletNewsDao.listPageNew(
new PageParam(currentPage,numPerPage) ,paramMap,"listAppletNews");
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())){
return new PageBeanNew<>(currentPage,numPerPage,0,new ArrayList<>());
new PageParam(currentPage, numPerPage), paramMap, "listAppletNews4Wechat");
if (null == pageBeanNew || ListUtils.isEmpty(pageBeanNew.getRecordList())) {
return new PageBeanNew<>(currentPage, numPerPage, 0, new ArrayList<>());
}
fillLabel(pageBeanNew.getRecordList());
return pageBeanNew;
}
......@@ -517,4 +524,52 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
return exist;
}
@Override
public void addUserNewsClassify(List<Long> newsClassifyIds, Long wechatUserId) {
if (null == wechatUserId){
return;
}
appletNewsClassifyDao.deleteClassifyByWechatUesrId(wechatUserId);
if (ListUtils.isEmpty(newsClassifyIds)){
List<AppletNewsClassifyDTO> list = appletNewsClassifyDao.getAllNewsClassify(true);
if (ListUtils.isEmpty(list)){
return;
}
newsClassifyIds.add(list.get(0).getId());
}
List<AppletNewsClassifyUser> addList = new ArrayList<>();
for (Long classifyId : newsClassifyIds){
AppletNewsClassifyUser classifyUser = new AppletNewsClassifyUser();
classifyUser.setNewsClassifyId(classifyId);
classifyUser.setWechatUserId(wechatUserId);
addList.add(classifyUser);
}
appletNewsClassifyDao.batchInsertUserNewsClassify(addList);
}
@Override
public List<AppletNewsClassifyDTO> getAllNewsClassify4Wechat(Long wechatUserId) {
List<AppletNewsClassifyDTO> list = appletNewsClassifyDao.getAllNewsClassify(true);
if (ListUtils.isEmpty(list)) {
return new ArrayList<>();
}
List<Long> chooseIds = appletNewsClassifyDao.getClassifyIdsByUserId(wechatUserId);
if (ListUtils.isEmpty(chooseIds)) {
chooseIds.add(list.get(0).getId());
}
for (AppletNewsClassifyDTO appletNewsClassifyDTO : list) {
if (!ListUtils.isEmpty(chooseIds) && chooseIds.contains(appletNewsClassifyDTO.getId())) {
appletNewsClassifyDTO.setChoose(true);
} else {
appletNewsClassifyDTO.setChoose(false);
}
}
return list;
}
@Override
public List<AppletNewsClassifyDTO> getNewsClassifyByUser(Long wechatUserId) {
return appletNewsClassifyDao.getClassifysByUserId(wechatUserId);
}
}
......@@ -17,6 +17,7 @@ import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
......@@ -37,6 +38,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
import java.util.stream.Collectors;
/**
......@@ -64,7 +66,6 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
@Override
public void addUserBook(AppletUserBookcase appletUserBookcase) {
//数据库去重
appletUserBookcaseDao.deleteByBookIdUserId(appletUserBookcase);
appletUserBookcaseDao.insert(appletUserBookcase);
Long wechatUserId = appletUserBookcase.getWechatUserId();
JedisClusterUtils.del(USER_BOOK_CASE + wechatUserId);
......@@ -215,9 +216,42 @@ public class AppletUserBookcaseBizImpl implements AppletUserBookcaseBiz {
@Override
public void deleteByIds(List<Long> ids, Long wechatUserId) {
if (ListUtils.isEmpty(ids)){
return;
}
appletUserBookcaseDao.deleteByIds(ids);
JedisClusterUtils.del(USER_BOOK_CASE + wechatUserId);
JedisClusterUtils.del(USER_BOOK_CASE_COUNT + wechatUserId);
}
@Override
@ParamLog("更新读者关于本书的阅读方式")
public void updateUserReadType(AppletUserBookcase appletUserBookcase) {
appletUserBookcaseDao.updateUserReadType(appletUserBookcase);
}
@Override
@ParamLog("获取用户当前本书的阅读方式")
public AppletUserBookcase getUserReadType(Long wechatUserId, Long bookId, Long adviserId, Long channelId) {
AppletUserBookcase appletUserBookcase = appletUserBookcaseDao.getUserReadType(wechatUserId,bookId,adviserId,channelId);
return appletUserBookcase;
}
@Override
public void randomChangeBook(Long wechatUserId) {
List<AppletUserBookcase> bookcaseList = appletUserBookcaseDao.getListByUserId(wechatUserId);
//无书或只有一本不处理
if (ListUtils.isEmpty(bookcaseList) || bookcaseList.size()==1){
return;
}
//去除最近一本书
bookcaseList.remove(0);
//随机取一本书埋点
AppletUserBookcase appletUserBookcase = bookcaseList.get(new Random().nextInt(bookcaseList.size()));
this.addUserBook(appletUserBookcase);
ThreadPoolUtils.OTHER_THREAD_POOL.execute(()->{
this.listByWechatUserId(wechatUserId,0,1);
});
}
}
......@@ -2,6 +2,7 @@ package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.dto.AppletBooklistClassifyDTO;
import com.pcloud.book.applet.entity.AppletBooklistClassify;
import com.pcloud.book.applet.entity.AppletBooklistClassifyUser;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
......@@ -18,4 +19,36 @@ public interface AppletBooklistClassifyDao extends BaseDao<AppletBooklistClassif
* @return
*/
List<AppletBooklistClassifyDTO> getAllBooklistClassify(Boolean showState);
/**
* 用户选择书单栏目
* @author:zhuyajie
* @date:2020/5/14 11:15
* * @param null
*/
void batchInsertUserBooklistClassify(List<AppletBooklistClassifyUser> booklistClassifyUsers);
/**
* 用户删除书单栏目
*
* @author:zhuyajie
* @date:2020/5/14 11:15 * @param null
*/
void deleteClassifyByWechatUesrId(Long wechatUserId);
/**
* 获取用户选择的书单栏目id
*
* @author:zhuyajie
* @date:2020/5/14 11:18 * @param null
*/
List<Long> getClassifyIdsByUserId(Long wechatUserId);
/**
* 获取用户选择的书单栏目
*
* @author:zhuyajie
* @date:2020/5/14 11:32 * @param null
*/
List<AppletBooklistClassifyDTO> getClassifysByUserId(Long wechatUserId);
}
......@@ -2,6 +2,7 @@ package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.dto.AppletNewsClassifyDTO;
import com.pcloud.book.applet.entity.AppletNewsClassify;
import com.pcloud.book.applet.entity.AppletNewsClassifyUser;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
......@@ -19,4 +20,35 @@ public interface AppletNewsClassifyDao extends BaseDao<AppletNewsClassify> {
* @return
*/
List<AppletNewsClassifyDTO> getAllNewsClassify(Boolean showState);
/**
* 用户选择资讯栏目
* @author:zhuyajie
* @date:2020/5/14 11:15
* * @param null
*/
void batchInsertUserNewsClassify(List<AppletNewsClassifyUser> appletNewsClassifyUsers);
/**
* 用户删除资讯栏目
*
* @author:zhuyajie
* @date:2020/5/14 11:15 * @param null
*/
void deleteClassifyByWechatUesrId(Long wechatUserId);
/**
* 获取用户选择的资讯栏目id
*
* @author:zhuyajie
* @date:2020/5/14 11:18 * @param null
*/
List<Long> getClassifyIdsByUserId(Long wechatUserId);
/**
* 获取用户选择的资讯栏目
*
* @author:zhuyajie
* @date:2020/5/14 11:32 * @param null
*/
List<AppletNewsClassifyDTO> getClassifysByUserId(Long wechatUserId);
}
......@@ -56,4 +56,15 @@ public interface AppletUserBookcaseDao extends BaseDao<AppletUserBookcase> {
* * @param null
*/
void deleteByIds(List<Long> ids);
void updateUserReadType(AppletUserBookcase appletUserBookcase);
AppletUserBookcase getUserReadType(Long wechatUserId, Long bookId, Long adviserId, Long channelId);
/**
* 查书架列表
* @author:zhuyajie
* @date:2020/5/15
* * @param null
*/
List<AppletUserBookcase> getListByUserId(Long wechatUserId);
}
......@@ -3,7 +3,9 @@ package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletBooklistClassifyDao;
import com.pcloud.book.applet.dto.AppletBooklistClassifyDTO;
import com.pcloud.book.applet.entity.AppletBooklistClassify;
import com.pcloud.book.applet.entity.AppletBooklistClassifyUser;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
......@@ -25,4 +27,24 @@ public class AppletBooklistClassifyDaoImpl extends BaseDaoImpl<AppletBooklistCla
map.put("showState", showState);
return getSessionTemplate().selectList(getStatement("getAllBooklistClassify"), map);
}
@Override
public void batchInsertUserBooklistClassify(List<AppletBooklistClassifyUser> booklistClassifyUsers) {
getSessionTemplate().insert(getStatement("batchInsertUserBooklistClassify"), booklistClassifyUsers);
}
@Override
public void deleteClassifyByWechatUesrId(Long wechatUserId) {
getSessionTemplate().delete(getStatement("deleteClassifyByWechatUesrId"), wechatUserId);
}
@Override
public List<Long> getClassifyIdsByUserId(Long wechatUserId) {
return getSessionTemplate().selectList(getStatement("getClassifyIdsByUserId"), wechatUserId);
}
@Override
public List<AppletBooklistClassifyDTO> getClassifysByUserId(Long wechatUserId) {
return getSessionTemplate().selectList(getStatement("getClassifysByUserId"), wechatUserId);
}
}
......@@ -3,7 +3,9 @@ package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.dao.AppletNewsClassifyDao;
import com.pcloud.book.applet.dto.AppletNewsClassifyDTO;
import com.pcloud.book.applet.entity.AppletNewsClassify;
import com.pcloud.book.applet.entity.AppletNewsClassifyUser;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
......@@ -23,4 +25,24 @@ public class AppletNewsClassifyDaoImpl extends BaseDaoImpl<AppletNewsClassify> i
map.put("showState", showState);
return getSessionTemplate().selectList(getStatement("getAllNewsClassify"), map);
}
@Override
public void batchInsertUserNewsClassify(List<AppletNewsClassifyUser> appletNewsClassifyUsers) {
getSessionTemplate().insert(getStatement("batchInsertUserNewsClassify"), appletNewsClassifyUsers);
}
@Override
public void deleteClassifyByWechatUesrId(Long wechatUserId) {
getSessionTemplate().delete(getStatement("deleteClassifyByWechatUesrId"), wechatUserId);
}
@Override
public List<Long> getClassifyIdsByUserId(Long wechatUserId) {
return getSessionTemplate().selectList(getStatement("getClassifyIdsByUserId"),wechatUserId);
}
@Override
public List<AppletNewsClassifyDTO> getClassifysByUserId(Long wechatUserId) {
return getSessionTemplate().selectList(getStatement("getClassifysByUserId"), wechatUserId);
}
}
......@@ -66,4 +66,24 @@ public class AppletUserBookcaseDaoImpl extends BaseDaoImpl<AppletUserBookcase> i
public void deleteByIds(List<Long> list) {
getSessionTemplate().delete(getStatement("deleteByIds"), list);
}
@Override
public void updateUserReadType(AppletUserBookcase appletUserBookcase) {
getSessionTemplate().update(getStatement("updateUserReadType"),appletUserBookcase);
}
@Override
public AppletUserBookcase getUserReadType(Long wechatUserId, Long bookId, Long adviserId, Long channelId) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("wechatUserId",wechatUserId);
paramMap.put("bookId",bookId);
paramMap.put("adviserId",adviserId);
paramMap.put("channelId",channelId);
return getSessionTemplate().selectOne(getStatement("getUserReadType"),paramMap);
}
@Override
public List<AppletUserBookcase> getListByUserId(Long wechatUserId) {
return getSessionTemplate().selectList(getStatement("getListByUserId"), wechatUserId);
}
}
......@@ -23,4 +23,10 @@ public class AppletBooklistClassifyDTO extends BaseDto {
@ApiModelProperty("是否展示")
private Boolean showState;
@ApiModelProperty("图标")
private String pic;
@ApiModelProperty("用户是否选择")
private Boolean choose;
}
......@@ -24,5 +24,9 @@ public class AppletNewsClassifyDTO extends BaseDto {
@ApiModelProperty("资讯数量")
private Integer newsCount;
@ApiModelProperty("图标")
private String pic;
@ApiModelProperty("用户是否选择")
private Boolean choose;
}
......@@ -29,4 +29,7 @@ public class UserLastBookReDTO {
@ApiModelProperty("权益id")
private Long rightSettingId;
@ApiModelProperty("阅读方式")
private Integer readType;
}
......@@ -17,4 +17,7 @@ public class AppletBooklistClassify extends BaseEntity {
@ApiModelProperty("是否展示")
private Boolean showState;
@ApiModelProperty("图标")
private String pic;
}
package com.pcloud.book.applet.entity;
import java.util.Date;
import java.io.Serializable;
import lombok.Data;
/**
* 用户书单栏目选择(AppletBooklistClassifyUser)实体类
*
* @author makejava
* @since 2020-05-14 14:40:31
*/
@Data
public class AppletBooklistClassifyUser implements Serializable {
private static final long serialVersionUID = -92412747639655546L;
private Long id;
/**
* 书单栏目id
*/
private Long classifyId;
private Long wechatUserId;
/**
* 创建时间
*/
private Date createTime;
}
\ No newline at end of file
......@@ -17,4 +17,7 @@ public class AppletNewsClassify extends BaseEntity {
@ApiModelProperty("是否展示")
private Boolean showState;
@ApiModelProperty("图标")
private String pic;
}
package com.pcloud.book.applet.entity;
import java.util.Date;
import java.io.Serializable;
import lombok.Data;
/**
* 用户咨询栏目选择(AppletNewsClassifyUser)实体类
*
* @author makejava
* @since 2020-05-14 11:13:03
*/
@Data
public class AppletNewsClassifyUser implements Serializable {
private static final long serialVersionUID = -80975015210568526L;
private Long id;
/**
* 栏目id
*/
private Long newsClassifyId;
/**
* 用户id
*/
private Long wechatUserId;
private Date createTime;
}
\ No newline at end of file
......@@ -20,4 +20,7 @@ public class AppletUserBookcase extends BaseEntity {
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("阅读类型")
private Integer readType;
}
......@@ -178,12 +178,13 @@ public class AppletHomeFacade {
@RequestHeader("token") String token,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage,
@RequestParam(value = "name", required = false) @ApiParam("名称查询") String name) throws PermissionException {
@RequestParam(value = "name", required = false) @ApiParam("名称查询") String name,
@RequestParam(value = "classifyId", required = false) @ApiParam("书单栏目id") Long classifyId) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
}
return new ResponseDto<>(appletBooklistBiz.listBooklist(currentPage, numPerPage, name));
return new ResponseDto<>(appletBooklistBiz.listBooklist(currentPage, numPerPage, name, classifyId));
}
@ApiOperation("书单添加图书")
......@@ -320,13 +321,15 @@ public class AppletHomeFacade {
@ApiOperation("客户端获取书单列表")
@GetMapping("listBooklist4Wechat")
public ResponseDto<PageBeanNew<AppletBooklistDTO>> listBooklist4Wechat(
@CookieValue("userInfo") String userInfo,
@RequestParam(value = "classifyId", required = false) @ApiParam("书单栏目id") Long classifyId,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage){
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
}
return new ResponseDto<>(appletBooklistBiz.listBooklist4Wechat(classifyId,currentPage,numPerPage));
return new ResponseDto<>(appletBooklistBiz.listBooklist4Wechat(classifyId,currentPage,numPerPage,wechatUserId));
}
@ApiOperation("客户端根据id获取书单")
......@@ -448,26 +451,29 @@ public class AppletHomeFacade {
@RequestParam(value = "gradeLabelId", required = false) @ApiParam("年级标签")Long gradeLabelId,
@RequestParam(value = "subjectLabelId", required = false) @ApiParam("科目标签")Long subjectLabelId,
@RequestParam(value = "rightsClassifyId", required = false) @ApiParam("权益分类") Long rightsClassifyId,
@RequestParam(value = "source", required = false) @ApiParam("来源") String source
@RequestParam(value = "source", required = false) @ApiParam("来源") String source,
@RequestParam(value = "newsClassifyId", required = false) @ApiParam("资讯栏目id") Long newsClassifyId
) throws PermissionException {
SessionUtil.getInfoToken4Redis(token);
if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
}
return new ResponseDto<>(appletNewsBiz.listAppletNews(currentPage, numPerPage, name, firstClassify,secondClassify,gradeLabelId,
subjectLabelId,rightsClassifyId,source));
subjectLabelId,rightsClassifyId,source,newsClassifyId));
}
@ApiOperation("客户端资讯列表")
@GetMapping("listAppletNews4Wechat")
public ResponseDto<PageBeanNew<AppletNewsDTO>> listAppletNews4Wechat(
@CookieValue("userInfo") String userInfo,
@RequestParam("currentPage") @ApiParam("当前页") Integer currentPage,
@RequestParam("numPerPage") @ApiParam("每页数量") Integer numPerPage,
@RequestParam(value = "newsClassifyId", required = false) @ApiParam("资讯栏目id") Long newsClassifyId) {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null==currentPage || null == numPerPage){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少分页参数");
}
return new ResponseDto<>(appletNewsBiz.listAppletNews4Wechat(currentPage, numPerPage, newsClassifyId));
return new ResponseDto<>(appletNewsBiz.listAppletNews4Wechat(currentPage, numPerPage, newsClassifyId, wechatUserId));
}
@ApiOperation("添加资讯评论")
......@@ -606,13 +612,14 @@ public class AppletHomeFacade {
@RequestParam(value = "adviserId") Long adviserId,
@RequestParam(value = "bookId") Long bookId,
@RequestParam(value = "rightsSettingId") Long rightsSettingId,
@RequestParam(value = "channelId") Long channelId
@RequestParam(value = "channelId") Long channelId,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType
) {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null == wechatUserId){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
return new ResponseDto<>(pcloudGroupActivityBiz.getGroupActivity4Applet(rightsSettingId, adviserId ,bookId, channelId));
return new ResponseDto<>(pcloudGroupActivityBiz.getGroupActivity4Applet(rightsSettingId, adviserId ,bookId, channelId, readType));
}
@ApiOperation("资讯来源列表")
......@@ -707,6 +714,89 @@ public class AppletHomeFacade {
subjectLabelId, linkOnly,rightsClassifyId));
}
@ApiOperation("用户选择资讯栏目")
@PostMapping("addUserNewsClassify")
public ResponseDto<?> addUserNewsClassify(@CookieValue("userInfo") String userInfo, @RequestBody List<Long> newsClassifyIds){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appletNewsBiz.addUserNewsClassify(newsClassifyIds,wechatUserId);
return new ResponseDto<>();
}
@ApiOperation("所有资讯栏目列表+用户选择的资讯栏目")
@GetMapping("getAllNewsClassify4Wechat")
public ResponseDto<List<AppletNewsClassifyDTO>> getAllNewsClassify4Wechat(@CookieValue("userInfo") String userInfo){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletNewsBiz.getAllNewsClassify4Wechat(wechatUserId));
}
@ApiOperation("用户选择的资讯栏目")
@GetMapping("getNewsClassifyByUser")
public ResponseDto<List<AppletNewsClassifyDTO>> getNewsClassifyByUser(@CookieValue("userInfo") String userInfo){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletNewsBiz.getNewsClassifyByUser(wechatUserId));
}
@ApiOperation("用户选择书单栏目")
@PostMapping("addUserBooklistClassify")
public ResponseDto<?> addUserBooklistClassify(@CookieValue("userInfo") String userInfo, @RequestBody List<Long> classifyIds) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appletBooklistBiz.addUserBooklistClassify(classifyIds, wechatUserId);
return new ResponseDto<>();
}
@ApiOperation("所有书单栏目列表+用户选择的书单栏目")
@GetMapping("getAllBooklistClassify4Wechat")
public ResponseDto<List<AppletBooklistClassifyDTO>> getAllBooklistClassify4Wechat(@CookieValue("userInfo") String userInfo) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletBooklistBiz.getAllBooklistClassify4Wechat(wechatUserId));
}
@ApiOperation("用户选择的书单栏目")
@GetMapping("getBooklistClassifyByUser")
public ResponseDto<List<AppletBooklistClassifyDTO>> getBooklistClassifyByUser(@CookieValue("userInfo") String userInfo) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(appletBooklistBiz.getBooklistClassifyByUser(wechatUserId));
}
@ApiOperation("已读书刊随机换一本书展示")
@GetMapping("randomChangeBook")
public ResponseDto<?> randomChangeBook(@CookieValue("userInfo") String userInfo){
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
appletUserBookcaseBiz.randomChangeBook(wechatUserId);
return new ResponseDto<>();
}
@ApiOperation("更新读者关于本书的阅读方式")
@PostMapping("updateUserReadType")
public ResponseDto<?> updateUserReadType(
@CookieValue("userInfo") String userInfo,
@RequestBody @ApiParam("图书") AppletUserBookcase appletUserBookcase){
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null == appletUserBookcase || null == appletUserBookcase.getBookId() || null == appletUserBookcase.getAdviserId()
|| null == appletUserBookcase.getChannelId()){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
appletUserBookcase.setWechatUserId(wechatUserId);
appletUserBookcaseBiz.updateUserReadType(appletUserBookcase);
return new ResponseDto<>();
}
@ApiOperation("获取用户当前本书的阅读方式")
@GetMapping("getUserReadType")
public ResponseDto<AppletUserBookcase> getUserReadType(
@CookieValue("userInfo") String userInfo,
@RequestParam("bookId") Long bookId,
@RequestParam("adviserId") Long adviserId,
@RequestParam("channelId") Long channelId) {
Long wechatUserId = Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null == bookId || null == adviserId || null == channelId){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"缺少参数");
}
AppletUserBookcase appletUserBookcase = appletUserBookcaseBiz.getUserReadType(wechatUserId,bookId,adviserId,channelId);
return new ResponseDto<>(appletUserBookcase);
}
}
......
......@@ -8,7 +8,6 @@ import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
......@@ -43,7 +42,7 @@ public interface RightsSettingBiz {
* @param rightsType
* @return
*/
List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType);
List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType);
/**
* 小程序首页权益查询
......@@ -61,7 +60,7 @@ public interface RightsSettingBiz {
* @param rightsType
* @return
*/
RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType);
RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType);
/**
* 每周/长期权益查询--小程序
......@@ -70,7 +69,7 @@ public interface RightsSettingBiz {
* @param wechatUserId
* @return
*/
List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId);
List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType);
/**
* 查所有权益分类
......@@ -96,22 +95,24 @@ public interface RightsSettingBiz {
* @Param [rightsSettingId, wechatUserId, type]
* @return com.pcloud.book.rightsSetting.entity.RightsSetting
**/
RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type, Long adviserId, Long bookId, Long channelId);
RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type, Long adviserId, Long bookId, Long channelId, Integer readType);
RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId);
RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId, Integer readType);
FillRightsSettingAppletsDTO getFillRightsSettingApplets(Long rightsSettingId, Long wechatUserId, Long rightsClassifyId,
Integer top);
List<RightsItemGroup> getRightsItemGroups(Long rightsSettingId, Long adviserId, Long bookId, Long channelId, Boolean removeCanNotBuy);
List<RightsItemGroup> getRightsItemGroups(Long rightsSettingId, Long adviserId, Long bookId, Long channelId, Boolean removeCanNotBuy, Integer readType);
RightsSettingDto getRightSettingByBookId(Long bookId, Long adviserId, Long channelId);
List<RightsNowPic> getAllDefaultRightsNowPics();
List<RightsNowPic> getAllDefaultRightsNowPics(Integer type);
void addRightsNowPic(RightsNowPic rightsNowPic);
PageBeanNew<RightsNowPic> getRightsNowPics(Integer currentPage, Integer numPerPage);
PageBeanNew<RightsNowPic> getRightsNowPics(Integer currentPage, Integer numPerPage, Integer type);
void deleteRightsNowPic(Long rightsNowPicId);
RightsSettingDto getReadType4Book(Long wechatUserId, Long bookId, Long channelId, Long adviserId);
}
......@@ -3,17 +3,21 @@ package com.pcloud.book.rightsSetting.biz.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.biz.AppletUserBookcaseBiz;
import com.pcloud.book.applet.dao.AppletNewsDao;
import com.pcloud.book.applet.dto.AppletGroupStatementDTO;
import com.pcloud.book.applet.dto.AppletNewsDTO;
import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletUserBookcase;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookAdviserBiz;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dto.BookAdviserDto;
import com.pcloud.book.book.dto.BookDto;
......@@ -23,6 +27,7 @@ import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.cultivate.enums.ReadTypeEnum;
import com.pcloud.book.custom.biz.CustomPlanBiz;
import com.pcloud.book.custom.entity.CustomPlan;
import com.pcloud.book.custom.mapper.CustomPlanMapper;
......@@ -42,6 +47,7 @@ import com.pcloud.book.rightsSetting.dao.RightsReadPlanDao;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dao.RightsSettingItemDao;
import com.pcloud.book.rightsSetting.dto.FillRightsSettingAppletsDTO;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.rightsSetting.entity.RightsCustomRelation;
......@@ -49,6 +55,7 @@ import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsReadPlan;
import com.pcloud.book.rightsSetting.entity.RightsReadType;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
......@@ -56,11 +63,11 @@ import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import com.pcloud.book.rightsSetting.enums.RightsItemGroupType;
import com.pcloud.book.rightsSetting.enums.RightsNowItemType;
import com.pcloud.book.rightsSetting.enums.RightsTypeEnum;
import com.pcloud.book.rightsSetting.mapper.RightsReadTypeMapper;
import com.pcloud.book.rightsSetting.mapper.RightsSettingTitleMapper;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.book.util.common.CommonUtils;
import com.pcloud.book.util.common.YesOrNoEnums;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
......@@ -72,7 +79,7 @@ import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
......@@ -93,6 +100,8 @@ import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class RightsSettingBizImpl implements RightsSettingBiz {
......@@ -152,9 +161,14 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Autowired
private AppletGroupSearchRecordBiz appletGroupSearchRecordBiz;
@Autowired
private RightsReadTypeMapper rightsReadTypeMapper;
@Autowired
private AppletUserBookcaseBiz appletUserBookcaseBiz;
@Override
@ParamLog("新增权益设置")
@Transactional(rollbackFor = Exception.class)
public Long addRightsSetting(RightsSetting rightsSetting) {
rightsSettingCheck.rightsSettingCheck(rightsSetting);
setClassifyAndLabel(rightsSetting);
......@@ -162,6 +176,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
throw new BookBizException(BookBizException.ERROR, "已存在相同的权益设置");
}
rightsSettingDAO.insert(rightsSetting);
Long rightsSettingId = rightsSetting.getId();
if (null == rightsSettingId){
throw new BookBizException(BookBizException.DB_DML_FAIL,"新增权益设置失败");
}
List<RightsReadType> rightsReadTypes = rightsSetting.getRightsReadTypes();
if (!ListUtils.isEmpty(rightsReadTypes)){
rightsReadTypes.forEach(e -> e.setRightsSettingId(rightsSettingId));
rightsReadTypeMapper.batchInsert(rightsReadTypes);
}
return rightsSetting.getId();
}
......@@ -209,8 +232,10 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override
@ParamLog("删除权益设置")
@Transactional(rollbackFor = Exception.class)
public void deleteRightsSetting(Long id) {
rightsSettingDAO.deleteByPrimaryKey(id);
rightsReadTypeMapper.deleteByRightsSettingId(id);
//删除即享权益项
rightsNowItemDao.deleteByRightsSettingId(id);
rightsSettingItemDao.deleteByRightsSettingId(id, null);
......@@ -231,10 +256,17 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
setClassifyAndLabel(rightsSetting);
rightsSetting.setUpdateTime(new Date());
rightsSettingDAO.updateByPrimaryKey(rightsSetting);
Long rightsSettingId = rightsSetting.getId();
//更新阅读方式
rightsReadTypeMapper.deleteByRightsSettingId(rightsSettingId);
List<RightsReadType> rightsReadTypes = rightsSetting.getRightsReadTypes();
if (!ListUtils.isEmpty(rightsReadTypes)){
rightsReadTypes.forEach(e -> e.setRightsSettingId(rightsSettingId));
rightsReadTypeMapper.batchInsert(rightsReadTypes);
}
//更新即享权益
updateRightNowItemByRightId(rightsSetting);
//新增/修改每周或长期权益
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingWeekItems(), rightsSetting.getId(), RightsTypeEnum.WEEK.value);
if (!ListUtils.isEmpty(rightsSetting.getRightsSettingWeekItems())){
for (RightsSettingItem rightsSettingItem : rightsSetting.getRightsSettingWeekItems()) {
rightsSettingItem.setUuid(StringUtil.getUUID());
......@@ -246,6 +278,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsSettingItem.setRightsSettingId(rightsSetting.getId());
rightsSettingItem.setRightsType(RightsTypeEnum.WEEK.value);
List<RightsSettingItem> list = rightsSettingItemDao.queryAll(rightsSettingItem);
//更新阅读计划
updateReadPlan(rightsSetting, list);
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingLongTermItems(), rightsSetting.getId(), RightsTypeEnum.LONG_TERM.value);
}
private void updateReadPlan(RightsSetting rightsSetting, List<RightsSettingItem> list) {
List<RightsReadPlan> rightsReadPlans = new ArrayList<>();
List<RightsCustomRelation> rightsCustomRelations = new ArrayList<>();
if (!ListUtils.isEmpty(list)) {
......@@ -277,7 +315,6 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
//批量插入rightsReadPlans和rightsCustomRelations
rightsReadPlanDao.insert(rightsReadPlans);
rightsCustomRelationDao.insert(rightsCustomRelations);
this.batchInsertRightsSettingItem(rightsSetting.getRightsSettingLongTermItems(), rightsSetting.getId(), RightsTypeEnum.LONG_TERM.value);
}
@ParamLog("更新权益的即享权益项集合")
......@@ -442,8 +479,24 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsSetting.setBookName(bookDto == null ? "" : bookDto.getBookName());
}
fillRightsNowItems(rightsSetting);
rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(),null,null,null, false));
fillGiftCouponPack(rightsSetting);
rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(),null,null,null, false, null));
fillGiftCouponPack(rightsSetting,null);
//设置每周权益
setWeekRights(rightsSetting);
//设置长期权益
rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id, RightsTypeEnum.LONG_TERM.value,null));
//设置阅读方式
setReadType(rightsSetting);
return rightsSetting;
}
private void setReadType(RightsSetting rightsSetting) {
List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSetting.getId());
rightsSetting.setRightsReadTypes(ListUtils.isEmpty(rightsReadTypes) ? new ArrayList<>() : rightsReadTypes);
}
private void setWeekRights(RightsSetting rightsSetting) {
Long id = rightsSetting.getId();
List<RightsSettingItem> rightsItems = rightsSettingItemDao.getItemsByRightsSettingId4Read(id, RightsTypeEnum.WEEK.value);
List<Long> itemIdList = new ArrayList<>();
for (RightsSettingItem item : rightsItems) {
......@@ -486,8 +539,6 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
rightsSetting.setRightsSettingWeekItems(rightsItems);
rightsSetting.setRightsSettingLongTermItems(getItemsByRightsSettingId(id, RightsTypeEnum.LONG_TERM.value));
return rightsSetting;
}
/**
......@@ -498,8 +549,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* @Param [rightsSetting, wechatUserId]
**/
@ParamLog(value = "填充线上网课", isAfterReturn = false)
private RightsSetting setOnlineCourse(RightsSetting rightsSetting, Long wechatUserId) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.ONLINE_COURSE);
private RightsSetting setOnlineCourse(RightsSetting rightsSetting, Long wechatUserId, Integer readType) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.ONLINE_COURSE,readType);
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), Collections.singletonList(RightsNowItemType.ONLINE_COURSE.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemType.ONLINE_COURSE, rightsSetting.getId(), wechatUserId, 2L, 3);
rightsSetting.setOnlineRightsSettingTitle(rightsSettingTitle);
......@@ -514,8 +565,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* @return void
**/
@ParamLog(value = "填充学习工具", isAfterReturn = false)
private RightsSetting setLearningTool(RightsSetting rightsSetting, Long wechatUserId) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.LEARNING_TOOL);
private RightsSetting setLearningTool(RightsSetting rightsSetting, Long wechatUserId, Integer readType) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.LEARNING_TOOL,readType);
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), Collections.singletonList(RightsNowItemType.LEARNING_TOOL.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemType.LEARNING_TOOL, rightsSetting.getId(), wechatUserId, 3L, 1);
rightsSetting.setLearningToolTitle(rightsSettingTitle);
......@@ -530,8 +581,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* @return void
**/
@ParamLog(value = "填充抽奖", isAfterReturn = false)
private RightsSetting setDraw(RightsSetting rightsSetting, Long wechatUserId) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.DRAW);
private RightsSetting setDraw(RightsSetting rightsSetting, Long wechatUserId, Integer readType) {
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.DRAW,readType);
List<RightsNowItem> nowItems = rightsNowItemDao.getListByRightsSettingId(rightsSetting.getId(), Collections.singletonList(RightsNowItemType.DRAW.value));
processNowItems(rightsSettingTitle, nowItems, RightsNowItemType.DRAW, rightsSetting.getId(), wechatUserId, 4L, 1);
rightsSetting.setDrawSettingTitle(rightsSettingTitle);
......@@ -539,8 +590,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
@ParamLog(value = "填充礼券包", isAfterReturn = false)
private RightsSetting setGiftCouponPackage(RightsSetting rightsSetting, Long wechatUserId) {
fillGiftCouponPack(rightsSetting);
private RightsSetting setGiftCouponPackage(RightsSetting rightsSetting, Long wechatUserId, Integer readType) {
fillGiftCouponPack(rightsSetting,readType);
fillUserGiftReceiveStatus(rightsSetting,wechatUserId);
return rightsSetting;
}
......@@ -552,8 +603,8 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* @Param [rightsSetting, learningTool]
* @return com.pcloud.book.rightsSetting.entity.RightsSettingTitle
**/
private RightsSettingTitle getRightsSettingTitle(RightsSetting rightsSetting, RightsNowItemType learningTool) {
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingId(rightsSetting.getId());
private RightsSettingTitle getRightsSettingTitle(RightsSetting rightsSetting, RightsNowItemType learningTool,Integer readType) {
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingId(rightsSetting.getId(), readType);
Map<Integer, RightsSettingTitle> rightsSettingTitleMap = new HashMap<>();
if (!ListUtils.isEmpty(rightsSettingTitles)) {
rightsSettingTitleMap = rightsSettingTitles.stream().collect(Collectors.toMap(RightsSettingTitle::getRightsSettingNowType, Function.identity()));
......@@ -575,6 +626,9 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
private void processNowItems(RightsSettingTitle rightsSettingTitle, List<RightsNowItem> nowItems, RightsNowItemType itemType,
Long rightsSettingId, Long wechatUserId, Long rightsClassifyId,
Integer top) {
if (null == rightsSettingTitle || null == rightsSettingTitle.getRightsSettingId()){
return;
}
List<RightsNowItem> items = Lists.newArrayList();
if (CollectionUtils.isEmpty(nowItems)) {
// 填充咨询
......@@ -622,7 +676,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
types.add(RightsNowItemType.ONLINE_COURSE.value);
types.add(RightsNowItemType.LEARNING_TOOL.value);
types.add(RightsNowItemType.DRAW.value);
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingId(rightsSetting.getId());
List<RightsSettingTitle> rightsSettingTitles = rightsSettingTitleMapper.getByRightSettingId(rightsSetting.getId(),null);
RightsSettingTitle rightsSettingTitler4Online = new RightsSettingTitle();
RightsSettingTitle rightsSettingTitler4Learningtool = new RightsSettingTitle();
RightsSettingTitle rightsSettingTitler4Draw = new RightsSettingTitle();
......@@ -742,9 +796,12 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
}
private void fillGiftCouponPack(RightsSetting rightsSetting) {
private void fillGiftCouponPack(RightsSetting rightsSetting, Integer readType) {
List<RightsNowItem> giftCouponPackItems = rightsNowItemDao.getGiftCouponListByRightsSettingId(rightsSetting.getId());
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.GIFT_COUPON_PACKAGE);
RightsSettingTitle rightsSettingTitle = getRightsSettingTitle(rightsSetting, RightsNowItemType.GIFT_COUPON_PACKAGE,readType);
if (null == rightsSettingTitle || null == rightsSettingTitle.getRightsSettingId()){
return;
}
if (null != rightsSetting.getGiftCouponPackageTitle()) {
// 礼券包默认开启
rightsSettingTitle.setOpenState(true);
......@@ -885,10 +942,11 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
}
@Override
public List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType) {
public List<RightsSettingItem> getItemsByRightsSettingId(Long rightsSettingId, String rightsType, Integer readType) {
RightsSettingItem item = new RightsSettingItem();
item.setRightsSettingId(rightsSettingId);
item.setRightsType(rightsType);
item.setReadType(readType);
return rightsSettingItemDao.queryAll(item);
}
......@@ -913,21 +971,21 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@Override
@ParamLog(value = "小程序首页本周/长期权益查询", isAfterReturn = false)
public RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType) {
public RightsSettingDto getItemByRightsSettingId4AppletHome(Long rightsSettingId, Long wechatUserId, String rightsType, Integer readType) {
RightsSettingDto rightsSettingDto = new RightsSettingDto();
//每周/长期权益
if (RightsTypeEnum.WEEK.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingWeekItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId));
rightsSettingDto.setRightsSettingWeekItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.WEEK.value, wechatUserId, readType));
} else if (RightsTypeEnum.LONG_TERM.value.equals(rightsType)) {
rightsSettingDto.setRightsSettingLongTermItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId));
rightsSettingDto.setRightsSettingLongTermItems(getItemsByRightsSettingId4Applet(rightsSettingId, RightsTypeEnum.LONG_TERM.value, wechatUserId, readType));
}
return rightsSettingDto;
}
@Override
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId) {
List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId, rightsType);
public List<RightsSettingItem> getItemsByRightsSettingId4Applet(Long rightsSettingId, String rightsType, Long wechatUserId, Integer readType) {
List<RightsSettingItem> list = getItemsByRightsSettingId(rightsSettingId, rightsType, readType);
if (ListUtils.isEmpty(list)) {
return new ArrayList<>();
}
......@@ -1096,52 +1154,53 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("根据权益id和类型获取即享权益项")
@Override
public RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type, Long adviserId, Long bookId, Long channelId) {
public RightsSetting getRightsSettingRightsNowItemsByType(Long rightsSettingId, Long wechatUserId, Integer type, Long adviserId, Long bookId, Long channelId, Integer readType) {
RightsSetting rightsSetting = rightsSettingDAO.selectByPrimaryKey(rightsSettingId);
if (rightsSetting == null) {
throw new BookBizException(BookBizException.ERROR, "未找到权益!");
}
// 获取配套资料
if (RightsNowItemType.SERVES.value.equals(type)){
return setServe(rightsSetting,adviserId, bookId, channelId);
return setServe(rightsSetting,adviserId, bookId, channelId, readType);
}
// 获取抽奖权益
if (RightsNowItemType.DRAW.value.equals(type)) {
return setDraw(rightsSetting, wechatUserId);
return setDraw(rightsSetting, wechatUserId, readType);
}
// 获取学习工具权益
if (RightsNowItemType.LEARNING_TOOL.value.equals(type)) {
return setLearningTool(rightsSetting, wechatUserId);
return setLearningTool(rightsSetting, wechatUserId, readType);
}
// 获取线上网课权益
if (RightsNowItemType.ONLINE_COURSE.value.equals(type)) {
return setOnlineCourse(rightsSetting, wechatUserId);
return setOnlineCourse(rightsSetting, wechatUserId, readType);
}
// 获取专享礼券包权益
if (RightsNowItemType.GIFT_COUPON_PACKAGE.value.equals(type)) {
return setGiftCouponPackage(rightsSetting, wechatUserId);
return setGiftCouponPackage(rightsSetting, wechatUserId, readType);
}
return rightsSetting;
}
@ParamLog(value = "填充配套资料", isAfterReturn = false)
private RightsSetting setServe(RightsSetting rightsSetting,Long adviserId, Long bookId, Long channelId) {
RightsSettingTitle rightsSettingTitle = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSetting.getId(),RightsNowItemType.SERVES.value);
private RightsSetting setServe(RightsSetting rightsSetting,Long adviserId, Long bookId, Long channelId, Integer readType) {
RightsSettingTitle rightsSettingTitle = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSetting.getId(),RightsNowItemType.SERVES.value, null);
rightsSetting.setServesTitle(rightsSettingTitle != null ? rightsSettingTitle : new RightsSettingTitle());
rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(), adviserId, bookId, channelId, true));
rightsSetting.setRightsItemGroups(getRightsItemGroups(rightsSetting.getId(), adviserId, bookId, channelId, true, readType));
return rightsSetting;
}
@ParamLog("根据权益id获取即享权益项专享礼包")
@Override
public RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId) {
public RightsSetting getRightsSettingGiftCoupons(Long rightsSettingId, Long wechatUserId, Integer readType) {
RightsSetting rightsSetting = new RightsSetting();
rightsSetting.setId(rightsSettingId);
RightsSettingTitle rightsSettingTitle4Gift = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSettingId, RightsNowItemType.GIFT_COUPON_PACKAGE.value);
if (null != rightsSettingTitle4Gift) {
rightsSetting.setGiftCouponPackageTitle(rightsSettingTitle4Gift);
RightsSettingTitle rightsSettingTitle4Gift = rightsSettingTitleMapper.getByRightSettingIdAndType(rightsSettingId, RightsNowItemType.GIFT_COUPON_PACKAGE.value, readType);
if (null == rightsSettingTitle4Gift || null == rightsSettingTitle4Gift.getRightsSettingId()){
return rightsSetting;
}
fillGiftCouponPack(rightsSetting);
rightsSetting.setGiftCouponPackageTitle(rightsSettingTitle4Gift);
fillGiftCouponPack(rightsSetting, readType);
fillUserGiftReceiveStatus(rightsSetting, wechatUserId);
return rightsSetting;
}
......@@ -1197,11 +1256,11 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("根据权益id获取即享权益配套资料分组集合")
@Override
public List<RightsItemGroup> getRightsItemGroups(Long rightsSettingId, Long adviserId, Long bookId, Long channelId, Boolean removeCanNotBuy) {
public List<RightsItemGroup> getRightsItemGroups(Long rightsSettingId, Long adviserId, Long bookId, Long channelId, Boolean removeCanNotBuy, Integer readType) {
if (rightsSettingId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
List<RightsItemGroup> groups = rightsItemGroupDao.getListByRightSettingId(rightsSettingId);
List<RightsItemGroup> groups = rightsItemGroupDao.getListByRightSettingId(rightsSettingId, readType);
if (ListUtils.isEmpty(groups)) {
return groups;
}
......@@ -1254,15 +1313,15 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("获取即享权益图片库")
@Override
public List<RightsNowPic> getAllDefaultRightsNowPics() {
return rightsNowPicDao.getAllDefaultRightsNowPics();
public List<RightsNowPic> getAllDefaultRightsNowPics(Integer type) {
return rightsNowPicDao.getAllDefaultRightsNowPics(type);
}
@ParamLog("新增即享权益图片")
@Transactional(rollbackFor = Exception.class)
@Override
public void addRightsNowPic(RightsNowPic rightsNowPic) {
if (rightsNowPic==null||StringUtil.isEmpty(rightsNowPic.getPicUrl())){
if (rightsNowPic==null||StringUtil.isEmpty(rightsNowPic.getPicUrl())||null==rightsNowPic.getType()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
}
rightsNowPic.setDefaultPic(false);
......@@ -1271,11 +1330,13 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("获取即享权益图片列表")
@Override
public PageBeanNew<RightsNowPic> getRightsNowPics(Integer currentPage, Integer numPerPage) {
public PageBeanNew<RightsNowPic> getRightsNowPics(Integer currentPage, Integer numPerPage, Integer type) {
if (currentPage==null||numPerPage==null||currentPage<0||numPerPage<=0){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
}
PageBeanNew<RightsNowPic> pageNew = rightsNowPicDao.listPageNew(new PageParam(currentPage, numPerPage), new HashMap<>(), "getRightsNowPics");
Map<String, Object> map = new HashMap<>();
map.put("type", type);
PageBeanNew<RightsNowPic> pageNew = rightsNowPicDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getRightsNowPics");
return pageNew;
}
......@@ -1289,6 +1350,58 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
rightsNowPicDao.deleteById(rightsNowPicId);
}
@Override
@ParamLog("获取当前图书的阅读方式")
public RightsSettingDto getReadType4Book(Long wechatUserId, Long bookId, Long channelId, Long adviserId) {
RightsSettingDto rightsSettingDto = rightsSettingDAO.getByBookId(bookId);
AppletUserBookcase appletUserBookcase = appletUserBookcaseBiz.getUserReadType(wechatUserId,bookId,adviserId,channelId);
Integer chooseReadType = null == appletUserBookcase || null == appletUserBookcase.getReadType() ? null :
appletUserBookcase.getReadType();
if (null != rightsSettingDto) {
Long rightsSettingId = rightsSettingDto.getId();
ReadTypeCountDTO readTypeCountDTO = rightsSettingTitleMapper.getCount4Title(rightsSettingId);
List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSettingId);
setReadType(rightsSettingDto, readTypeCountDTO, rightsReadTypes);
rightsSettingDto.setChooseReadType(chooseReadType);
return rightsSettingDto;
}
//根据分类获取权益
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
if (null != adviserDto) {
rightsSettingDto = getByLabel(adviserDto.getTempletId(), adviserDto.getSecondTempletId(), adviserDto.getGraLabelId(),
adviserDto.getSubLabelId());
if (null == rightsSettingDto) {
log.error("该书没有匹配的分类权益,bookId=" + bookId);
return new RightsSettingDto();
}
List<RightsReadType> rightsReadTypes = rightsReadTypeMapper.getByRightsSettingId(rightsSettingDto.getId());
ReadTypeCountDTO readTypeCountDTO = rightsSettingTitleMapper.getCount4Title(rightsSettingDto.getId());
setReadType(rightsSettingDto, readTypeCountDTO, rightsReadTypes);
rightsSettingDto.setChooseReadType(chooseReadType);
}
return rightsSettingDto;
}
private void setReadType(RightsSettingDto rightsSettingDto, ReadTypeCountDTO readTypeCountDTO, List<RightsReadType> rightsReadTypes) {
if (!ListUtils.isEmpty(rightsReadTypes) && null != readTypeCountDTO && (
!Objects.equals(BookConstant.zero,readTypeCountDTO.getEasyReadCount()) ||
!Objects.equals(BookConstant.zero,readTypeCountDTO.getEfficientReadCount()) ||
!Objects.equals(BookConstant.zero,readTypeCountDTO.getDeepReadCount())
)){
rightsReadTypes.forEach(e -> {
if (ReadTypeEnum.QS_READ.value.equals(e.getReadType())) {
e.setRightsCount(readTypeCountDTO.getEasyReadCount());
} else if (ReadTypeEnum.GX_READ.value.equals(e.getReadType())) {
e.setRightsCount(readTypeCountDTO.getEfficientReadCount());
} else if (ReadTypeEnum.SD_READ.value.equals(e.getReadType())) {
e.setRightsCount(readTypeCountDTO.getDeepReadCount());
}
});
}
rightsSettingDto.setRightsReadTypes(ListUtils.isEmpty(rightsReadTypes) ? new ArrayList<>() : rightsReadTypes);
}
@ParamLog("移除不能购买的应用或作品")
private void removeCanNotBuy(List<RightsNowItem> nowItems) {
if (ListUtils.isEmpty(nowItems)) {
......@@ -1338,7 +1451,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
@ParamLog("用户是否领取专享礼包券")
private void fillUserGiftReceiveStatus(RightsSetting rightsSetting, Long wechatUserId) {
if (rightsSetting == null || wechatUserId == null || ListUtils.isEmpty(rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList())) {
if (rightsSetting == null || wechatUserId == null || null == rightsSetting.getGiftCouponPackageTitle() || ListUtils.isEmpty(rightsSetting.getGiftCouponPackageTitle().getRightsSettingItemList())) {
return;
}
List<Long> list = giftReceiveDao.getUserReceiveGiftId(wechatUserId,rightsSetting.getId());
......@@ -1358,6 +1471,7 @@ public class RightsSettingBizImpl implements RightsSettingBiz {
* 根据书刊获取权益
* @return
*/
@Override
public RightsSettingDto getRightSettingByBookId(Long bookId, Long adviserId, Long channelId){
//根据分类获取权益
BookAdviserDto adviserDto = bookAdviserBiz.getBase(bookId, channelId, adviserId);
......
......@@ -5,12 +5,14 @@ import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.book.rightsSetting.entity.RightsNowItem;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
import com.pcloud.book.rightsSetting.enums.RightsWeekTypeEnum;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
......@@ -52,9 +54,29 @@ public class RightsSettingCheck {
if (ListUtils.isEmpty(list)) {
return;
}
List<Long> classifyIds = list.stream().filter(s -> s.getRightsClassifyId() != null).map(RightsSettingItem::getRightsClassifyId).distinct().collect(Collectors.toList());
if (classifyIds.size() < list.size()) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "权益分类不能重复!");
Map<Long, List<RightsSettingItem>> listMap = list.stream().collect(Collectors.groupingBy(RightsSettingItem::getRightsClassifyId));
for (Map.Entry<Long, List<RightsSettingItem>> entry : listMap.entrySet()) {
List<RightsSettingItem> items = entry.getValue();
if (items.size() > 1) {
int easyReadCount = 0;
int efficientReadCount = 0;
int deepReadCount = 0;
for (RightsSettingItem item : items) {
if (null != item.getEasyRead() && item.getEasyRead()) {
++easyReadCount;
}
if (null != item.getEfficientRead() && item.getEfficientRead()) {
++efficientReadCount;
}
if (null != item.getDeepRead() && item.getDeepRead()) {
++deepReadCount;
}
}
Integer typeId = items.get(0).getRightsClassifyId().intValue();
if (easyReadCount > 1 || efficientReadCount > 1 || deepReadCount > 1) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "查询到对应的权益分类阅读方式有重复配置,请修改权益分类:"+RightsWeekTypeEnum.getValue(typeId));
}
}
}
}
......
......@@ -18,5 +18,5 @@ public interface RightsItemGroupDao extends BaseDao<RightsItemGroup> {
void deleteByRightsSettingId(Long rightsSettingId);
List<RightsItemGroup> getListByRightSettingId(Long rightsSettingId);
List<RightsItemGroup> getListByRightSettingId(Long rightsSettingId, Integer readType);
}
\ No newline at end of file
......@@ -6,5 +6,5 @@ import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface RightsNowPicDao extends BaseDao<RightsNowPic> {
List<RightsNowPic> getAllDefaultRightsNowPics();
List<RightsNowPic> getAllDefaultRightsNowPics(Integer type);
}
......@@ -5,7 +5,9 @@ import com.pcloud.book.rightsSetting.entity.RightsItemGroup;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName com.pcloud.book.rightsSetting.dao.impl.RightsItemGroupDaoImpl
......@@ -28,7 +30,10 @@ public class RightsItemGroupDaoImpl extends BaseDaoImpl<RightsItemGroup> impleme
}
@Override
public List<RightsItemGroup> getListByRightSettingId(Long rightsSettingId) {
return super.getSqlSession().selectList(getStatement("getListByRightSettingId"),rightsSettingId);
public List<RightsItemGroup> getListByRightSettingId(Long rightsSettingId, Integer readType) {
Map<String,Object>map = new HashMap<>();
map.put("rightsSettingId",rightsSettingId);
map.put("readType",readType);
return super.getSqlSession().selectList(getStatement("getListByRightSettingId"),map);
}
}
\ No newline at end of file
......@@ -3,9 +3,12 @@ package com.pcloud.book.rightsSetting.dao.impl;
import com.pcloud.book.rightsSetting.dao.RightsNowPicDao;
import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName com.pcloud.book.rightsSetting.dao.impl.RightsItemPicDaoImpl
......@@ -17,7 +20,9 @@ import java.util.List;
@Component("rightsNowPicDao")
public class RightsNowPicDaoImpl extends BaseDaoImpl<RightsNowPic> implements RightsNowPicDao {
@Override
public List<RightsNowPic> getAllDefaultRightsNowPics() {
return super.getSqlSession().selectList(getStatement("getAllDefaultRightsNowPics"));
public List<RightsNowPic> getAllDefaultRightsNowPics(Integer type) {
Map<String, Object> map = new HashMap<>();
map.put("type", type);
return super.getSqlSession().selectList(getStatement("getAllDefaultRightsNowPics"), map);
}
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.dto;
import lombok.Data;
/**
* @ClassName com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO
* @Author 吴博
* @Description 每种阅读方式配置的权益数量DTO
* @Date 2020/5/15 9:25
* @Version 1.0
**/
@Data
public class ReadTypeCountDTO {
//阅读类型
private Long rightsSettingId;
//轻松阅读权益数量
private Integer easyReadCount;
//高效阅读权益数量
private Integer efficientReadCount;
//深度阅读权益数量
private Integer deepReadCount;
}
\ No newline at end of file
......@@ -21,4 +21,9 @@ public class RightsSettingDto extends RightsSetting {
* 书名
*/
private String bookName;
/**
* 当前选择的读书类型
*/
private Integer chooseReadType;
}
......@@ -48,4 +48,12 @@ public class RightsItemGroup extends BaseEntity {
@ApiModelProperty("应用或作品集合")
private List<RightsNowItem> rightsNowItems;
@ApiModelProperty("轻松阅读")
private Boolean easyRead;
@ApiModelProperty("高效阅读")
private Boolean efficientRead;
@ApiModelProperty("深度阅读")
private Boolean deepRead;
}
\ No newline at end of file
......@@ -22,4 +22,6 @@ public class RightsNowPic extends BaseEntity {
@ApiModelProperty("是否默认图片")
private Boolean defaultPic;
@ApiModelProperty("图片库类型(1立享权益2资讯3书单4书刊分类)")
private Integer type;
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import javax.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
@Data
@ApiModel
public class RightsReadType {
private Long id;
@ApiModelProperty("权益id")
private Long rightsSettingId;
@ApiModelProperty("阅读类型 1,轻松 2 高效 3 深度")
@Range(min = 1,max = 3,message = "阅读类型只能是轻松、高效和深度")
private Integer readType;
@ApiModelProperty("描述")
@Size(max = 30,message="描述最多30个字")
private String description;
@ApiModelProperty("学习时长1-10")
@Range(min = 1,max = 10,message = "学习时长只能选择1-10")
private Integer learningLength;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date updateTime;
@ApiModelProperty("权益数量")
private Integer rightsCount;
}
\ No newline at end of file
......@@ -5,8 +5,11 @@ import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import lombok.Data;
import lombok.NonNull;
import org.hibernate.validator.constraints.Length;
@Data
public class RightsSetting extends BaseTempletClassify {
......@@ -89,6 +92,15 @@ public class RightsSetting extends BaseTempletClassify {
@ApiModelProperty("权益配套资料分组集合")
private List<RightsItemGroup> rightsItemGroups;
@ApiModelProperty("权益阅读方式标题")
@Length(min=0, max=30,message = "权益阅读方式标题最大30个字")
private String readTypeTitle;
@ApiModelProperty("权益de阅读方式")
@Size(min = 3,max = 3,message = "目前有且只有3种阅读方式")
@Valid
private List<RightsReadType> rightsReadTypes;
public RightsSetting() {
}
......
......@@ -79,4 +79,20 @@ public class RightsSettingItem extends BaseEntity {
@ApiModelProperty("社群")
private List<GroupActivity4AppletDTO> groupActivity4AppletList;
/**
* 轻松阅读
*/
private Boolean easyRead;
/**
* 高效阅读
*/
private Boolean efficientRead;
/**
* 深度阅读
*/
private Boolean deepRead;
/**
* 阅读方式1轻松2高效3深度
*/
private Integer readType;
}
\ No newline at end of file
......@@ -35,6 +35,17 @@ public class RightsSettingTitle {
* 列表
*/
private List<RightsNowItem> rightsSettingItemList;
/**
* 轻松阅读
*/
private Boolean easyRead;
/**
* 高效阅读
*/
private Boolean efficientRead;
/**
* 深度阅读
*/
private Boolean deepRead;
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.enums;
/**
* 图片库类型
* @author:zhuyajie
* @date:2020/5/19 10:39
* * @param null
*/
public enum PicTypeEnum {
/**
* 1立享权益
*/
rights_now(1),
/**
* 2资讯
*/
news(2),
/**
* 3书单
*/
booklist(3),
/**
* 4书刊分类
*/
applet_book_classify(4);
public final Integer value;
PicTypeEnum(Integer value) {
this.value = value;
}
}
package com.pcloud.book.rightsSetting.enums;
/**
* @描述:权益类型-
* @作者:zhuyajie
* @创建时间:17:36 2020/4/19
* @版本:1.0
*/
public enum RightsWeekTypeEnum {
/**
* 7线上学习/阅读提醒
*/
ONLINE_REMIND(7,"线上学习/阅读提醒"),
/**
* 8线上读书活动
*/
ONLINE_READING_ACTIVITY(8,"线上读书活动"),
/**
* 9书单推荐
*/
BOOK_RECOMMEND(9,"书单推荐"),
/**
* 10资讯推送
*/
NEWS_PUSH(10,"资讯推送"),
/**
* 11亲子活动设计
*/
FAMILY_ACTIVITY(11,"亲子活动设计"),
/**
* 12线上精品课
*/
ONLINE_QUALITY_COURSE(12,"线上精品课"),
/**
*13线下读书活动推荐
*/
OFFLINE_READING_ACTIVITY(13,"线下读书活动推荐"),
/**
* 14抢兑课程/实物礼品
*/
COURSE_OR_GIFT(14,"抢兑课程/实物礼品");
public final Integer key;
public final String value;
RightsWeekTypeEnum(Integer key, String value) {
this.value = value;
this.key = key;
}
public static String getValue(Integer key) {
for (RightsWeekTypeEnum typeEnum : RightsWeekTypeEnum.values()) {
if (typeEnum.getKey().equals(key)) {
return typeEnum.getValue();
}
}
return null;
}
public Integer getKey() {
return key;
}
public String getValue() {
return value;
}
}
......@@ -4,6 +4,7 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.RightsNowPic;
import com.pcloud.book.rightsSetting.entity.RightsReadType;
import com.pcloud.book.rightsSetting.entity.RightsSetting;
import com.pcloud.book.rightsSetting.entity.RightsSettingClassify;
import com.pcloud.book.rightsSetting.entity.RightsSettingItem;
......@@ -14,7 +15,9 @@ import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import com.pcloud.common.utils.string.StringUtil;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -29,6 +32,7 @@ import java.util.List;
import javax.validation.constraints.Min;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.SneakyThrows;
@RequestMapping("rightsSetting")
......@@ -39,7 +43,8 @@ public class RightsSettingFacede {
private RightsSettingBiz rightsSettingBiz;
@PostMapping("addRightsSetting")
public ResponseDto<Long> addRightsSetting( @RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting ) throws PermissionException {
public ResponseDto<Long> addRightsSetting( @RequestHeader("token") String token,
@RequestBody @Validated RightsSetting rightsSetting ) throws PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<Long>(rightsSettingBiz.addRightsSetting(rightsSetting));
}
......@@ -52,7 +57,8 @@ public class RightsSettingFacede {
}
@PostMapping("updateRightsSetting")
public ResponseDto<?> updateRightsSetting( @RequestHeader("token") String token, @RequestBody RightsSetting rightsSetting ) throws PermissionException {
public ResponseDto<?> updateRightsSetting( @RequestHeader("token") String token,
@RequestBody @Validated RightsSetting rightsSetting ) throws PermissionException {
SessionUtil.getToken4Redis(token);
rightsSettingBiz.updateRightsSetting(rightsSetting);
return new ResponseDto<>();
......@@ -117,12 +123,14 @@ public class RightsSettingFacede {
public ResponseDto<?> getItemByRightsSettingId4AppletHome(
@CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId,
@RequestParam(value = "rightsType", required = false) String rightsType ) {
@RequestParam(value = "rightsType", required = false) String rightsType,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType
) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == rightsSettingId || StringUtil.isEmpty(rightsType)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType));
return new ResponseDto<>(rightsSettingBiz.getItemByRightsSettingId4AppletHome(rightsSettingId, wechatUserId, rightsType, readType));
}
@ApiOperation("所有权益分类")
......@@ -155,22 +163,24 @@ public class RightsSettingFacede {
message = "权益类型不能小于1") Integer rightsSettingType ,
@RequestParam(value = "adviserId",required = false) Long adviserId,
@RequestParam(value = "bookId", required = false)Long bookId,
@RequestParam(value = "channelId", required = false)Long channelId) {
@RequestParam(value = "channelId", required = false)Long channelId,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType) {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
return new ResponseDto<>(rightsSettingBiz.getRightsSettingRightsNowItemsByType(rightsSettingId, wechatUserId, rightsSettingType,adviserId,bookId,channelId));
return new ResponseDto<>(rightsSettingBiz.getRightsSettingRightsNowItemsByType(rightsSettingId, wechatUserId, rightsSettingType,adviserId,bookId,channelId,readType));
}
@ApiOperation("根据权益id获取即享权益项专享礼包")
@GetMapping("getRightsSettingGiftCoupons")
public ResponseDto<RightsSetting> getRightsSettingGiftCoupons(
@CookieValue("userInfo") String userInfo,
@RequestParam("rightsSettingId") Long rightsSettingId
@RequestParam("rightsSettingId") Long rightsSettingId,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType
) throws PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (null == rightsSettingId) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(rightsSettingBiz.getRightsSettingGiftCoupons(rightsSettingId, wechatUserId));
return new ResponseDto<>(rightsSettingBiz.getRightsSettingGiftCoupons(rightsSettingId, wechatUserId, readType));
}
@ApiOperation("根据权益id获取即享权益项补充咨询")
......@@ -193,13 +203,14 @@ public class RightsSettingFacede {
@RequestParam("rightsSettingId") Long rightsSettingId,
@RequestParam("adviserId") Long adviserId,
@RequestParam("bookId")Long bookId,
@RequestParam("channelId")Long channelId
@RequestParam("channelId")Long channelId,
@RequestParam(value = "readType",required = false)@ApiParam("阅读方式1轻松2高效3深度") Integer readType
) throws PermissionException {
Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
if (null==rightsSettingId){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数缺失!");
}
return new ResponseDto<>(rightsSettingBiz.getRightsItemGroups(rightsSettingId, adviserId, bookId, channelId, true));
return new ResponseDto<>(rightsSettingBiz.getRightsItemGroups(rightsSettingId, adviserId, bookId, channelId, true,readType));
}
@ApiOperation("根据书刊的分类获取对应的分类权益信息")
......@@ -217,10 +228,11 @@ public class RightsSettingFacede {
@ApiOperation("获取即享权益默认图片库")
@GetMapping("getAllDefaultRightsNowPics")
public ResponseDto<?> getAllDefaultRightsNowPics(
@RequestHeader("token") String token
@RequestHeader("token") String token,
@RequestParam(value = "type", required = false) @ApiParam("图片类型(1立享权益2资讯3书单4书刊分类)") Integer type
) throws PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(rightsSettingBiz.getAllDefaultRightsNowPics());
return new ResponseDto<>(rightsSettingBiz.getAllDefaultRightsNowPics(type));
}
@ApiOperation("新增即享权益图片")
......@@ -239,10 +251,11 @@ public class RightsSettingFacede {
public ResponseDto<?> getRightsNowPics(
@RequestHeader("token") String token,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
@RequestParam("numPerPage") Integer numPerPage,
@RequestParam(value = "type", required = false) @ApiParam("图片类型(1立享权益2资讯3书单4书刊分类)") Integer type
) throws PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(rightsSettingBiz.getRightsNowPics(currentPage,numPerPage));
return new ResponseDto<>(rightsSettingBiz.getRightsNowPics(currentPage,numPerPage,type));
}
@ApiOperation("删除即享权益图片")
......@@ -256,4 +269,16 @@ public class RightsSettingFacede {
return new ResponseDto<>();
}
@ApiOperation("获取当前图书的阅读方式")
@GetMapping("getReadType4Book")
public ResponseDto<RightsSettingDto> getReadType4Book(
@CookieValue("userInfo") String userInfo,
@RequestParam("bookId") Long bookId,
@RequestParam("channelId") Long channelId,
@RequestParam("adviserId") Long adviserId
) throws PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
RightsSettingDto rightsSettingDto = rightsSettingBiz.getReadType4Book(wechatUserId,bookId,channelId,adviserId);
return new ResponseDto<>(rightsSettingDto);
}
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.mapper;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.entity.RightsReadType;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface RightsReadTypeMapper {
int deleteByPrimaryKey(Long id);
int insert(RightsReadType record);
int insertSelective(RightsReadType record);
RightsReadType selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(RightsReadType record);
int updateByPrimaryKey(RightsReadType record);
void deleteByRightsSettingId(Long rightsSettingId);
void batchInsert(List<RightsReadType> rightsReadTypes);
List<RightsReadType> getByRightsSettingId(Long rightsSettingId);
@MapKey("readType")
Map<Integer, ReadTypeCountDTO> getCounMapt4Title(Long rightsSettingId);
}
\ No newline at end of file
package com.pcloud.book.rightsSetting.mapper;
import com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO;
import com.pcloud.book.rightsSetting.entity.RightsSettingTitle;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
......@@ -18,7 +21,9 @@ public interface RightsSettingTitleMapper {
void batchUpdate(List<RightsSettingTitle> rightsSettingTitles);
List<RightsSettingTitle> getByRightSettingId(Long rightsSettingId);
List<RightsSettingTitle> getByRightSettingId(@Param("rightsSettingId")Long rightsSettingId, @Param("readType")Integer readType);
RightsSettingTitle getByRightSettingIdAndType(@Param("rightsSettingId") Long rightsSettingId, @Param("type") Integer type);
RightsSettingTitle getByRightSettingIdAndType(@Param("rightsSettingId") Long rightsSettingId, @Param("type") Integer type, @Param("readType")Integer readType);
ReadTypeCountDTO getCount4Title(Long rightsSettingId);
}
\ No newline at end of file
......@@ -43,5 +43,5 @@ public interface PcloudGroupActivityBiz {
* 根据分类获取社群共读
* @return
*/
GroupActivity4AppletDTO getGroupActivity4Applet(Long rightSettingId, Long adviserId, Long bookId, Long channelId);
GroupActivity4AppletDTO getGroupActivity4Applet(Long rightSettingId, Long adviserId, Long bookId, Long channelId, Integer readType);
}
......@@ -290,7 +290,7 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
}
@Override
public GroupActivity4AppletDTO getGroupActivity4Applet(Long rightSettingId, Long adviserId, Long bookId, Long channelId) {
public GroupActivity4AppletDTO getGroupActivity4Applet(Long rightSettingId, Long adviserId, Long bookId, Long channelId, Integer readType) {
BookDto adviserBook = bookBiz.getAdviserBook(bookId, adviserId, channelId);
BookDto dto = Optional.ofNullable(adviserBook).orElseThrow(() -> new BookBizException(BookBizException.ID_NOT_EXIST, "未找到相关书刊"));
// 处理分类和标签
......@@ -306,7 +306,10 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
return new GroupActivity4AppletDTO();
}
// 是否开启社群服务开关
RightsSettingTitle right = rightsSettingTitleMapper.getByRightSettingIdAndType(rightSettingId, RightsNowItemType.GROUP_SERVICE.value);
RightsSettingTitle right = rightsSettingTitleMapper.getByRightSettingIdAndType(rightSettingId, RightsNowItemType.GROUP_SERVICE.value,readType);
if (null == right){
return new GroupActivity4AppletDTO();
}
groupActivity4AppletDTO.setOpenStatus(Objects.isNull(right.getOpenState()) ? false : right.getOpenState());
groupActivity4AppletDTO.setRightsSettingTitle(right.getRightsSettingTitle());
groupActivity4AppletDTO.setRightsSettingDesc(right.getRightsSettingDesc());
......
......@@ -38,7 +38,7 @@
selectByExampleQueryId="false">
</table>-->
<table tableName="rights_setting_title" domainObjectName="RightsSettingTitle"
<table tableName="rights_read_type" domainObjectName="RightsReadType"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
......
......@@ -103,6 +103,9 @@
<if test="name != null">
AND b.booklist_name LIKE CONCAT("%", #{name} ,"%")
</if>
<if test="classifyId >0">
AND b.classify_id= #{classifyId}
</if>
GROUP BY b.id
order by b.create_time desc
</select>
......@@ -154,10 +157,25 @@
FROM applet_booklist b
LEFT JOIN applet_booklist_config c ON b.id=c.booklist_id
WHERE 1=1
AND b.classify_id= #{classifyId}
<if test="classifyId != null">
AND b.classify_id= #{classifyId}
</if>
<if test="classifyIdList != null">
AND b.classify_id in
<foreach collection="classifyIdList" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
GROUP BY b.id
HAVING COUNT(c.id)>0
order by b.create_time desc
<choose>
<when test="order>0 and order == 1">
ORDER BY RAND()
</when>
<otherwise>
order by b.create_time desc
</otherwise>
</choose>
</select>
<select id="getBookBaseByBooklistId" parameterType="map" resultType="com.pcloud.book.applet.dto.BookDTO4Booklist">
......
......@@ -8,18 +8,20 @@
<result column="show_state" property="showState" jdbcType="BOOLEAN" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="pic" property="pic" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, classify_name, seq, show_state, create_time,update_time
id, classify_name, seq, show_state, create_time,update_time,pic
</sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletBooklistClassify" useGeneratedKeys="true" keyProperty="id">
insert into applet_booklist_classify (
classify_name, seq, show_state, create_time, update_time
classify_name, seq, show_state, create_time, update_time, pic
)
values (
#{classifyName}, #{seq}, #{showState}, NOW(), NOW()
#{classifyName}, #{seq}, #{showState}, NOW(), NOW(), #{pic}
)
</insert>
......@@ -35,6 +37,9 @@
<if test="showState != null">
show_state = #{showState},
</if>
<if test="pic != null">
pic=#{pic},
</if>
update_time=NOW()
</set>
where id = #{id,jdbcType=BIGINT}
......@@ -57,7 +62,8 @@
b.classify_name classifyName,
b.seq seq,
COUNT(c.id) booklistCount,
b.show_state showState
b.show_state showState,
b.pic
FROM applet_booklist_classify b
LEFT JOIN applet_booklist c ON b.id=c.classify_id
WHERE 1=1
......@@ -75,13 +81,46 @@
<select id="getAllBooklistClassify" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletBooklistClassifyDTO">
SELECT
id, classify_name classifyName, seq, show_state showState
id, classify_name classifyName, seq, show_state showState, pic
FROM applet_booklist_classify
where 1=1
<if test="showState != null">
AND show_state = #{showState}
</if>
ORDER BY seq ASC
ORDER BY seq ASC, id asc
</select>
<insert id="batchInsertUserBooklistClassify" parameterType="list" keyProperty="id" useGeneratedKeys="true">
insert into applet_booklist_classify_user (
classify_id, wechat_user_id, create_time)
values
<foreach collection="list" item="item" index="index" separator=",">
( #{item.classifyId}, #{item.wechatUserId}, NOW() )
</foreach>
</insert>
<delete id="deleteClassifyByWechatUesrId" parameterType="long">
DELETE FROM applet_booklist_classify_user
WHERE wechat_user_id = #{wechatUserId}
</delete>
<select id="getClassifyIdsByUserId" parameterType="long" resultType="long">
SELECT classify_id
FROM applet_booklist_classify_user
WHERE wechat_user_id = #{wechatUserId}
</select>
<select id="getClassifysByUserId" parameterType="long" resultType="com.pcloud.book.applet.dto.AppletBooklistClassifyDTO">
SELECT
c.id, c.classify_name classifyName, c.seq, c.show_state showState, c.pic
FROM
applet_booklist_classify_user u
LEFT JOIN applet_booklist_classify c ON u.classify_id = c.id
WHERE
u.wechat_user_id = #{wechatUserId}
AND c.show_state = 1
ORDER BY
c.seq ASC
</select>
</mapper>
\ No newline at end of file
......@@ -384,4 +384,52 @@
ORDER BY n.create_time DESC
</select>
<select id="listAppletNews4Wechat" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletNewsDTO">
SELECT
n.id,
n.news_name newsName,
n.source,
n.news_classify_id newsClassifyId,
n.pro_label_id proLabelId,
n.dep_label_id depLabelId,
n.pur_label_id purLabelId,
n.type,
n.digest,
n.pic1,
n.pic2,
n.pic3,
n.content,
n.show_state showState,
c.news_classify newsClassify,
n.create_time createTime,
n.first_classify firstClassify,
n.second_classify secondClassify,
n.grade_label_id gradeLabelId,
n.subject_label_id subjectLabelId,
n.rights_classify_id rightsClassifyId,
n.jump_type jumpType,
n.jump_url jumpUrl
FROM applet_news n
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
WHERE n.show_state = 1
<if test="newsClassifyId >0">
AND n.news_classify_id = #{newsClassifyId}
</if>
<if test="newsClassifyIdList != null">
AND n.news_classify_id in
<foreach collection="newsClassifyIdList" item="item" open="(" separator="," close=")">
${item}
</foreach>
</if>
<choose>
<when test="order>0 and order == 1">
ORDER BY RAND()
</when>
<otherwise>
ORDER BY n.create_time DESC
</otherwise>
</choose>
</select>
</mapper>
\ No newline at end of file
......@@ -8,18 +8,19 @@
<result column="show_state" property="showState" jdbcType="BOOLEAN" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="pic" property="pic" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, news_classify, seq, show_state, create_time,update_time
id, news_classify, seq, show_state, create_time,update_time, pic
</sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletNewsClassify" useGeneratedKeys="true" keyProperty="id">
insert into applet_news_classify (
news_classify, seq, show_state, create_time, update_time
news_classify, seq, show_state, create_time, update_time, pic
)
values (
#{newsClassify}, #{seq}, #{showState}, NOW(), NOW()
#{newsClassify}, #{seq}, #{showState}, NOW(), NOW(), #{pic}
)
</insert>
......@@ -35,6 +36,9 @@
<if test="showState != null">
show_state = #{showState},
</if>
<if test="pic != null">
pic=#{pic},
</if>
update_time=NOW()
</set>
where id = #{id,jdbcType=BIGINT}
......@@ -57,7 +61,8 @@
b.news_classify newsClassify,
b.seq seq,
COUNT(c.id) newsCount,
b.show_state showState
b.show_state showState,
b.pic pic
FROM applet_news_classify b
LEFT JOIN applet_news c ON b.id=c.news_classify_id
WHERE 1=1
......@@ -75,13 +80,46 @@
<select id="getAllNewsClassify" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletNewsClassifyDTO">
SELECT
id, news_classify newsClassify, seq, show_state showState
id, news_classify newsClassify, seq, show_state showState, pic
FROM applet_news_classify
where 1=1
<if test="showState != null">
AND show_state = #{showState}
</if>
ORDER BY seq ASC
ORDER BY seq ASC, id asc
</select>
<insert id="batchInsertUserNewsClassify" parameterType="list" keyProperty="id" useGeneratedKeys="true">
insert into applet_news_classify_user (
news_classify_id, wechat_user_id, create_time)
values
<foreach collection="list" item="item" index="index" separator=",">
( #{item.newsClassifyId}, #{item.wechatUserId}, NOW() )
</foreach>
</insert>
<delete id="deleteClassifyByWechatUesrId" parameterType="long">
DELETE FROM applet_news_classify_user
WHERE wechat_user_id = #{wechatUserId}
</delete>
<select id="getClassifyIdsByUserId" parameterType="long" resultType="long">
SELECT news_classify_id
FROM applet_news_classify_user
WHERE wechat_user_id = #{wechatUserId}
</select>
<select id="getClassifysByUserId" parameterType="long" resultType="com.pcloud.book.applet.dto.AppletNewsClassifyDTO">
SELECT
c.id, c.news_classify newsClassify, c.seq, c.show_state showState, c.pic
FROM
applet_news_classify_user u
LEFT JOIN applet_news_classify c ON u.news_classify_id = c.id
WHERE
u.wechat_user_id = #{wechatUserId}
AND c.show_state = 1
ORDER BY
c.seq ASC
</select>
</mapper>
\ No newline at end of file
......@@ -8,10 +8,11 @@
<result column="channel_id" property="channelId" jdbcType="BIGINT" />
<result column="adviser_id" property="adviserId" jdbcType="BIGINT" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="read_type" property="readType" jdbcType="TINYINT" />
</resultMap>
<sql id="Base_Column_List" >
id, wechat_user_id, book_id, channel_id, adviser_id, create_time
id, wechat_user_id, book_id, channel_id, adviser_id, create_time,read_type
</sql>
<insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletUserBookcase" useGeneratedKeys="true" keyProperty="id">
......@@ -21,6 +22,9 @@
values (
#{wechatUserId}, #{bookId}, #{channelId}, #{adviserId}, NOW()
)
on duplicate key
update
create_time = now()
</insert>
<select id="listByWechatUserId" parameterType="long" resultType="com.pcloud.book.applet.dto.AppletUserBookcaseDTO">
......@@ -97,7 +101,8 @@
SELECT
t.book_id bookId,
t.adviser_id adviserId,
t.channel_id channelId
t.channel_id channelId,
t.read_type readType
FROM
applet_user_bookcase t
INNER JOIN book_group t1 ON t.book_id = t1.book_id
......@@ -116,7 +121,8 @@
SELECT
t.book_id bookId,
t.adviser_id adviserId,
t.channel_id channelId
t.channel_id channelId,
t.read_type readType
FROM
applet_user_bookcase t
WHERE
......@@ -136,4 +142,40 @@
</foreach>
</delete>
<update id="updateUserReadType" parameterType="com.pcloud.book.applet.entity.AppletUserBookcase">
update
applet_user_bookcase
set
read_type = #{readType}
WHERE
wechat_user_id=#{wechatUserId}
AND book_id=#{bookId}
AND channel_id=#{channelId}
AND adviser_id=#{adviserId}
</update>
<select id="getUserReadType" parameterType="map" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
applet_user_bookcase
where
wechat_user_id=#{wechatUserId}
AND book_id=#{bookId}
AND channel_id=#{channelId}
AND adviser_id=#{adviserId}
limit 1
</select>
<select id="getListByUserId" parameterType="long" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
applet_user_bookcase
WHERE
wechat_user_id = #{wechatUserId}
ORDER BY
create_time DESC
</select>
</mapper>
\ No newline at end of file
......@@ -13,10 +13,13 @@
<result property="desc2" column="desc2" jdbcType="VARCHAR"/>
<result property="desc3" column="desc3" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result column="easy_read" jdbcType="TINYINT" property="easyRead" />
<result column="efficient_read" jdbcType="TINYINT" property="efficientRead" />
<result column="deep_read" jdbcType="TINYINT" property="deepRead" />
</resultMap>
<sql id="Base_Column_List">
id, rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time
id, rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time, easy_read,efficient_read,deep_read
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -34,7 +37,8 @@
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsItemGroup" useGeneratedKeys="true" keyProperty="id">
insert into rights_item_group
<trim prefix="(" suffix=")" suffixOverrides=",">
rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time
rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time,
easy_read,efficient_read,deep_read
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{rightsSettingId,jdbcType=BIGINT},
......@@ -45,13 +49,15 @@
#{desc1,jdbcType=VARCHAR},
#{desc2,jdbcType=VARCHAR},
#{desc3,jdbcType=VARCHAR},
NOW()
NOW(),
#{easyRead},#{efficientRead},#{deepRead}
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsItemGroup" useGeneratedKeys="true" keyProperty="id">
insert into rights_item_group (
rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time
rights_setting_id, name, show_state, type, pic, desc1, desc2, desc3, create_time,
easy_read,efficient_read,deep_read
) values
<foreach collection="list" item="item" index="index" separator=",">
(
......@@ -63,7 +69,8 @@
#{item.desc1,jdbcType=VARCHAR},
#{item.desc2,jdbcType=VARCHAR},
#{item.desc3,jdbcType=VARCHAR},
NOW()
NOW(),
#{item.easyRead},#{item.efficientRead},#{item.deepRead}
)
</foreach>
</insert>
......@@ -73,10 +80,21 @@
where rights_setting_id=#{rightsSettingId}
</delete>
<select id="getListByRightSettingId" parameterType="long" resultMap="BaseResultMap">
<select id="getListByRightSettingId" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from rights_item_group
where rights_setting_id=#{rightsSettingId}
<choose>
<when test="readType==1">
and easy_read=1
</when>
<when test="readType==2">
and efficient_read=1
</when>
<when test="readType==3">
and deep_read=1
</when>
</choose>
</select>
</mapper>
\ No newline at end of file
......@@ -7,10 +7,11 @@
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="defaultPic" column="default_pic" jdbcType="BOOLEAN"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="type" column="type" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, pic_url, default_pic, create_time
id, pic_url, default_pic, create_time, type
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -28,38 +29,46 @@
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsNowPic" useGeneratedKeys="true" keyProperty="id">
insert into rights_now_pic
<trim prefix="(" suffix=")" suffixOverrides=",">
pic_url, default_pic, create_time
pic_url, default_pic, create_time, type
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{picUrl,jdbcType=VARCHAR},
#{defaultPic,jdbcType=BOOLEAN},
NOW()
NOW(),
#{type}
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsNowPic" useGeneratedKeys="true" keyProperty="id">
insert into rights_now_pic (
pic_url, default_pic, create_time
pic_url, default_pic, create_time, type
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.picUrl,jdbcType=VARCHAR},
#{item.defaultPic,jdbcType=BOOLEAN},
NOW()
NOW(),
#{type}
)
</foreach>
</insert>
<select id="getAllDefaultRightsNowPics" resultMap="BaseResultMap">
<select id="getAllDefaultRightsNowPics" resultMap="BaseResultMap" parameterType="map">
select <include refid="Base_Column_List"/>
from rights_now_pic
where default_pic=1
<if test="type != null">
and type = #{type}
</if>
</select>
<select id="getRightsNowPics" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from rights_now_pic
where default_pic=0
<if test="type != null">
and type = #{type}
</if>
order by create_time desc
</select>
......
<?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.RightsReadTypeMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.rightsSetting.entity.RightsReadType" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="rights_setting_id" property="rightsSettingId" jdbcType="BIGINT" />
<result column="read_type" property="readType" jdbcType="INTEGER" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="learning_length" property="learningLength" jdbcType="INTEGER" />
<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, read_type, description, learning_length, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from rights_read_type
where id = #{id,jdbcType=BIGINT}
</select>
<select id="getByRightsSettingId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from rights_read_type
where rights_setting_id = #{rightsSettingId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from rights_read_type
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByRightsSettingId" parameterType="long">
delete
from
rights_read_type
where
rights_setting_id = #{rightsSettingId}
</delete>
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType" >
insert into rights_read_type (id, rights_setting_id, read_type,
description, learning_length, create_time,
update_time)
values (#{id,jdbcType=BIGINT}, #{rightsSettingId,jdbcType=BIGINT}, #{readType,jdbcType=INTEGER},
#{description,jdbcType=VARCHAR}, #{learningLength,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType" >
insert into rights_read_type
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="rightsSettingId != null" >
rights_setting_id,
</if>
<if test="readType != null" >
read_type,
</if>
<if test="description != null" >
description,
</if>
<if test="learningLength != null" >
learning_length,
</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="readType != null" >
#{readType,jdbcType=INTEGER},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
<if test="learningLength != null" >
#{learningLength,jdbcType=INTEGER},
</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.RightsReadType">
insert into rights_read_type (rights_setting_id, read_type,
description, learning_length, create_time, update_time)
values
<foreach collection="list" item="item" index="index" separator=",">
( #{item.rightsSettingId,jdbcType=BIGINT}, #{item.readType,jdbcType=INTEGER},
#{item.description,jdbcType=VARCHAR}, #{item.learningLength,jdbcType=INTEGER},now(), now())
</foreach>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsReadType" >
update rights_read_type
<set >
<if test="rightsSettingId != null" >
rights_setting_id = #{rightsSettingId,jdbcType=BIGINT},
</if>
<if test="readType != null" >
read_type = #{readType,jdbcType=INTEGER},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
<if test="learningLength != null" >
learning_length = #{learningLength,jdbcType=INTEGER},
</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.RightsReadType" >
update rights_read_type
set rights_setting_id = #{rightsSettingId,jdbcType=BIGINT},
read_type = #{readType,jdbcType=INTEGER},
description = #{description,jdbcType=VARCHAR},
learning_length = #{learningLength,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
......@@ -11,6 +11,9 @@
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="title" column="title" jdbcType="VARCHAR"/>
<result property="uuid" column="uuid" jdbcType="VARCHAR"/>
<result property="easyRead" column="easy_read" jdbcType="TINYINT" />
<result property="efficientRead" column="efficient_read" jdbcType="TINYINT" />
<result property="deepRead" column="deep_read" jdbcType="TINYINT" />
</resultMap>
<!--通过实体作为筛选条件查询-->
......@@ -19,7 +22,7 @@
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,
c.book_id bookId
c.book_id bookId, i.easy_read easyRead,i.efficient_read efficientRead,i.deep_read deepRead
from book.rights_setting_item i
left join book.rights_read_plan p on i.id=p.rights_setting_item_id
LEFT JOIN rights_setting c ON c.id=i.rights_setting_id
......@@ -36,14 +39,27 @@
<if test="rightsClassifyId != null ">
and i.rights_classify_id = #{rightsClassifyId}
</if>
<choose>
<when test="readType==1">
and i.easy_read=1
</when>
<when test="readType==2">
and i.efficient_read=1
</when>
<when test="readType==3">
and i.deep_read=1
</when>
</choose>
</where>
order by i.id asc
</select>
<!--新增所有列-->
<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,uuid)
values (#{rightsSettingId}, #{rightsType}, #{rightsClassifyId}, #{description}, NOW(), #{title},#{uuid})
insert into book.rights_setting_item(rights_setting_id, rights_type, rights_classify_id, description, create_time,title,uuid,
easy_read,efficient_read,deep_read)
values (#{rightsSettingId}, #{rightsType}, #{rightsClassifyId}, #{description}, NOW(), #{title},#{uuid},
#{easyRead},#{efficientRead},#{deepRead})
</insert>
<!--通过权益主键删除-->
......@@ -58,7 +74,8 @@
<!--批量新增-->
<insert id="batchInsert" useGeneratedKeys="true" parameterType="java.util.List">
insert into book.rights_setting_item (
rights_setting_id, rights_type, rights_classify_id, description, create_time,title,uuid
rights_setting_id, rights_type, rights_classify_id, description, create_time,title,uuid,
easy_read,efficient_read,deep_read
)
values
<foreach collection="list" item="item" index="index" separator="," >
......@@ -69,7 +86,8 @@
#{item.description,jdbcType=VARCHAR},
NOW(),
#{item.title},
#{item.uuid}
#{item.uuid},
#{item.easyRead},#{item.efficientRead},#{item.deepRead}
)
</foreach>
</insert>
......@@ -87,7 +105,8 @@
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
i.description, i.create_time createTime, i.title,i.uuid,IFNULL(p.is_open,0) isOpen,p.service_desc serviceDesc,
i.easy_read easyRead,i.efficient_read efficientRead,i.deep_read deepRead
from book.rights_setting_item i
left join book.rights_read_plan p on i.id=p.rights_setting_item_id
<where>
......
......@@ -18,6 +18,7 @@
<result column="online_course_open" property="onlineCourseOpen" jdbcType="BOOLEAN" />
<result column="learning_tool_open" property="learningToolOpen" jdbcType="BOOLEAN" />
<result column="draw_open" property="drawNowOpen" jdbcType="BOOLEAN" />
<result column="read_type_title" property="readTypeTitle" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="DtoResultMap" type="com.pcloud.book.rightsSetting.dto.RightsSettingDto">
......@@ -38,11 +39,12 @@
<result column="online_course_open" property="onlineCourseOpen" jdbcType="BOOLEAN" />
<result column="learning_tool_open" property="learningToolOpen" jdbcType="BOOLEAN" />
<result column="draw_open" property="drawNowOpen" jdbcType="BOOLEAN" />
<result column="read_type_title" property="readTypeTitle" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, introduce, detail, count, first_classify, second_classify, grade_label_id, subject_label_id,
create_time, update_time, enable_group_service, rights_setting_type, book_id
,online_course_open,learning_tool_open,draw_open
,online_course_open,learning_tool_open,draw_open,read_type_title
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
......@@ -59,12 +61,12 @@
count, first_classify, second_classify,
grade_label_id, subject_label_id, create_time,
update_time, enable_group_service, rights_setting_type, book_id,
online_course_open,learning_tool_open,draw_open)
online_course_open,learning_tool_open,draw_open,read_type_title)
values ( #{introduce,jdbcType=VARCHAR}, #{detail,jdbcType=VARCHAR},
#{count,jdbcType=INTEGER}, #{firstClassify,jdbcType=BIGINT}, #{secondClassify,jdbcType=BIGINT},
#{gradeLabelId,jdbcType=BIGINT}, #{subjectLabelId,jdbcType=BIGINT}, now(),
#{updateTime,jdbcType=TIMESTAMP}, #{enableGroupService}, #{rightsSettingType}, #{bookId},
#{onlineCourseOpen},#{learningToolOpen},#{drawNowOpen})
#{onlineCourseOpen},#{learningToolOpen},#{drawNowOpen},#{readTypeTitle})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsSetting" >
update rights_setting
......@@ -131,7 +133,8 @@
book_id = #{bookId},
online_course_open = #{onlineCourseOpen},
learning_tool_open = #{learningToolOpen},
draw_open = #{drawNowOpen}
draw_open = #{drawNowOpen},
read_type_title = #{readTypeTitle}
where id = #{id,jdbcType=BIGINT}
</update>
......
......@@ -10,20 +10,23 @@
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="rights_setting_now_type" jdbcType="TINYINT" property="rightsSettingNowType" />
<result column="easy_read" jdbcType="TINYINT" property="easyRead" />
<result column="efficient_read" jdbcType="TINYINT" property="efficientRead" />
<result column="deep_read" jdbcType="TINYINT" property="deepRead" />
</resultMap>
<sql id="baseSql">
id, rights_setting_id, rights_setting_title,
rights_setting_desc, open_state, create_time,
update_time,rights_setting_now_type
update_time,rights_setting_now_type,easy_read,efficient_read,deep_read
</sql>
<insert id="insert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
insert into rights_setting_title (id, rights_setting_id, rights_setting_title,
rights_setting_desc, open_state, create_time,
update_time,rights_setting_now_type)
update_time,rights_setting_now_type,easy_read,efficient_read,deep_read)
values (#{id,jdbcType=BIGINT}, #{rightsSettingId,jdbcType=BIGINT}, #{rightsSettingTitle,jdbcType=VARCHAR},
#{rightsSettingDesc,jdbcType=VARCHAR}, #{openState,jdbcType=TINYINT}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP},#{rightsSettingNowType})
#{updateTime,jdbcType=TIMESTAMP},#{rightsSettingNowType},#{easyRead},#{efficientRead},#{deepRead})
</insert>
<insert id="insertSelective" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
insert into rights_setting_title
......@@ -86,11 +89,13 @@
<insert id="batchInsert" parameterType="com.pcloud.book.rightsSetting.entity.RightsSettingTitle">
insert into rights_setting_title (id, rights_setting_id, rights_setting_title,
rights_setting_desc, open_state, create_time, update_time,rights_setting_now_type)
rights_setting_desc, open_state, create_time, update_time,rights_setting_now_type,
easy_read,efficient_read,deep_read)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id,jdbcType=BIGINT}, #{item.rightsSettingId,jdbcType=BIGINT}, #{item.rightsSettingTitle,jdbcType=VARCHAR},
#{item.rightsSettingDesc,jdbcType=VARCHAR}, #{item.openState,jdbcType=TINYINT}, now(), now(),#{item.rightsSettingNowType})
#{item.rightsSettingDesc,jdbcType=VARCHAR}, #{item.openState,jdbcType=TINYINT}, now(), now(),#{item.rightsSettingNowType},
#{item.easyRead},#{item.efficientRead},#{item.deepRead})
</foreach>
</insert>
......@@ -113,6 +118,21 @@
when id=#{item.id} then #{item.openState}
</foreach>
</trim>
<trim prefix="easy_read =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.easyRead}
</foreach>
</trim>
<trim prefix="efficient_read =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.efficientRead}
</foreach>
</trim>
<trim prefix="deep_read =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when id=#{item.id} then #{item.deepRead}
</foreach>
</trim>
</trim>
where id in
<foreach collection="list" index="index" item="item" separator="," open="(" close=")">
......@@ -127,6 +147,17 @@
rights_setting_title
where
rights_setting_id = #{rightsSettingId}
<choose>
<when test="readType==1">
and easy_read=1
</when>
<when test="readType==2">
and efficient_read=1
</when>
<when test="readType==3">
and deep_read=1
</when>
</choose>
</select>
<select id="getByRightSettingIdAndType" resultMap="BaseResultMap" parameterType="map">
......@@ -138,6 +169,31 @@
rights_setting_id = #{rightsSettingId}
and
rights_setting_now_type = #{type}
<choose>
<when test="readType==1">
and easy_read=1
</when>
<when test="readType==2">
and efficient_read=1
</when>
<when test="readType==3">
and deep_read=1
</when>
</choose>
</select>
<select id="getCount4Title" resultType="com.pcloud.book.rightsSetting.dto.ReadTypeCountDTO" parameterType="long">
SELECT
rights_setting_id rightsSettingId,
SUM(IFNULL(easy_read, 0)) easyReadCount,
SUM(IFNULL(efficient_read, 0)) efficientReadCount,
SUM(IFNULL(deep_read, 0)) deepReadCount
FROM
`rights_setting_title`
GROUP BY
rights_setting_id
HAVING
rights_setting_id = #{rightsSettingId};
</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