Commit caa1806b by 裴大威

Merge branch 'feat-zp-1002796' into 'master'

1002796 共读社群页面社群书没有书刊时展示内容

See merge request rays/pcloud-book!658
parents 2da0c543 a77a089b
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.dto.AppletGroupManageDTO;
import com.pcloud.book.applet.entity.AppletGroupSearchRecord;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
......@@ -49,4 +51,6 @@ public interface AppletGroupSearchRecordBiz {
void deleteById(Long id);
void deleteByIds(List<Long> ids);
List<GroupActivity4AppletDTO> getTishBookSchoolList(Long bookGroupId);
}
\ No newline at end of file
package com.pcloud.book.applet.biz.impl;
import com.pcloud.book.applet.dto.AppletGroupManageDTO;
import com.pcloud.book.applet.dto.AppletGroupSearchRecordDTO;
import com.pcloud.book.applet.entity.AppletGroupSearchRecord;
import com.pcloud.book.applet.dao.AppletGroupSearchRecordDao;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
import com.pcloud.book.book.dao.BookAdviserDao;
import com.pcloud.book.book.dto.BookAdviserDto;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.group.biz.BookGroupClassifyBiz;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtilParent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -33,13 +45,28 @@ public class AppletGroupSearchRecordBizImpl implements AppletGroupSearchRecordBi
private static final Logger LOGGER = LoggerFactory.getLogger(AppletGroupSearchRecordBizImpl.class);
private static final String GROUP_HEAD_URL_REDIS="BOOK:APPLET:pcloudGroupActivityBizImpl_groupHeadUrl";
@Autowired
private AppletGroupSearchRecordDao appletGroupSearchRecordDao;
@Autowired
private BookGroupClassifyBiz bookGroupClassifyBiz;
@Resource
private PcloudGroupActivityDao pcloudGroupActivityDao;
@Autowired
private RightsSettingBiz rightsSettingBiz;
@Autowired
private BookGroupDao bookGroupDao;
@Autowired
private BookAdviserDao bookAdviserDao;
@Autowired
private ReaderConsr readerConsr;
@Override
@ParamLog("通过ID查询单条数据")
public AppletGroupSearchRecord getById(Long id) {
......@@ -105,4 +132,40 @@ public class AppletGroupSearchRecordBizImpl implements AppletGroupSearchRecordBi
}
appletGroupSearchRecordDao.deleteByIds(ids);
}
@Override
public List<GroupActivity4AppletDTO> getTishBookSchoolList(Long bookGroupId) {
BookGroupDTO bookGroupDTO = bookGroupDao.getBookBaseInfoById(bookGroupId);
BookAdviserDto adviserDto = bookAdviserDao.getBase(bookGroupDTO.getBookId(),bookGroupDTO.getChannelId(),bookGroupDTO.getCreateUser());
BaseTempletClassify baseTempletClassify=new BaseTempletClassify();
if(adviserDto!=null){
baseTempletClassify.setFirstClassify(adviserDto.getTempletId());
baseTempletClassify.setSecondClassify(adviserDto.getSecondTempletId());
baseTempletClassify.setGradeLabelId(adviserDto.getGraLabelId());
baseTempletClassify.setSubjectLabelId(adviserDto.getSubLabelId());
rightsSettingBiz.setClassifyAndLabel(baseTempletClassify);
}
//设置头像
List<GroupActivity4AppletDTO> tishBookSchoolList = pcloudGroupActivityDao.getTishBookSchoolList(baseTempletClassify);
if(ListUtils.isEmpty(tishBookSchoolList)){
return new ArrayList<>();
}
for (GroupActivity4AppletDTO groupActivity4AppletDTO:tishBookSchoolList) {
String filterStr = StringUtilParent.replaceHtml(groupActivity4AppletDTO.getDesc());
String subStr = filterStr.length() > 60 ? filterStr.substring(0, 60) + "..." : filterStr;
groupActivity4AppletDTO.setCutDesc(subStr);
//头像列表从缓存里取
List<String> headUrlList = JedisClusterUtils.hgetJson2List(GROUP_HEAD_URL_REDIS,groupActivity4AppletDTO.getGroupActivityId().toString(),String.class);
//缓存为空或数量不一致,重新获取
if (ListUtils.isEmpty(headUrlList) ||
(headUrlList.size()<9 && !groupActivity4AppletDTO.getUserNumber().equals(headUrlList.size()))){
headUrlList = readerConsr.getRandomHeadUrlList(groupActivity4AppletDTO.getUserNumber()>9 ? 9:groupActivity4AppletDTO.getUserNumber());
JedisClusterUtils.hset2Json(GROUP_HEAD_URL_REDIS,groupActivity4AppletDTO.getGroupActivityId().toString(),headUrlList);
JedisClusterUtils.expire(GROUP_HEAD_URL_REDIS,3600);
}
groupActivity4AppletDTO.setHeadUrlList(headUrlList);
}
return tishBookSchoolList;
}
}
\ No newline at end of file
......@@ -123,4 +123,17 @@ public class AppletGroupManageFacade {
appletGroupSearchRecordBiz.deleteByIds(ids);
return new ResponseDto<>();
}
@ApiOperation("推荐本书相关学舍列表集合")
@GetMapping("getTishBookSchoolList")
public ResponseDto<?> getTishBookSchoolList(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "bookGroupId") Long bookGroupId
)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw BookBizException.PARAM_DELETION;
}
return new ResponseDto<>(appletGroupSearchRecordBiz.getTishBookSchoolList(bookGroupId));
}
}
\ No newline at end of file
......@@ -165,6 +165,4 @@ public class RightsSettingFacede {
}
return new ResponseDto<>(rightsSettingBiz.getFillRightsSettingApplets(rightsSettingId,wechatUserId));
}
}
\ No newline at end of file
......@@ -34,7 +34,10 @@ public interface PcloudGroupActivityBiz {
/**
* 获取共读活动列表(分页)
*/
PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer joinType, Integer numPerPage, Integer currentPage);
PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer joinType,Long firstClassify,
Long secondClassify,
Long gradeLabelId,
Long subjectLabelId ,Integer numPerPage, Integer currentPage);
/**
* 根据分类获取社群共读
......
......@@ -4,7 +4,11 @@ import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
......@@ -12,6 +16,8 @@ import com.pcloud.book.group.biz.GroupQrcodeBiz;
import com.pcloud.book.group.vo.GroupQrcodeBaseInfoVO;
import com.pcloud.book.reading.biz.ReadingActivityBiz;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.skill.biz.PcloudGroupActivityBiz;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
import com.pcloud.book.skill.dao.PcloudSkillDao;
......@@ -33,17 +39,20 @@ import com.sdk.wxgroup.SendGroupInviteVO;
import com.sdk.wxgroup.SendPicMessageVO;
import com.sdk.wxgroup.WxGroupSDK;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
......@@ -70,6 +79,10 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
private RightsSettingBiz rightsSettingBiz;
@Autowired
private ReaderConsr readerConsr;
@Autowired
private BookLabelDao bookLabelDao;
@Autowired
private AssistTempletConsr assistTempletConsr;
@ParamLog("保存共读活动")
@Override
......@@ -158,14 +171,29 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
}
@Override
public PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer joinType, Integer numPerPage, Integer currentPage) {
public PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer joinType,Long firstClassify,
Long secondClassify,
Long gradeLabelId,
Long subjectLabelId, Integer numPerPage, Integer currentPage) {
PageParam pageParam = new PageParam(currentPage, numPerPage);
BaseTempletClassify baseTempletClassify =new BaseTempletClassify();
baseTempletClassify.setFirstClassify(firstClassify);
baseTempletClassify.setSecondClassify(secondClassify);
baseTempletClassify.setSubjectLabelId(subjectLabelId);
baseTempletClassify.setGradeLabelId(gradeLabelId);
if (null != baseTempletClassify.getFirstClassify()){
rightsSettingBiz.setClassifyAndLabel(baseTempletClassify);
}
Map<String, Object> paraMap = Maps.newHashMap();
paraMap.put("name", name);
paraMap.put("proLabelId", proLabelId);
paraMap.put("purLabelId", purLabelId);
paraMap.put("depLabelId", depLabelId);
paraMap.put("joinType", joinType);
paraMap.put("firstClassify", baseTempletClassify.getFirstClassify());
paraMap.put("secondClassify", baseTempletClassify.getSecondClassify());
paraMap.put("gradeLabelId", baseTempletClassify.getGradeLabelId());
paraMap.put("subjectLabelId", baseTempletClassify.getSubjectLabelId());
PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity = pcloudGroupActivityDao.listPageNew(pageParam, paraMap, "queryGroupActivity");
if (null == queryGroupActivity || CollectionUtils.isEmpty(queryGroupActivity.getRecordList())) {
return queryGroupActivity;
......@@ -183,7 +211,8 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
responseVO.setProLabelName(labelName.get(responseVO.getProLabelId()));
responseVO.setDepLabelName(labelName.get(responseVO.getDepLabelId()));
}
//设置分类名称
setLabelContent(queryGroupActivity.getRecordList());
// 截取字符串
for(QueryGroupActivityResponseVO vo : queryGroupActivity.getRecordList()){
String filterStr = StringUtilParent.replaceHtml(vo.getDesc());
......@@ -193,6 +222,58 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
return queryGroupActivity;
}
private void setLabelContent(List<QueryGroupActivityResponseVO> rightsSettingDtos) {
log.info("权益设置标签具体内容");
if (ListUtils.isEmpty(rightsSettingDtos)){
return;
}
List<Long> firstClassifyIds = new ArrayList<>();
List<Long> secondClassifyIds = new ArrayList<>();
List<Long> classifyIds = new ArrayList<>();
List<Long> gradeLabelIds = new ArrayList<>();
List<Long> subjectLabelIds = new ArrayList<>();
List<Long> labelIds = new ArrayList<>();
for (QueryGroupActivityResponseVO queryGroupActivityResponseVO:rightsSettingDtos) {
firstClassifyIds.add(queryGroupActivityResponseVO.getFirstClassify());
secondClassifyIds.add(queryGroupActivityResponseVO.getSecondClassify());
gradeLabelIds.add(queryGroupActivityResponseVO.getGradeLabelId());
subjectLabelIds.add(queryGroupActivityResponseVO.getSubjectLabelId());
}
if (!ListUtils.isEmpty(firstClassifyIds)){
classifyIds.addAll(firstClassifyIds);
}
if (!ListUtils.isEmpty(secondClassifyIds)){
classifyIds.addAll(secondClassifyIds);
}
if (!ListUtils.isEmpty(gradeLabelIds)){
labelIds.addAll(gradeLabelIds);
}
if (!ListUtils.isEmpty(subjectLabelIds)){
labelIds.addAll(subjectLabelIds);
}
Map<Long, AssistTempletDTO> classifyMap = new HashMap<>();
Map<Long, BookLabel> labelMap= new HashMap<>();
if (!ListUtils.isEmpty(classifyIds)){
classifyMap = assistTempletConsr.mapByIds4Classify(classifyIds);
}
if (!ListUtils.isEmpty(labelIds)){
labelMap = bookLabelDao.getMapByIds(labelIds);
}
for (QueryGroupActivityResponseVO rightsSettingDto : rightsSettingDtos){
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getFirstClassify())){
rightsSettingDto.setFirstClassifyName(classifyMap.get(rightsSettingDto.getFirstClassify()).getTempletName());
}
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(rightsSettingDto.getSecondClassify())){
rightsSettingDto.setSecondClassifyName(classifyMap.get(rightsSettingDto.getSecondClassify()).getTempletName());
}
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getGradeLabelId())){
rightsSettingDto.setGradeLabelName(labelMap.get(rightsSettingDto.getGradeLabelId()).getName());
}
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(rightsSettingDto.getSubjectLabelId())){
rightsSettingDto.setSubjectLabelName(labelMap.get(rightsSettingDto.getSubjectLabelId()).getName());
}
}
}
@Override
public GroupActivity4AppletDTO getGroupActivity4Applet(Long firstClassify, Long secondClassify,
......
package com.pcloud.book.skill.dao;
import com.pcloud.book.applet.dto.AppletGroupManageDTO;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.book.skill.entity.PcloudGroupActivity;
import com.pcloud.book.skill.facade.response.QueryGroupActivityResponseVO;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
......@@ -13,4 +16,6 @@ public interface PcloudGroupActivityDao extends BaseDao<PcloudGroupActivity> {
void updateByPrimaryKeySelective(PcloudGroupActivity entity);
GroupActivity4AppletDTO getGroupActivity4Applet(Map<String, Object> map);
List<GroupActivity4AppletDTO> getTishBookSchoolList(BaseTempletClassify baseTempletClassify);
}
\ No newline at end of file
package com.pcloud.book.skill.dao.impl;
import com.pcloud.book.rightsSetting.entity.BaseTempletClassify;
import com.pcloud.book.skill.dao.PcloudGroupActivityDao;
import com.pcloud.book.skill.dto.GroupActivity4AppletDTO;
import com.pcloud.book.skill.entity.PcloudGroupActivity;
import com.pcloud.book.skill.facade.response.QueryGroupActivityResponseVO;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
......@@ -28,4 +30,9 @@ public class PcloudGroupActivityDaoImpl extends BaseDaoImpl<PcloudGroupActivity>
return super.getSqlSession().selectOne(getStatement("getGroupActivity4Applet"), map);
}
@Override
public List<GroupActivity4AppletDTO> getTishBookSchoolList(BaseTempletClassify baseTempletClassify) {
return super.getSqlSession().selectList(getStatement("getTishBookSchoolList"), baseTempletClassify);
}
}
......@@ -58,9 +58,13 @@ public class PcloudGroupActivityFacade {
@RequestParam(value = "purLabelId", required = false) Long purLabelId,
@RequestParam(value = "depLabelId", required = false) Long depLabelId,
@RequestParam(value = "joinType", required = false) Integer joinType,
@RequestParam(value = "firstClassify", required = false) Long firstClassify,
@RequestParam(value = "secondClassify", required = false) Long secondClassify,
@RequestParam(value = "gradeLabelId", required = false) Long gradeLabelId,
@RequestParam(value = "subjectLabelId", required = false) Long subjectLabelId,
@RequestParam("numPerPage") Integer numPerPage,
@RequestParam("currentPage") Integer currentPage){
return new ResponseDto<>(pcloudGroupActivityBiz.queryGroupActivity(name, proLabelId, purLabelId, depLabelId, joinType, numPerPage, currentPage));
return new ResponseDto<>(pcloudGroupActivityBiz.queryGroupActivity(name, proLabelId, purLabelId, depLabelId, joinType,firstClassify,secondClassify, gradeLabelId,subjectLabelId,numPerPage, currentPage));
}
......
......@@ -51,11 +51,23 @@ public class QueryGroupActivityResponseVO {
@ApiModelProperty("第一级类型标识")
private Long firstClassify;
@ApiModelProperty("第一级类型标识名称")
private String firstClassifyName;
@ApiModelProperty("第二级类型标识")
private Long secondClassify;
@ApiModelProperty("第二级类型标识名称")
private String secondClassifyName;
@ApiModelProperty("年级标签id")
private Long gradeLabelId;
@ApiModelProperty("年级标签名称")
private String gradeLabelName;
@ApiModelProperty("科目标签id")
private Long subjectLabelId;
@ApiModelProperty("科目标签名称")
private String subjectLabelName;
}
......@@ -68,6 +68,58 @@
<if test="joinType != null">
and a.join_type = #{joinType}
</if>
<if test="firstClassify != null">
and a.first_classify = #{firstClassify}
</if>
<if test="secondClassify != null">
and a.second_classify = #{secondClassify}
</if>
<if test="gradeLabelId != null">
and a.grade_label_id = #{gradeLabelId}
</if>
<if test="subjectLabelId != null">
and a.subject_label_id = #{subjectLabelId}
</if>
order by a.id desc
</select>
<select id="getTishBookSchoolList" resultType="com.pcloud.book.skill.dto.GroupActivity4AppletDTO" parameterType="com.pcloud.book.rightsSetting.entity.BaseTempletClassify" >
SELECT
a.id,
a.id groupActivityId,
a.`name`,
a.description as `desc`,
a.join_type AS joinType,
a.group_pic AS groupPic,
a.book_group_qrcode_id AS bookGroupQrcodeId,
b.group_name AS groupName,
b.user_number userNumber,
b.classify_id classifyId,
c.book_group_id bookGroupId,
a.first_classify AS firstClassify,
a.second_classify AS secondClassify,
a.grade_label_id AS gradeLabelId,
a.subject_label_id AS subjectLabelId
FROM
pcloud_group_activity a
INNER JOIN book_group_qrcode b on a.book_group_qrcode_id = b.id AND b.is_delete = 0
INNER JOIN book_group_classify c ON b.classify_id = c.id AND c.is_delete = 0
WHERE
a.is_delete = 0
<if test="firstClassify != null">
and a.first_classify = #{firstClassify}
</if>
<if test="secondClassify != null">
and a.second_classify = #{secondClassify}
</if>
<if test="gradeLabelId != null">
and a.grade_label_id = #{gradeLabelId}
</if>
<if test="subjectLabelId != null">
and a.subject_label_id = #{subjectLabelId}
</if>
ORDER BY id DESC
LIMIT 10
</select>
<select id="getById" resultMap="BaseResultMap" parameterType="long" >
......
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