Commit 7cb56b0c by 阮思源

1002140新版个人号1.0

parent d275579c
......@@ -577,6 +577,32 @@ public class BookDto extends BaseDto {
*/
private Boolean hasServe;
/**
* 书籍简称
*/
private String shortBookName;
/**
* 年级标签id
*/
private Long graLabelId;
/**
* 科目标签id
*/
private Long subLabelId;
/**
* 版本标签id
*/
private Long verLabelId;
/**
* 地域标签id
*/
private Long areaLabelId;
public String getQrRemark() {
return qrRemark;
}
......@@ -1541,6 +1567,46 @@ public class BookDto extends BaseDto {
this.hasServe = hasServe;
}
public String getShortBookName() {
return shortBookName;
}
public void setShortBookName(String shortBookName) {
this.shortBookName = shortBookName;
}
public Long getGraLabelId() {
return graLabelId;
}
public void setGraLabelId(Long graLabelId) {
this.graLabelId = graLabelId;
}
public Long getSubLabelId() {
return subLabelId;
}
public void setSubLabelId(Long subLabelId) {
this.subLabelId = subLabelId;
}
public Long getVerLabelId() {
return verLabelId;
}
public void setVerLabelId(Long verLabelId) {
this.verLabelId = verLabelId;
}
public Long getAreaLabelId() {
return areaLabelId;
}
public void setAreaLabelId(Long areaLabelId) {
this.areaLabelId = areaLabelId;
}
@Override
public String toString() {
return "BookDto{" +
......@@ -1657,6 +1723,11 @@ public class BookDto extends BaseDto {
", friendsCount=" + friendsCount +
", bookGroupCipher='" + bookGroupCipher + '\'' +
", hasServe=" + hasServe +
", shortBookName='" + shortBookName + '\'' +
", graLabelId=" + graLabelId +
", subLabelId=" + subLabelId +
", verLabelId=" + verLabelId +
", areaLabelId=" + areaLabelId +
"} " + super.toString();
}
}
......@@ -202,6 +202,26 @@ public class Book extends BaseEntity {
*/
private String secondTypeCode;
/**
* 年级标签id
*/
private Long graLabelId;
/**
* 科目标签id
*/
private Long subLabelId;
/**
* 版本标签id
*/
private Long verLabelId;
/**
* 地域标签id
*/
private Long areaLabelId;
public Long getBookId() {
return bookId;
}
......@@ -498,6 +518,38 @@ public class Book extends BaseEntity {
this.secondTypeCode = secondTypeCode;
}
public Long getGraLabelId() {
return graLabelId;
}
public void setGraLabelId(Long graLabelId) {
this.graLabelId = graLabelId;
}
public Long getSubLabelId() {
return subLabelId;
}
public void setSubLabelId(Long subLabelId) {
this.subLabelId = subLabelId;
}
public Long getVerLabelId() {
return verLabelId;
}
public void setVerLabelId(Long verLabelId) {
this.verLabelId = verLabelId;
}
public Long getAreaLabelId() {
return areaLabelId;
}
public void setAreaLabelId(Long areaLabelId) {
this.areaLabelId = areaLabelId;
}
@Override
public String toString() {
return "Book{" +
......@@ -538,6 +590,10 @@ public class Book extends BaseEntity {
", bookGroupId=" + bookGroupId +
", secondTempletId=" + secondTempletId +
", secondTypeCode='" + secondTypeCode + '\'' +
'}';
", graLabelId=" + graLabelId +
", subLabelId=" + subLabelId +
", verLabelId=" + verLabelId +
", areaLabelId=" + areaLabelId +
"} " + super.toString();
}
}
......@@ -68,6 +68,26 @@ public class BookAdviser extends BaseEntity {
*/
private Long secondTempletId;
/**
* 年级标签id
*/
private Long graLabelId;
/**
* 科目标签id
*/
private Long subLabelId;
/**
* 版本标签id
*/
private Long verLabelId;
/**
* 地域标签id
*/
private Long areaLabelId;
public Long getTempletId() {
return templetId;
}
......@@ -148,6 +168,38 @@ public class BookAdviser extends BaseEntity {
this.secondTempletId = secondTempletId;
}
public Long getGraLabelId() {
return graLabelId;
}
public void setGraLabelId(Long graLabelId) {
this.graLabelId = graLabelId;
}
public Long getSubLabelId() {
return subLabelId;
}
public void setSubLabelId(Long subLabelId) {
this.subLabelId = subLabelId;
}
public Long getVerLabelId() {
return verLabelId;
}
public void setVerLabelId(Long verLabelId) {
this.verLabelId = verLabelId;
}
public Long getAreaLabelId() {
return areaLabelId;
}
public void setAreaLabelId(Long areaLabelId) {
this.areaLabelId = areaLabelId;
}
@Override
public String toString() {
return "BookAdviser{" +
......@@ -161,8 +213,10 @@ public class BookAdviser extends BaseEntity {
", isMainEditor=" + isMainEditor +
", isDelete=" + isDelete +
", secondTempletId=" + secondTempletId +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
", graLabelId=" + graLabelId +
", subLabelId=" + subLabelId +
", verLabelId=" + verLabelId +
", areaLabelId=" + areaLabelId +
"} " + super.toString();
}
}
package com.pcloud.book.group.dto;
import com.pcloud.common.dto.BaseDto;
import lombok.Data;
/**
* @描述:个人号用户社群书信息
* @作者:zhuyajie
* @创建时间:15:31 2020/1/2
* @版本:1.0
*/
@Data
public class SelfRobotBookGroupDTO extends BaseDto {
/**
* 小号名称
*/
private String wxId;
/**
* 小号昵称
*/
private String wxNickName;
/**
* 社群书id
*/
private Long bookGroupId;
/**
* 社群码名称
*/
private String groupQrcodeName;
/**
* 书刊id
*/
private Long bookId;
/**
* 编辑id
*/
private Long adviserId;
}
......@@ -14,7 +14,12 @@ public enum JoinGroupTypeEnum {
/**
* 客服机器人
*/
ROBOT(2, "客服机器人");
ROBOT(2, "客服机器人"),
/**
* AI客服机器人
*/
AI_ROBOT(3, "AI客服机器人");
private final Integer code;
......
......@@ -9,6 +9,7 @@ import com.pcloud.book.group.dto.GroupUseDTO;
import com.pcloud.book.group.dto.PersonalQrcodeDTO;
import com.pcloud.book.group.dto.QueryByBookAdviserDTO;
import com.pcloud.book.group.dto.ResourceBrowseParamDto;
import com.pcloud.book.group.dto.SelfRobotBookGroupDTO;
import com.pcloud.book.group.dto.SelfRobotUserDTO;
import com.pcloud.book.group.dto.SelfRobtParamDTO;
import com.pcloud.common.dto.ResponseDto;
......@@ -195,4 +196,8 @@ public interface BookGroupService {
@ApiOperation("获取作品或应用关联的社群书数量")
@PostMapping("getAssocBookGroupCount")
ResponseEntity<ResponseDto<List<BookGroupCountDTO>>> getAssocBookGroupCount(@RequestBody List<BookGroupCountDTO> bookGroupCountDTOS);
@ApiOperation("根据用户和社群书id获取个人号信息")
@GetMapping("getSelfRobotBookGroupInfoByUser")
ResponseEntity<ResponseDto<SelfRobotBookGroupDTO>> getSelfRobotBookGroupInfoByUser(@RequestParam("wxUserId") String wxUserId, @RequestParam("bookGroupId") Long bookGroupId);
}
......@@ -5,6 +5,7 @@ package com.pcloud.book.book.biz;
import com.pcloud.book.base.dto.CountDto;
import com.pcloud.book.book.dto.*;
import com.pcloud.book.book.entity.Book;
import com.pcloud.book.book.entity.BookAdviser;
import com.pcloud.common.exceptions.BizException;
......@@ -138,13 +139,8 @@ public interface BookAdviserBiz {
/**
* 更新模板
* @param bookId 图书标识
* @param channelId 运营标识
* @param adviserId 标识
* @param templetId 模板标识
* @param secondTempletId 第二级列表
*/
public void updateBookTemplet(Long bookId, Long channelId, Long adviserId, Long templetId, Long secondTempletId);
public void updateBookTemplet(Book book);
/**
* 获取图书每日新增个数-出版
......@@ -168,7 +164,7 @@ public interface BookAdviserBiz {
* @param templetId 模板标识
* @param secondTempletId 模板第二阶级标识
*/
public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId, Boolean recoverScene);
public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId, Long graLabelId, Long subLabelId, Long verLabelId, Long areaLabelId, Boolean recoverScene);
/**
* 获取编辑的图书总数
......
......@@ -12,6 +12,7 @@ import com.pcloud.book.book.dto.BookInfo4AnlysicsDTO;
import com.pcloud.book.book.dto.BookInfoAnalysicsDTO;
import com.pcloud.book.book.dto.BookInfoAndAuthStatusDTO;
import com.pcloud.book.book.entity.Book;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.vo.ListNoAuthBookParam;
import com.pcloud.book.book.vo.ListNoAuthGroupBookParam;
import com.pcloud.common.exceptions.BizException;
......@@ -584,4 +585,10 @@ public interface BookBiz {
* @return
*/
PageBeanNew<AdviserBookInfoDTO> getListPage4SelfBookGroup(Integer currentPage, Integer numPerPage, String name);
/**
* 获取书籍标签
*/
Map<Integer,List<BookLabel>> getBookLabels();
}
......@@ -17,6 +17,7 @@ import com.pcloud.book.book.dto.BookCountAndAdviserIdDTO;
import com.pcloud.book.book.dto.BookCountByAdvisersDto;
import com.pcloud.book.book.dto.BookCountDto;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.entity.Book;
import com.pcloud.book.book.entity.BookAdviser;
import com.pcloud.book.book.set.BookSet;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
......@@ -138,7 +139,9 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
if (bookAdviserDto != null && BookConstant.BOOK_ADVISER_DELETE.equals(bookAdviserDto.getIsDelete())) { // 编辑之前设置过,但是已经删除,走恢复流程
// 20190723-刘娜【ID1001264】社群书删除后,再创建时不要自动恢复
recoverBook4Adviser(bookAdviser.getBookId(), bookAdviser.getAdviserId(), bookAdviser.getChannelId(),
bookAdviser.getTempletId(),bookAdviser.getSecondTempletId(), false);
bookAdviser.getTempletId(), bookAdviser.getSecondTempletId(),
bookAdviser.getGraLabelId(), bookAdviser.getSubLabelId(), bookAdviser.getVerLabelId(), bookAdviser.getAreaLabelId(),
false);
} else {
// 判断是否配置过该书籍推广信息
checkIsHaveOtherAdviser(bookAdviser.getBookId(), bookAdviser.getChannelId(), bookAdviser.getAdviserId());
......@@ -530,16 +533,20 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
/**
* 更新图书模板
*/
@ParamLog("更新图书模板")
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBookTemplet(Long bookId, Long channelId, Long adviserId, Long templetId, Long secondTempletId) {
LOGGER.info("更新图书模板,<START>.[bookId]=" + bookId + "channelId=" + channelId + "adviserId=" + adviserId + "templetId="+templetId+"secondTempletId="+secondTempletId);
public void updateBookTemplet(Book book) {
BookAdviser bookAdviser = new BookAdviser();
bookAdviser.setBookId(bookId);
bookAdviser.setTempletId(templetId);
bookAdviser.setAdviserId(adviserId);
bookAdviser.setChannelId(channelId);
bookAdviser.setSecondTempletId(secondTempletId);
bookAdviser.setBookId(book.getBookId());
bookAdviser.setTempletId(book.getTempletId());
bookAdviser.setAdviserId(book.getLastModifiedUser());
bookAdviser.setChannelId(book.getChannelId());
bookAdviser.setSecondTempletId(book.getSecondTempletId());
bookAdviser.setGraLabelId(book.getGraLabelId());
bookAdviser.setSubLabelId(book.getSubLabelId());
bookAdviser.setAreaLabelId(book.getAreaLabelId());
bookAdviser.setVerLabelId(book.getVerLabelId());
bookAdviserDao.updateBookTemplet(bookAdviser);
}
......@@ -635,7 +642,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
// 删除图书关联二维码
qrcodeSceneConsr.deleteByBook(bookId, channelId, null);
// 删除书籍编辑的状态
updateBookAdviserStatus(bookId, null, channelId, null,null, BookConstant.BOOK_ADVISER_DELETE, null);
updateBookAdviserStatus(bookId, null, channelId, null,null, null, null, null, null, BookConstant.BOOK_ADVISER_DELETE, null);
// 删除读者端的书架的书籍
bookcaseConsr.deleteBookForAdviser(bookId, channelId, adviserId);
}
......@@ -657,7 +664,7 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
// 删除图书关联二维码
qrcodeSceneConsr.deleteByBook(bookId, channelId, adviserId);
// 删除书籍编辑的状态
updateBookAdviserStatus(bookId, adviserId, channelId, null,null, BookConstant.BOOK_ADVISER_DELETE, null);
updateBookAdviserStatus(bookId, adviserId, channelId, null,null, null, null, null, null, BookConstant.BOOK_ADVISER_DELETE, null);
// 删除读者端的书架的书籍
bookcaseConsr.deleteBookForAdviser(bookId, channelId, adviserId);
}
......@@ -667,11 +674,13 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId, Boolean recoverScene) {
public void recoverBook4Adviser(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId,
Long graLabelId, Long subLabelId, Long verLabelId, Long areaLabelId,
Boolean recoverScene) {
LOGGER.info("恢复书籍-编辑 <START>.[bookId]=" + bookId + ",adviserId=" + adviserId + ",channelId=" + channelId + " templetId= " + templetId + "secondTempletId=" + secondTempletId);
checkIsHaveOtherAdviser(bookId, channelId, adviserId);
// 恢复书籍编辑的状态
updateBookAdviserStatus(bookId, adviserId, channelId, templetId, secondTempletId, BookConstant.BOOK_ADVISER_NO_DELETE,BookConstant.MAIN_ADVISER);
updateBookAdviserStatus(bookId, adviserId, channelId, templetId, secondTempletId, graLabelId, subLabelId, verLabelId, areaLabelId, BookConstant.BOOK_ADVISER_NO_DELETE,BookConstant.MAIN_ADVISER);
// 恢复图书关联的二维码 20190723-刘娜【ID1001264】社群书删除后,再创建时不要自动恢复
if (recoverScene) {
bookGroupBiz.recoverByBookId(bookId, channelId, adviserId);
......@@ -689,7 +698,9 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
* @param isMainAdviser
* @param secondTempletId 第二级标题id
*/
private void updateBookAdviserStatus(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId, Integer deleteStatus, Integer isMainAdviser) {
private void updateBookAdviserStatus(Long bookId, Long adviserId, Long channelId, Long templetId,Long secondTempletId,
Long graLabelId, Long subLabelId, Long verLabelId, Long areaLabelId,
Integer deleteStatus, Integer isMainAdviser) {
LOGGER.info("修改书籍编辑的状态(删除或者恢复) <START>.[bookId]=" + bookId + ",adviserId=" + adviserId + ",channelId="
+ channelId + ",deleteStatus=" + deleteStatus+",isMainAdviser="+isMainAdviser+"templetId"+templetId);
Map<String, Object> paramMap = new HashMap<>();
......@@ -700,6 +711,10 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
paramMap.put("status", deleteStatus);
paramMap.put("templetId", templetId);
paramMap.put("secondTempletId",secondTempletId);
paramMap.put("graLabelId",graLabelId);
paramMap.put("subLabelId",subLabelId);
paramMap.put("verLabelId",verLabelId);
paramMap.put("areaLabelId",areaLabelId);
bookAdviserDao.updateBook4Adviser(paramMap);
if (BookConstant.BOOK_ADVISER_DELETE.equals(deleteStatus)) {
bookGroupBiz.deleteByBookId(bookId, channelId, adviserId);
......
......@@ -22,6 +22,7 @@ import com.pcloud.book.book.biz.BookResourceBiz;
import com.pcloud.book.book.cache.BookCache;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dto.AdviserBookInfoDTO;
import com.pcloud.book.book.dto.BookAdviserDto;
import com.pcloud.book.book.dto.BookAdviserUpdateTimeDTO;
......@@ -37,6 +38,7 @@ import com.pcloud.book.book.dto.BookInfoAndAuthStatusDTO;
import com.pcloud.book.book.dto.BookNameUpdateDTO;
import com.pcloud.book.book.entity.Book;
import com.pcloud.book.book.entity.BookAdviser;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.set.BookSet;
import com.pcloud.book.book.tools.BookTools;
import com.pcloud.book.book.vo.ListNoAuthBookParam;
......@@ -147,6 +149,8 @@ public class BookBizImpl implements BookBiz {
private MainLineConsr mainLineConsr;
@Autowired
private BookGroupBiz bookGroupBiz;
@Autowired
private BookLabelDao bookLabelDao;
/**
......@@ -1504,7 +1508,7 @@ public class BookBizImpl implements BookBiz {
// 清除redis中数据
bookCache.clearRedisByBook(book.getBookId(), book.getIsbn(), book.getSerialNumber());
//修改图书类型
bookAdviserBiz.updateBookTemplet(book.getBookId(), book.getChannelId(), book.getLastModifiedUser(), book.getTempletId(), book.getSecondTempletId());
bookAdviserBiz.updateBookTemplet(book);
LOGGER.info("修改图书基本信息与类型[END]");
}
......@@ -1520,6 +1524,10 @@ public class BookBizImpl implements BookBiz {
bookAdviser.setCreatedUser(book.getCreatedUser());
bookAdviser.setTempletId(book.getTempletId());
bookAdviser.setSecondTempletId(book.getSecondTempletId());
bookAdviser.setSubLabelId(book.getSubLabelId());
bookAdviser.setGraLabelId(book.getGraLabelId());
bookAdviser.setAreaLabelId(book.getAreaLabelId());
bookAdviser.setVerLabelId(book.getVerLabelId());
bookAdviserBiz.create(bookAdviser);
}
......@@ -1779,4 +1787,15 @@ public class BookBizImpl implements BookBiz {
}
return pageBean;
}
@ParamLog("获取书籍标签")
@Override
public Map<Integer, List<BookLabel>> getBookLabels() {
Map<Integer, List<BookLabel>> map = new HashMap<>();
List<BookLabel> bookLabels = bookLabelDao.getAll();
if (!ListUtils.isEmpty(bookLabels)) {
map = bookLabels.stream().collect(Collectors.groupingBy(BookLabel::getType));
}
return map;
}
}
package com.pcloud.book.book.dao;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
public interface BookLabelDao extends BaseDao<BookLabel> {
List<BookLabel> getListByType(Integer type);
List<BookLabel> getAll();
Map<Long,BookLabel> getMapByIds(List<Long> list);
}
package com.pcloud.book.book.dao.impl;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/27 17:23
**/
@Repository("bookLabelDao")
public class BookLabelDaoImpl extends BaseDaoImpl<BookLabel> implements BookLabelDao {
@Override
public List<BookLabel> getListByType(Integer type) {
return super.getSqlSession().selectList(super.getStatement("getListByType"), type);
}
@Override
public List<BookLabel> getAll() {
return super.getSqlSession().selectList(super.getStatement("getAll"));
}
@Override
public Map<Long, BookLabel> getMapByIds(List<Long> list) {
return super.getSqlSession().selectMap(super.getStatement("getMapByIds"), list,"id");
}
}
package com.pcloud.book.book.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/27 17:20
**/
@Data
@ApiModel("书籍标签")
public class BookLabel extends BaseEntity {
@ApiModelProperty("标签名称")
private String name;
@ApiModelProperty("标签类型")
private Integer type;
}
......@@ -599,4 +599,10 @@ public interface BookFacade {
@RequestParam(value = "currentPage", required = false) Integer currentPage,
@RequestParam(value = "numPerPage", required = false) Integer numPerPage)
throws BizException, PermissionException;
@ApiOperation("获取书籍标签")
@GetMapping("getBookLabels")
ResponseDto<?> getBookLabels(
@RequestHeader("token") String token
) throws BizException, PermissionException;
}
......@@ -149,7 +149,7 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
@RequestParam(value = "channelId", required = false) Long channelId)
throws BizException, PermissionException, JsonParseException {
Long adviserId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
bookAdviserBiz.recoverBook4Adviser(bookId, adviserId, channelId, null,null, true);
bookAdviserBiz.recoverBook4Adviser(bookId, adviserId, channelId, null,null, null, null, null, null, true);
return new ResponseDto<>();
}
......
......@@ -824,4 +824,13 @@ public class BookFacadeImpl implements BookFacade {
return new ResponseDto<>(null == pageBean ? new PageBeanNew<>() : pageBean);
}
@GetMapping("getBookLabels")
@Override
public ResponseDto<?> getBookLabels(
@RequestHeader("token") String token
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(bookBiz.getBookLabels());
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.keywords.entity.BookGuide;
import com.pcloud.book.keywords.entity.BookGuideReply;
import com.pcloud.book.keywords.entity.BookKeyword;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.push.entity.PushGroup;
import com.pcloud.book.push.entity.PushItem;
import com.pcloud.common.page.PageBeanNew;
......@@ -26,4 +27,6 @@ public interface BookGroupAppBiz {
void exportBookGroupAppDTOSByBookGroupId(Long bookGroupId,String systemCode,Long partyId);
void addOldBookGroupAppToNew();
void addSelfKeywordToBookGroupApp(List<SelfRobotKeyword> selfRobotKeywords);
}
......@@ -23,6 +23,7 @@ import com.pcloud.book.group.dto.QrcodeNameAndProIdDTO;
import com.pcloud.book.group.dto.ResourceBrowseParamDto;
import com.pcloud.book.group.dto.SelfBookGroupStDTO;
import com.pcloud.book.group.dto.SelfBookGroupStParamDTO;
import com.pcloud.book.group.dto.SelfRobotBookGroupDTO;
import com.pcloud.book.group.dto.SelfRobotUserDTO;
import com.pcloud.book.group.dto.SelfRobtParamDTO;
import com.pcloud.book.group.dto.TopAgentBookGroupDTO;
......@@ -30,6 +31,7 @@ import com.pcloud.book.group.dto.UserSelectParamDTO;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.dto.AgentStatisticsInfoDTO;
import com.pcloud.book.group.entity.WxWechatUserCorrelation;
import com.pcloud.book.group.vo.BookGroupAnalysisParam;
import com.pcloud.book.group.vo.BookGroupAnalysisVO;
import com.pcloud.book.group.vo.FriendsVO;
......@@ -721,4 +723,17 @@ public interface BookGroupBiz {
* @return
*/
List<ListKeywordVO> getClassifyKeywordStatistic(Long classifyId);
/**
* 新增微信用户和rays系统用户关联关系
*/
void createWxWechatUserCorrelation(Long wechatUserId, WxWechatUserCorrelation wxWechatUserCorrelation);
/**
* 根据用户和社群书id获取个人号信息
* @param wxUserId
* @param bookGroupId
* @return
*/
SelfRobotBookGroupDTO getSelfRobotBookGroupInfoByUser(String wxUserId, Long bookGroupId);
}
......@@ -32,6 +32,7 @@ import com.pcloud.book.keywords.dao.BookKeywordDao;
import com.pcloud.book.keywords.entity.BookGuide;
import com.pcloud.book.keywords.entity.BookGuideReply;
import com.pcloud.book.keywords.entity.BookKeyword;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.push.dao.PushGroupDao;
import com.pcloud.book.push.entity.PushGroup;
......@@ -351,6 +352,36 @@ public class BookGroupAppBizImpl implements BookGroupAppBiz {
}
@ParamLog("将个人号应用关键词插入到社群书应用")
@Override
public void addSelfKeywordToBookGroupApp(List<SelfRobotKeyword> selfRobotKeywords) {
if (ListUtils.isEmpty(selfRobotKeywords)) {
return;
}
List<BookGroupApp> bookGroupApps = new ArrayList<>();
for (SelfRobotKeyword selfRobotKeyword : selfRobotKeywords) {
if (ReplyTypeEnum.APP.value.equals(selfRobotKeyword.getType())) {
BookGroupApp bookGroupApp = new BookGroupApp();
bookGroupApp.setOriginType(BookGroupAppOriginTypeEnum.SELF_KEYWORD.code);
bookGroupApp.setServeId(selfRobotKeyword.getServeId());
bookGroupApp.setServeType(selfRobotKeyword.getServeType());
bookGroupApp.setClassifyId(0L);
bookGroupApp.setBookGroupId(selfRobotKeyword.getBookGroupId());
bookGroupApp.setCreateUser(selfRobotKeyword.getCreateUser());
//判断是否已经添加过
BookGroupApp bookGroupAppOld = bookGroupAppDao.getByCondition(bookGroupApp);
if (bookGroupAppOld != null) {
continue;
}
bookGroupApps.add(bookGroupApp);
}
}
if (ListUtils.isEmpty(bookGroupApps)) {
return;
}
bookGroupAppDao.batchInsert(bookGroupApps);
}
@ParamLog("导出")
private void exportDTOS(List<BookGroupAppDTO> list, Long bookGroupId, String systemCode, Long partyId) {
if (ListUtils.isEmpty(list)) {
......
......@@ -12,7 +12,9 @@ import com.pcloud.audioapp.audioLesson.service.AudioLessonService;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.book.set.BookSet;
import com.pcloud.book.consumer.analysisengine.BrowseRecordConsr;
import com.pcloud.book.consumer.app.AppConsr;
......@@ -47,6 +49,7 @@ import com.pcloud.book.group.dao.TempletRelevanceDao;
import com.pcloud.book.group.dao.WeixinQrcodeDao;
import com.pcloud.book.group.dao.WeixinQrcodeGenerationDao;
import com.pcloud.book.group.dao.WxUserWechatRelevanceDao;
import com.pcloud.book.group.dao.WxWechatUserCorrelationDao;
import com.pcloud.book.group.dto.AgentStatisticsInfoDTO;
import com.pcloud.book.group.dto.AltAndCountDTO;
import com.pcloud.book.group.dto.AltIdAndNameDTO;
......@@ -76,6 +79,7 @@ import com.pcloud.book.group.dto.QrcodeNameAndProIdDTO;
import com.pcloud.book.group.dto.ResourceBrowseParamDto;
import com.pcloud.book.group.dto.SelfBookGroupStDTO;
import com.pcloud.book.group.dto.SelfBookGroupStParamDTO;
import com.pcloud.book.group.dto.SelfRobotBookGroupDTO;
import com.pcloud.book.group.dto.SelfRobotUserDTO;
import com.pcloud.book.group.dto.SelfRobtParamDTO;
import com.pcloud.book.group.dto.StatisticsIncomeDto;
......@@ -94,6 +98,7 @@ import com.pcloud.book.group.entity.WeixinQrcodeGeneration;
import com.pcloud.book.group.entity.WxUserWechatRelevance;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.enums.ChangeOriginTypeEnum;
import com.pcloud.book.group.entity.WxWechatUserCorrelation;
import com.pcloud.book.group.enums.CipherTypeEnum;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.enums.LargeTempletEnum;
......@@ -187,6 +192,7 @@ import com.pcloud.wechatgroup.selfrobot.dto.AvailableRobotParamDTO;
import com.pcloud.wechatgroup.selfrobot.dto.RobotBaseInfoDTO;
import com.pcloud.wechatgroup.selfrobot.dto.SelfRobotDTO;
import com.pcloud.wechatgroup.selfrobot.dto.UserRobotDTO;
import com.pcloud.wechatgroup.selfrobot.enums.SelfRobotTypeEnum;
import com.sdk.wxgroup.SendMessageTypeEnum;
import org.apache.commons.collections.MapUtils;
......@@ -319,6 +325,10 @@ public class BookGroupBizImpl implements BookGroupBiz {
private ExportConsr exportConsr;
@Autowired
private WxUserWechatRelevanceDao wxUserWechatRelevanceDao;
@Autowired
private WxWechatUserCorrelationDao wxWechatUserCorrelationDao;
@Autowired
private BookLabelDao bookLabelDao;
private static final ThreadPoolExecutor PLATFORM_STATISTICS_EXPORT_THREAD = new ThreadPoolExecutor(2, 2,
0, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
......@@ -481,11 +491,37 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
}
if (bookGroupDTO.getBookId() != null) {
BookDto bookDto = bookDao.getBaseById(bookGroupDTO.getBookId());
Map<String, Object> paramMap = Maps.newHashMap();
paramMap.put("bookId", bookGroupDTO.getBookId());
paramMap.put("adviserId", adviserId);
paramMap.put("channelId", bookGroupDTO.getChannelId());
BookDto bookDto = bookDao.getById(paramMap);
if (bookDto != null) {
bookGroupDTO.setBookName(bookDto.getBookName());
bookGroupDTO.setBookImg(bookDto.getCoverImg());
bookGroupDTO.setPublish(bookDto.getPublish());
bookGroupDTO.setAreaLabelId(bookDto.getAreaLabelId());
bookGroupDTO.setVerLabelId(bookDto.getVerLabelId());
bookGroupDTO.setGraLabelId(bookDto.getGraLabelId());
bookGroupDTO.setSubLabelId(bookDto.getSubLabelId());
List<Long> bookLabelIds = new ArrayList<>();
bookLabelIds.add(bookDto.getAreaLabelId());
bookLabelIds.add(bookDto.getVerLabelId());
bookLabelIds.add(bookDto.getGraLabelId());
bookLabelIds.add(bookDto.getSubLabelId());
Map<Long, BookLabel> bookLabelMap = bookLabelDao.getMapByIds(bookLabelIds);
if (bookLabelMap.get(bookDto.getAreaLabelId()) != null) {
bookGroupDTO.setAreaLabelName(bookLabelMap.get(bookDto.getAreaLabelId()).getName());
}
if (bookLabelMap.get(bookDto.getVerLabelId()) != null) {
bookGroupDTO.setVerLabelName(bookLabelMap.get(bookDto.getVerLabelId()).getName());
}
if (bookLabelMap.get(bookDto.getGraLabelId()) != null) {
bookGroupDTO.setGraLabelName(bookLabelMap.get(bookDto.getGraLabelId()).getName());
}
if (bookLabelMap.get(bookDto.getSubLabelId()) != null) {
bookGroupDTO.setSubLabelName(bookLabelMap.get(bookDto.getSubLabelId()).getName());
}
}
}
}
......@@ -582,21 +618,34 @@ public class BookGroupBizImpl implements BookGroupBiz {
@ParamLog(value = "更新群二维码信息", isAfterReturn = false)
@Transactional(rollbackFor = Exception.class)
public void updateBookGroup(BookGroup bookGroup) throws BizException {
if (null == bookGroup.getId() || StringUtil.isEmpty(bookGroup.getGroupQrcodeName()) || null == bookGroup.getProLabelId()
|| null == bookGroup.getDepLabelId() || null == bookGroup.getPurLabelId() || bookGroup.getJoinGroupType() == null) {
if (null == bookGroup.getId()
|| StringUtil.isEmpty(bookGroup.getGroupQrcodeName())
|| bookGroup.getJoinGroupType() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
if (JoinGroupTypeEnum.GROUP_QRCODE.getCode().equals(bookGroup.getJoinGroupType())
&& (StringUtil.isEmpty(bookGroup.getJoinTitle())
|| StringUtil.isEmpty(bookGroup.getJoinSlogan()))) {
|| StringUtil.isEmpty(bookGroup.getJoinSlogan())
|| null == bookGroup.getProLabelId()
|| null == bookGroup.getDepLabelId()
|| null == bookGroup.getPurLabelId() )) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
if (JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroup.getJoinGroupType())
&& (bookGroup.getIsInviteGroup() == null
|| StringUtil.isEmpty(bookGroup.getAddFriendGuide())
|| StringUtil.isEmpty(bookGroup.getCustomerServiceName()))) {
|| StringUtil.isEmpty(bookGroup.getCustomerServiceName())
|| null == bookGroup.getProLabelId()
|| null == bookGroup.getDepLabelId()
|| null == bookGroup.getPurLabelId())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
if (JoinGroupTypeEnum.AI_ROBOT.getCode().equals(bookGroup.getJoinGroupType())
&& (StringUtil.isEmpty(bookGroup.getAddFriendGuide())
|| StringUtil.isEmpty(bookGroup.getShortBookName()))) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数有误!");
}
if (bookGroup.getGroupQrcodeName().contains("#")){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "名称不能包含#!");
}
......@@ -607,6 +656,7 @@ public class BookGroupBizImpl implements BookGroupBiz {
if (!bookGroup.getJoinGroupType().equals(group.getJoinGroupType())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "社群码前后类型不一致!!");
}
checkShortBookName(bookGroup);
if (null == group.getProductId()) {
AddAppProductParamDTO addAppProductParamDTO = new AddAppProductParamDTO();
addAppProductParamDTO.setAppProCode(ProductTypeConstant.BOOK_GROUP);
......@@ -631,6 +681,16 @@ public class BookGroupBizImpl implements BookGroupBiz {
bookGroupDao.update(bookGroup);
}
@ParamLog("判断书籍简称是否重复")
private void checkShortBookName(BookGroup bookGroup) {
if (!StringUtil.isEmpty(bookGroup.getShortBookName())) {
BookGroup byShortBookName = bookGroupDao.getByShortBookName(bookGroup.getShortBookName());
if (byShortBookName != null && !byShortBookName.getId().equals(bookGroup.getId())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "书籍简称已存在,请重新设置");
}
}
}
/**
* 根据书刊ID删除
*/
......@@ -1413,6 +1473,12 @@ public class BookGroupBizImpl implements BookGroupBiz {
availableRobotParamDTO.setGrade(bookGroupDTO.getDepLabelName());
availableRobotParamDTO.setSubject(bookGroupDTO.getProLabelName());
availableRobotParamDTO.setSpecialAgent(bookGroupDTO.getBelongSpecialAgent());
if (JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){
availableRobotParamDTO.setRobotType(SelfRobotTypeEnum.version_origin.getCode());
}
if (JoinGroupTypeEnum.AI_ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){
availableRobotParamDTO.setRobotType(SelfRobotTypeEnum.version1.getCode());
}
SelfRobotDTO selfRobotDTO = wechatGroupConsr.getAvailableRobotByBookGroup(availableRobotParamDTO);
if (selfRobotDTO == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "未找到机器人!");
......@@ -4086,4 +4152,36 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
return listKeywordVOS;
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("新增微信用户和rays系统用户关联关系")
@Override
public void createWxWechatUserCorrelation(Long wechatUserId, WxWechatUserCorrelation wxWechatUserCorrelation) {
if (wxWechatUserCorrelation==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数为空!");
}
if (wxWechatUserCorrelation.getBookGroupId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"bookGroupId参数为空!");
}
if (StringUtil.isEmpty(wxWechatUserCorrelation.getWxId())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"wxUserId参数为空!");
}
wxWechatUserCorrelation.setWechatUserId(wechatUserId);
//判断库里有没有
WxWechatUserCorrelation old = wxWechatUserCorrelationDao.getByWxIdAndBookGroupId(wxWechatUserCorrelation.getBookGroupId(), wxWechatUserCorrelation.getWxId());
if (old!=null){
return;
}
wxWechatUserCorrelationDao.insert(wxWechatUserCorrelation);
}
@Override
public SelfRobotBookGroupDTO getSelfRobotBookGroupInfoByUser(String wxUserId, Long bookGroupId) {
SelfRobotBookGroupDTO dto = bookGroupCipherUserDao.getSelfRobotBookGroupInfoByUser(wxUserId, bookGroupId);
if (null != dto) {
GroupRobotDTO robotDTO = wechatGroupConsr.getGroupRobotByWxId(dto.getWxId());
dto.setWxNickName(robotDTO.getNickName());
}
return dto;
}
}
......@@ -6,6 +6,7 @@ import com.pcloud.book.group.dto.BookGroupIdAndCountDTO;
import com.pcloud.book.group.dto.CountAndTimeDTO;
import com.pcloud.book.group.dto.DayCountDTO;
import com.pcloud.book.group.dto.LabelUserCountDTO;
import com.pcloud.book.group.dto.SelfRobotBookGroupDTO;
import com.pcloud.book.group.dto.SelfRobotUserDTO;
import com.pcloud.book.group.entity.BookGroupCipherUser;
import com.pcloud.book.group.vo.UserBookInfoItemVO;
......@@ -154,4 +155,17 @@ public interface BookGroupCipherUserDao extends BaseDao<BookGroupCipherUser> {
* @return
*/
List<AltAndCountDTO> getAltFriendList(Long bookGroupId);
/**
* 根据wxUserId获取
*/
BookGroupCipherUser getByWxUserId(String wxUserId);
/**
* 根据用户和社群书id获取个人号信息
* @param wxUserId
* @param bookGroupId
* @return
*/
SelfRobotBookGroupDTO getSelfRobotBookGroupInfoByUser(String wxUserId, Long bookGroupId);
}
......@@ -298,4 +298,9 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
* @return
*/
BookGroupStatistic4AgentDTO getBaseInfoByBookId(Long bookId);
/**
* 根据书籍简称获取
*/
BookGroup getByShortBookName(String shortBookName);
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.entity.WxWechatUserCorrelation;
import com.pcloud.common.core.dao.BaseDao;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/31 17:05
**/
public interface WxWechatUserCorrelationDao extends BaseDao<WxWechatUserCorrelation> {
WxWechatUserCorrelation getByWxIdAndBookGroupId(Long bookGroupId, String wxId);
}
......@@ -7,6 +7,7 @@ import com.pcloud.book.group.dto.BookGroupIdAndCountDTO;
import com.pcloud.book.group.dto.CountAndTimeDTO;
import com.pcloud.book.group.dto.DayCountDTO;
import com.pcloud.book.group.dto.LabelUserCountDTO;
import com.pcloud.book.group.dto.SelfRobotBookGroupDTO;
import com.pcloud.book.group.dto.SelfRobotUserDTO;
import com.pcloud.book.group.entity.BookGroupCipherUser;
import com.pcloud.book.group.vo.UserBookInfoItemVO;
......@@ -168,4 +169,17 @@ public class BookGroupCipherUserDaoImpl extends BaseDaoImpl<BookGroupCipherUser>
public List<AltAndCountDTO> getAltFriendList(Long bookGroupId) {
return getSessionTemplate().selectList(getStatement("getAltFriendList"), bookGroupId);
}
@Override
public BookGroupCipherUser getByWxUserId(String wxUserId) {
return getSessionTemplate().selectOne(getStatement("getByWxUserId"), wxUserId);
}
@Override
public SelfRobotBookGroupDTO getSelfRobotBookGroupInfoByUser(String wxUserId, Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
map.put("wxUserId", wxUserId);
return getSessionTemplate().selectOne(getStatement("getSelfRobotBookGroupInfoByUser"), map);
}
}
......@@ -336,4 +336,9 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
public BookGroupStatistic4AgentDTO getBaseInfoByBookId(Long bookId) {
return getSessionTemplate().selectOne(getStatement("getBaseInfoByBookId"), bookId);
}
@Override
public BookGroup getByShortBookName(String shortBookName) {
return super.getSqlSession().selectOne(getStatement("getByShortBookName"),shortBookName);
}
}
......@@ -25,7 +25,9 @@ public class BookGroupServeDaoImpl extends BaseDaoImpl<BookGroupServe> implement
@Override
public List<BookGroupServe> getListByBookGroupId(Long bookGroupId) {
return super.getSqlSession().selectList(getStatement("getListByBookGroupId"), bookGroupId);
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
return super.getSqlSession().selectList(getStatement("getListByBookGroupId"), map);
}
@Override
......
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.WxWechatUserCorrelationDao;
import com.pcloud.book.group.entity.WxWechatUserCorrelation;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/31 17:06
**/
@Component("wxWechatUserCorrelationDao")
public class WxWechatUserCorrelationDaoImpl extends BaseDaoImpl<WxWechatUserCorrelation> implements WxWechatUserCorrelationDao {
@Override
public WxWechatUserCorrelation getByWxIdAndBookGroupId(Long bookGroupId, String wxId) {
Map<String,Object> map=new HashMap<>();
map.put("bookGroupId",bookGroupId);
map.put("wxId",wxId);
return this.getSqlSession().selectOne(getStatement("getByWxIdAndBookGroupId"),map);
}
}
......@@ -214,6 +214,52 @@ public class BookGroupDTO extends BaseDto {
* 是否属于特殊出版社
*/
private Boolean belongSpecialAgent;
/**
* 书籍简称
*/
private String shortBookName;
/**
* 年级标签id
*/
private Long graLabelId;
/**
* 科目标签id
*/
private Long subLabelId;
/**
* 版本标签id
*/
private Long verLabelId;
/**
* 地域标签id
*/
private Long areaLabelId;
/**
* 年级标签名称
*/
private String graLabelName;
/**
* 科目标签名称
*/
private String subLabelName;
/**
* 版本标签名称
*/
private String verLabelName;
/**
* 地域标签名称
*/
private String areaLabelName;
public String getUrl() {
return url;
......@@ -545,6 +591,78 @@ public class BookGroupDTO extends BaseDto {
this.belongSpecialAgent = belongSpecialAgent;
}
public String getShortBookName() {
return shortBookName;
}
public void setShortBookName(String shortBookName) {
this.shortBookName = shortBookName;
}
public Long getGraLabelId() {
return graLabelId;
}
public void setGraLabelId(Long graLabelId) {
this.graLabelId = graLabelId;
}
public Long getSubLabelId() {
return subLabelId;
}
public void setSubLabelId(Long subLabelId) {
this.subLabelId = subLabelId;
}
public Long getVerLabelId() {
return verLabelId;
}
public void setVerLabelId(Long verLabelId) {
this.verLabelId = verLabelId;
}
public Long getAreaLabelId() {
return areaLabelId;
}
public void setAreaLabelId(Long areaLabelId) {
this.areaLabelId = areaLabelId;
}
public String getGraLabelName() {
return graLabelName;
}
public void setGraLabelName(String graLabelName) {
this.graLabelName = graLabelName;
}
public String getSubLabelName() {
return subLabelName;
}
public void setSubLabelName(String subLabelName) {
this.subLabelName = subLabelName;
}
public String getVerLabelName() {
return verLabelName;
}
public void setVerLabelName(String verLabelName) {
this.verLabelName = verLabelName;
}
public String getAreaLabelName() {
return areaLabelName;
}
public void setAreaLabelName(String areaLabelName) {
this.areaLabelName = areaLabelName;
}
@Override
public String toString() {
return "BookGroupDTO{" +
......@@ -590,5 +708,15 @@ public class BookGroupDTO extends BaseDto {
", assocState=" + assocState +
", belongSpecialAgent=" + belongSpecialAgent +
'}';
", shortBookName='" + shortBookName + '\'' +
", graLabelId=" + graLabelId +
", subLabelId=" + subLabelId +
", verLabelId=" + verLabelId +
", areaLabelId=" + areaLabelId +
", graLabelName=" + graLabelName +
", subLabelName=" + subLabelName +
", verLabelName=" + verLabelName +
", areaLabelName=" + areaLabelName +
"} " + super.toString();
}
}
\ No newline at end of file
......@@ -150,6 +150,11 @@ public class BookGroup extends BaseEntity {
*/
private Boolean belongSpecialAgent;
/**
* 书籍简称
*/
private String shortBookName;
public Long getId() {
return id;
}
......@@ -366,6 +371,14 @@ public class BookGroup extends BaseEntity {
this.belongSpecialAgent = belongSpecialAgent;
}
public String getShortBookName() {
return shortBookName;
}
public void setShortBookName(String shortBookName) {
this.shortBookName = shortBookName;
}
@Override
public String toString() {
return "BookGroup{" +
......@@ -397,5 +410,7 @@ public class BookGroup extends BaseEntity {
", agentId=" + agentId +
", belongSpecialAgent=" + belongSpecialAgent +
'}';
", shortBookName='" + shortBookName + '\'' +
"} " + super.toString();
}
}
\ No newline at end of file
......@@ -25,6 +25,9 @@ public class BookGroupCipherUser extends BaseEntity {
@ApiModelProperty("机器人id")
private String altId;
@ApiModelProperty("书籍简称")
private String shortBookName;
public Long getBookGroupId() {
return bookGroupId;
}
......@@ -57,6 +60,14 @@ public class BookGroupCipherUser extends BaseEntity {
this.altId = altId;
}
public String getShortBookName() {
return shortBookName;
}
public void setShortBookName(String shortBookName) {
this.shortBookName = shortBookName;
}
@Override
public String toString() {
return "BookGroupCipherUser{" +
......@@ -64,6 +75,7 @@ public class BookGroupCipherUser extends BaseEntity {
", bookGroupCipher='" + bookGroupCipher + '\'' +
", wxUserId='" + wxUserId + '\'' +
", altId='" + altId + '\'' +
", shortBookName='" + shortBookName + '\'' +
"} " + super.toString();
}
}
package com.pcloud.book.group.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/31 16:51
**/
@Data
@ApiModel("微信用户和rays系统用户关联关系")
public class WxWechatUserCorrelation extends BaseEntity {
@ApiModelProperty("社群书id")
private Long bookGroupId;
@ApiModelProperty("微信用户id")
private String wxId;
@ApiModelProperty("rays系统微信用户id")
private Long wechatUserId;
}
......@@ -18,7 +18,12 @@ public enum BookGroupAppOriginTypeEnum {
/**
* 配置资源
*/
SERVE(4, "配置资源");
SERVE(4, "配置资源"),
/**
* 个人关键词
*/
SELF_KEYWORD(5,"个人关键词");
public final Integer code;
......
......@@ -7,6 +7,7 @@ import com.pcloud.book.group.dto.UserSelectParamDTO;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.WxWechatUserCorrelation;
import com.pcloud.book.group.vo.BookGroupAnalysisParam;
import com.pcloud.book.group.vo.BookGroupAnalysisVO;
import com.pcloud.book.group.vo.FriendsVO;
......@@ -149,7 +150,7 @@ public interface BookGroupFacade {
@RequestParam(value = "isMainEditor", required = false) Integer isMainEditor,
@RequestParam(value = "isFundSupport", required = false) Integer isFundSupport,
@RequestParam(value = "bookId", required = false) Integer bookId,
@RequestParam(value = "joinGroupType", required = false) Integer joinGroupType,
@RequestParam(value = "joinGroupType", required = false) String joinGroupType,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "hasServe", required = false) Boolean hasServe)
......@@ -669,4 +670,11 @@ public interface BookGroupFacade {
@GetMapping("getClassifyKeywordStatistic")
ResponseDto<List<ListKeywordVO>> getClassifyKeywordStatistic(
@RequestHeader("token") String token, @RequestParam("classifyId") Long classifyId) throws PermissionException;
@ApiOperation("新增微信用户和rays系统用户关联关系")
@PostMapping("createWxWechatUserCorrelation")
ResponseDto<?> createWxWechatUserCorrelation(
@CookieValue("userInfo") String userInfo,
@RequestBody WxWechatUserCorrelation wxWechatUserCorrelation
)throws BizException, PermissionException;
}
......@@ -12,6 +12,8 @@ import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.entity.WxWechatUserCorrelation;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.facade.BookGroupFacade;
import com.pcloud.book.group.vo.BookGroupAnalysisParam;
import com.pcloud.book.group.vo.BookGroupAnalysisVO;
......@@ -53,6 +55,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -192,7 +195,7 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
@RequestParam(value = "isMainEditor", required = false) Integer isMainEditor,
@RequestParam(value = "isFundSupport", required = false) Integer isFundSupport,
@RequestParam(value = "bookId", required = false) Integer bookId,
@RequestParam(value = "joinGroupType", required = false) Integer joinGroupType,
@RequestParam(value = "joinGroupType", required = false) String joinGroupType,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "hasServe", required = false) Boolean hasServe)
......@@ -211,7 +214,15 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
paramMap.put("bookName", bookName != null && "".equals(bookName.trim()) ? null : bookName);
paramMap.put("typeCode", typeCode != null && "".equals(typeCode.trim()) ? null : typeCode);
paramMap.put("bookId", bookId);
paramMap.put("joinGroupType", joinGroupType);
List<Integer> joinGroupTypes = new ArrayList<>();
if ("GROUP".equals(joinGroupType)) {
joinGroupTypes.add(JoinGroupTypeEnum.GROUP_QRCODE.getCode());
}
if ("ROBOT".equals(joinGroupType)) {
joinGroupTypes.add(JoinGroupTypeEnum.ROBOT.getCode());
joinGroupTypes.add(JoinGroupTypeEnum.AI_ROBOT.getCode());
}
paramMap.put("joinGroupTypes", joinGroupTypes);
if (!StringUtil.isEmpty(startDate) && !StringUtil.isEmpty(endDate)) {
paramMap.put("startDate", startDate + " 00:00:00");
paramMap.put("endDate", endDate + " 23:59:59");
......@@ -1042,4 +1053,16 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
List<ListKeywordVO> listKeywordVOS = bookGroupBiz.getClassifyKeywordStatistic(classifyId);
return new ResponseDto<>(listKeywordVOS);
}
@ApiOperation("新增微信用户和rays系统用户关联关系")
@PostMapping("createWxWechatUserCorrelation")
@Override
public ResponseDto<?> createWxWechatUserCorrelation(
@CookieValue("userInfo") String userInfo,
@RequestBody WxWechatUserCorrelation wxWechatUserCorrelation
) throws BizException, PermissionException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
bookGroupBiz.createWxWechatUserCorrelation(wechatUserId,wxWechatUserCorrelation);
return new ResponseDto<>();
}
}
......@@ -11,6 +11,7 @@ import com.pcloud.book.group.dto.GroupUseDTO;
import com.pcloud.book.group.dto.PersonalQrcodeDTO;
import com.pcloud.book.group.dto.QueryByBookAdviserDTO;
import com.pcloud.book.group.dto.ResourceBrowseParamDto;
import com.pcloud.book.group.dto.SelfRobotBookGroupDTO;
import com.pcloud.book.group.dto.SelfRobotUserDTO;
import com.pcloud.book.group.dto.SelfRobtParamDTO;
import com.pcloud.book.group.service.BookGroupService;
......@@ -337,4 +338,12 @@ public class BookGroupServiceImpl implements BookGroupService {
}
@ApiOperation("根据用户和社群书id获取个人号信息")
@GetMapping("getSelfRobotBookGroupInfoByUser")
@Override
public ResponseEntity<ResponseDto<SelfRobotBookGroupDTO>> getSelfRobotBookGroupInfoByUser(@RequestParam("wxUserId") String wxUserId, @RequestParam("bookGroupId") Long bookGroupId) {
SelfRobotBookGroupDTO selfRobotBookGroupDTO = bookGroupBiz.getSelfRobotBookGroupInfoByUser(wxUserId, bookGroupId);
return ResponseHandleUtil.toResponse(selfRobotBookGroupDTO);
}
}
package com.pcloud.book.keywords.biz;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
public interface SelfRobotKeywordBiz {
void batchAddSelfRobotKeyword(Long partyId, List<SelfRobotKeyword> selfRobotKeywords);
void updateSelfRobotKeyword(Long partyId, SelfRobotKeyword selfRobotKeyword);
void deleteSelfRobotKeyword(Long id);
PageBeanNew<SelfRobotKeyword> getSelfRobotKeywordList(Long bookGroupId, String keyword, Integer currentPage, Integer numPerPage);
void updateSelfRobotKeywordSeqNum(SelfRobotKeyword selfRobotKeyword);
String getAppOrProductServeUrl(Long bookGroupId, Long serveId, String serveType, String serveUrl);
String getMaxKeyword(Long bookGroupId);
}
......@@ -122,7 +122,7 @@ public class BookGuideBizImpl implements BookGuideBiz {
//如果暗号为空,表示直接加好友,需要发送统一欢迎语
if (cipher == null) {
SendTextMessageVO vo = new SendTextMessageVO();
vo.setContent("你好,请将书的专属暗号发给我!可以在扫码后的页面上复制,也可以在书上印码位置处找到。");
vo.setContent("终于和您见面了!\n请告诉我您在读哪本书?\n您可以在书中二维码旁找到本书的识别码,以微信聊天的形式发给我。");
vo.setCode(SendMessageTypeEnum.SELF.getCode());
vo.setWxId(agreeAddUserDTO.getRobotWxId());
vo.setAltId(agreeAddUserDTO.getRobotWxId());
......
......@@ -8,6 +8,7 @@ import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookKeywordWarehouseBiz;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.content.ResourceConsr;
import com.pcloud.book.consumer.live.LiveCons;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
......@@ -32,6 +33,7 @@ import com.pcloud.book.group.entity.BookGroupCipherUser;
import com.pcloud.book.group.entity.BookGroupClassify;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.enums.QrcodeStatusEnum;
import com.pcloud.book.group.enums.TouchTypeEnum;
......@@ -46,6 +48,7 @@ import com.pcloud.book.keywords.biz.BookKeywordBiz;
import com.pcloud.book.keywords.dao.BookKeywordDao;
import com.pcloud.book.keywords.dao.BookKeywordRecordDao;
import com.pcloud.book.keywords.dao.KeywordDao;
import com.pcloud.book.keywords.dao.SelfRobotKeywordDao;
import com.pcloud.book.keywords.dto.KeywordDTO;
import com.pcloud.book.keywords.dto.KeywordStatisticsDTO;
import com.pcloud.book.keywords.dto.ReplyKeywordDTO;
......@@ -53,6 +56,7 @@ import com.pcloud.book.keywords.dto.ServiceResourceDTO;
import com.pcloud.book.keywords.entity.BookKeyword;
import com.pcloud.book.keywords.entity.BookKeywordRecord;
import com.pcloud.book.keywords.entity.Keyword;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.keywords.vo.DeleteKeywordVO;
import com.pcloud.book.keywords.vo.KeywordVO;
......@@ -79,14 +83,18 @@ import com.pcloud.common.utils.bean.ResponesUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import com.pcloud.liveapp.live.dto.CourseListDto;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import com.pcloud.wechatgroup.group.dto.RobotReplyDTO;
import com.pcloud.wechatgroup.message.dto.SendTextDTO;
import com.sdk.wxgroup.ChangeNameVO;
import com.sdk.wxgroup.SendArticleMessageVO;
import com.sdk.wxgroup.SendFileVO;
import com.sdk.wxgroup.SendGroupInviteVO;
import com.sdk.wxgroup.SendMessageTypeEnum;
import com.sdk.wxgroup.SendPicMessageVO;
import com.sdk.wxgroup.SendTextMessageVO;
import com.sdk.wxgroup.WxGroupSDK;
......@@ -166,6 +174,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private BookGroupAppBiz bookGroupAppBiz;
@Autowired
private WxUserWechatRelevanceDao wxUserWechatRelevanceDao;
@Autowired
private SelfRobotKeywordDao selfRobotKeywordDao;
@Autowired
private ResourceConsr resourceConsr;
/**
* 字符串切割长度
*/
......@@ -498,9 +510,155 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
dealBookGroupCipher(sendTextDTO);
//判断是否为某个群分类名称
inviteToGroupByKeyword(sendTextDTO);
//智能机器人新版个人号回复
dealSelfShortBookName(sendTextDTO);
//回复关键词
replySelfKeyword(sendTextDTO);
}
}
@ParamLog("回复新版关键词")
private void replySelfKeyword(SendTextDTO sendTextDTO) {
String content = sendTextDTO.getTextContent();
BookGroupCipherUser bookGroupCipherUser = bookGroupCipherUserDao.getByWxUserId(sendTextDTO.getWechatUserId());
if (bookGroupCipherUser == null || StringUtil.isEmpty(bookGroupCipherUser.getShortBookName())) {
return;
}
SelfRobotKeyword selfRobotKeyword = selfRobotKeywordDao.getByBookGroupIdAndKeyword(bookGroupCipherUser.getBookGroupId(), content);
if (selfRobotKeyword != null) {
sendSelfKeyword(selfRobotKeyword, sendTextDTO);
} else {
BookGroup bookGroup = bookGroupDao.getByShortBookName(content);
if (bookGroup == null) {
//既不是关键词也不是识别码
sendText(sendTextDTO, "请按以上指引回复准确的内容以便获取对应服务,谢谢!");
}
}
}
@ParamLog("推送新版关键词回复消息")
private void sendSelfKeyword(SelfRobotKeyword selfRobotKeyword, SendTextDTO sendTextDTO) {
String userWxId = sendTextDTO.getWechatUserId();
String ip = sendTextDTO.getIp();
Integer code = sendTextDTO.getCode();
String robotId = sendTextDTO.getWxId();
Integer type = selfRobotKeyword.getType();
if (ReplyTypeEnum.TEXT.value.equals(type)) {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(selfRobotKeyword.getContent());
sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
sendTextMessageVO.setCode(code);
WxGroupSDK.sendTextMessage(sendTextMessageVO);
}
if (ReplyTypeEnum.IMAGE.value.equals(type)) {
SendPicMessageVO sendPicMessageVO = new SendPicMessageVO();
sendPicMessageVO.setWxGroupId(userWxId);
sendPicMessageVO.setAltId(robotId);
sendPicMessageVO.setPicUrl(selfRobotKeyword.getPicUrl());
sendPicMessageVO.setIp(ip);
sendPicMessageVO.setCode(code);
WxGroupSDK.sendPicMessage(sendPicMessageVO);
}
if (ReplyTypeEnum.LINK.value.equals(type)) {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
String content = selfRobotKeyword.getGuide() + ",点击这里进入:" + selfRobotKeyword.getLinkUrl();
sendTextMessageVO.setContent(content);
sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
sendTextMessageVO.setCode(code);
WxGroupSDK.sendTextMessage(sendTextMessageVO);
}
if (ReplyTypeEnum.APP.value.equals(type)) {
BookGroupDTO bookGroupDTO = bookGroupDao.getDTOById(selfRobotKeyword.getBookGroupId());
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(bookGroupDTO.getChannelId());
if (AppAndProductTypeEnum.APP.value.equals(selfRobotKeyword.getServeType())) {
AppDto appDto = appConsr.getBaseById(selfRobotKeyword.getServeId());
if (appDto != null) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
}
}
// 处理链接地址
String endUrl = selfRobotKeyword.getLinkUrl() + "&book_group_id=" + selfRobotKeyword.getBookGroupId() + "&wxId=" + userWxId;
String linkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, endUrl);
String resultUrl = UrlUtils.getShortUrl4Own(linkUrl);
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
String content = selfRobotKeyword.getGuide() + ",点击这里进入:" + resultUrl;
sendTextMessageVO.setContent(content);
sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
sendTextMessageVO.setCode(code);
WxGroupSDK.sendTextMessage(sendTextMessageVO);
}
if (ReplyTypeEnum.RESOURCE.value.equals(type)) {
SendFileVO sendFileVO = new SendFileVO();
Map<Long, ResourceDTO> map = resourceConsr.mapByIds(Arrays.asList(selfRobotKeyword.getResourceId()));
ResourceDTO resourceDTO = map.get(selfRobotKeyword.getResourceId());
if (resourceDTO != null) {
sendFileVO.setFileUrl(resourceDTO.getFileUrl());
sendFileVO.setFileName(resourceDTO.getResourceName());
}
sendFileVO.setIp(ip);
sendFileVO.setAltId(robotId);
sendFileVO.setWxId(userWxId);
WxGroupSDK.sendFile(sendFileVO);
}
}
@ParamLog("获取的关键词是否为社群书的简称")
private void dealSelfShortBookName(SendTextDTO sendTextDTO) {
String content = sendTextDTO.getTextContent();
BookGroup bookGroup = bookGroupDao.getByShortBookName(content);
if (bookGroup != null) {
addBookGroupCipherUser(sendTextDTO, null, content, bookGroup.getId());
dealBySelfRobot(sendTextDTO, bookGroup.getId(), bookGroup.getChannelId());
} else {
//判断之前是否有关联,如果没有,提示输入正确的识别码
Long bookGroupId = bookGroupCipherUserDao.getBookGroupIdByWxUserId(sendTextDTO.getWechatUserId());
if (bookGroupId == null) {
sendText(sendTextDTO, "识别码发送错误,请核对后重新发送。");
}
}
}
@ParamLog("处理智能机器人个人号回复")
private void dealBySelfRobot(SendTextDTO sendTextDTO, Long bookGroupId, Long channelId) {
String text = "";
List<SelfRobotKeyword> selfRobotKeywords = selfRobotKeywordDao.getListByBookGroupId(bookGroupId);
if (!ListUtils.isEmpty(selfRobotKeywords)) {
text = text + "识别码收到!我猜您有以下愿望:\n";
Integer size = selfRobotKeywords.size();
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
for (int i = 0; i < size; i++) {
SelfRobotKeyword selfRobotKeyword = selfRobotKeywords.get(i);
String toAddIn = selfRobotKeyword.getGuide() + "请回复:" + selfRobotKeyword.getKeyword() + "\n";
//最后一个
if (i + 1 == size) {
// 拼接反馈链接
String feedbackUrl = "*common/C" + channelId + "/A0/feedback/suggest?bookGroupId="+bookGroupId+"&wxId=" + sendTextDTO.getWechatUserId();
String url = SendWeixinRequestTools.splitUrl(accountSettingDto, feedbackUrl);
toAddIn = toAddIn + "回复对应数字序号给我,我将祝你达成所愿,提高读书效率。\n如有其他问题反馈,请点击链接:\n"
+ UrlUtils.getShortUrl4Own(url);
}
String contents = text + toAddIn;
if (contents.length() > LE) {
sendText(sendTextDTO, text);
text = toAddIn;
} else {
text = contents;
}
}
} else {
text = text + "抱歉,本图书配套服务正在快马加鞭地赶来。服务到达时,会微信通知您。";
}
sendText(sendTextDTO, text);
}
@ParamLog("获取的关键词是否为社群书的暗号")
private void dealBookGroupCipher(SendTextDTO sendTextDTO) {
String cipher = sendTextDTO.getTextContent();
......@@ -511,7 +669,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
BookGroup bookGroup = bookGroupDao.getByBookGroupCipher(cipher);
if (bookGroup != null) {
try {
addBookGroupCipherUser(sendTextDTO, cipher, bookGroup.getId());
addBookGroupCipherUser(sendTextDTO, cipher,null, bookGroup.getId());
updateWxUserWechatRelevance(sendTextDTO);
dealByBookGroup(sendTextDTO, bookGroup.getId(), false);
} catch (Exception e) {
......@@ -531,9 +689,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
}
@ParamLog("增加暗号对应书记录")
private void addBookGroupCipherUser(SendTextDTO sendTextDTO, String cipher, Long bookGroupId) {
private void addBookGroupCipherUser(SendTextDTO sendTextDTO, String cipher, String shortBookName, Long bookGroupId) {
BookGroupCipherUser bookGroupCipherUser = new BookGroupCipherUser();
bookGroupCipherUser.setBookGroupCipher(cipher);
bookGroupCipherUser.setShortBookName(shortBookName);
bookGroupCipherUser.setBookGroupId(bookGroupId);
bookGroupCipherUser.setWxUserId(sendTextDTO.getWechatUserId());
bookGroupCipherUser.setAltId(sendTextDTO.getWxId());
......@@ -561,7 +720,7 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
if (i == 1 || i == 2) {
text = text + "🔥";
}
String toAdd = i + "." + bookGroupServe.getServeName() + bookGroupServe.getShortUrl() + "\n";
String toAdd = i + "." + bookGroupServe.getServeName() + "\n" + bookGroupServe.getShortUrl() + "\n";
String content = text + toAdd;
if (content.length() > LE) {
sendText(sendTextDTO, text);
......@@ -722,11 +881,11 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private void inviteToGroupByKeyword(SendTextDTO sendTextDTO) {
String userWxId = sendTextDTO.getWechatUserId();
//获取这个人最近一次触发的关联社群码
Long bookGroupId = bookGroupCipherUserDao.getBookGroupIdByWxUserId(userWxId);
if (bookGroupId == null) {
BookGroupCipherUser bookGroupCipherUser = bookGroupCipherUserDao.getByWxUserId(userWxId);
if (bookGroupCipherUser == null || StringUtil.isEmpty(bookGroupCipherUser.getBookGroupCipher())) {
return;
}
List<BookGroupClassify> bookGroupClassifyList = bookGroupClassifyDao.getListByBookGroupId(bookGroupId);
List<BookGroupClassify> bookGroupClassifyList = bookGroupClassifyDao.getListByBookGroupId(bookGroupCipherUser.getBookGroupId());
if (!ListUtils.isEmpty(bookGroupClassifyList)) {
for (BookGroupClassify bookGroupClassify : bookGroupClassifyList) {
if (bookGroupClassify.getClassify().equals(sendTextDTO.getTextContent())) {
......
package com.pcloud.book.keywords.biz.impl;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.content.ResourceConsr;
import com.pcloud.book.consumer.resource.ProductConsr;
import com.pcloud.book.group.biz.BookGroupAppBiz;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.keywords.biz.SelfRobotKeywordBiz;
import com.pcloud.book.keywords.dao.SelfRobotKeywordDao;
import com.pcloud.book.keywords.dto.MaxSeqNAndBGDTO;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.resourcecenter.product.dto.ProductTypeDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/30 11:35
**/
@Component("selfRobotKeywordBiz")
public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
@Autowired
private SelfRobotKeywordDao selfRobotKeywordDao;
@Autowired
private BookGroupDao bookGroupDao;
@Autowired
private AppConsr appConsr;
@Autowired
private BookGroupAppBiz bookGroupAppBiz;
@Autowired
private ProductConsr productConsr;
@Autowired
private ResourceConsr resourceConsr;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Transactional(rollbackFor = Exception.class)
@ParamLog("批量新增个人号关键词")
@Override
public void batchAddSelfRobotKeyword(Long partyId, List<SelfRobotKeyword> selfRobotKeywords) {
checkBatchAddSelfRobotKeyword(selfRobotKeywords);
List<Long> bookGroupIds = selfRobotKeywords.stream().map(SelfRobotKeyword::getBookGroupId).distinct().collect(Collectors.toList());
List<BookGroupDTO> dtos = bookGroupDao.getDTOByIds(bookGroupIds);
Map<Long, Long> btcMap = new HashMap<>();
for (BookGroupDTO bookGroupDTO : dtos) {
btcMap.put(bookGroupDTO.getId(), bookGroupDTO.getChannelId());
}
//获取最大排序值
List<MaxSeqNAndBGDTO> maxSeqNAndBGDTOS = selfRobotKeywordDao.getMaxSeqNumByBookGroupIds(bookGroupIds);
Map<Long, Integer> maxSeqMap = new HashMap<>();
if (!ListUtils.isEmpty(maxSeqNAndBGDTOS)) {
for (MaxSeqNAndBGDTO maxSeqNAndBGDTO : maxSeqNAndBGDTOS) {
maxSeqMap.put(maxSeqNAndBGDTO.getBookGroupId(), maxSeqNAndBGDTO.getMaxSeqNum());
}
}
for (SelfRobotKeyword selfRobotKeyword : selfRobotKeywords) {
selfRobotKeyword.setCreateUser(partyId);
Long bookGroupId = selfRobotKeyword.getBookGroupId();
Integer maxSeqNum = maxSeqMap.get(bookGroupId);
if (maxSeqNum == null) {
maxSeqNum = 0;
}
selfRobotKeyword.setSeqNum(maxSeqNum + 1);
maxSeqNum = maxSeqNum + 1;
maxSeqMap.put(bookGroupId, maxSeqNum);
}
//新增
selfRobotKeywordDao.batchInsert(selfRobotKeywords);
//将作品应用关键词加到社群书应用
bookGroupAppBiz.addSelfKeywordToBookGroupApp(selfRobotKeywords);
Map<Long, List<SelfRobotKeyword>> listMap = selfRobotKeywords.stream().filter(s -> AppAndProductTypeEnum.PRODUCT.value.equalsIgnoreCase(s.getServeType())).collect(Collectors.groupingBy(s -> s.getBookGroupId()));
for (Long bookGroupId : bookGroupIds) {
List<SelfRobotKeyword> list = listMap.get(bookGroupId);
if (!ListUtils.isEmpty(list)) {
List<Long> productIds = list.stream().filter(s -> s.getServeId() != null).map(SelfRobotKeyword::getServeId).collect(Collectors.toList());
//自动上架
productConsr.productAutoOnShelves(btcMap.get(bookGroupId), productIds);
}
}
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("更新个人号关键词")
@Override
public void updateSelfRobotKeyword(Long partyId, SelfRobotKeyword selfRobotKeyword) {
checkUpdateSelfRobotKeyword(selfRobotKeyword);
BookGroupDTO dto = bookGroupDao.getDTOById(selfRobotKeyword.getBookGroupId());
if (dto==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "未找到该社群书!");
}
selfRobotKeywordDao.updateSelfRobotKeyword(selfRobotKeyword);
if (ReplyTypeEnum.APP.value.equals(selfRobotKeyword.getType())
&& AppAndProductTypeEnum.PRODUCT.value.equals(selfRobotKeyword.getServeType())) {
//上架
productConsr.productAutoOnShelves(dto.getChannelId(), Arrays.asList(selfRobotKeyword.getServeId()));
}
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("删除个人号关键词")
@Override
public void deleteSelfRobotKeyword(Long id) {
selfRobotKeywordDao.deleteById(id);
}
@ParamLog("获取个人号关键词列表")
@Override
public PageBeanNew<SelfRobotKeyword> getSelfRobotKeywordList(Long bookGroupId, String keyword, Integer currentPage, Integer numPerPage) {
if (bookGroupId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "bookGroupId参数为空!");
}
if (currentPage == null || numPerPage == null || currentPage < 0 || numPerPage <= 0) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "分页参数错误!");
}
PageParam pageParam = new PageParam(currentPage, numPerPage);
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
map.put("keyword", keyword);
PageBeanNew<SelfRobotKeyword> page = selfRobotKeywordDao.listPageNew(pageParam, map, "getSelfRobotKeywordList");
fillSelfRobotKeyword(page.getRecordList());
return page;
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("删除个人号关键词")
@Override
public void updateSelfRobotKeywordSeqNum(SelfRobotKeyword selfRobotKeyword) {
if (selfRobotKeyword==null||selfRobotKeyword.getId()==null||selfRobotKeyword.getSeqNum()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
}
selfRobotKeywordDao.updateSeqNum(selfRobotKeyword.getId(),selfRobotKeyword.getSeqNum());
}
@ParamLog("获取应用或作品链接")
@Override
public String getAppOrProductServeUrl(Long bookGroupId, Long serveId, String serveType, String serveUrl) {
if (bookGroupId==null||serveId==null||StringUtil.isEmpty(serveUrl)){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
}
BookGroupDTO dto = bookGroupDao.getDTOById(bookGroupId);
if (dto==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数错误!");
}
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(dto.getChannelId());
if ("APP".equalsIgnoreCase(serveType)) {
AppDto appDto = appConsr.getBaseById(serveId);
if (appDto != null) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
}
}
// 处理链接地址
String endUrl = serveUrl + "&book_group_id=" + bookGroupId;
String linkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, endUrl);
return linkUrl;
}
@Override
public String getMaxKeyword(Long bookGroupId) {
return selfRobotKeywordDao.getMaxKeyword(bookGroupId);
}
@ParamLog("填充列表")
private void fillSelfRobotKeyword(List<SelfRobotKeyword> selfRobotKeywords) {
if (ListUtils.isEmpty(selfRobotKeywords)){
return;
}
List<Long> appIds=new ArrayList<>();
List<Long> productIds=new ArrayList<>();
List<Long> resourceIds=new ArrayList<>();
for (SelfRobotKeyword selfRobotKeyword:selfRobotKeywords){
Integer type=selfRobotKeyword.getType();
if (ReplyTypeEnum.APP.value.equals(type)){
if (AppAndProductTypeEnum.APP.value.equals(selfRobotKeyword.getServeType())){
appIds.add(selfRobotKeyword.getServeId());
}
if (AppAndProductTypeEnum.PRODUCT.value.equals(selfRobotKeyword.getServeType())){
productIds.add(selfRobotKeyword.getServeId());
}
}
if (ReplyTypeEnum.RESOURCE.value.equals(type)){
resourceIds.add(selfRobotKeyword.getResourceId());
}
}
Map<Long, AppDto> appDtoMap=new HashMap<>();
Map<Long, ProductDto> productDtoMap=new HashMap<>();
Map<Long, ResourceDTO> resourceDTOMap=new HashMap<>();
if (!ListUtils.isEmpty(appIds)){
appDtoMap = appConsr.getBaseByIds(appIds);
}
if (!ListUtils.isEmpty(productIds)){
productDtoMap = productConsr.getProBasesByIds(productIds);
}
if (!ListUtils.isEmpty(resourceIds)){
resourceDTOMap = resourceConsr.mapByIds(resourceIds);
}
for (SelfRobotKeyword selfRobotKeyword:selfRobotKeywords){
Integer type=selfRobotKeyword.getType();
if (ReplyTypeEnum.APP.value.equals(type)){
Long serveId=selfRobotKeyword.getServeId();
if (AppAndProductTypeEnum.APP.value.equals(selfRobotKeyword.getServeType())){
AppDto appDto=appDtoMap.get(serveId);
if (appDto!=null){
selfRobotKeyword.setServePic(appDto.getSquareImg());
selfRobotKeyword.setServeName(appDto.getTitle());
selfRobotKeyword.setServeTypeCode(appDto.getTypeCode());
selfRobotKeyword.setServeTypeName(appDto.getTypeName());
}
}
if (AppAndProductTypeEnum.PRODUCT.value.equals(selfRobotKeyword.getServeType())){
ProductDto productDto=productDtoMap.get(serveId);
if (productDto!=null){
selfRobotKeyword.setServePic(productDto.getCoverImg());
selfRobotKeyword.setServeName(productDto.getProductName());
ProductTypeDto productTypeDto = productDto.getProductTypeDto();
if (productTypeDto!=null){
selfRobotKeyword.setServeTypeCode(productTypeDto.getTypeCode());
selfRobotKeyword.setServeTypeName(productTypeDto.getTypeName());
}
}
}
}
if (ReplyTypeEnum.RESOURCE.value.equals(type)){
ResourceDTO resourceDTO = resourceDTOMap.get(selfRobotKeyword.getResourceId());
if (resourceDTO!=null){
selfRobotKeyword.setResourceName(resourceDTO.getResourceName());
selfRobotKeyword.setResourceUrl(resourceDTO.getFileUrl());
selfRobotKeyword.setResourceTypeCode(resourceDTO.getTypeCode());
selfRobotKeyword.setResourceTypeName(resourceDTO.getTypeName());
selfRobotKeyword.setFileType(resourceDTO.getFileType());
selfRobotKeyword.setResourcePdfItems(resourceDTO.getResourcePdfItems());
selfRobotKeyword.setResourceOfficeItemDTOs(resourceDTO.getResourceOfficeItemDTOs());
}
}
}
}
@ParamLog("批量新增个人号关键词参数校验")
private void checkBatchAddSelfRobotKeyword(List<SelfRobotKeyword> selfRobotKeywords) {
if (ListUtils.isEmpty(selfRobotKeywords)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数为空!");
}
for (SelfRobotKeyword selfRobotKeyword : selfRobotKeywords) {
checkAddSelfRobotKeyword(selfRobotKeyword);
}
}
@ParamLog("更新个人号关键词校验")
private void checkUpdateSelfRobotKeyword(SelfRobotKeyword selfRobotKeyword){
if (selfRobotKeyword==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数为空!");
}
if (selfRobotKeyword.getId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "id不能为空!");
}
checkAddSelfRobotKeyword(selfRobotKeyword);
}
@ParamLog("校验新增个人号关键词")
private void checkAddSelfRobotKeyword(SelfRobotKeyword selfRobotKeyword){
if (selfRobotKeyword==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "参数为空!");
}
if (selfRobotKeyword.getBookGroupId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "社群码id不能为空!");
}
if (selfRobotKeyword.getType() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "类型不能为空!");
}
if (StringUtil.isEmpty(selfRobotKeyword.getGuide())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "引导语不能为空!");
}
if (StringUtil.isEmpty(selfRobotKeyword.getKeyword())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "关键词不能为空!");
}
Integer type = selfRobotKeyword.getType();
if (ReplyTypeEnum.TEXT.value.equals(type) && StringUtil.isEmpty(selfRobotKeyword.getContent())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "内容不能为空!");
}
if (ReplyTypeEnum.IMAGE.value.equals(type) && StringUtil.isEmpty(selfRobotKeyword.getPicUrl())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "图片地址不能为空!");
}
if (ReplyTypeEnum.LINK.value.equals(type) && StringUtil.isEmpty(selfRobotKeyword.getLinkUrl())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "链接地址不能为空!");
}
if (ReplyTypeEnum.APP.value.equals(type) && (StringUtil.isEmpty(selfRobotKeyword.getServeType()) || selfRobotKeyword.getServeId() == null)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "应用或作品id和类型不能为空!");
}
if (ReplyTypeEnum.RESOURCE.value.equals(type) && selfRobotKeyword.getResourceId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "资源id和连接不能为空!");
}
}
}
package com.pcloud.book.keywords.dao;
import com.pcloud.book.keywords.dto.MaxSeqNAndBGDTO;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/30 11:39
**/
public interface SelfRobotKeywordDao extends BaseDao<SelfRobotKeyword> {
Integer batchInsert(List<SelfRobotKeyword> selfRobotKeywords);
void updateSelfRobotKeyword(SelfRobotKeyword selfRobotKeyword);
void deleteByBookGroupIds(List<Long> bookGroupIds);
List<SelfRobotKeyword> getListByBookGroupId(Long bookGroupId);
SelfRobotKeyword getByBookGroupIdAndKeyword(Long bookGroupId, String keyword);
Integer getCountByBookGroupId(Long bookGroupId);
List<MaxSeqNAndBGDTO> getMaxSeqNumByBookGroupIds(List<Long> bookGroupIds);
void updateSeqNum(Long id, Integer seqNum);
String getMaxKeyword(Long bookGroupId);
}
package com.pcloud.book.keywords.dao.impl;
import com.pcloud.book.keywords.dao.SelfRobotKeywordDao;
import com.pcloud.book.keywords.dto.MaxSeqNAndBGDTO;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/30 11:39
**/
@Component("selfRobotKeywordDao")
public class SelfRobotKeywordDaoImpl extends BaseDaoImpl<SelfRobotKeyword> implements SelfRobotKeywordDao {
@Override
public Integer batchInsert(List<SelfRobotKeyword> selfRobotKeywords) {
return this.getSqlSession().insert(this.getStatement("batchInsert"), selfRobotKeywords);
}
@Override
public void updateSelfRobotKeyword(SelfRobotKeyword selfRobotKeyword) {
this.getSqlSession().update(this.getStatement("updateSelfRobotKeyword"), selfRobotKeyword);
}
@Override
public void deleteByBookGroupIds(List<Long> bookGroupIds) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupIds", bookGroupIds);
this.getSqlSession().delete(this.getStatement("deleteByBookGroupIds"), map);
}
@Override
public List<SelfRobotKeyword> getListByBookGroupId(Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
return this.getSqlSession().selectList(this.getStatement("getListByBookGroupId"), map);
}
@Override
public SelfRobotKeyword getByBookGroupIdAndKeyword(Long bookGroupId, String keyword) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
map.put("keyword", keyword);
return this.getSqlSession().selectOne(this.getStatement("getByBookGroupIdAndKeyword"), map);
}
@Override
public Integer getCountByBookGroupId(Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
return this.getSqlSession().selectOne(this.getStatement("getCountByBookGroupId"), map);
}
@Override
public List<MaxSeqNAndBGDTO> getMaxSeqNumByBookGroupIds(List<Long> bookGroupIds) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupIds", bookGroupIds);
return this.getSqlSession().selectList(this.getStatement("getMaxSeqNumByBookGroupIds"), map);
}
@Override
public void updateSeqNum(Long id, Integer seqNum) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("seqNum", seqNum);
this.getSqlSession().update(this.getStatement("updateSeqNum"), map);
}
@Override
public String getMaxKeyword(Long bookGroupId) {
Map<String, Object> map = new HashMap<>();
map.put("bookGroupId", bookGroupId);
return this.getSqlSession().selectOne(this.getStatement("getMaxKeyword"), map);
}
}
package com.pcloud.book.keywords.dto;
import lombok.Data;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/31 12:06
**/
@Data
public class MaxSeqNAndBGDTO {
private Integer maxSeqNum;
private Long bookGroupId;
}
package com.pcloud.book.keywords.entity;
import com.pcloud.common.entity.BaseEntity;
import com.pcloud.contentcenter.resource.dto.ResourceOfficeItemDTO;
import com.pcloud.contentcenter.resource.dto.ResourcePdfItemDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/30 10:55
**/
@Data
@ApiModel("个人号关键词")
public class SelfRobotKeyword extends BaseEntity {
@ApiModelProperty("社群码id")
private Long bookGroupId;
@ApiModelProperty("引导语")
private String guide;
@ApiModelProperty("关键词")
private String keyword;
@ApiModelProperty("类型 1 文字 2 图片 3 链接 4应用 5素材")
private Integer type;
@ApiModelProperty("内容")
private String content;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("链接地址")
private String linkUrl;
@ApiModelProperty("图片地址")
private String picUrl;
@ApiModelProperty("应用或作品id")
private Long serveId;
@ApiModelProperty("应用或作品类型")
private String serveType;
@ApiModelProperty("资源id")
private Long resourceId;
@ApiModelProperty("排序值")
private Integer seqNum;
@ApiModelProperty("创建人")
private Long createUser;
@ApiModelProperty("应用或作品图片")
private String servePic;
@ApiModelProperty("应用或作品名称")
private String serveName;
@ApiModelProperty("应用或作品类型名称")
private String serveTypeName;
@ApiModelProperty("应用或作品类型编码")
private String serveTypeCode;
@ApiModelProperty("资源链接")
private String resourceUrl;
@ApiModelProperty("资源名称")
private String resourceName;
@ApiModelProperty("资源类型编码")
private String resourceTypeCode;
@ApiModelProperty("资源类型名称")
private String resourceTypeName;
@ApiModelProperty("文件类型")
private String fileType;
@ApiModelProperty("pdf转码后的单张图片集合")
private List<ResourcePdfItemDTO> resourcePdfItems;
@ApiModelProperty("文件转码后的单张图片集合")
private List<ResourceOfficeItemDTO> resourceOfficeItemDTOs;
}
......@@ -22,7 +22,11 @@ public enum ReplyTypeEnum {
/**
* 应用
*/
APP(4);
APP(4),
/**
* 资源
*/
RESOURCE(5);
/**
* 值
*/
......
package com.pcloud.book.keywords.facade;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@Api(description = "个人号关键词")
public interface SelfRobotKeywordFacade {
@ApiOperation("批量新增个人号关键词")
@PostMapping("batchAddSelfRobotKeyword")
ResponseDto<?> batchAddSelfRobotKeyword(
@RequestHeader("token") String token,
@RequestBody @ApiParam("个人号关键词") List<SelfRobotKeyword> selfRobotKeywords
) throws BizException, PermissionException;
@ApiOperation("更新个人号关键词")
@PostMapping("updateSelfRobotKeyword")
ResponseDto<?> updateSelfRobotKeyword(
@RequestHeader("token") String token,
@RequestBody @ApiParam("个人号关键词") SelfRobotKeyword selfRobotKeyword
) throws BizException, PermissionException;
@ApiOperation("删除个人号关键词")
@GetMapping("deleteSelfRobotKeyword")
ResponseDto<?> deleteSelfRobotKeyword(
@RequestHeader("token") String token,
@RequestParam("id") @ApiParam("个人号关键词id") Long id
) throws BizException, PermissionException;
@ApiOperation("获取个人号关键词列表")
@GetMapping("getSelfRobotKeywordList")
ResponseDto<?> getSelfRobotKeywordList(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId,
@RequestParam(value = "keyword",required = false) @ApiParam("关键词") String keyword,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
) throws BizException, PermissionException;
@ApiOperation("客户端获取个人号关键词列表")
@GetMapping("getSelfRobotKeywordList4Wechat")
ResponseDto<?> getSelfRobotKeywordList4Wechat(
@CookieValue("userInfo") String userInfo,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId,
@RequestParam(value = "keyword",required = false) @ApiParam("关键词") String keyword,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
) throws BizException, PermissionException;
@ApiOperation("修改个人号关键词排序值")
@PostMapping("updateSelfRobotKeywordSeqNum")
ResponseDto<?> updateSelfRobotKeywordSeqNum(
@RequestHeader("token") String token,
@RequestBody @ApiParam("个人号关键词") SelfRobotKeyword selfRobotKeyword
) throws BizException, PermissionException;
@ApiOperation("获取应用或作品链接")
@GetMapping("getAppOrProductServeUrl")
ResponseDto<?> getAppOrProductServeUrl(
@CookieValue("userInfo") String userInfo,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId,
@RequestParam("serveId") @ApiParam("作品或应用id") Long serveId,
@RequestParam("serveType") @ApiParam("作品或应用类型") String serveType,
@RequestParam("serveUrl") @ApiParam("作品或应用链接") String serveUrl
) throws BizException, PermissionException;
@ApiOperation("获取最大关键词")
@GetMapping("getMaxKeyword")
ResponseDto<?> getMaxKeyword(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId
) throws BizException, PermissionException;
}
package com.pcloud.book.keywords.facade.impl;
import com.pcloud.book.keywords.biz.SelfRobotKeywordBiz;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.keywords.facade.SelfRobotKeywordFacade;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.cookie.Cookie;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Description
* @Author ruansiyuan
* @Date 2019/12/30 11:05
**/
@RestController("selfRobotKeywordFacade")
@RequestMapping("selfRobotKeyword")
public class SelfRobotKeywordFacadeImpl implements SelfRobotKeywordFacade {
@Autowired
private SelfRobotKeywordBiz selfRobotKeywordBiz;
@ApiOperation("批量新增个人号关键词")
@PostMapping("batchAddSelfRobotKeyword")
@Override
public ResponseDto<?> batchAddSelfRobotKeyword(
@RequestHeader("token") String token,
@RequestBody @ApiParam("个人号关键词") List<SelfRobotKeyword> selfRobotKeywords
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
selfRobotKeywordBiz.batchAddSelfRobotKeyword(partyId, selfRobotKeywords);
return new ResponseDto<>();
}
@ApiOperation("更新个人号关键词")
@PostMapping("updateSelfRobotKeyword")
@Override
public ResponseDto<?> updateSelfRobotKeyword(
@RequestHeader("token") String token,
@RequestBody @ApiParam("个人号关键词") SelfRobotKeyword selfRobotKeyword
) throws BizException, PermissionException {
Long partyId = (Long) SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
selfRobotKeywordBiz.updateSelfRobotKeyword(partyId, selfRobotKeyword);
return new ResponseDto<>();
}
@ApiOperation("删除个人号关键词")
@GetMapping("deleteSelfRobotKeyword")
@Override
public ResponseDto<?> deleteSelfRobotKeyword(
@RequestHeader("token") String token,
@RequestParam("id") @ApiParam("个人号关键词id") Long id
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
selfRobotKeywordBiz.deleteSelfRobotKeyword(id);
return new ResponseDto<>();
}
@ApiOperation("获取个人号关键词列表")
@GetMapping("getSelfRobotKeywordList")
@Override
public ResponseDto<?> getSelfRobotKeywordList(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId,
@RequestParam(value = "keyword",required = false) @ApiParam("关键词") String keyword,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(selfRobotKeywordBiz.getSelfRobotKeywordList(bookGroupId,keyword,currentPage,numPerPage));
}
@ApiOperation("客户端获取个人号关键词列表")
@GetMapping("getSelfRobotKeywordList4Wechat")
@Override
public ResponseDto<?> getSelfRobotKeywordList4Wechat(
@CookieValue("userInfo") String userInfo,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId,
@RequestParam(value = "keyword",required = false) @ApiParam("关键词") String keyword,
@RequestParam("currentPage") Integer currentPage,
@RequestParam("numPerPage") Integer numPerPage
) throws BizException, PermissionException {
Cookie.getUserInfo(userInfo);
return new ResponseDto<>(selfRobotKeywordBiz.getSelfRobotKeywordList(bookGroupId,keyword,currentPage,numPerPage));
}
@ApiOperation("修改个人号关键词排序值")
@PostMapping("updateSelfRobotKeywordSeqNum")
@Override
public ResponseDto<?> updateSelfRobotKeywordSeqNum(
@RequestHeader("token") String token,
@RequestBody @ApiParam("个人号关键词") SelfRobotKeyword selfRobotKeyword
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
selfRobotKeywordBiz.updateSelfRobotKeywordSeqNum(selfRobotKeyword);
return new ResponseDto<>();
}
@ApiOperation("获取应用或作品链接")
@GetMapping("getAppOrProductServeUrl")
@Override
public ResponseDto<?> getAppOrProductServeUrl(
@CookieValue("userInfo") String userInfo,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId,
@RequestParam("serveId") @ApiParam("作品或应用id") Long serveId,
@RequestParam("serveType") @ApiParam("作品或应用类型") String serveType,
@RequestParam("serveUrl") @ApiParam("作品或应用链接") String serveUrl
) throws BizException, PermissionException {
Cookie.getUserInfo(userInfo);
return new ResponseDto<>(selfRobotKeywordBiz.getAppOrProductServeUrl(bookGroupId,serveId,serveType,serveUrl));
}
@ApiOperation("获取最大关键词")
@GetMapping("getMaxKeyword")
@Override
public ResponseDto<?> getMaxKeyword(
@RequestHeader("token") String token,
@RequestParam("bookGroupId") @ApiParam("社群码id") Long bookGroupId
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(selfRobotKeywordBiz.getMaxKeyword(bookGroupId));
}
}
......@@ -6,6 +6,7 @@ import com.pcloud.book.group.dao.BookGroupServeDao;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.keywords.dao.BookKeywordDao;
import com.pcloud.book.keywords.dao.SelfRobotKeywordDao;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.SceneCode;
......@@ -40,6 +41,8 @@ public class SomeUserScanBookGroupListener {
private BookGroupServeDao bookGroupServeDao;
@Autowired
private TemplateConsr templateConsr;
@Autowired
private SelfRobotKeywordDao selfRobotKeywordDao;
@ParamLog("接收社群码扫码人数达到一定数量topic")
@RabbitHandler
......@@ -68,6 +71,13 @@ public class SomeUserScanBookGroupListener {
isSend = true;
}
}
if (JoinGroupTypeEnum.AI_ROBOT.getCode().equals(joinGroupType)) {
//1v1查询有没有配置资源服务
Integer count = selfRobotKeywordDao.getCountByBookGroupId(bookGroupId);
if (count <= 0) {
isSend = true;
}
}
if (isSend) {
//发送模板消息
sendTemplate(dto);
......
......@@ -56,6 +56,11 @@
<result column="join_group_type" property="joinGroupType" jdbcType="INTEGER"/>
<result column="book_group_cipher" property="bookGroupCipher" jdbcType="VARCHAR"/>
<result column="has_serve" property="hasServe" jdbcType="VARCHAR"/>
<result column="short_book_name" property="shortBookName" jdbcType="VARCHAR"/>
<result column="GRA_LABEL_ID" property="graLabelId" jdbcType="BIGINT" />
<result column="SUB_LABEL_ID" property="subLabelId" jdbcType="BIGINT" />
<result column="VER_LABEL_ID" property="verLabelId" jdbcType="BIGINT" />
<result column="AREA_LABEL_ID" property="areaLabelId" jdbcType="BIGINT" />
</resultMap>
<resultMap id="bookListPageMap" type="bookDto" extends ="bookMap">
......@@ -284,7 +289,8 @@
SELECT
B.BOOK_ID, B.TYPE_CODE,B.ISBN, B.BOOK_NAME,T.TYPE_NAME, B.REMARK, B.AUTHOR, B.PUBLISH,
B.PUBLISH_DATE, B.COVER_IMG, B.AD_IMG, B.DETAIL, B.`VERSION`,B.BOOK_PRICE,B.ISSN,B.SERIAL_NUMBER,BA.IS_MAIN_EDITOR,
IF(ISNULL(BF.BOOK_FUND_ID),0,1) IS_FUND_SUPPORT,START_TIME,END_TIME,BA.TEMPLET_ID,BA.SECOND_TEMPLET_ID
IF(ISNULL(BF.BOOK_FUND_ID),0,1) IS_FUND_SUPPORT,START_TIME,END_TIME,BA.TEMPLET_ID,BA.SECOND_TEMPLET_ID,
BA.GRA_LABEL_ID,BA.SUB_LABEL_ID,BA.VER_LABEL_ID,BA.AREA_LABEL_ID
FROM
BOOK_ADVISER BA
INNER JOIN
......@@ -545,7 +551,8 @@
SELECT
A.BOOK_ID, A.CHANNEL_ID, A.ADVISER_ID, A.IS_MAIN_EDITOR, B.ISBN, B.BOOK_NAME, B.TYPE_CODE,
B.AUTHOR, B.PUBLISH, B.PUBLISH_DATE, B.COVER_IMG, B.ORIGIN_NAME, B.BOOK_PRICE, B.ISSN, B.BOOK_NUM, B.SERIAL_NUMBER,
A.TEMPLET_ID,A.SECOND_TEMPLET_ID, A.LAST_MODIFIED_DATE, A.BOOK_ADVISER_ID, CONCAT('BK',A.BOOK_ID) uniqueNumber
A.TEMPLET_ID,A.SECOND_TEMPLET_ID, A.LAST_MODIFIED_DATE, A.BOOK_ADVISER_ID, CONCAT('BK',A.BOOK_ID) uniqueNumber,
A.GRA_LABEL_ID,A.SUB_LABEL_ID,A.VER_LABEL_ID,A.AREA_LABEL_ID
FROM
BOOK_ADVISER A
INNER JOIN BOOK B ON A.BOOK_ID = B.BOOK_ID AND B.IS_DELETE = 0
......@@ -568,25 +575,21 @@
B.AUTHOR, B.PUBLISH, B.PUBLISH_DATE, B.COVER_IMG, B.ORIGIN_NAME, B.BOOK_PRICE, B.ISSN, B.BOOK_NUM, B.SERIAL_NUMBER,
IF(ISNULL(BF.BOOK_FUND_ID),0,1) IS_FUND_SUPPORT, A.TEMPLET_ID, A.BOOK_ADVISER_ID, CONCAT('BK',A.BOOK_ID) uniqueNumber,
G.update_time LAST_MODIFIED_DATE, G.create_time CREATED_DATE, G.id BOOK_GROUP_ID, G.group_qrcode_url groupQrcodeUrl,
G.group_qrcode_name groupQrcodeName, G.dep_label_id depLabelId, G.join_group_type, G.book_group_cipher
, case count(bgs.id)
when 0 then 0
else 1
end has_serve
G.group_qrcode_name groupQrcodeName, G.dep_label_id depLabelId, G.join_group_type, G.book_group_cipher, G.short_book_name
, if(IFNULL(case G.join_group_type
WHEN 1 then bk.id
WHEN 2 THEN bgs.id
WHEN 3 THEN srk.id
else null END,0)=0,0,1)as has_serve
FROM
book_group G
LEFT JOIN BOOK_ADVISER A ON G.BOOK_ID = A.BOOK_ID AND G.CHANNEL_ID = A.CHANNEL_ID AND G.CREATE_USER = A.ADVISER_ID
LEFT JOIN BOOK B ON A.BOOK_ID = B.BOOK_ID
LEFT JOIN BOOK_TYPE T ON B.TYPE_CODE = T.TYPE_CODE
LEFT JOIN BOOK_FUND BF ON BF.BOOK_ID = A.BOOK_ID AND BF.END_TIME <![CDATA[ > ]]> NOW() AND BF.START_TIME <![CDATA[ < ]]> NOW()
<choose>
<when test="joinGroupType!=null and joinGroupType==2">
LEFT JOIN BOOK_GROUP_SERVE bgs on G.id=bgs.book_group_id
</when>
<otherwise>
LEFT JOIN BOOK_KEYWORD bgs on G.id=bgs.book_group_id and bgs.is_delete=0
</otherwise>
</choose>
LEFT JOIN BOOK_KEYWORD bk on G.id=bk.book_group_id and bk.is_delete=0
LEFT JOIN self_robot_keyword srk ON G.id = srk.book_group_id
WHERE
G.create_user = #{adviserId} AND G.is_delete = 0
AND (
......@@ -632,15 +635,18 @@
<if test="startDate != null and endDate != null">
AND G.create_time BETWEEN #{startDate} AND #{endDate}
</if>
<if test="joinGroupType !=null">
AND G.join_group_type=#{joinGroupType}
<if test="joinGroupTypes !=null and joinGroupTypes.size()>0">
AND G.join_group_type in
<foreach collection="joinGroupTypes" item="item" index="index" open="(" separator="," close=")">
${item}
</foreach>
</if>
GROUP BY G.id
<if test="hasServe!=null and hasServe==true">
having count(bgs.id)>0
having has_serve=1
</if>
<if test="hasServe!=null and hasServe==false">
having count(bgs.id)=0
having has_serve=0
</if>
ORDER BY
G.UPDATE_TIME DESC
......
......@@ -34,12 +34,14 @@
<!-- 新增书籍和编辑关联信息-->
<insert id="insert" parameterType="bookAdviser" useGeneratedKeys="true" keyProperty="bookAdviserId" flushCache="true">
INSERT INTO BOOK_ADVISER (
BOOK_ID, ADVISER_ID, CHANNEL_ID, CREATED_USER, CREATED_DATE,IS_MAIN_EDITOR, TEMPLET_ID, SECOND_TEMPLET_ID
BOOK_ID, ADVISER_ID, CHANNEL_ID, CREATED_USER, CREATED_DATE,IS_MAIN_EDITOR, TEMPLET_ID, SECOND_TEMPLET_ID,
GRA_LABEL_ID,SUB_LABEL_ID,VER_LABEL_ID,AREA_LABEL_ID
)
VALUES (
#{bookId, jdbcType=VARCHAR}, #{adviserId, jdbcType=VARCHAR}, #{channelId, jdbcType=VARCHAR},
#{adviserId, jdbcType=BIGINT}, NOW(),#{isMainEditor, jdbcType=BIT},#{templetId, jdbcType=BIGINT},
#{secondTempletId, jdbcType=BIGINT}
#{secondTempletId, jdbcType=BIGINT},#{graLabelId, jdbcType=BIGINT},#{subLabelId, jdbcType=BIGINT},
#{verLabelId, jdbcType=BIGINT},#{areaLabelId, jdbcType=BIGINT}
)
ON
DUPLICATE KEY UPDATE IS_DELETE = 0, IS_MAIN_EDITOR = #{isMainEditor, jdbcType=BIT}
......@@ -49,6 +51,18 @@
<if test="secondTempletId!=null">
,SECOND_TEMPLET_ID=#{secondTempletId, jdbcType=BIGINT}
</if>
<if test="secondTempletId!=null">
,SECOND_TEMPLET_ID=#{secondTempletId, jdbcType=BIGINT}
</if>
<if test="secondTempletId!=null">
,SECOND_TEMPLET_ID=#{secondTempletId, jdbcType=BIGINT}
</if>
<if test="secondTempletId!=null">
,SECOND_TEMPLET_ID=#{secondTempletId, jdbcType=BIGINT}
</if>
<if test="secondTempletId!=null">
,SECOND_TEMPLET_ID=#{secondTempletId, jdbcType=BIGINT}
</if>
</insert>
<!-- 批量新增书籍和编辑关联信息-->
......@@ -366,6 +380,18 @@
<if test="secondTempletId!=null">
,SECOND_TEMPLET_ID = #{secondTempletId, jdbcType=BIGINT}
</if>
<if test="graLabelId!=null">
,GRA_LABEL_ID = #{graLabelId, jdbcType=BIGINT}
</if>
<if test="subLabelId!=null">
,SUB_LABEL_ID = #{subLabelId, jdbcType=BIGINT}
</if>
<if test="verLabelId!=null">
,VER_LABEL_ID = #{verLabelId, jdbcType=BIGINT}
</if>
<if test="areaLabelId!=null">
,AREA_LABEL_ID = #{areaLabelId, jdbcType=BIGINT}
</if>
WHERE
BOOK_ID = #{bookId, jdbcType=BIGINT}
AND
......@@ -421,6 +447,18 @@
<if test="secondTempletId != null">
,SECOND_TEMPLET_ID = #{secondTempletId}
</if>
<if test="graLabelId!=null">
,GRA_LABEL_ID = #{graLabelId, jdbcType=BIGINT}
</if>
<if test="subLabelId!=null">
,SUB_LABEL_ID = #{subLabelId, jdbcType=BIGINT}
</if>
<if test="verLabelId!=null">
,VER_LABEL_ID = #{verLabelId, jdbcType=BIGINT}
</if>
<if test="areaLabelId!=null">
,AREA_LABEL_ID = #{areaLabelId, jdbcType=BIGINT}
</if>
,LAST_MODIFIED_DATE = NOW()
WHERE
BOOK_ID = #{bookId, jdbcType=BIGINT}
......
<?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.book.dao.impl.BookLabelDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.book.entity.BookLabel">
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="type" property="type" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
id,`name`,`type`
</sql>
<select id="getListByType" parameterType="integer" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
book_label
where type=#{type}
</select>
<!--获取全部-->
<select id="getAll" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from book_label
</select>
<!--根据id查询map-->
<select id="getMapByIds" parameterType="list" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from book_label
where id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -7,12 +7,13 @@
<result column="book_group_cipher" property="bookGroupCipher" jdbcType="VARCHAR"/>
<result column="wx_user_id" property="wxUserId" jdbcType="VARCHAR"/>
<result column="alt_id" property="altId" jdbcType="VARCHAR"/>
<result column="short_book_name" property="shortBookName" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_group_id, book_group_cipher, wx_user_id, alt_id, create_time
id, book_group_id, book_group_cipher, wx_user_id, alt_id, short_book_name, create_time
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.BookGroupCipherUser" useGeneratedKeys="true"
......@@ -23,6 +24,7 @@
book_group_cipher,
wx_user_id,
alt_id,
short_book_name,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
......@@ -30,6 +32,7 @@
#{bookGroupCipher,jdbcType=VARCHAR},
#{wxUserId,jdbcType=VARCHAR},
#{altId,jdbcType=VARCHAR},
#{shortBookName,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
......@@ -454,6 +457,33 @@
</if>
</select>
<!--根据wxUserId获取-->
<select id="getByWxUserId" parameterType="string" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from book_group_cipher_user where
wx_user_id=#{wxUserId}
order by create_time desc
limit 1
</select>
<select id="getSelfRobotBookGroupInfoByUser" parameterType="map" resultType="com.pcloud.book.group.dto.SelfRobotBookGroupDTO">
SELECT
u.book_group_id bookGroupId,
g.group_qrcode_name groupQrcodeName,
u.alt_id wxId,
g.book_id bookId,
g.create_user adviserId
FROM
book_group_cipher_user u
LEFT JOIN book_group g ON u.book_group_id = g.id
WHERE
u.book_group_id = #{bookGroupId}
AND u.wx_user_id = #{wxUserId}
ORDER BY
u.id DESC
LIMIT 1
</select>
<select id="getAltCountByBookGroup" parameterType="long" resultType="integer">
SELECT
COUNT(DISTINCT alt_id)
......
......@@ -29,6 +29,7 @@
<result column="is_some_update" property="isSomeUpdate" jdbcType="BOOLEAN"/>
<result column="agent_id" property="agentId" jdbcType="BIGINT"/>
<result column="belong_special_agent" property="belongSpecialAgent" jdbcType="BOOLEAN"/>
<result column="short_book_name" property="shortBookName" jdbcType="VARCHAR"/>
</resultMap>
<resultMap id="BookGroupDTO" type="com.pcloud.book.group.dto.BookGroupDTO">
......@@ -63,6 +64,7 @@
<result column="is_some_update" property="isSomeUpdate" jdbcType="BOOLEAN"/>
<result column="agent_id" property="agentId" jdbcType="BIGINT"/>
<result column="belong_special_agent" property="belongSpecialAgent" jdbcType="BOOLEAN"/>
<result column="short_book_name" property="shortBookName" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
......@@ -70,7 +72,8 @@
pur_label_id, join_title, join_slogan, personal_qrcode_url, product_id, create_user,
create_time,
update_time, is_delete, is_show_book_name,join_group_type,add_friend_guide,customer_service_name,
is_invite_group,book_group_cipher, last_push_update_time, is_some_update, agent_id, belong_special_agent
is_invite_group,book_group_cipher, last_push_update_time, is_some_update, agent_id, belong_special_agent,
short_book_name
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -304,6 +307,9 @@
<if test="agentId != null">
agent_id = #{agentId},
</if>
<if test="shortBookName != null">
short_book_name = #{shortBookName},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......@@ -903,4 +909,12 @@
AND book_id = #{bookId}
</select>
<!--根据书籍简称获取-->
<select id="getByShortBookName" parameterType="string" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from book_group
where short_book_name =#{shortBookName}
limit 1
</select>
</mapper>
\ No newline at end of file
......@@ -71,7 +71,7 @@
</delete>
<!--根据社群书id获取集合-->
<select id="getListByBookGroupId" parameterType="long" resultMap="BaseResultMap">
<select id="getListByBookGroupId" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from book_group_serve
where book_group_id=#{bookGroupId}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.keywords.dao.impl.SelfRobotKeywordDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.keywords.entity.SelfRobotKeyword">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="guide" property="guide" jdbcType="VARCHAR"/>
<result column="keyword" property="keyword" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="link_url" property="linkUrl" jdbcType="VARCHAR"/>
<result column="pic_url" property="picUrl" jdbcType="VARCHAR"/>
<result column="serve_id" property="serveId" jdbcType="BIGINT"/>
<result column="serve_type" property="serveType" jdbcType="VARCHAR"/>
<result column="resource_id" property="resourceId" jdbcType="BIGINT"/>
<result column="seq_num" property="seqNum" jdbcType="INTEGER"/>
<result column="create_user" property="createUser" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_group_id, guide, keyword, type, content, description, link_url, pic_url, serve_id,
serve_type, resource_id,seq_num,create_user, create_time
</sql>
<insert id="insert" parameterType="com.pcloud.book.keywords.entity.SelfRobotKeyword" useGeneratedKeys="true"
keyProperty="id">
insert into self_robot_keyword
<trim prefix="(" suffix=")" suffixOverrides=",">
book_group_id,
guide,
keyword,
type,
content,
description,
link_url,
pic_url,
serve_id,
serve_type,
resource_id,
seq_num,
create_user,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{bookGroupId,jdbcType=BIGINT},
#{guide,jdbcType=VARCHAR},
#{keyword,jdbcType=VARCHAR},
#{type,jdbcType=INTEGER},
#{content,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{linkUrl,jdbcType=VARCHAR},
#{picUrl,jdbcType=VARCHAR},
#{serveId,jdbcType=BIGINT},
#{serveType,jdbcType=VARCHAR},
#{resourceId,jdbcType=BIGINT},
#{seqNum,jdbcType=INTEGER},
#{createUser,jdbcType=BIGINT},
NOW()
</trim>
</insert>
<!--批量插入-->
<insert id="batchInsert" parameterType="com.pcloud.book.keywords.entity.SelfRobotKeyword" useGeneratedKeys="true" keyProperty="id">
insert into self_robot_keyword (
book_group_id,
guide,
keyword,
type,
content,
description,
link_url,
pic_url,
serve_id,
serve_type,
resource_id,
seq_num,
create_user,
create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.bookGroupId,jdbcType=BIGINT},
#{item.guide,jdbcType=VARCHAR},
#{item.keyword,jdbcType=VARCHAR},
#{item.type,jdbcType=INTEGER},
#{item.content,jdbcType=VARCHAR},
#{item.description,jdbcType=VARCHAR},
#{item.linkUrl,jdbcType=VARCHAR},
#{item.picUrl,jdbcType=VARCHAR},
#{item.serveId,jdbcType=BIGINT},
#{item.serveType,jdbcType=VARCHAR},
#{item.resourceId,jdbcType=BIGINT},
#{item.seqNum,jdbcType=INTEGER},
#{item.createUser,jdbcType=BIGINT},
NOW()
)
</foreach>
</insert>
<update id="updateSelfRobotKeyword" parameterType="com.pcloud.book.keywords.entity.SelfRobotKeyword">
update self_robot_keyword
<set>
book_group_id = #{bookGroupId,jdbcType=BIGINT},
guide = #{guide,jdbcType=VARCHAR},
keyword = #{keyword,jdbcType=VARCHAR},
type = #{type,jdbcType=INTEGER},
content = #{content,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
link_url = #{linkUrl,jdbcType=VARCHAR},
pic_url = #{picUrl,jdbcType=VARCHAR},
serve_id = #{serveId,jdbcType=BIGINT},
serve_type = #{serveType,jdbcType=VARCHAR},
resource_id = #{resourceId,jdbcType=BIGINT},
seq_num = #{seqNum,jdbcType=INTEGER}
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<!--删除-->
<delete id="deleteById" parameterType="long">
delete from self_robot_keyword
where id=#{id}
</delete>
<!--根据社群码id集合删除-->
<delete id="deleteByBookGroupIds" parameterType="map">
delete from self_robot_keyword
where book_group_id in
<foreach collection="bookGroupIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
</delete>
<!--根据社群书id获取-->
<select id="getListByBookGroupId" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from self_robot_keyword
where book_group_id=#{bookGroupId}
order by seq_num
</select>
<!--根据社群码和关键词获取-->
<select id="getByBookGroupIdAndKeyword" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from self_robot_keyword
where book_group_id=#{bookGroupId}
and keyword=#{keyword}
limit 1
</select>
<!--根据社群码id获取数量-->
<select id="getCountByBookGroupId" parameterType="map" resultType="integer">
select count(1)
from self_robot_keyword
where book_group_id=#{bookGroupId}
</select>
<!--批量获取最大排序值-->
<select id="getMaxSeqNumByBookGroupIds" parameterType="map" resultType="com.pcloud.book.keywords.dto.MaxSeqNAndBGDTO">
select
book_group_id bookGroupId,
ifnull(max(seq_num), 0) maxSeqNum
from self_robot_keyword
where book_group_id in
<foreach collection="bookGroupIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
group by book_group_id
</select>
<!--获取列表-->
<select id="getSelfRobotKeywordList" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from self_robot_keyword
where book_group_id=#{bookGroupId}
<if test="keyword!=null">
and keyword like concat('%', #{keyword},'%')
</if>
order by seq_num
</select>
<!--更新最大排序值-->
<update id="updateSeqNum" parameterType="map">
update self_robot_keyword
set seq_num=#{seqNum}
where id=#{id}
</update>
<!--获取最大关键词-->
<select id="getMaxKeyword" parameterType="map" resultType="string">
select max(keyword) from self_robot_keyword
where book_group_id=#{bookGroupId}
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.WxWechatUserCorrelationDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.WxWechatUserCorrelation">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
<result column="wx_id" property="wxId" jdbcType="VARCHAR"/>
<result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, book_group_id, wx_id, wechat_user_id, create_time
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.WxWechatUserCorrelation" useGeneratedKeys="true"
keyProperty="id">
insert into wx_wechat_user_correlation
<trim prefix="(" suffix=")" suffixOverrides=",">
book_group_id,
wx_id,
wechat_user_id,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{bookGroupId,jdbcType=BIGINT},
#{wxId,jdbcType=VARCHAR},
#{wechatUserId,jdbcType=BIGINT},
NOW()
</trim>
</insert>
<!--根据微信id和社群码id获取-->
<select id="getByWxIdAndBookGroupId" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from wx_wechat_user_correlation
where wx_id=#{wxId}
and book_group_id=#{bookGroupId}
</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