Commit bb956790 by zhuyajie

多条关键词回复

parent 4a4d9f5f
......@@ -29,10 +29,7 @@ import com.pcloud.book.group.enums.AppAndProductTypeEnum;
import com.pcloud.book.group.enums.BookGroupAppOriginTypeEnum;
import com.pcloud.book.keywords.dao.BookGuideDao;
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.entity.*;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.push.dao.PushGroupDao;
import com.pcloud.book.push.entity.PushGroup;
......@@ -360,20 +357,23 @@ public class BookGroupAppBizImpl implements BookGroupAppBiz {
}
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;
List<SelfRobotKeywordReply> replyList = selfRobotKeyword.getKeywordReplyList();
for (SelfRobotKeywordReply keywordReply : replyList){
if (ReplyTypeEnum.APP.value.equals(keywordReply.getType())) {
BookGroupApp bookGroupApp = new BookGroupApp();
bookGroupApp.setOriginType(BookGroupAppOriginTypeEnum.SELF_KEYWORD.code);
bookGroupApp.setServeId(keywordReply.getServeId());
bookGroupApp.setServeType(keywordReply.getServeType());
bookGroupApp.setClassifyId(0L);
bookGroupApp.setBookGroupId(selfRobotKeyword.getBookGroupId());
bookGroupApp.setCreateUser(selfRobotKeyword.getCreateUser());
//判断是否已经添加过
BookGroupApp bookGroupAppOld = bookGroupAppDao.getByCondition(bookGroupApp);
if (bookGroupAppOld != null) {
continue;
}
bookGroupApps.add(bookGroupApp);
}
bookGroupApps.add(bookGroupApp);
}
}
if (ListUtils.isEmpty(bookGroupApps)) {
......
......@@ -25,18 +25,12 @@ import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.group.vo.GroupQrcodeBaseInfoVO;
import com.pcloud.book.keywords.biz.BookGuideBiz;
import com.pcloud.book.keywords.biz.BookKeywordBiz;
import com.pcloud.book.keywords.dao.BookGuideDao;
import com.pcloud.book.keywords.dao.BookGuideReplyDao;
import com.pcloud.book.keywords.dao.KeywordDao;
import com.pcloud.book.keywords.dao.SelfRobotKeywordDao;
import com.pcloud.book.keywords.dao.*;
import com.pcloud.book.keywords.dto.GuideDTO;
import com.pcloud.book.keywords.dto.KeywordDTO;
import com.pcloud.book.keywords.dto.KeywordStatusDTO;
import com.pcloud.book.keywords.dto.ReplyKeywordDTO;
import com.pcloud.book.keywords.entity.BookGuide;
import com.pcloud.book.keywords.entity.BookGuideReply;
import com.pcloud.book.keywords.entity.Keyword;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.keywords.entity.*;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.keywords.vo.GuideVO;
import com.pcloud.book.keywords.vo.ReplyMessageVO;
......@@ -125,6 +119,8 @@ public class BookGuideBizImpl implements BookGuideBiz {
@Value("${system.env}")
private String envStr;
@Autowired
private SelfRobotKeywordReplyDao selfRobotKeywordReplyDao;
@ParamLog("同意加好友发送欢迎语")
@Override
......@@ -157,49 +153,28 @@ public class BookGuideBizImpl implements BookGuideBiz {
bookGroupCipherUser.setAltId(agreeAddUserDTO.getRobotWxId());
//新增暗号对应记录
bookGroupCipherUserDao.insert(bookGroupCipherUser);
/* SendTextMessageVO addFriendVo = new SendTextMessageVO();
addFriendVo.setContent(dto.getAddFriendGuide());
addFriendVo.setCode(SendMessageTypeEnum.SELF.getCode());
addFriendVo.setWxId(agreeAddUserDTO.getRobotWxId());
addFriendVo.setAltId(agreeAddUserDTO.getRobotWxId());
addFriendVo.setWxGroupId(agreeAddUserDTO.getUserWxId());
addFriendVo.setIp(agreeAddUserDTO.getIp());
WxGroupSDK.sendTextMessage(addFriendVo);
log.info("临时demo发送个人号加好友欢迎语信息"+addFriendVo.toString());*/
//好友引导语
sendFriendGuide(bookGroupId, agreeAddUserDTO);
//回复关键词引导语
List<SelfRobotKeyword> selfRobotKeywords = selfRobotKeywordDao.getListByBookGroupId(bookGroupId);
if (!ListUtils.isEmpty(selfRobotKeywords)){
/* try {
String content="现在你试试回复我定制一套【背单词】读书计划【 】内关键词来唤醒我";
SendTextMessageVO voh = new SendTextMessageVO();
voh.setContent(content);
voh.setCode(SendMessageTypeEnum.SELF.getCode());
voh.setWxId(agreeAddUserDTO.getRobotWxId());
voh.setAltId(agreeAddUserDTO.getRobotWxId());
voh.setWxGroupId(agreeAddUserDTO.getUserWxId());
voh.setIp(agreeAddUserDTO.getIp());
WxGroupSDK.sendTextMessage(voh);
log.info("临时demo发送个人号加好友信息唤醒"+voh.toString());
Thread.sleep(5000);
} catch (InterruptedException e) {
log.error("发消息休眠5秒出错", e);
}*/
ThreadPoolUtils.SEND_MESSAGE_THREAD_POOL.execute(()->{
for (SelfRobotKeyword selfRobotKeyword:selfRobotKeywords){
try {
if ("长江作业本".equals(selfRobotKeyword.getKeyword())){
Thread.sleep(1000*60*10);
}
SendTextMessageVO vo = new SendTextMessageVO();
vo.setContent(selfRobotKeyword.getGuide());
vo.setCode(SendMessageTypeEnum.SELF.getCode());
vo.setWxId(agreeAddUserDTO.getRobotWxId());
vo.setAltId(agreeAddUserDTO.getRobotWxId());
vo.setWxGroupId(agreeAddUserDTO.getUserWxId());
vo.setIp(agreeAddUserDTO.getIp());
WxGroupSDK.sendTextMessage(vo);
if (!StringUtil.isEmpty(selfRobotKeyword.getGuide())){
SendTextMessageVO vo = new SendTextMessageVO();
vo.setContent(selfRobotKeyword.getGuide());
vo.setCode(SendMessageTypeEnum.SELF.getCode());
vo.setWxId(agreeAddUserDTO.getRobotWxId());
vo.setAltId(agreeAddUserDTO.getRobotWxId());
vo.setWxGroupId(agreeAddUserDTO.getUserWxId());
vo.setIp(agreeAddUserDTO.getIp());
WxGroupSDK.sendTextMessage(vo);
log.info("临时demo发送个人号加好友信息"+vo.toString());
}
if ("学前".equals(selfRobotKeyword.getKeyword())
&&envStr.toUpperCase().equals("PRO")&&agreeAddUserDTO.getRobotWxId().equals("wxid_x8i897ryabo722")){
SendGroupInviteVO sendGroupInviteVO = new SendGroupInviteVO();
......@@ -211,19 +186,26 @@ public class BookGuideBizImpl implements BookGuideBiz {
log.info("临时发送入群连接 sendGroupInviteVO:{}", sendGroupInviteVO);
}
if ("教辅书单".equals(selfRobotKeyword.getKeyword())){
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());
List<SelfRobotKeywordReply> replyList = selfRobotKeywordReplyDao.getListByKeywordId(selfRobotKeyword.getId());
if (ListUtils.isEmpty(replyList)){
continue;
}
for (SelfRobotKeywordReply keywordReply : replyList){
if (ReplyTypeEnum.RESOURCE.value.equals(keywordReply.getType())){
SendFileVO sendFileVO = new SendFileVO();
Map<Long, ResourceDTO> map = resourceConsr.mapByIds(Arrays.asList(keywordReply.getResourceId()));
ResourceDTO resourceDTO = map.get(keywordReply.getResourceId());
if (resourceDTO != null) {
sendFileVO.setFileUrl(resourceDTO.getFileUrl());
sendFileVO.setFileName(resourceDTO.getResourceName());
}
sendFileVO.setIp(agreeAddUserDTO.getIp());
sendFileVO.setAltId(agreeAddUserDTO.getRobotWxId());
sendFileVO.setWxId(agreeAddUserDTO.getUserWxId());
WxGroupSDK.sendFile(sendFileVO);
}
}
sendFileVO.setIp(agreeAddUserDTO.getIp());
sendFileVO.setAltId(agreeAddUserDTO.getRobotWxId());
sendFileVO.setWxId(agreeAddUserDTO.getUserWxId());
WxGroupSDK.sendFile(sendFileVO);
}
log.info("临时demo发送个人号加好友信息"+vo.toString());
Thread.sleep(1000*40);
} catch (InterruptedException e) {
log.error("发消息休眠5秒出错", e);
......
......@@ -45,18 +45,12 @@ import com.pcloud.book.group.vo.ClassifyVO;
import com.pcloud.book.group.vo.GroupQrcode4ClassifyVO;
import com.pcloud.book.group.vo.ListClassifyVO;
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.dao.*;
import com.pcloud.book.keywords.dto.KeywordDTO;
import com.pcloud.book.keywords.dto.KeywordStatisticsDTO;
import com.pcloud.book.keywords.dto.ReplyKeywordDTO;
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.entity.*;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.keywords.vo.DeleteKeywordVO;
import com.pcloud.book.keywords.vo.KeywordVO;
......@@ -182,6 +176,8 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private ResourceConsr resourceConsr;
@Value("${system.env}")
private String envStr;
@Autowired
private SelfRobotKeywordReplyDao selfRobotKeywordReplyDao;
/**
* 字符串切割长度
*/
......@@ -609,71 +605,115 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
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());
List<SelfRobotKeywordReply> replyList = selfRobotKeywordReplyDao.getListByKeywordId(selfRobotKeyword.getId());
if (ListUtils.isEmpty(replyList)){
return;
}
for (SelfRobotKeywordReply keywordReply : replyList){
Integer type = keywordReply.getType();
if (ReplyTypeEnum.TEXT.value.equals(type)) {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(keywordReply.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(keywordReply.getPicUrl());
sendPicMessageVO.setIp(ip);
sendPicMessageVO.setCode(code);
WxGroupSDK.sendPicMessage(sendPicMessageVO);
}
if (ReplyTypeEnum.LINK.value.equals(type)) {
/* SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
String content;
if (!StringUtil.isEmpty(selfRobotKeyword.getGuide())){
content = selfRobotKeyword.getGuide() + ",点击这里进入:" + keywordReply.getLinkUrl();
}else {
content = "点击这里进入:" + keywordReply.getLinkUrl();
}
sendTextMessageVO.setContent(content);
sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
sendTextMessageVO.setCode(code);
WxGroupSDK.sendTextMessage(sendTextMessageVO);*/
SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO();
sendArticleMessageVO.setCode(code);
sendArticleMessageVO.setAltId(robotId);
sendArticleMessageVO.setDescription(keywordReply.getDescription());
sendArticleMessageVO.setWxGroupId(userWxId);
sendArticleMessageVO.setLinkUrl(keywordReply.getLinkUrl());
sendArticleMessageVO.setPicUrl(keywordReply.getPicUrl());
sendArticleMessageVO.setTitle(keywordReply.getContent());
sendArticleMessageVO.setIp(ip);
WxGroupSDK.sendArticleMessage(sendArticleMessageVO);
}
// 处理链接地址
String endUrl = selfRobotKeyword.getLinkUrl() + "&book_group_id=" + selfRobotKeyword.getBookGroupId() + "&wxId=" + userWxId + "&robotWxId=" + robotId;
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());
if (ReplyTypeEnum.APP.value.equals(type)) {
BookGroupDTO bookGroupDTO = bookGroupDao.getDTOById(selfRobotKeyword.getBookGroupId());
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(bookGroupDTO.getChannelId());
if (AppAndProductTypeEnum.APP.value.equals(keywordReply.getServeType())) {
AppDto appDto = appConsr.getBaseById(keywordReply.getServeId());
if (appDto != null) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(appDto.getChannelId());
}
}
// 处理链接地址
String endUrl = keywordReply.getLinkUrl() + "&book_group_id=" + selfRobotKeyword.getBookGroupId() + "&wxId=" + userWxId + "&robotWxId=" + robotId;
String linkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, endUrl);
String resultUrl = UrlUtils.getShortUrl4Own(linkUrl);
/* SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
String content;
if (!StringUtil.isEmpty(selfRobotKeyword.getGuide())){
content = selfRobotKeyword.getGuide() + ",点击这里进入:" + resultUrl;
}else {
content = "点击这里进入:" + resultUrl;
}
sendTextMessageVO.setContent(content);
sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
sendTextMessageVO.setCode(code);
WxGroupSDK.sendTextMessage(sendTextMessageVO);*/
SendArticleMessageVO sendArticleMessageVO = new SendArticleMessageVO();
sendArticleMessageVO.setCode(code);
sendArticleMessageVO.setAltId(robotId);
sendArticleMessageVO.setDescription(keywordReply.getDescription());
sendArticleMessageVO.setWxGroupId(userWxId);
sendArticleMessageVO.setLinkUrl(resultUrl);
sendArticleMessageVO.setPicUrl(keywordReply.getPicUrl());
sendArticleMessageVO.setTitle(keywordReply.getContent());
sendArticleMessageVO.setIp(ip);
WxGroupSDK.sendArticleMessage(sendArticleMessageVO);
}
if (ReplyTypeEnum.RESOURCE.value.equals(type)) {
SendFileVO sendFileVO = new SendFileVO();
Map<Long, ResourceDTO> map = resourceConsr.mapByIds(Arrays.asList(keywordReply.getResourceId()));
ResourceDTO resourceDTO = map.get(keywordReply.getResourceId());
if (resourceDTO != null) {
sendFileVO.setFileUrl(resourceDTO.getFileUrl());
String fileName = resourceDTO.getResourceName();
String fileType = resourceDTO.getFileType();
log.info("fileName="+fileName+"+fileType+"+fileType);
if (fileName.contains(fileType)){//去掉后缀
fileName = fileName.substring(0, fileName.indexOf(fileType)-1);
}
log.info("fileName="+fileName);
sendFileVO.setFileName(fileName);
}
sendFileVO.setIp(ip);
sendFileVO.setAltId(robotId);
sendFileVO.setWxId(userWxId);
WxGroupSDK.sendFile(sendFileVO);
}
sendFileVO.setIp(ip);
sendFileVO.setAltId(robotId);
sendFileVO.setWxId(userWxId);
WxGroupSDK.sendFile(sendFileVO);
}
}
@ParamLog("获取的关键词是否为社群书的简称")
......@@ -710,7 +750,12 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
for (int i = 0; i < size; i++) {
SelfRobotKeyword selfRobotKeyword = selfRobotKeywords.get(i);
String toAddIn = selfRobotKeyword.getGuide() + ",请回复“" + selfRobotKeyword.getKeyword() + "”\n";
String toAddIn;
if (!StringUtil.isEmpty(selfRobotKeyword.getGuide())){
toAddIn = selfRobotKeyword.getGuide() + ",请回复“" + selfRobotKeyword.getKeyword() + "”\n";
}else {
toAddIn = "请回复“" + selfRobotKeyword.getKeyword() + "”\n";
}
//最后一个
if (i + 1 == size) {
// 拼接反馈链接
......
......@@ -13,8 +13,10 @@ 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.dao.SelfRobotKeywordReplyDao;
import com.pcloud.book.keywords.dto.MaxSeqNAndBGDTO;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.keywords.entity.SelfRobotKeywordReply;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog;
......@@ -58,6 +60,8 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
private ResourceConsr resourceConsr;
@Autowired
private QrcodeSceneConsr qrcodeSceneConsr;
@Autowired
private SelfRobotKeywordReplyDao selfRobotKeywordReplyDao;
@Transactional(rollbackFor = Exception.class)
@ParamLog("批量新增个人号关键词")
......@@ -88,18 +92,31 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
selfRobotKeyword.setSeqNum(maxSeqNum + 1);
maxSeqNum = maxSeqNum + 1;
maxSeqMap.put(bookGroupId, maxSeqNum);
//新增
selfRobotKeywordDao.insert(selfRobotKeyword);
Long keywordId = selfRobotKeyword.getId();
List<SelfRobotKeywordReply> replyList = selfRobotKeyword.getKeywordReplyList();
replyList.forEach(selfRobotKeywordReply -> {
selfRobotKeywordReply.setKeywordId(keywordId);
selfRobotKeywordReply.setCreateUser(partyId);
});
selfRobotKeywordReplyDao.insert(replyList);
}
//新增
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);
List<SelfRobotKeyword> list = selfRobotKeywordDao.getListByBookGroupId(bookGroupId);
for (SelfRobotKeyword keyword : list){
List<SelfRobotKeywordReply> replyList = selfRobotKeywordReplyDao.getListByKeywordId(keyword.getId());
if (!ListUtils.isEmpty(replyList)) {
List<SelfRobotKeywordReply> replyProductList = replyList.stream().filter(s -> AppAndProductTypeEnum.PRODUCT.value.equalsIgnoreCase(s.getServeType())).collect(Collectors.toList());
if (ListUtils.isEmpty(replyProductList)){
continue;
}
List<Long> productIds = replyProductList.stream().filter(s -> s.getServeId() != null).map(SelfRobotKeywordReply::getServeId).collect(Collectors.toList());
//自动上架
productConsr.productAutoOnShelves(btcMap.get(bookGroupId), productIds);
}
}
}
......@@ -115,10 +132,19 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
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()));
selfRobotKeywordReplyDao.deleteByKeywordId(selfRobotKeyword.getId());
List<SelfRobotKeywordReply> replyList = selfRobotKeyword.getKeywordReplyList();
replyList.forEach(selfRobotKeywordReply -> {
selfRobotKeywordReply.setKeywordId(selfRobotKeyword.getId());
selfRobotKeywordReply.setCreateUser(partyId);
});
selfRobotKeywordReplyDao.insert(replyList);
for (SelfRobotKeywordReply selfRobotKeywordReply:replyList){
if (ReplyTypeEnum.APP.value.equals(selfRobotKeywordReply.getType())
&& AppAndProductTypeEnum.PRODUCT.value.equals(selfRobotKeywordReply.getServeType())) {
//上架
productConsr.productAutoOnShelves(dto.getChannelId(), Arrays.asList(selfRobotKeywordReply.getServeId()));
}
}
}
......@@ -127,6 +153,7 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
@Override
public void deleteSelfRobotKeyword(Long id) {
selfRobotKeywordDao.deleteById(id);
selfRobotKeywordReplyDao.deleteByKeywordId(id);
}
@ParamLog("获取个人号关键词列表")
......@@ -189,19 +216,25 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
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());
for (SelfRobotKeyword selfRobotKeyword : selfRobotKeywords){
List<SelfRobotKeywordReply> replyList = selfRobotKeywordReplyDao.getListByKeywordId(selfRobotKeyword.getId());
if (ListUtils.isEmpty(replyList)){
continue;
}
for (SelfRobotKeywordReply keywordReply : replyList){
Integer type=keywordReply.getType();
if (ReplyTypeEnum.APP.value.equals(type)){
if (AppAndProductTypeEnum.APP.value.equals(keywordReply.getServeType())){
appIds.add(keywordReply.getServeId());
}
if (AppAndProductTypeEnum.PRODUCT.value.equals(keywordReply.getServeType())){
productIds.add(keywordReply.getServeId());
}
}
if (AppAndProductTypeEnum.PRODUCT.value.equals(selfRobotKeyword.getServeType())){
productIds.add(selfRobotKeyword.getServeId());
if (ReplyTypeEnum.RESOURCE.value.equals(type)){
resourceIds.add(keywordReply.getResourceId());
}
}
if (ReplyTypeEnum.RESOURCE.value.equals(type)){
resourceIds.add(selfRobotKeyword.getResourceId());
}
}
Map<Long, AppDto> appDtoMap=new HashMap<>();
Map<Long, ProductDto> productDtoMap=new HashMap<>();
......@@ -216,43 +249,50 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
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());
List<SelfRobotKeywordReply> replyList = selfRobotKeywordReplyDao.getListByKeywordId(selfRobotKeyword.getId());
if (ListUtils.isEmpty(replyList)){
continue;
}
for (SelfRobotKeywordReply keywordReply : replyList){
Integer type=keywordReply.getType();
if (ReplyTypeEnum.APP.value.equals(type)){
Long serveId=keywordReply.getServeId();
if (AppAndProductTypeEnum.APP.value.equals(keywordReply.getServeType())){
AppDto appDto=appDtoMap.get(serveId);
if (appDto!=null){
keywordReply.setServePic(appDto.getSquareImg());
keywordReply.setServeName(appDto.getTitle());
keywordReply.setServeTypeCode(appDto.getTypeCode());
keywordReply.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 (AppAndProductTypeEnum.PRODUCT.value.equals(keywordReply.getServeType())){
ProductDto productDto=productDtoMap.get(serveId);
if (productDto!=null){
keywordReply.setServePic(productDto.getCoverImg());
keywordReply.setServeName(productDto.getProductName());
ProductTypeDto productTypeDto = productDto.getProductTypeDto();
if (productTypeDto!=null){
keywordReply.setServeTypeCode(productTypeDto.getTypeCode());
keywordReply.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());
if (ReplyTypeEnum.RESOURCE.value.equals(type)){
ResourceDTO resourceDTO = resourceDTOMap.get(keywordReply.getResourceId());
if (resourceDTO!=null){
keywordReply.setResourceName(resourceDTO.getResourceName());
keywordReply.setResourceUrl(resourceDTO.getFileUrl());
keywordReply.setResourceTypeCode(resourceDTO.getTypeCode());
keywordReply.setResourceTypeName(resourceDTO.getTypeName());
keywordReply.setFileType(resourceDTO.getFileType());
keywordReply.setResourcePdfItems(resourceDTO.getResourcePdfItems());
keywordReply.setResourceOfficeItemDTOs(resourceDTO.getResourceOfficeItemDTOs());
}
}
}
selfRobotKeyword.setKeywordReplyList(replyList);
}
}
......@@ -310,30 +350,35 @@ public class SelfRobotKeywordBizImpl implements SelfRobotKeywordBiz {
if (selfRobotKeyword.getBookGroupId() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "社群码id不能为空!");
}
if (selfRobotKeyword.getType() == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "类型不能为空!");
if (ListUtils.isEmpty(selfRobotKeyword.getKeywordReplyList())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "回复不能为空!");
}
if (StringUtil.isEmpty(selfRobotKeyword.getGuide())) {
/* 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和连接不能为空!");
for (SelfRobotKeywordReply selfRobotKeywordReply: selfRobotKeyword.getKeywordReplyList()){
if (null == selfRobotKeywordReply.getType()){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "回复类型不能为空!");
}
Integer type = selfRobotKeywordReply.getType();
if (ReplyTypeEnum.TEXT.value.equals(type) && StringUtil.isEmpty(selfRobotKeywordReply.getContent())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "内容不能为空!");
}
if (ReplyTypeEnum.IMAGE.value.equals(type) && StringUtil.isEmpty(selfRobotKeywordReply.getPicUrl())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "图片地址不能为空!");
}
if (ReplyTypeEnum.LINK.value.equals(type) && StringUtil.isEmpty(selfRobotKeywordReply.getLinkUrl())) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "链接地址不能为空!");
}
if (ReplyTypeEnum.APP.value.equals(type) && (StringUtil.isEmpty(selfRobotKeywordReply.getServeType()) || selfRobotKeywordReply.getServeId() == null)) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "应用或作品id和类型不能为空!");
}
if (ReplyTypeEnum.RESOURCE.value.equals(type) && selfRobotKeywordReply.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.book.keywords.entity.SelfRobotKeywordReply;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
/**
* @Description
* @Author zhuyajie
* @Date 2020/02/03 11:39
**/
public interface SelfRobotKeywordReplyDao extends BaseDao<SelfRobotKeywordReply> {
void deleteByKeywordId(Long keywordId);
List<SelfRobotKeywordReply> getListByKeywordId(Long keywordId);
}
package com.pcloud.book.keywords.dao.impl;
import com.pcloud.book.keywords.dao.SelfRobotKeywordDao;
import com.pcloud.book.keywords.dao.SelfRobotKeywordReplyDao;
import com.pcloud.book.keywords.dto.MaxSeqNAndBGDTO;
import com.pcloud.book.keywords.entity.SelfRobotKeyword;
import com.pcloud.book.keywords.entity.SelfRobotKeywordReply;
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 zhuyajie
* @Date 2020/02/03 11:39
**/
@Component("selfRobotKeywordReplyDao")
public class SelfRobotKeywordReplyDaoImpl extends BaseDaoImpl<SelfRobotKeywordReply> implements SelfRobotKeywordReplyDao {
@Override
public void deleteByKeywordId(Long keywordId) {
getSessionTemplate().delete(getStatement("deleteByKeywordId"), keywordId);
}
@Override
public List<SelfRobotKeywordReply> getListByKeywordId(Long keywordId) {
return getSessionTemplate().selectList(getStatement("getListByKeywordId"), keywordId);
}
}
......@@ -27,66 +27,12 @@ public class SelfRobotKeyword extends BaseEntity {
@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;
@ApiModelProperty("关键词回复列表")
private List<SelfRobotKeywordReply> keywordReplyList;
}
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 zhuyajie
* @Date 2020/02/03 11:39
**/
@Data
@ApiModel("个人号关键词回复")
public class SelfRobotKeywordReply extends BaseEntity {
@ApiModelProperty("关键词id")
private Long keywordId;
@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;
}
......@@ -6,14 +6,6 @@
<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"/>
......@@ -21,8 +13,7 @@
<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
id, book_group_id, guide, keyword, seq_num, create_user, create_time
</sql>
<insert id="insert" parameterType="com.pcloud.book.keywords.entity.SelfRobotKeyword" useGeneratedKeys="true"
......@@ -32,14 +23,6 @@
book_group_id,
guide,
keyword,
type,
content,
description,
link_url,
pic_url,
serve_id,
serve_type,
resource_id,
seq_num,
create_user,
create_time
......@@ -48,14 +31,6 @@
#{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()
......@@ -68,14 +43,6 @@
book_group_id,
guide,
keyword,
type,
content,
description,
link_url,
pic_url,
serve_id,
serve_type,
resource_id,
seq_num,
create_user,
create_time
......@@ -85,14 +52,6 @@
#{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()
......@@ -106,14 +65,6 @@
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}
......@@ -203,4 +154,10 @@
${item}
</foreach>
</select>
<select id="getById" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from self_robot_keyword
where id=#{id}
</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.keywords.dao.impl.SelfRobotKeywordReplyDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.keywords.entity.SelfRobotKeywordReply">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="keyword_id" property="keywordId" jdbcType="BIGINT"/>
<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, keyword_id, 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.SelfRobotKeywordReply" useGeneratedKeys="true"
keyProperty="id">
insert into self_robot_keyword_reply
<trim prefix="(" suffix=")" suffixOverrides=",">
keyword_id,
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=",">
#{keywordId,jdbcType=BIGINT},
#{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.SelfRobotKeywordReply" useGeneratedKeys="true" keyProperty="id">
insert into self_robot_keyword_reply (
keyword_id,
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.keywordId,jdbcType=BIGINT},
#{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>
<delete id="deleteByKeywordId" parameterType="map">
delete from self_robot_keyword_reply
where keyword_id = #{keywordId}
</delete>
<select id="getListByKeywordId" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from self_robot_keyword_reply
where keyword_id = #{keywordId}
order by seq_num, id
</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