Commit cd0230bf by zhuyajie

1002681小程序学舍

parent bf67e2df
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.dto.UpdateAppletGroupManageDTO;
import com.pcloud.book.applet.entity.AppletGroupManage;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
/**
* 学舍群管理(AppletGroupManage)表服务接口
*
* @author zyq
* @since 2020-04-01 14:05:41
*/
public interface AppletGroupManageBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletGroupManage getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(String name, Integer currentPage, Integer numPerPage);
/**
* 任意门
* @param recommend
* @param currentPage
* @param numPerPage
* @return
*/
PageBeanNew getList4Applet(Integer recommend, Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param groupActivityIds
* @return 主键
*/
void insert(List<Long> groupActivityIds);
/**
* 修改数据
*
* @param updateAppletGroupManageDTO 实例对象
*/
void update(UpdateAppletGroupManageDTO updateAppletGroupManageDTO);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
}
\ No newline at end of file
package com.pcloud.book.applet.biz;
import com.pcloud.book.applet.entity.AppletGroupSearchRecord;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
/**
* (AppletGroupSearchRecord)表服务接口
*
* @author zyq
* @since 2020-04-01 17:34:47
*/
public interface AppletGroupSearchRecordBiz {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
AppletGroupSearchRecord getById(Long id);
/**
* 分页查询
*/
PageBeanNew getList(Long wechatUserId, Integer isMore, Integer currentPage, Integer numPerPage);
/**
* 新增数据
*
* @param appletGroupSearchRecord 实例对象
* @return 主键
*/
Long insert(AppletGroupSearchRecord appletGroupSearchRecord);
/**
* 修改数据
*
* @param appletGroupSearchRecord 实例对象
*/
void update(AppletGroupSearchRecord appletGroupSearchRecord);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
void deleteById(Long id);
void deleteByIds(List<Long> ids);
}
\ No newline at end of file
package com.pcloud.book.applet.biz.impl;
import com.google.common.collect.Lists;
import com.pcloud.book.applet.dto.AppletGroupManageDTO;
import com.pcloud.book.applet.dto.UpdateAppletGroupManageDTO;
import com.pcloud.book.applet.entity.AppletGroupManage;
import com.pcloud.book.applet.dao.AppletGroupManageDao;
import com.pcloud.book.applet.biz.AppletGroupManageBiz;
import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
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.StringUtil;
import com.pcloud.common.utils.string.StringUtilParent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 学舍群管理(AppletGroupManage)表服务实现类
*
* @author zyq
* @since 2020-04-01 14:05:42
*/
@Service("appletGroupManageBiz")
public class AppletGroupManageBizImpl implements AppletGroupManageBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletGroupManageBizImpl.class);
private static final String GROUP_HEAD_URL_REDIS="BOOK:APPLET:appletGroupManage_groupHeadUrl";
@Autowired
private AppletGroupManageDao appletGroupManageDao;
@Autowired
private LabelConsr labelConsr;
@Autowired
private ReaderConsr readerConsr;
@Override
public AppletGroupManage getById(Long id) {
return appletGroupManageDao.getById(id);
}
@Override
public PageBeanNew getList(String name, Integer currentPage, Integer numPerPage) {
Map<String,Object> map = new HashMap<>();
map.put("name", name);
PageBeanNew<AppletGroupManageDTO> recordList = appletGroupManageDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getList");
if (null == recordList || CollectionUtils.isEmpty(recordList.getRecordList())) {
return recordList;
}
// 组装标签名称
List<Long> labelId = Lists.newArrayList();
for (AppletGroupManageDTO dto : recordList.getRecordList()) {
labelId.add(dto.getProLabelId());
labelId.add(dto.getPurLabelId());
labelId.add(dto.getDepLabelId());
}
Map<Long, String> labelName = labelConsr.getLabelName(labelId);
for (AppletGroupManageDTO dto : recordList.getRecordList()) {
dto.setPurLabelName(labelName.get(dto.getPurLabelId()));
dto.setProLabelName(labelName.get(dto.getProLabelId()));
dto.setDepLabelName(labelName.get(dto.getDepLabelId()));
}
// 截取字符串
for(AppletGroupManageDTO dto : recordList.getRecordList()){
String filterStr = StringUtilParent.replaceHtml(dto.getDesc());
String subStr = filterStr.length() > 60 ? filterStr.substring(0, 60) + "..." : filterStr;
dto.setCutDesc(subStr);
dto.setQrcodeHeadUrl(readerConsr.getNineHeadUrl());
}
return recordList;
}
@Override
public PageBeanNew getList4Applet(Integer recommend, Integer currentPage, Integer numPerPage) {
Map<String,Object> map = new HashMap<>();
map.put("recommend", recommend);
PageBeanNew<AppletGroupManageDTO> recordList = appletGroupManageDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getList4Applet");
if (null == recordList || CollectionUtils.isEmpty(recordList.getRecordList())) {
return recordList;
}
// 截取字符串
for(AppletGroupManageDTO dto : recordList.getRecordList()){
String filterStr = StringUtilParent.replaceHtml(dto.getDesc());
String subStr = filterStr.length() > 60 ? filterStr.substring(0, 60) + "..." : filterStr;
dto.setCutDesc(subStr);
//头像列表从缓存里取
List<String> headUrlList = JedisClusterUtils.hgetJson2List(GROUP_HEAD_URL_REDIS,dto.getGroupActivityId().toString(),String.class);
//缓存为空或数量不一致,重新获取
if (ListUtils.isEmpty(headUrlList) ||
(headUrlList.size()<9&&!dto.getUserNumber().equals(headUrlList.size()))){
headUrlList = readerConsr.getRandomHeadUrlList(dto.getUserNumber()>9?9:dto.getUserNumber());
JedisClusterUtils.hset2Json(GROUP_HEAD_URL_REDIS,dto.getGroupActivityId().toString(),headUrlList);
JedisClusterUtils.expire(GROUP_HEAD_URL_REDIS,3600);
}
dto.setHeadUrlList(headUrlList);
dto.setQrcodeHeadUrl(readerConsr.getNineHeadUrl());
}
return recordList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void insert(List<Long> groupActivityIds) {
if(!ListUtils.isEmpty(groupActivityIds)){
List<AppletGroupManage> list = Lists.newArrayList();
Integer maxSeqNum = appletGroupManageDao.getMaxSeqNum();
AppletGroupManage appletGroupManage;
for (Long groupActivityId : groupActivityIds) {
appletGroupManage = new AppletGroupManage();
appletGroupManage.setGroupActivityId(groupActivityId);
appletGroupManage.setRecommend(0);
appletGroupManage.setEnable(1);
appletGroupManage.setSeqNum((maxSeqNum + groupActivityIds.indexOf(groupActivityId) + 1));
list.add(appletGroupManage);
}
try {
appletGroupManageDao.insert(list);
} catch (DuplicateKeyException e){
throw new BizException("请勿添加重复数据");
}
}
}
@Override
public void update(UpdateAppletGroupManageDTO updateAppletGroupManageDTO) {
if(updateAppletGroupManageDTO == null || !NumberUtil.isNumber(updateAppletGroupManageDTO.getId())){
throw BizException.PARAM_IS_NULL;
}
AppletGroupManage appletGroupManage = new AppletGroupManage();
BeanUtils.copyProperties(updateAppletGroupManageDTO, appletGroupManage);
appletGroupManageDao.update(appletGroupManage);
}
@Override
public void deleteById(Long id) {
appletGroupManageDao.deleteById(id);
}
}
\ No newline at end of file
package com.pcloud.book.applet.biz.impl;
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.group.biz.BookGroupClassifyBiz;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dto.BookGroupDTO;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* (AppletGroupSearchRecord)表服务实现类
*
* @author zyq
* @since 2020-04-01 17:34:47
*/
@Service("appletGroupSearchRecordBiz")
public class AppletGroupSearchRecordBizImpl implements AppletGroupSearchRecordBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(AppletGroupSearchRecordBizImpl.class);
@Autowired
private AppletGroupSearchRecordDao appletGroupSearchRecordDao;
@Autowired
private BookGroupClassifyBiz bookGroupClassifyBiz;
@Autowired
private BookGroupDao bookGroupDao;
@Override
@ParamLog("通过ID查询单条数据")
public AppletGroupSearchRecord getById(Long id) {
return appletGroupSearchRecordDao.getById(id);
}
@Override
@ParamLog("查询多条数据")
public PageBeanNew getList(Long wechatUserId, Integer isMore, Integer currentPage, Integer numPerPage) {
Map<String,Object> map = new HashMap<>();
map.put("wechatUserId", wechatUserId);
PageBeanNew pageBeanNew = appletGroupSearchRecordDao.listPageNew(new PageParam(currentPage, numPerPage), map, "getList");
List<AppletGroupSearchRecordDTO> recordList = pageBeanNew.getRecordList();
if (ListUtils.isEmpty(recordList)){
return pageBeanNew;
}
// 填充分类信息
for (AppletGroupSearchRecordDTO dto : recordList){
if(isMore == 1) {
dto.setClassifyCount(bookGroupClassifyBiz.getClassifyCount(dto.getBookGroupId()));
} else {
dto.setClassify4WechatVOList(bookGroupClassifyBiz.listClassify4Wechat(dto.getBookGroupId(), dto.getWechatUserId()));
}
}
return pageBeanNew;
}
@Override
@ParamLog("新增")
public Long insert(AppletGroupSearchRecord appletGroupSearchRecord) {
if(!NumberUtil.isNumber(appletGroupSearchRecord.getBookId()) || !NumberUtil.isNumber(appletGroupSearchRecord.getChannelId()) || !NumberUtil.isNumber(appletGroupSearchRecord.getAdviserId())){
throw BizException.PARAM_DELETION;
}
BookGroupDTO bookGroupDTO = bookGroupDao.getDTOByBookId(appletGroupSearchRecord.getBookId(), appletGroupSearchRecord.getChannelId(), appletGroupSearchRecord.getAdviserId());
if(bookGroupDTO != null && bookGroupDTO.getId() != null && bookGroupDTO.getId() > 0){
appletGroupSearchRecord.setBookGroupId(bookGroupDTO.getId());
appletGroupSearchRecordDao.insert(appletGroupSearchRecord);
return appletGroupSearchRecord.getId();
}
return 0L;
}
@Override
@ParamLog("修改")
public void update(AppletGroupSearchRecord appletGroupSearchRecord) {
if(appletGroupSearchRecord == null || !NumberUtil.isNumber(appletGroupSearchRecord.getId())){
throw BizException.PARAM_DELETION;
}
appletGroupSearchRecordDao.update(appletGroupSearchRecord);
}
@Override
@ParamLog("删除")
public void deleteById(Long id) {
appletGroupSearchRecordDao.deleteById(id);
}
@Override
@ParamLog("删除")
public void deleteByIds(List<Long> ids) {
if(ListUtils.isEmpty(ids)){
throw BizException.PARAM_DELETION;
}
appletGroupSearchRecordDao.deleteByIds(ids);
}
}
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.entity.AppletGroupManage;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* 学舍群管理(AppletGroupManage)表数据库访问层
*
* @author zyq
* @since 2020-04-01 14:05:40
*/
public interface AppletGroupManageDao extends BaseDao<AppletGroupManage> {
Integer getMaxSeqNum();
}
\ No newline at end of file
package com.pcloud.book.applet.dao;
import com.pcloud.book.applet.entity.AppletGroupSearchRecord;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* (AppletGroupSearchRecord)表数据库访问层
*
* @author zyq
* @since 2020-04-01 17:34:47
*/
public interface AppletGroupSearchRecordDao extends BaseDao<AppletGroupSearchRecord> {
void deleteByIds(List<Long> ids);
}
\ No newline at end of file
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.entity.AppletGroupManage;
import com.pcloud.book.applet.dao.AppletGroupManageDao;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 学舍群管理(AppletGroupManage)表数据库访问层
*
* @author zyq
* @since 2020-04-01 14:05:41
*/
@Repository("appletGroupManageDaoImpl")
public class AppletGroupManageDaoImpl extends BaseDaoImpl<AppletGroupManage> implements AppletGroupManageDao {
@Override
public Integer getMaxSeqNum() {
return super.sqlSessionTemplate.selectOne(getStatement("getMaxSeqNum"));
}
}
\ No newline at end of file
package com.pcloud.book.applet.dao.impl;
import com.pcloud.book.applet.entity.AppletGroupSearchRecord;
import com.pcloud.book.applet.dao.AppletGroupSearchRecordDao;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* (AppletGroupSearchRecord)表数据库访问层
*
* @author zyq
* @since 2020-04-01 17:34:47
*/
@Repository("appletGroupSearchRecordDaoImpl")
public class AppletGroupSearchRecordDaoImpl extends BaseDaoImpl<AppletGroupSearchRecord> implements AppletGroupSearchRecordDao {
@Override
public void deleteByIds(List<Long> list) {
super.sqlSessionTemplate.delete(getStatement("deleteByIds"), list);
}
}
\ No newline at end of file
package com.pcloud.book.applet.dto;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 学舍群管理(AppletGroupManage)实体类
*
* @author zyq
* @since 2020-04-01 14:05:37
*/
@Data
public class AppletGroupManageDTO extends BaseEntity {
private Long id;
@ApiModelProperty("共读活动id")
private Long groupActivityId;
@ApiModelProperty("上架")
private Integer enable;
@ApiModelProperty("推荐到首页")
private Integer recommend;
@ApiModelProperty("共度名称")
private String name;
@ApiModelProperty("描述")
private String desc;
@ApiModelProperty("描述")
private String cutDesc;
@ApiModelProperty("群图片,加群方式为图片时有效")
private String groupPic;
@ApiModelProperty("社群码id")
private Long bookGroupQrcodeId;
@ApiModelProperty("社群码名称")
private String groupName;
@ApiModelProperty("专业标签id")
private Long proLabelId;
@ApiModelProperty("专业标签")
private String proLabelName;
@ApiModelProperty("深度标签id")
private Long depLabelId;
@ApiModelProperty("深度标签")
private String depLabelName;
@ApiModelProperty("目的标签id")
private Long purLabelId;
@ApiModelProperty("目的标签")
private String purLabelName;
@ApiModelProperty("群人数")
private Integer userNumber;
@ApiModelProperty("序号")
private Integer seqNum;
@ApiModelProperty("头像")
private String qrcodeHeadUrl;
@ApiModelProperty("群分类id")
private Long classifyId;
@ApiModelProperty("群id")
private Long bookGroupId;
@ApiModelProperty("头像列表")
private List<String> headUrlList;
}
\ No newline at end of file
package com.pcloud.book.applet.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.book.group.vo.ListClassify4WechatVO;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* (AppletGroupSearchRecord)实体类
*
* @author zyq
* @since 2020-04-01 17:34:47
*/
@Data
public class AppletGroupSearchRecordDTO implements Serializable {
private Long id;
@ApiModelProperty("社群码id")
private Long bookGroupId;
@ApiModelProperty("用户id")
private Long wechatUserId;
@ApiModelProperty("图书id")
private Long bookId;
@ApiModelProperty("运营id")
private Long channelId;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("书籍名称")
private String bookName;
@ApiModelProperty("出版社")
private String publish;
@ApiModelProperty("作者")
private String author;
@ApiModelProperty("简介")
private String remark;
@ApiModelProperty("书籍封面")
private String coverImg;
@ApiModelProperty("交流群个数")
private Integer classifyCount;
@ApiModelProperty("群分类信息")
private List<ListClassify4WechatVO> classify4WechatVOList;
}
\ No newline at end of file
package com.pcloud.book.applet.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class UpdateAppletGroupManageDTO implements Serializable {
private Long id;
@ApiModelProperty("上架")
private Integer enable;
@ApiModelProperty("推荐到首页")
private Integer recommend;
@ApiModelProperty("序号")
private Integer seqNum;
}
package com.pcloud.book.applet.entity;
import java.util.Date;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 学舍群管理(AppletGroupManage)实体类
*
* @author zyq
* @since 2020-04-01 14:05:37
*/
@Data
public class AppletGroupManage extends BaseEntity {
private static final long serialVersionUID = 756856688436151148L;
private Long id;
@ApiModelProperty("共读活动id")
private Long groupActivityId;
@ApiModelProperty("上架")
private Integer enable;
@ApiModelProperty("推荐到首页")
private Integer recommend;
@ApiModelProperty("序号")
private Integer seqNum;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}
\ No newline at end of file
package com.pcloud.book.applet.entity;
import java.util.Date;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* (AppletGroupSearchRecord)实体类
*
* @author zyq
* @since 2020-04-01 17:34:47
*/
@Data
public class AppletGroupSearchRecord extends BaseEntity {
private static final long serialVersionUID = 217602641427761867L;
private Long id;
@ApiModelProperty("社群码id")
private Long bookGroupId;
@ApiModelProperty("用户id")
private Long wechatUserId;
@ApiModelProperty("图书id")
private Long bookId;
@ApiModelProperty("运营id")
private Long channelId;
@ApiModelProperty("编辑id")
private Long adviserId;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.applet.facade;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
import com.pcloud.book.applet.dto.UpdateAppletGroupManageDTO;
import com.pcloud.book.applet.biz.AppletGroupManageBiz;
import com.pcloud.book.applet.entity.AppletGroupSearchRecord;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/**
* 学舍群管理(AppletGroupManage)表控制层
*
* @author zyq
* @since 2020-04-01 14:05:42
*/
@Api("小睿学舍群管理")
@RestController("appletGroupManageFacade")
@RequestMapping("appletGroupManage")
public class AppletGroupManageFacade {
@Autowired
private AppletGroupManageBiz appletGroupManageBiz;
@Autowired
private AppletGroupSearchRecordBiz appletGroupSearchRecordBiz;
@ApiOperation("社群任意门")
@GetMapping("getList")
public ResponseDto<?> getList(@RequestHeader("token") String token,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
return new ResponseDto<>(appletGroupManageBiz.getList(name, currentPage, numPerPage));
}
@ApiOperation("社群任意门Applet")
@GetMapping("getList4Applet")
public ResponseDto<?> getList4Applet(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "recommend", required = false) Integer recommend,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "5") Integer numPerPage)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw BookBizException.PARAM_DELETION;
}
return new ResponseDto<>(appletGroupManageBiz.getList4Applet(recommend, currentPage, numPerPage));
}
@ApiOperation("新增社群")
@PostMapping("insert")
public ResponseDto<?> insert(@RequestHeader("token") String token, @RequestBody List<Long> groupActivityIds)
throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
appletGroupManageBiz.insert(groupActivityIds);
return new ResponseDto<>();
}
@ApiOperation("更新上下架、推荐首页")
@PostMapping("update")
public ResponseDto<?> update(@RequestHeader("token") String token,@RequestBody UpdateAppletGroupManageDTO UpdateAppletGroupManageDTO) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
appletGroupManageBiz.update(UpdateAppletGroupManageDTO);
return new ResponseDto<>();
}
@ApiOperation("删除社群")
@GetMapping("deleteById")
public ResponseDto<?> deleteById(@RequestHeader("token") String token, @RequestParam Long id) throws BizException, PermissionException {
SessionUtil.getToken4Redis(token);
if (null == id) {
throw BookBizException.PARAM_DELETION;
}
appletGroupManageBiz.deleteById(id);
return new ResponseDto<>();
}
@ApiOperation("新增社群书搜索记录")
@PostMapping("insertSearchRecord")
public ResponseDto<?> insertSearchRecord(@CookieValue("userInfo") String userInfo, @RequestBody AppletGroupSearchRecord appletGroupSearchRecord)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw BookBizException.PARAM_DELETION;
}
appletGroupSearchRecord.setWechatUserId(wechatUserId);
return new ResponseDto<>(appletGroupSearchRecordBiz.insert(appletGroupSearchRecord));
}
@ApiOperation("分页查询社群书搜索记录")
@GetMapping("getSearchRecordList")
public ResponseDto<?> getSearchRecordList(@CookieValue("userInfo") String userInfo,
@RequestParam(value = "isMore", defaultValue = "0") Integer isMore,
@RequestParam(value = "currentPage", defaultValue = "0") Integer currentPage,
@RequestParam(value = "numPerPage", defaultValue = "10") Integer numPerPage)
throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw BookBizException.PARAM_DELETION;
}
return new ResponseDto<>(appletGroupSearchRecordBiz.getList(wechatUserId, isMore, currentPage, numPerPage));
}
@ApiOperation("删除共读社群记录")
@PostMapping("deleteSearchRecordByIds")
public ResponseDto<?> deleteSearchRecordByIds(@CookieValue("userInfo") String userInfo, @RequestBody List<Long> ids) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if(!NumberUtil.isNumber(wechatUserId)){
throw BookBizException.PARAM_DELETION;
}
appletGroupSearchRecordBiz.deleteByIds(ids);
return new ResponseDto<>();
}
}
\ No newline at end of file
package com.pcloud.book.consumer.reader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -84,6 +85,17 @@ public class ReaderConsr {
return JSONUtils.toJSONString(headUrls);
}
@ParamLog("获取n个用户头像")
public List<String> getRandomHeadUrlList(Integer random) {
List<WechatUserRobotDto> wechatUsers = this.selectRobotsRandom(random);
if (ListUtils.isEmpty(wechatUsers)) {
return new ArrayList<>();
}
List<String> headUrls = wechatUsers.stream().map(a -> a.getWechatUserHeadUrl()).collect(Collectors.toList());
return headUrls;
}
@ParamLog(value = "获取wechatUserId", isAfterReturn = false)
public Long getWechatUserId(String wxUserId,Long channelId) throws BizException {
if (channelId == null || StringUtil.isEmpty(wxUserId)) {
......
......@@ -47,6 +47,11 @@ public interface BookGroupClassifyBiz {
void addClassify(AddClassifyVO addClassifyVO, Long partyId);
/**
* 获取群分类数量
*/
Integer getClassifyCount(Long bookGroupId);
/**
* @Author:lili
* @Desr:更新分类
* @Date:2019/4/17 15:53
......
......@@ -358,8 +358,9 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
}
}
@Override
@ParamLog("获取社群下有多少分类")
private Integer getClassifyCount(Long bookGroupId) {
public Integer getClassifyCount(Long bookGroupId) {
Integer count = bookGroupClassifyDao.getClassifyCount(bookGroupId);
return count;
}
......
......@@ -33,6 +33,6 @@ public interface PcloudGroupActivityBiz {
/**
* 获取共读活动列表(分页)
*/
PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer numPerPage, Integer currentPage);
PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer joinType, Integer numPerPage, Integer currentPage);
}
......@@ -144,13 +144,14 @@ public class PcloudGroupActivityBizImpl implements PcloudGroupActivityBiz {
}
@Override
public PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer numPerPage, Integer currentPage) {
public PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity(String name, Long proLabelId, Long purLabelId, Long depLabelId, Integer joinType, Integer numPerPage, Integer currentPage) {
PageParam pageParam = new PageParam(currentPage, numPerPage);
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);
PageBeanNew<QueryGroupActivityResponseVO> queryGroupActivity = pcloudGroupActivityDao.listPageNew(pageParam, paraMap, "queryGroupActivity");
if (null == queryGroupActivity || CollectionUtils.isEmpty(queryGroupActivity.getRecordList())) {
return queryGroupActivity;
......
......@@ -57,9 +57,10 @@ public class PcloudGroupActivityFacade {
@RequestParam(value = "proLabelId", required = false) Long proLabelId,
@RequestParam(value = "purLabelId", required = false) Long purLabelId,
@RequestParam(value = "depLabelId", required = false) Long depLabelId,
@RequestParam(value = "joinType", required = false) Integer joinType,
@RequestParam("numPerPage") Integer numPerPage,
@RequestParam("currentPage") Integer currentPage){
return new ResponseDto<>(pcloudGroupActivityBiz.queryGroupActivity(name, proLabelId, purLabelId, depLabelId, numPerPage, currentPage));
return new ResponseDto<>(pcloudGroupActivityBiz.queryGroupActivity(name, proLabelId, purLabelId, depLabelId, joinType, numPerPage, currentPage));
}
......
<?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.applet.dao.impl.AppletGroupManageDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletGroupManage">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="group_activity_id" property="groupActivityId" jdbcType="BIGINT"/>
<result column="enable" property="enable" jdbcType="INTEGER"/>
<result column="recommend" property="recommend" jdbcType="INTEGER"/>
<result column="seq_num" property="seqNum" jdbcType="INTEGER"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, group_activity_id, enable, recommend, seq_num, create_time
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_group_manage
WHERE id = #{id}
</select>
<select id="getList" resultType="com.pcloud.book.applet.dto.AppletGroupManageDTO">
SELECT
a.id,
a.group_activity_id groupActivityId,
a.`enable`,
a.recommend,
a.seq_num seqNum,
b.`name`,
b.description as `desc`,
b.group_pic AS groupPic,
b.book_group_qrcode_id AS bookGroupQrcodeId,
b.pro_label_id AS proLabelId,
b.dep_label_id AS depLabelId,
b.pur_label_id AS purLabelId,
c.group_name AS groupName,
c.user_number userNumber
FROM
applet_group_manage a
INNER JOIN pcloud_group_activity b ON a.group_activity_id = b.id AND b.is_delete = 0
LEFT JOIN book_group_qrcode c on b.book_group_qrcode_id = c.id AND c.is_delete = 0
WHERE 1=1
<if test="name!=null">
AND b.name like concat('%',#{name},'%')
</if>
<if test="enable!=null">
AND a.enable=#{enable}
</if>
<if test="recommend!=null">
AND a.recommend=#{recommend}
</if>
ORDER BY a.seq_num, a.id DESC
</select>
<select id="getList4Applet" resultType="com.pcloud.book.applet.dto.AppletGroupManageDTO">
SELECT
a.id,
a.group_activity_id groupActivityId,
b.`name`,
b.description as `desc`,
b.group_pic AS groupPic,
b.book_group_qrcode_id AS bookGroupQrcodeId,
c.group_name AS groupName,
c.user_number userNumber,
c.classify_id classifyId,
d.book_group_id bookGroupId
FROM
applet_group_manage a
INNER JOIN pcloud_group_activity b ON a.group_activity_id = b.id AND b.is_delete = 0
INNER JOIN book_group_qrcode c ON b.book_group_qrcode_id = c.id AND c.is_delete = 0
INNER JOIN book_group_classify d ON c.classify_id = d.id AND d.is_delete = 0
WHERE a.enable=1
<if test="recommend!=null">
AND a.recommend=#{recommend}
</if>
<if test="name!=null">
AND b.name like concat('%',#{name},'%')
</if>
ORDER BY a.seq_num, a.id DESC
</select>
<select id="getMaxSeqNum" resultType="integer">
SELECT
IFNULL(MAX(seq_num), 0)
FROM applet_group_manage
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_group_manage(
group_activity_id,
enable,
recommend,
seq_num,
create_time
) VALUES (
#{groupActivityId, jdbcType=BIGINT},
#{enable, jdbcType=INTEGER},
#{recommend, jdbcType=INTEGER},
#{seqNum, jdbcType=INTEGER},
NOW()
)
</insert>
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_group_manage (
group_activity_id,
enable,
recommend,
seq_num,
create_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.groupActivityId, jdbcType=BIGINT},
#{item.enable, jdbcType=INTEGER},
#{item.recommend, jdbcType=INTEGER},
#{item.seqNum, jdbcType=INTEGER},
NOW()
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE applet_group_manage
<set>
<if test="groupActivityId != null">
group_activity_id = #{groupActivityId},
</if>
<if test="enable != null">
enable = #{enable},
</if>
<if test="recommend != null">
recommend = #{recommend},
</if>
<if test="seqNum != null">
seq_num = #{seqNum},
</if>
</set>
WHERE id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM applet_group_manage where id = #{id}
</delete>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pcloud.book.applet.dao.impl.AppletGroupSearchRecordDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletGroupSearchRecord">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="book_id" property="bookId" jdbcType="BIGINT"/>
<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="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_group_id, wechat_user_id, book_id, channel_id, adviser_id, create_time, update_time
</sql>
<select id="getById" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM applet_group_search_record
WHERE id = #{id}
</select>
<select id="getList" resultType="com.pcloud.book.applet.dto.AppletGroupSearchRecordDTO">
SELECT
a.id,
a.book_group_id bookGroupId,
a.book_id bookId,
a.channel_id channelId,
a.adviser_id adviserId,
a.wechat_user_id wechatUserId,
d.BOOK_NAME bookName,
d.AUTHOR author,
d.PUBLISH publish,
d.REMARK remark,
d.COVER_IMG coverImg
FROM applet_group_search_record a
INNER JOIN BOOK d ON a.BOOK_ID = d.BOOK_ID
WHERE 1=1
<if test="wechatUserId!=null">
AND a.wechat_user_id = #{wechatUserId}
</if>
ORDER BY update_time DESC
</select>
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_group_search_record(
book_group_id,
wechat_user_id,
book_id,
channel_id,
adviser_id,
create_time,
update_time
) VALUES (
#{bookGroupId, jdbcType=BIGINT},
#{wechatUserId, jdbcType=BIGINT},
#{bookId, jdbcType=BIGINT},
#{channelId, jdbcType=BIGINT},
#{adviserId, jdbcType=BIGINT},
NOW(),
NOW()
)
ON DUPLICATE KEY UPDATE update_time=NOW()
</insert>
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true">
INSERT INTO applet_group_search_record (
book_group_id,
wechat_user_id,
book_id,
channel_id,
adviser_id,
create_time,
update_time
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.bookGroupId, jdbcType=BIGINT},
#{item.wechatUserId, jdbcType=BIGINT},
#{item.bookId, jdbcType=BIGINT},
#{item.channelId, jdbcType=BIGINT},
#{item.adviserId, jdbcType=BIGINT},
NOW(),
NOW()
)
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
UPDATE applet_group_search_record
<set>
<if test="bookGroupId != null">
book_group_id = #{bookGroupId},
</if>
<if test="wechatUserId != null">
wechat_user_id = #{wechatUserId},
</if>
<if test="bookId != null">
book_id = #{bookId},
</if>
<if test="channelId != null">
channel_id = #{channelId},
</if>
<if test="adviserId != null">
adviser_id = #{adviserId},
</if>
</set>
WHERE id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
DELETE FROM applet_group_search_record where id = #{id}
</delete>
<!--通过主键删除-->
<delete id="deleteByIds">
DELETE FROM applet_group_search_record
where id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
${item}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -56,6 +56,9 @@
<if test="name != null">
and a.name like CONCAT('%', #{name},'%')
</if>
<if test="joinType != null">
and a.join_type = #{joinType}
</if>
</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