Commit 553e6438 by 阮思源

'【ID1002408】小睿提供个性化定制服务——阶段管理'

parent 57bf1fcb
...@@ -4,13 +4,15 @@ import com.alibaba.druid.pool.DruidDataSource; ...@@ -4,13 +4,15 @@ import com.alibaba.druid.pool.DruidDataSource;
import com.pcloud.book.mq.config.MQTopicConumer; import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.common.core.constant.MQQueueConstant; import com.pcloud.common.core.constant.MQQueueConstant;
import com.pcloud.common.core.constant.MQTopicProducer; import com.pcloud.common.core.constant.MQTopicProducer;
import com.pcloud.common.core.mq.MQExchangeConstants;
import com.pcloud.common.core.mq.MQQueueConstants;
import com.pcloud.common.core.mq.RabbitMQFactory; import com.pcloud.common.core.mq.RabbitMQFactory;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.DirectExchange; import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.CustomExchange;
import org.springframework.amqp.core.Queue; import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
...@@ -35,8 +37,6 @@ import springfox.documentation.spi.DocumentationType; ...@@ -35,8 +37,6 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.pcloud.book.guide.constant.DelayQueueConstant.*;
@SpringBootApplication @SpringBootApplication
@ComponentScan("com.pcloud") @ComponentScan("com.pcloud")
@EnableEurekaClient @EnableEurekaClient
...@@ -181,7 +181,7 @@ public class BookApplication { ...@@ -181,7 +181,7 @@ public class BookApplication {
} }
@Bean @Bean
public Queue convert2BookQueue(){ public Queue convert2BookQueue() {
return RabbitMQFactory.queueBuilder(MQQueueConstant.CONVERT_TO_BOOK); return RabbitMQFactory.queueBuilder(MQQueueConstant.CONVERT_TO_BOOK);
} }
...@@ -209,33 +209,33 @@ public class BookApplication { ...@@ -209,33 +209,33 @@ public class BookApplication {
} }
@Bean @Bean
public Queue wxGroupUserBindQueue(){ public Queue wxGroupUserBindQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.CONSUMER_WXGROUP_USER_BIND); return RabbitMQFactory.queueBuilder(MQTopicConumer.CONSUMER_WXGROUP_USER_BIND);
} }
@Bean @Bean
public Binding wxGroupUserBindBind(){ public Binding wxGroupUserBindBind() {
return RabbitMQFactory.bindingExchange(wxGroupUserBindQueue(), MQTopicProducer.WXGROUP_USER_BIND); return RabbitMQFactory.bindingExchange(wxGroupUserBindQueue(), MQTopicProducer.WXGROUP_USER_BIND);
} }
@Bean @Bean
public Queue wxLiveBroadcastReminderBindQueue(){ public Queue wxLiveBroadcastReminderBindQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.WX_LIVE_BROADCAST_REMINDER); return RabbitMQFactory.queueBuilder(MQTopicConumer.WX_LIVE_BROADCAST_REMINDER);
} }
@Bean @Bean
public Binding wxLiveBroadcastReminderBindBind(){ public Binding wxLiveBroadcastReminderBindBind() {
return RabbitMQFactory.bindingExchange(wxLiveBroadcastReminderBindQueue(), MQTopicProducer.WX_LIVE_BROADCAST_REMINDER); return RabbitMQFactory.bindingExchange(wxLiveBroadcastReminderBindQueue(), MQTopicProducer.WX_LIVE_BROADCAST_REMINDER);
} }
@Bean @Bean
public Queue someUserScanBookGroupQueue(){ public Queue someUserScanBookGroupQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.CONSUMER_SOME_USER_SCAN_BOOK_GROUP); return RabbitMQFactory.queueBuilder(MQTopicConumer.CONSUMER_SOME_USER_SCAN_BOOK_GROUP);
} }
@Bean @Bean
public Binding someUserScanBookGroupBind(){ public Binding someUserScanBookGroupBind() {
return RabbitMQFactory.bindingExchange(someUserScanBookGroupQueue(), MQTopicProducer.SOME_USER_SCAN_BOOK_GROUP); return RabbitMQFactory.bindingExchange(someUserScanBookGroupQueue(), MQTopicProducer.SOME_USER_SCAN_BOOK_GROUP);
} }
...@@ -261,4 +261,37 @@ public class BookApplication { ...@@ -261,4 +261,37 @@ public class BookApplication {
public Binding wxGroupRealStatusBind() { public Binding wxGroupRealStatusBind() {
return RabbitMQFactory.bindingExchange(wxGroupRealStatusQueue(), MQTopicProducer.ROBOT_REAL_STATUS); return RabbitMQFactory.bindingExchange(wxGroupRealStatusQueue(), MQTopicProducer.ROBOT_REAL_STATUS);
} }
@Bean
public CustomExchange delayExchange() {
Map<String, Object> args = new HashMap<>();
args.put(RabbitMQFactory.X_DELAYED_TYPE, RabbitMQFactory.DIRECT);
return new CustomExchange(MQExchangeConstants.BOOK_DELAYED_EXCHANGE, RabbitMQFactory.X_DELAYED_MESSAGE, true, false, args);
}
/**
* 创建一个立即消费队列
*/
@Bean
public Queue immediateQueue() {
return new Queue(MQQueueConstants.BOOK_IMMEDIATE_QUEUE_FOR_DELAY, true);
}
/**
* 把立即消费的队列和延时消费的exchange绑定在一起
*/
@Bean
public Binding bindingNotify() {
return BindingBuilder.bind(immediateQueue()).to(delayExchange()).with(MQExchangeConstants.BOOK_DELAY_ROUTING_KEY).noargs();
}
@Bean
public Queue selfRobotSendTextQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.SELF_ROBOT_SEND_TEXT);
}
@Bean
public Binding selfRobotSendTextBind() {
return RabbitMQFactory.bindingExchange(selfRobotSendTextQueue(),MQTopicProducer.SELF_ROBOT_SEND_TEXT);
}
} }
...@@ -25,4 +25,6 @@ public interface PcloudGuideBiz { ...@@ -25,4 +25,6 @@ public interface PcloudGuideBiz {
void copyGuideSetting(String fromRobotWxId, String toRobotWxId); void copyGuideSetting(String fromRobotWxId, String toRobotWxId);
void add4Classify(Create4ClassifyVO create4ClassifyVO); void add4Classify(Create4ClassifyVO create4ClassifyVO);
void stopPcloudGuidePush(String robotWxId, String userWxId);
} }
...@@ -16,6 +16,7 @@ import com.pcloud.book.keywords.enums.ReplyTypeEnum; ...@@ -16,6 +16,7 @@ import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.utils.BeanUtils; import com.pcloud.common.utils.BeanUtils;
import com.pcloud.common.utils.ListUtils; import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.contentcenter.resource.dto.ResourceDTO; import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -28,6 +29,8 @@ import java.util.List; ...@@ -28,6 +29,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.pcloud.book.guide.constant.PcloudGuideRedisConstant.PCLOUD_GUIDE_SUFFIX;
@Component("pcloudGuideBiz") @Component("pcloudGuideBiz")
public class PcloudGuideBizImpl implements PcloudGuideBiz { public class PcloudGuideBizImpl implements PcloudGuideBiz {
...@@ -281,4 +284,9 @@ public class PcloudGuideBizImpl implements PcloudGuideBiz { ...@@ -281,4 +284,9 @@ public class PcloudGuideBizImpl implements PcloudGuideBiz {
pcloudGuideMessageMapper.batchInsert(list); pcloudGuideMessageMapper.batchInsert(list);
} }
} }
@Override
public void stopPcloudGuidePush(String robotWxId, String userWxId) {
JedisClusterUtils.hdel(robotWxId + PCLOUD_GUIDE_SUFFIX, userWxId);
}
} }
...@@ -56,6 +56,7 @@ import com.pcloud.book.keywords.vo.UpdateGuideVO; ...@@ -56,6 +56,7 @@ import com.pcloud.book.keywords.vo.UpdateGuideVO;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz; import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao; import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot; import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.book.weixinclock.dao.WeixinClockGroupClassifyDao; import com.pcloud.book.weixinclock.dao.WeixinClockGroupClassifyDao;
import com.pcloud.book.weixinclock.dto.WeixinClockDto; import com.pcloud.book.weixinclock.dto.WeixinClockDto;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
...@@ -141,6 +142,8 @@ public class BookGuideBizImpl implements BookGuideBiz { ...@@ -141,6 +142,8 @@ public class BookGuideBizImpl implements BookGuideBiz {
private PcloudRobotDao pcloudRobotDao; private PcloudRobotDao pcloudRobotDao;
@Autowired @Autowired
private PcloudGuideMapper pcloudGuideMapper; private PcloudGuideMapper pcloudGuideMapper;
@Autowired
private PersonalStageBiz personalStageBiz;
@Value("${wechat.group.link.prefix}") @Value("${wechat.group.link.prefix}")
private String wechatGroupLinkPrefix; private String wechatGroupLinkPrefix;
...@@ -162,6 +165,9 @@ public class BookGuideBizImpl implements BookGuideBiz { ...@@ -162,6 +165,9 @@ public class BookGuideBizImpl implements BookGuideBiz {
pcloudRobotBiz.sendWelcomeReply(agreeAddUserDTO.getRobotWxId(), agreeAddUserDTO.getUserWxId(), agreeAddUserDTO.getIp()); pcloudRobotBiz.sendWelcomeReply(agreeAddUserDTO.getRobotWxId(), agreeAddUserDTO.getUserWxId(), agreeAddUserDTO.getIp());
//好友引导语 //好友引导语
sendFriendGuide(null, agreeAddUserDTO); sendFriendGuide(null, agreeAddUserDTO);
if (personalStageBiz.isPersonalStageUser(agreeAddUserDTO.getRobotWxId())){
personalStageBiz.createAddUserStageUser(agreeAddUserDTO.getRobotWxId(),agreeAddUserDTO.getUserWxId(), agreeAddUserDTO.getIp());
}
return; return;
} }
SendTextMessageVO vo = new SendTextMessageVO(); SendTextMessageVO vo = new SendTextMessageVO();
......
...@@ -86,6 +86,9 @@ import com.pcloud.book.pcloudkeyword.enums.KeywordTypeEnum; ...@@ -86,6 +86,9 @@ import com.pcloud.book.pcloudkeyword.enums.KeywordTypeEnum;
import com.pcloud.book.pcloudkeyword.enums.MethodEnum; import com.pcloud.book.pcloudkeyword.enums.MethodEnum;
import com.pcloud.book.pcloudkeyword.enums.RelevanceTypeEnum; import com.pcloud.book.pcloudkeyword.enums.RelevanceTypeEnum;
import com.pcloud.book.pcloudkeyword.set.PcloudRobotSet; import com.pcloud.book.pcloudkeyword.set.PcloudRobotSet;
import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.book.personalstage.biz.PersonalStageJumpBiz;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.reading.biz.ReadingActivityBiz; import com.pcloud.book.reading.biz.ReadingActivityBiz;
import com.pcloud.book.util.common.ThreadPoolUtils; import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.base.constants.ChannelEnum; import com.pcloud.channelcenter.base.constants.ChannelEnum;
...@@ -244,6 +247,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz { ...@@ -244,6 +247,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
private AdviserConsr adviserConsr; private AdviserConsr adviserConsr;
@Autowired @Autowired
private PcloudRobotSet pcloudRobotSet; private PcloudRobotSet pcloudRobotSet;
@Autowired
private PersonalStageBiz personalStageBiz;
@Autowired
private PersonalStageJumpBiz personalStageJumpBiz;
/** /**
* 字符串切割长度 * 字符串切割长度
...@@ -592,6 +599,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz { ...@@ -592,6 +599,10 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
sendSearchBook(sendTextDTO); sendSearchBook(sendTextDTO);
return; return;
} }
if (personalStageBiz.isPersonalStageUser(sendTextDTO.getWxId())){
personalStageBiz.userSendPersonalStage(sendTextDTO.getWechatUserId(), sendTextDTO.getIp(), sendTextDTO.getCode(), sendTextDTO.getWxId(), sendTextDTO.getTextContent());
return;
}
sendPcloudKeyword(sendTextDTO,pcloudRobot); sendPcloudKeyword(sendTextDTO,pcloudRobot);
return; return;
} }
......
...@@ -95,4 +95,8 @@ public class MQTopicConumer { ...@@ -95,4 +95,8 @@ public class MQTopicConumer {
*/ */
public static final String WXGROUP_SEND_NOT_TEXT = PREFIX + MQTopicProducer.WXGROUP_SEND_NOT_TEXT; public static final String WXGROUP_SEND_NOT_TEXT = PREFIX + MQTopicProducer.WXGROUP_SEND_NOT_TEXT;
/**
* 个人号发送文本消息
*/
public static final String SELF_ROBOT_SEND_TEXT = PREFIX + MQTopicProducer.SELF_ROBOT_SEND_TEXT;
} }
package com.pcloud.book.mq.delay;
import com.pcloud.common.core.mq.DelayQueueDTO;
import com.pcloud.common.core.mq.MQExchangeConstants;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
/**
* 延时队列消息生产者
*/
@Slf4j
@Component
public class DelayMessageSender {
@Resource
private RabbitTemplate rabbitTemplate;
public void send(DelayQueueDTO dto) {
this.rabbitTemplate.convertAndSend(MQExchangeConstants.BOOK_DELAYED_EXCHANGE, MQExchangeConstants.BOOK_DELAY_ROUTING_KEY, dto, message -> {
message.getMessageProperties().setDelay(dto.getTimeout());
return message;
});
}
}
package com.pcloud.book.mq.delay;
import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.book.personalstage.constant.PersonalStageConstant;
import com.pcloud.common.core.mq.DelayQueueDTO;
import com.pcloud.common.core.mq.MQQueueConstants;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Date;
import lombok.extern.slf4j.Slf4j;
/**
* 监听延时队列
*/
@Slf4j
@Component
@RabbitListener(queues = MQQueueConstants.BOOK_IMMEDIATE_QUEUE_FOR_DELAY)
public class DelayReceiver {
@Autowired
private PersonalStageBiz personalStageBiz;
@RabbitHandler
public void onMessage(DelayQueueDTO dto) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
log.info("收到延时消息:{} 时间:{}", dto, sdf.format(new Date()) + " Delay sent.");
if (dto==null){
log.info("收到延时消息为空!");
return;
}
if (PersonalStageConstant.PERSONALSTAGE_DELAY_WAKEUP.equals(dto.getType())){
personalStageBiz.dealDelayWakeup(dto);
} else if (PersonalStageConstant.PERSONALSTAGE_DELAY_FUSING.equals(dto.getType())) {
personalStageBiz.dealDelayFusingFinish(dto);
}
}
}
package com.pcloud.book.mq.topic;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.book.personalstage.biz.PersonalStageJumpBiz;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.wechatgroup.base.constants.WechatGroupConstant;
import com.pcloud.wechatgroup.message.dto.SendTextDTO;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component("selfRobotSendTextListener")
@RabbitListener(queues = MQTopicConumer.SELF_ROBOT_SEND_TEXT)
public class SelfRobotSendTextListener {
private static final Logger LOGGER = LoggerFactory.getLogger(SelfRobotSendTextListener.class);
@Autowired
private PersonalStageJumpBiz personalStageJumpBiz;
/**
* 接收个人号发送文本消息
*/
@ParamLog("接收个人号文本消息")
@RabbitHandler
public void onMessage(SendTextDTO sendTextDTO) throws BizException {
try {
LOGGER.info("接收到个人号发送文本消息,处理中:"+sendTextDTO.toString());
//TODO 处理个人号消息
if (!StringUtil.isEmpty(sendTextDTO.getTextContent()) && sendTextDTO.getTextContent().startsWith(WechatGroupConstant.SELF_ROBOT_CONTENT_KEYWORD)) {
personalStageJumpBiz.handlePersonalStageJump(sendTextDTO.getWechatGroupId(), sendTextDTO.getWxId(), sendTextDTO.getTextContent(), JumpTypeEnum.ROBOT_TRIGGER);
}
} catch (Exception e) {
LOGGER.error("接收用户发送文本消息失败" + e.getMessage(), e);
}
}
}
...@@ -8,6 +8,7 @@ import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao; ...@@ -8,6 +8,7 @@ import com.pcloud.book.pcloudkeyword.dao.PcloudRobotDao;
import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordClassify; import com.pcloud.book.pcloudkeyword.entity.PcloudKeywordClassify;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot; import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify; import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils; import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
...@@ -36,6 +37,8 @@ public class WxGroupSendNotTextListener { ...@@ -36,6 +37,8 @@ public class WxGroupSendNotTextListener {
private PcloudRobotClassifyDao pcloudRobotClassifyDao; private PcloudRobotClassifyDao pcloudRobotClassifyDao;
@Autowired @Autowired
private PcloudKeywordClassifyDao pcloudKeywordClassifyDao; private PcloudKeywordClassifyDao pcloudKeywordClassifyDao;
@Autowired
private PersonalStageBiz personalStageBiz;
@ParamLog("接收用户发送非文本消息") @ParamLog("接收用户发送非文本消息")
@RabbitHandler @RabbitHandler
...@@ -52,6 +55,10 @@ public class WxGroupSendNotTextListener { ...@@ -52,6 +55,10 @@ public class WxGroupSendNotTextListener {
bookKeywordBiz.silenceProcess(userWxId, code, robotId); bookKeywordBiz.silenceProcess(userWxId, code, robotId);
// 机器人自动唤醒 // 机器人自动唤醒
bookKeywordBiz.robotWakeUp(userWxId, ip, code, robotId); bookKeywordBiz.robotWakeUp(userWxId, ip, code, robotId);
if (personalStageBiz.isPersonalStageUser(sendNotTextDTO.getWxId())){
personalStageBiz.userSendPersonalStage(userWxId,ip,code,robotId,null);
return;
}
//判断是否为平台端小号 //判断是否为平台端小号
PcloudRobot pcloudRobot = pcloudRobotDao.getByWxId(sendNotTextDTO.getWxId()); PcloudRobot pcloudRobot = pcloudRobotDao.getByWxId(sendNotTextDTO.getWxId());
if (pcloudRobot!=null){ if (pcloudRobot!=null){
......
package com.pcloud.book.personalstage.biz;
import com.pcloud.book.personalstage.dto.PersonalStageDTO;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.common.core.mq.DelayQueueDTO;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBean;
import com.pcloud.common.page.PageParam;
import java.util.List;
public interface PersonalStageBiz {
Long createPersonalStage(PersonalStage personalStage);
void updatePersonalStage(PersonalStage personalStage);
void deletePersonalStage(Long id);
PersonalStage getPersonalStage(Long id);
void updateSeqNum(PersonalStage personalStage);
/**
* 获取阶段列表
* @param robotClassifyId 分类ID
* @param pageParam 分页参数
* @return
* @throws BizException
*/
PageBean getPersonalStageList(Long robotClassifyId, PageParam pageParam) throws BizException;
/**
* 获取阶段列表
* @param robotClassifyId 分类ID
* @return
* @throws BizException
*/
List<PersonalStageDTO> getPersonalStageListNoPage(Long robotClassifyId) throws BizException;
void userSendPersonalStage(String userWxId, String ip, Integer code, String robotId, String content);
Boolean isPersonalStageUser(String robotId);
void createAddUserStageUser(String robotId, String userWxId, String ip);
void dealDelayWakeup(DelayQueueDTO dto);
void nextStageAddStageUserAndWakeupDelay(String robotId, String userWxId, String ip, Long personalStageId);
void sendNotKeywordReply(String robotId, String userWxId, String ip, Long personalStageId);
void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId);
void dealDelayFusingFinish(DelayQueueDTO dto);
}
package com.pcloud.book.personalstage.biz;
import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.personalstage.vo.request.CreateStageJumpRequestVO;
import com.pcloud.book.personalstage.vo.request.UpdateStageJumpRequestVO;
import com.pcloud.common.page.PageBeanNew;
public interface PersonalStageJumpBiz {
/**
* 新建阶段跳转
* @param vo
*/
void createPersonalStageJump(CreateStageJumpRequestVO vo);
/**
* 修改阶段跳转
* @param vo
*/
void updatePersonalStageJump(UpdateStageJumpRequestVO vo);
PageBeanNew getJumpList(Long personalStageId, Integer currentPage, Integer numPerPage);
PersonalStageJumpDto getJump(Long jumpId);
void deleteJump(Long jumpId);
Long updateEmailStatus(Long jumpId, Integer openEmail);
/**
* 处理用户跳转逻辑
* 用户的消息状态
* @return false:未能跳转到下个阶段,需要后续的其它处理;
* true:命中关键字,已经跳转到下个阶段,无需后续处理;
*/
Boolean handlePersonalStageJump(String userWxId, String robotWxId, String content, JumpTypeEnum jumpTypeEnum);
}
package com.pcloud.book.personalstage.check;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.book.personalstage.entity.PersonalStageReply;
import com.pcloud.book.personalstage.entity.PersonalStageReplyItem;
import com.pcloud.book.personalstage.entity.PersonalStageWakeup;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("定制化参数校验")
public class PersonalStageCheck {
@ParamLog("新增定制化阶段参数校验")
public void createPersonalStageParamCheck(PersonalStage personalStage) {
if (personalStage==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"定制化阶段不能为空!");
}
if (personalStage.getRobotClassifyId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"关键词分类不能为空!");
}
if (StringUtil.isEmpty(personalStage.getName())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"阶段名称不能为空!");
}
if (personalStage.getNotKeywordFusingCount()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"发送阶段非关键词回复语次数不能为空!");
}
if (personalStage.getNotKeywordFusingTime()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"触发熔断后几分钟恢复正常不能为空!");
}
if (ListUtils.isEmpty(personalStage.getStageNotKeywordReplies())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"阶段非关键词回复集合不能为空!");
}
checkReplies(personalStage.getStageNotKeywordReplies());
if (ListUtils.isEmpty(personalStage.getFusingNotKeywordReplies())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"熔断非关键词恢复集合不能为空!");
}
checkReplies(personalStage.getFusingNotKeywordReplies());
if (!ListUtils.isEmpty(personalStage.getPersonalStageWakeups())){
checkWakeups(personalStage.getPersonalStageWakeups());
}
}
@ParamLog("校验唤醒")
private void checkWakeups(List<PersonalStageWakeup> list) {
for (PersonalStageWakeup wakeup:list){
if (wakeup==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"唤醒不能为空!");
}
if (wakeup.getToStageStartTime()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"距离进入阶段时间不能为空!");
}
if (ListUtils.isEmpty(wakeup.getWakeupReplies())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"唤醒回复集合不能为空!");
}
checkReplies(wakeup.getWakeupReplies());
}
}
@ParamLog("校验回复")
private void checkReplies(List<PersonalStageReply> list) {
for (PersonalStageReply reply:list){
if (reply==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复不能为空!");
}
if (StringUtil.isEmpty(reply.getName())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复名称不能为空!");
}
if (ListUtils.isEmpty(reply.getPersonalStageReplyItems())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项集合不能为空!");
}
checkReplayItems(reply.getPersonalStageReplyItems());
}
}
@ParamLog("校验回复项")
private void checkReplayItems(List<PersonalStageReplyItem> list) {
for (PersonalStageReplyItem item:list){
if (item==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项不能为空!");
}
if (item.getReplyType()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项类型不能为空!");
}
if (ReplyTypeEnum.TEXT.value.equals(item.getReplyType())&&StringUtil.isEmpty(item.getContent())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项内容不能为空!");
}
if (ReplyTypeEnum.IMAGE.value.equals(item.getReplyType())&&StringUtil.isEmpty(item.getPicUrl())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项图片不能为空!");
}
}
}
@ParamLog("修改定制化阶段参数校验")
public void updatePersonalStageParamCheck(PersonalStage personalStage) {
if (personalStage==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"定制化阶段不能为空!");
}
if (personalStage.getId()==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"定制化阶段id不能为空!");
}
createPersonalStageParamCheck(personalStage);
}
}
package com.pcloud.book.personalstage.constant;
public class PersonalStageConstant {
public static final String PERSONALSTAGE_DELAY_WAKEUP="PERSONALSTAGE_DELAY_WAKEUP";
public static final String PERSONALSTAGE_DELAY_FUSING="PERSONALSTAGE_DELAY_FUSING";
}
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.dto.PersonalStageDTO;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageDao extends BaseDao<PersonalStage> {
void updateSeqNum(Long id, Integer seqNum);
Integer getMaxSeqNum();
Integer getCountByRobotClassifyId(Long robotClassifyId);
PersonalStage getFirstStage(Long robotClassifyId);
List<PersonalStageDTO> getPersonalStageList(Long robotClassifyId);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.entity.PersonalStageJump;
import com.pcloud.common.core.dao.BaseDao;
public interface PersonalStageJumpDao extends BaseDao<PersonalStageJump> {
Integer getCountByPersonalStageId(Long personalStageId);
PersonalStageJumpDto getDtoById(Long jumpId);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.entity.PersonalStageJumpEmail;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageJumpEmailDao extends BaseDao<PersonalStageJumpEmail> {
/**
* 批量新增
* @param personalStageJumpEmails
*/
void batchInsert(List<PersonalStageJumpEmail> personalStageJumpEmails);
List<PersonalStageJumpEmail> getByJumpId(Long jumpId);
/**
* 根据阶段跳转id删除
* @param jumpId
*/
void deleteByJumpId(Long jumpId);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.dto.PersonalStageJumpKeywordDto;
import com.pcloud.book.personalstage.entity.PersonalStageJumpKeyword;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageJumpKeywordDao extends BaseDao<PersonalStageJumpKeyword> {
/**
* 获取阶段内一个重复关键词
* @param keywords
* @return
*/
PersonalStageJumpKeyword getStageKeywordByKeywords(List<String> keywords, Long personalStageId);
/**
* 批量添加
* @param personalStageJumpKeywords
*/
void batchInsert(List<PersonalStageJumpKeyword> personalStageJumpKeywords);
/**
* 根据阶段跳转id删除
* @param jumpId
*/
void deleteByJumpId(Long jumpId);
/**
* 查询命中的关键字
* @param personalStageId
* @param content
* @param jumpType
* @return
*/
PersonalStageJumpKeywordDto getByKeyword(Long personalStageId, String content, Integer jumpType);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.entity.PersonalStageJumpLinkup;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageJumpLinkupDao extends BaseDao<PersonalStageJumpLinkup> {
/**
* 批量新增
* @param personalStageJumpLinkups
*/
void batchInsert(List<PersonalStageJumpLinkup> personalStageJumpLinkups);
/**
* 根据阶段跳转id删除
* @param personalStageJumpId
*/
void deleteByJumpId(Long personalStageJumpId);
/**
* 根据跳转id查询衔接语列表
* @param jumpId
* @return
*/
List<PersonalStageJumpLinkup> getByJumpId(Long jumpId);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.entity.PersonalStageReply;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageReplyDao extends BaseDao<PersonalStageReply> {
Integer batchInsert(List<PersonalStageReply> list);
List<Long> getIdsByPersonalStageId(Long personalStageId);
void deleteByIds(List<Long> list);
List<PersonalStageReply> getListByPersonalStageId(Long personalStageId);
List<Long> getIdsByRelevance(Integer relevanceType, Long relevanceId);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.entity.PersonalStageReplyItem;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageReplyItemDao extends BaseDao<PersonalStageReplyItem> {
Integer batchInsert(List<PersonalStageReplyItem> list);
void deleteByReplyIds(List<Long> list);
List<PersonalStageReplyItem> getListByReplyIds(List<Long> list);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.entity.PersonalStageUser;
import com.pcloud.common.core.dao.BaseDao;
public interface PersonalStageUserDao extends BaseDao<PersonalStageUser> {
PersonalStageUser getLast(String wxId, String robotId, Long personalStageId);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao;
import com.pcloud.book.personalstage.entity.PersonalStageWakeup;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageWakeupDao extends BaseDao<PersonalStageWakeup> {
Integer batchInsert(List<PersonalStageWakeup> list);
void deleteByPersonalStageId(Long personalStageId);
List<PersonalStageWakeup> getListByPersonalStageId(Long personalStageId);
PersonalStageWakeup getFirstWakeup(Long personalStageId);
}
\ No newline at end of file
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageDao;
import com.pcloud.book.personalstage.dto.PersonalStageDTO;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component("personalStage")
public class PersonalStageDaoImpl extends BaseDaoImpl<PersonalStage> implements PersonalStageDao {
@Override
public void updateSeqNum(Long id, Integer seqNum) {
Map<String,Object> map=new HashMap<>();
map.put("id",id);
map.put("seqNum",seqNum);
super.getSqlSession().update(getStatement("updateSeqNum"), map);
}
@Override
public Integer getMaxSeqNum() {
return super.getSqlSession().selectOne(getStatement("getMaxSeqNum"));
}
@Override
public Integer getCountByRobotClassifyId(Long robotClassifyId) {
return super.getSqlSession().selectOne(getStatement("getCountByRobotClassifyId"), robotClassifyId);
}
@Override
public PersonalStage getFirstStage(Long robotClassifyId) {
return super.getSqlSession().selectOne(getStatement("getFirstStage"), robotClassifyId);
}
@Override
public List<PersonalStageDTO> getPersonalStageList(Long robotClassifyId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("robotClassifyId", robotClassifyId);
return super.getSqlSession().selectList(getStatement("getPersonalStageList"), paramMap);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageJumpDao;
import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.entity.PersonalStageJump;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
@Component("personalStageJump")
public class PersonalStageJumpDaoImpl extends BaseDaoImpl<PersonalStageJump> implements PersonalStageJumpDao {
@Override
public Integer getCountByPersonalStageId(Long personalStageId) {
return super.getSqlSession().selectOne(getStatement("getCountByPersonalStageId"), personalStageId);
}
@Override
public PersonalStageJumpDto getDtoById(Long jumpId) {
return super.getSqlSession().selectOne(getStatement("getDtoById"), jumpId);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageJumpEmailDao;
import com.pcloud.book.personalstage.entity.PersonalStageJumpEmail;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("personalStageJumpEmail")
public class PersonalStageJumpEmailDaoImpl extends BaseDaoImpl<PersonalStageJumpEmail> implements PersonalStageJumpEmailDao {
@Override
public void batchInsert(List<PersonalStageJumpEmail> personalStageJumpEmails) {
super.getSessionTemplate().insert(getStatement("batchInsert"), personalStageJumpEmails);
}
@Override
public List<PersonalStageJumpEmail> getByJumpId(Long jumpId) {
return super.getSqlSession().selectList(getStatement("getByJumpId"), jumpId);
}
@Override
public void deleteByJumpId(Long jumpId) {
super.getSqlSession().delete(getStatement("deleteByJumpId"), jumpId);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageJumpKeywordDao;
import com.pcloud.book.personalstage.dto.PersonalStageJumpKeywordDto;
import com.pcloud.book.personalstage.entity.PersonalStageJumpKeyword;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component("personalStageJumpKeyword")
public class PersonalStageJumpKeywordDaoImpl extends BaseDaoImpl<PersonalStageJumpKeyword> implements PersonalStageJumpKeywordDao {
@Override
public PersonalStageJumpKeyword getStageKeywordByKeywords(List<String> keywords, Long personalStageId) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("keywords", keywords);
paramMap.put("personalStageId", personalStageId);
return super.getSessionTemplate().selectOne(getStatement("getStageKeywordByKeywords"), paramMap);
}
@Override
public void batchInsert(List<PersonalStageJumpKeyword> personalStageJumpKeywords) {
super.getSessionTemplate().insert(getStatement("batchInsert"), personalStageJumpKeywords);
}
@Override
public void deleteByJumpId(Long jumpId) {
super.getSqlSession().delete(getStatement("deleteByJumpId"), jumpId);
}
@Override
public PersonalStageJumpKeywordDto getByKeyword(Long personalStageId, String keyword, Integer jumpType) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("keyword", keyword);
paramMap.put("personalStageId", personalStageId);
paramMap.put("jumpType", jumpType);
return super.getSessionTemplate().selectOne(getStatement("getByKeyword"), paramMap);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageJumpLinkupDao;
import com.pcloud.book.personalstage.entity.PersonalStageJumpLinkup;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("personalStageJumpLinkup")
public class PersonalStageJumpLinkupDaoImpl extends BaseDaoImpl<PersonalStageJumpLinkup> implements PersonalStageJumpLinkupDao {
@Override
public void batchInsert(List<PersonalStageJumpLinkup> personalStageJumpLinkups) {
super.getSessionTemplate().insert(getStatement("batchInsert"), personalStageJumpLinkups);
}
@Override
public void deleteByJumpId(Long personalStageJumpId) {
super.sqlSessionTemplate.delete(getStatement("deleteByJumpId"), personalStageJumpId);
}
@Override
public List<PersonalStageJumpLinkup> getByJumpId(Long jumpId) {
return super.sqlSessionTemplate.selectList(getStatement("getByJumpId"), jumpId);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageReplyDao;
import com.pcloud.book.personalstage.entity.PersonalStageReply;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component("personalStageReply")
public class PersonalStageReplyDaoImpl extends BaseDaoImpl<PersonalStageReply> implements PersonalStageReplyDao {
@Override
public Integer batchInsert(List<PersonalStageReply> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public List<Long> getIdsByPersonalStageId(Long personalStageId) {
return super.getSqlSession().selectList(getStatement("getIdsByPersonalStageId"), personalStageId);
}
@Override
public void deleteByIds(List<Long> list) {
super.getSqlSession().delete(getStatement("deleteByIds"), list);
}
@Override
public List<PersonalStageReply> getListByPersonalStageId(Long personalStageId) {
return super.getSqlSession().selectList(getStatement("getListByPersonalStageId"), personalStageId);
}
@Override
public List<Long> getIdsByRelevance(Integer relevanceType, Long relevanceId) {
Map<String, Object> map = new HashMap<>();
map.put("relevanceType", relevanceType);
map.put("relevanceId", relevanceId);
return super.getSessionTemplate().selectList(getStatement("getIdsByRelevance"), map);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageReplyItemDao;
import com.pcloud.book.personalstage.entity.PersonalStageReplyItem;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("personalStageReplyItem")
public class PersonalStageReplyItemDaoImpl extends BaseDaoImpl<PersonalStageReplyItem> implements PersonalStageReplyItemDao {
@Override
public Integer batchInsert(List<PersonalStageReplyItem> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public void deleteByReplyIds(List<Long> list) {
super.getSqlSession().delete(getStatement("deleteByReplyIds"), list);
}
@Override
public List<PersonalStageReplyItem> getListByReplyIds(List<Long> list) {
return super.getSqlSession().selectList(getStatement("getListByReplyIds"), list);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageUserDao;
import com.pcloud.book.personalstage.entity.PersonalStageUser;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component("personalStageUser")
public class PersonalStageUserDaoImpl extends BaseDaoImpl<PersonalStageUser> implements PersonalStageUserDao {
@Override
public PersonalStageUser getLast(String wxId, String robotId, Long personalStageId) {
Map<String, Object> map = new HashMap<>();
map.put("wxId", wxId);
map.put("robotId", robotId);
map.put("personalStageId", personalStageId);
return super.getSessionTemplate().selectOne(getStatement("getLast"), map);
}
}
package com.pcloud.book.personalstage.dao.impl;
import com.pcloud.book.personalstage.dao.PersonalStageWakeupDao;
import com.pcloud.book.personalstage.entity.PersonalStageWakeup;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("personalStageWakeup")
public class PersonalStageWakeupDaoImpl extends BaseDaoImpl<PersonalStageWakeup> implements PersonalStageWakeupDao {
@Override
public Integer batchInsert(List<PersonalStageWakeup> list) {
return super.getSqlSession().insert(getStatement("batchInsert"), list);
}
@Override
public void deleteByPersonalStageId(Long personalStageId) {
super.getSqlSession().delete(getStatement("deleteByPersonalStageId"), personalStageId);
}
@Override
public List<PersonalStageWakeup> getListByPersonalStageId(Long personalStageId) {
return super.getSqlSession().selectList(getStatement("getListByPersonalStageId"), personalStageId);
}
@Override
public PersonalStageWakeup getFirstWakeup(Long personalStageId) {
return super.getSqlSession().selectOne(getStatement("getFirstWakeup"), personalStageId);
}
}
package com.pcloud.book.personalstage.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 熔断结束延迟DTO
* @author PENG
* @date 2020年2月22日11:08:01
*/
@Data
@ApiModel("熔断结束延迟DTO")
public class FusingFinishDelayDTO implements Serializable {
private static final long serialVersionUID = 8383714211800627924L;
@ApiModelProperty("阶段用户id")
private Long personalStageUserId;
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("用户wxId")
private String wxId;
@ApiModelProperty("ip地址")
private String ip;
}
package com.pcloud.book.personalstage.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.common.dto.BaseDto;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@ApiModel("定制化阶段")
@Data
public class PersonalStageDTO extends BaseDto {
private static final long serialVersionUID = -5560187538777872008L;
@ApiModelProperty("阶段id")
private Long id;
@ApiModelProperty("阶段名称")
private String name;
@ApiModelProperty("发送阶段非关键词回复语次数")
private Integer notKeywordFusingCount;
@ApiModelProperty("触发熔断后几分钟恢复正常")
private Long notKeywordFusingTime;
@ApiModelProperty("机器人分类id")
private Long robotClassifyId;
@ApiModelProperty("排序值")
private Integer seqNum;
@ApiModelProperty("非关键词回复条数")
private Integer notKeywordReplyCount;
@ApiModelProperty("非关键词熔断回复条数")
private Integer notKeywordFusingReplyCount;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}
\ No newline at end of file
package com.pcloud.book.personalstage.dto;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.book.personalstage.entity.PersonalStageJumpEmail;
import com.pcloud.book.personalstage.entity.PersonalStageJumpKeyword;
import com.pcloud.book.personalstage.entity.PersonalStageJumpLinkup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 定制化阶段跳转(PersonalStageJump)实体类
*
* @author makejava
* @since 2020-02-20 14:06:05
*/
@Data
public class PersonalStageJumpDto implements Serializable {
@ApiModelProperty("跳转id")
private Long id;
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("跳转类型:1读者输入关键词触发,2小睿发送关键词触发,3转账触发")
private Integer jumpType;
@ApiModelProperty("跳转后阶段id")
private Long afterPersonalStageId;
@ApiModelProperty("是否开启邮件提醒")
private Boolean openEmail;
@ApiModelProperty("转账说明")
private String transferMessage;
@ApiModelProperty("转账金额")
private Double transferMoney;
@ApiModelProperty("定制化阶段名称")
private String personalStageName;
@ApiModelProperty("跳转关键词文案列表")
private List<PersonalStageJumpKeyword> jumpKeywords;
@ApiModelProperty("邮件列表")
private List<PersonalStageJumpEmail> jumpEmails;
@ApiModelProperty("衔接语")
private List<PersonalStageJumpLinkup> jumpLinkups;
}
\ No newline at end of file
package com.pcloud.book.personalstage.dto;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("定制化阶段跳转关键词")
@Data
public class PersonalStageJumpKeywordDto extends BaseEntity {
private Long id;
@ApiModelProperty("阶段id")
private Long personalStageId;
@ApiModelProperty("定制化阶段跳转id")
private Long personalStageJumpId;
@ApiModelProperty("关键词")
private String keyword;
@ApiModelProperty("跳转类型:1读者输入关键词触发,2小睿发送关键词触发,3转账触发")
private Integer jumpType;
@ApiModelProperty("跳转后阶段id")
private Long afterPersonalStageId;
}
\ No newline at end of file
package com.pcloud.book.personalstage.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("唤醒延时dto")
public class WakeupDelayDTO implements Serializable {
@ApiModelProperty("唤醒id")
private Long personalStageWakeupId;
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("用户wxId")
private String wxId;
@ApiModelProperty("ip地址")
private String ip;
}
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel("定制化阶段")
@Data
public class PersonalStage extends BaseEntity {
@ApiModelProperty("阶段名称")
private String name;
@ApiModelProperty("发送阶段非关键词回复语次数")
private Integer notKeywordFusingCount;
@ApiModelProperty("触发熔断后几分钟恢复正常")
private Long notKeywordFusingTime;
@ApiModelProperty("机器人分类id")
private Long robotClassifyId;
@ApiModelProperty("排序值")
private Integer seqNum;
@ApiModelProperty("阶段非关键词回复集合")
private List<PersonalStageReply> stageNotKeywordReplies;
@ApiModelProperty("熔断非关键词恢复集合")
private List<PersonalStageReply> fusingNotKeywordReplies;
@ApiModelProperty("唤醒设置集合")
private List<PersonalStageWakeup> personalStageWakeups;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("定制化阶段跳转")
@Data
public class PersonalStageJump extends BaseEntity {
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("跳转类型:1读者输入关键词触发,2小睿发送关键词触发,3转账触发")
private Integer jumpType;
@ApiModelProperty("跳转后阶段id")
private Long afterPersonalStageId;
@ApiModelProperty("是否开启邮件提醒")
private Boolean openEmail;
@ApiModelProperty("转账说明")
private String transferMessage;
@ApiModelProperty("转账金额")
private Double transferMoney;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("定制化阶段跳转邮件")
@Data
public class PersonalStageJumpEmail extends BaseEntity {
@ApiModelProperty("定制化阶段跳转id")
private Long personalStageJumpId;
@ApiModelProperty("邮件")
private String email;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("定制化阶段跳转关键词")
@Data
public class PersonalStageJumpKeyword extends BaseEntity {
@ApiModelProperty("阶段id")
private Long personalStageId;
@ApiModelProperty("定制化阶段跳转id")
private Long personalStageJumpId;
@ApiModelProperty("关键词")
private String keyword;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("定制化阶段跳转衔接语")
@Data
public class PersonalStageJumpLinkup extends BaseEntity {
@ApiModelProperty("定制化阶段跳转id")
private Long personalStageJumpId;
@ApiModelProperty("衔接语")
private String linkupContent;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel("定制化回复")
@Data
public class PersonalStageReply extends BaseEntity {
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("关联id")
private Long relevanceId;
@ApiModelProperty("关联类型:1阶段非关键词回复,2非关键词熔断回复,3唤醒")
private Integer relevanceType;
@ApiModelProperty("回复项集合")
private List<PersonalStageReplyItem> personalStageReplyItems;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("定制化阶段回复项")
@Data
public class PersonalStageReplyItem extends BaseEntity {
@ApiModelProperty("定制化阶段回复id")
private Long personalStageReplyId;
@ApiModelProperty("回复类型 1 文字 2 图片 3 链接 4应用 5素材")
private Integer replyType;
@ApiModelProperty("内容")
private String content;
@ApiModelProperty("图片地址")
private String picUrl;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel("定制化阶段用户")
@Data
public class PersonalStageUser extends BaseEntity {
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("微信用户id")
private String wxId;
@ApiModelProperty("小号id")
private String robotId;
@ApiModelProperty("机器人分类id")
private Long robotClassifyId;
@ApiModelProperty("状态:1正常,2唤醒,3熔断,4结束")
private Integer state;
@ApiModelProperty("用户非关键词发送次数")
private Integer notKeywordSendCount;
}
\ No newline at end of file
package com.pcloud.book.personalstage.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@ApiModel("定制化阶段唤醒")
@Data
public class PersonalStageWakeup extends BaseEntity {
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("距离进入阶段时间")
private Integer toStageStartTime;
@ApiModelProperty("唤醒回复集合")
private List<PersonalStageReply> wakeupReplies;
}
\ No newline at end of file
package com.pcloud.book.personalstage.enums;
public enum JumpTypeEnum {
READER_TRIGGER(1,"读者输入关键词触发"),
ROBOT_TRIGGER(2,"小睿发送关键词触发"),
PAY_TRIGGER(3,"转账触发");
public final Integer key;
public final String desc;
JumpTypeEnum(Integer key, String desc){
this.key = key;
this.desc = desc;
}
}
package com.pcloud.book.personalstage.enums;
public enum PersonalStageUserStateEnum {
/**
* 正常
*/
NORMAL(1),
/**
* 唤醒
*/
WAKEUP(2),
/**
* 熔断
*/
FUSING(3),
/**
* 结束
*/
FINISH(4);
public final Integer value;
PersonalStageUserStateEnum(Integer value) {
this.value = value;
}
}
package com.pcloud.book.personalstage.enums;
public enum StageReplyRelevEnum {
/**
* 阶段非关键词回复
*/
STAGE_NOT_KEYWORD(1),
/**
* 非关键词熔断回复
*/
FUSING_NOT_KEYWORD(2),
/**
* 唤醒
*/
WAKEUP(3);
public final Integer value;
StageReplyRelevEnum(Integer value) {
this.value = value;
}
}
package com.pcloud.book.personalstage.facade;
import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.personalstage.vo.request.CreateStageJumpRequestVO;
import com.pcloud.book.personalstage.vo.request.UpdateStageJumpRequestVO;
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.book.base.exception.BookBizException;
import com.pcloud.common.page.PageParam;
import com.pcloud.book.personalstage.biz.PersonalStageJumpBiz;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 org.springframework.web.bind.annotation.*;
import java.util.Optional;
@Api("定制化阶段")
@RestController("personalStageFacade")
@RequestMapping("personalStage")
public class PersonalStageFacade {
@Autowired
private PersonalStageBiz personalStageBiz;
@Autowired
private PersonalStageJumpBiz personalStageJumpBiz;
@ApiOperation("新增定制化阶段")
@PostMapping("/createPersonalStage")
public ResponseDto<?> createPersonalStage(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("定制化阶段") PersonalStage personalStage
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(personalStageBiz.createPersonalStage(personalStage));
}
@ApiOperation("修改定制化阶段")
@PostMapping("/updatePersonalStage")
public ResponseDto<?> updatePersonalStage(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("定制化阶段") PersonalStage personalStage
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
personalStageBiz.updatePersonalStage(personalStage);
return new ResponseDto<>();
}
@ApiOperation("删除定制化阶段")
@GetMapping("/deletePersonalStage")
public ResponseDto<?> deletePersonalStage(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("id") @ApiParam("定制化阶段id") Long id
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
personalStageBiz.deletePersonalStage(id);
return new ResponseDto<>();
}
@ApiOperation("获取定制化阶段")
@GetMapping("/getPersonalStage")
public ResponseDto<?> getPersonalStage(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("id") @ApiParam("定制化阶段id") Long id
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(personalStageBiz.getPersonalStage(id));
}
@ApiOperation("修改排序值")
@PostMapping("/updateSeqNum")
public ResponseDto<?> updateSeqNum(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("定制化阶段") PersonalStage personalStage
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
personalStageBiz.updateSeqNum(personalStage);
return new ResponseDto<>();
}
@RequestMapping(value = "getPersonalStageList", method = RequestMethod.GET)
@ApiOperation(value = "获取阶段列表", httpMethod = "GET")
public ResponseDto<?> getPersonalStageList(@RequestHeader("token") String token, @RequestParam(value = "robotClassifyId", required = false) Long robotClassifyId,
@RequestParam(value = "currentPage", required = false) Integer currentPage,
@RequestParam(value = "numPerPage", required = false) Integer numPerPage)
throws PermissionException, BizException {
SessionUtil.getToken4Redis(token);
if (null == robotClassifyId) {
throw BookBizException.PARAM_DELETION;
}
if (currentPage == null || numPerPage == null || currentPage < 0 || numPerPage < 0) {
throw BookBizException.PAGE_PARAM_DELETION;
}
return new ResponseDto<>(personalStageBiz.getPersonalStageList(robotClassifyId, new PageParam(currentPage, numPerPage)));
}
@RequestMapping(value = "getPersonalStageListNoPage", method = RequestMethod.GET)
@ApiOperation(value = "获取阶段列表", httpMethod = "GET")
public ResponseDto<?> getPersonalStageListNoPage(@RequestHeader("token") String token, @RequestParam(value = "robotClassifyId", required = false) Long robotClassifyId)
throws PermissionException, BizException {
SessionUtil.getToken4Redis(token);
if (null == robotClassifyId) {
throw BookBizException.PARAM_DELETION;
}
return new ResponseDto<>(personalStageBiz.getPersonalStageListNoPage(robotClassifyId));
}
@ApiOperation("获取跳转列表")
@GetMapping("getJumpList")
public ResponseDto<?> getJumpList(@RequestHeader("token") String token, @RequestParam Long personalStageId, @RequestParam("currentPage") Integer currentPage, @RequestParam("numPerPage") Integer numPerPage) throws PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == personalStageId) {
throw BookBizException.PARAM_DELETION;
}
if (currentPage == null || numPerPage == null || currentPage < 0 || numPerPage < 0) {
throw BookBizException.PAGE_PARAM_DELETION;
}
return new ResponseDto<>(personalStageJumpBiz.getJumpList(personalStageId, currentPage, numPerPage));
}
@ApiOperation("获取跳转详情")
@GetMapping("getJump")
public ResponseDto<?> getJump(@RequestHeader("token") String token, @RequestParam Long jumpId) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == jumpId) {
throw BookBizException.PARAM_DELETION;
}
return new ResponseDto<>(personalStageJumpBiz.getJump(jumpId));
}
@ApiOperation("删除跳转")
@GetMapping("deleteJump")
public ResponseDto<?> deleteJump(@RequestHeader("token") String token, @RequestParam Long jumpId) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == jumpId) {
throw BookBizException.PARAM_DELETION;
}
personalStageJumpBiz.deleteJump(jumpId);
return new ResponseDto<>();
}
@ApiOperation("打开关闭Email通知")
@GetMapping("updateEmailStatus")
public ResponseDto<?> updateEmailStatus(@RequestHeader("token") String token, @RequestParam Long jumpId,@RequestParam Integer openEmail) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
if (null == jumpId) {
throw BookBizException.PARAM_DELETION;
}
return new ResponseDto<>(personalStageJumpBiz.updateEmailStatus(jumpId, openEmail));
}
@ApiOperation("新建跳转")
@PostMapping("createPersonalStageJump")
public ResponseDto<?> createPersonalStageJump(@RequestHeader("token") String token, @Validated @RequestBody CreateStageJumpRequestVO vo) throws PermissionException, BizException{
Optional.ofNullable(vo).orElseThrow(() -> new BookBizException(BookBizException.ERROR, "参数为空"));
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
personalStageJumpBiz.createPersonalStageJump(vo);
return new ResponseDto<>();
}
@ApiOperation("修改跳转")
@PostMapping("updatePersonalStageJump")
public ResponseDto<?> updatePersonalStageJump(@RequestHeader("token") String token, @Validated @RequestBody UpdateStageJumpRequestVO vo) throws PermissionException, BizException{
Optional.ofNullable(vo).orElseThrow(() -> new BookBizException(BookBizException.ERROR, "参数为空"));
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
personalStageJumpBiz.updatePersonalStageJump(vo);
return new ResponseDto<>();
}
}
package com.pcloud.book.personalstage.vo.request;
import com.pcloud.book.personalstage.entity.PersonalStageJumpEmail;
import com.pcloud.book.personalstage.entity.PersonalStageJumpKeyword;
import com.pcloud.book.personalstage.entity.PersonalStageJumpLinkup;
import com.pcloud.common.entity.BaseRequestVO;
import com.pcloud.common.utils.ListUtils;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
public abstract class BaseStageJumpRequestVO extends BaseRequestVO {
@NotNull(message = "阶段id不能为空")
private Long personalStageId;
@NotNull(message = "跳转类型不能为空")
private Integer jumpType;
private Long afterPersonalStageId;
@NotNull(message = "未设置是否开启邮件提醒")
private Boolean openEmail;
private String transferMessage;
private Double transferMoney;
@NotNull(message = "跳转关键词不能为空")
@Size(max = 5, message = "跳转关键词不能超过5个")
private List<String> keywords;
@Size(max = 5, message = "邮件地址不能超过5个")
private List<String> emails;
@Size(max = 5, message = "衔接语不能超过5个")
private List<String> linkupContents;
public static List<PersonalStageJumpKeyword> valueToJumpKeywords(BaseStageJumpRequestVO vo, Long personalStageJumpId){
List<String> keywords = vo.getKeywords();
if (ListUtils.isEmpty(keywords)){
return new ArrayList<>();
}
List<PersonalStageJumpKeyword> jumpKeywords = new ArrayList<>();
for (String keyword : keywords){
PersonalStageJumpKeyword jumpKeyword = new PersonalStageJumpKeyword();
jumpKeyword.setKeyword(keyword);
jumpKeyword.setPersonalStageId(vo.getPersonalStageId());
jumpKeyword.setPersonalStageJumpId(personalStageJumpId);
jumpKeywords.add(jumpKeyword);
}
return jumpKeywords;
}
public static List<PersonalStageJumpEmail> valueToJumpEmails(BaseStageJumpRequestVO vo, Long personalStageJumpId){
List<String> emails = vo.getEmails();
if (ListUtils.isEmpty(emails)){
return new ArrayList<>();
}
List<PersonalStageJumpEmail> jumpEmails = new ArrayList<>();
for (String email : emails){
PersonalStageJumpEmail jumpEmail = new PersonalStageJumpEmail();
jumpEmail.setEmail(email);
jumpEmail.setPersonalStageJumpId(personalStageJumpId);
jumpEmails.add(jumpEmail);
}
return jumpEmails;
}
public static List<PersonalStageJumpLinkup> valueToJumpLinkups(BaseStageJumpRequestVO vo, Long personalStageJumpId){
List<String> linkupContents = vo.getLinkupContents();
if (ListUtils.isEmpty(linkupContents)){
return new ArrayList<>();
}
List<PersonalStageJumpLinkup> jumpLinkups = new ArrayList<>();
for (String linkupContent : linkupContents){
PersonalStageJumpLinkup jumpLinkup = new PersonalStageJumpLinkup();
jumpLinkup.setLinkupContent(linkupContent);
jumpLinkup.setPersonalStageJumpId(personalStageJumpId);
jumpLinkups.add(jumpLinkup);
}
return jumpLinkups;
}
}
package com.pcloud.book.personalstage.vo.request;
import com.pcloud.book.personalstage.entity.PersonalStageJump;
import com.pcloud.common.utils.BeanUtils;
import lombok.Data;
import java.util.Date;
@Data
public class CreateStageJumpRequestVO extends BaseStageJumpRequestVO {
public static PersonalStageJump valueToJumpEntity(CreateStageJumpRequestVO vo){
PersonalStageJump personalStageJump = new PersonalStageJump();
BeanUtils.copyProperties(vo, personalStageJump);
personalStageJump.setCreateTime(new Date());
return personalStageJump;
}
}
package com.pcloud.book.personalstage.vo.request;
import com.pcloud.book.personalstage.entity.PersonalStageJump;
import com.pcloud.common.utils.BeanUtils;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
public class UpdateStageJumpRequestVO extends BaseStageJumpRequestVO {
@NotNull(message = "阶段跳转id不能为空")
private Long personalStageJumpId;
public static PersonalStageJump valueToJumpEntity(UpdateStageJumpRequestVO vo){
PersonalStageJump personalStageJump = new PersonalStageJump();
BeanUtils.copyProperties(vo, personalStageJump);
personalStageJump.setCreateTime(new Date());
personalStageJump.setId(vo.getPersonalStageJumpId());
return personalStageJump;
}
}
<?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.personalstage.dao.impl.PersonalStageDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStage">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="notKeywordFusingCount" column="not_keyword_fusing_count" jdbcType="INTEGER"/>
<result property="notKeywordFusingTime" column="not_keyword_fusing_time" jdbcType="BIGINT"/>
<result property="robotClassifyId" column="robot_classify_id" jdbcType="BIGINT"/>
<result property="seqNum" column="seq_num" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, name, not_keyword_fusing_count, not_keyword_fusing_time, robot_classify_id, seq_num, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStage" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage
<trim prefix="(" suffix=")" suffixOverrides=",">
name,
not_keyword_fusing_count,
not_keyword_fusing_time,
robot_classify_id,
seq_num,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{name,jdbcType=VARCHAR},
#{notKeywordFusingCount,jdbcType=INTEGER},
#{notKeywordFusingTime,jdbcType=BIGINT},
#{robotClassifyId,jdbcType=BIGINT},
#{seqNum,jdbcType=INTEGER},
NOW()
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.personalstage.entity.PersonalStage">
update personal_stage
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="notKeywordFusingCount != null">
not_keyword_fusing_count = #{notKeywordFusingCount,jdbcType=INTEGER},
</if>
<if test="notKeywordFusingTime != null">
not_keyword_fusing_time = #{notKeywordFusingTime,jdbcType=BIGINT},
</if>
<if test="robotClassifyId != null">
robot_classify_id = #{robotClassifyId,jdbcType=BIGINT},
</if>
<if test="seqNum != null">
seq_num = #{seqNum,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateSeqNum" parameterType="map">
update personal_stage
set seq_num=#{seqNum}
where id=#{id}
</update>
<select id="getPersonalStageList" parameterType="map" resultType="com.pcloud.book.personalstage.dto.PersonalStageDTO">
SELECT
s.id,
s.`name`,
sum(IF(r.relevance_type = 1, 1, 0)) notKeywordReplyCount,
sum(IF(r.relevance_type = 2, 1, 0)) notKeywordFusingReplyCount,
s.seq_num seqNum,
s.create_time createTime
FROM
personal_stage s
LEFT JOIN personal_stage_reply r ON r.personal_stage_id = s.id
AND r.relevance_type != 3
WHERE
s.robot_classify_id = #{robotClassifyId}
GROUP BY
s.id
ORDER BY
s.seq_num ASC,
s.id ASC
</select>
<select id="getMaxSeqNum" resultType="integer">
select ifnull(max(seq_num),0) from personal_stage
</select>
<select id="getCountByRobotClassifyId" parameterType="long" resultType="integer">
select count(1) from personal_stage
where robot_classify_id = #{robotClassifyId}
</select>
<select id="getFirstStage" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from personal_stage
where robot_classify_id = #{robotClassifyId}
order by seq_num, id
limit 1
</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.personalstage.dao.impl.PersonalStageJumpDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageJump">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/>
<result property="jumpType" column="jump_type" jdbcType="INTEGER"/>
<result property="afterPersonalStageId" column="after_personal_stage_id" jdbcType="BIGINT"/>
<result property="openEmail" column="open_email" jdbcType="BOOLEAN"/>
<result property="transferMessage" column="transfer_message" jdbcType="VARCHAR"/>
<result property="transferMoney" column="transfer_money" jdbcType="DOUBLE"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_id, jump_type, after_personal_stage_id, open_email, transfer_message, transfer_money, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_jump
where id = #{id,jdbcType=BIGINT}
</select>
<select id="getDtoById" resultType="com.pcloud.book.personalstage.dto.PersonalStageJumpDto" parameterType="java.lang.Long">
SELECT
a.id,
a.personal_stage_id personalStageId,
a.jump_type jumpType,
a.after_personal_stage_id afterPersonalStageId,
a.open_email openEmail,
a.transfer_message transferMessage,
a.transfer_money transferMoney,
b.name personalStageName
FROM personal_stage_jump a, personal_stage b
WHERE a.after_personal_stage_id = b.id AND a.id = #{jumpId,jdbcType=BIGINT}
</select>
<select id="getJumpList" resultType="com.pcloud.book.personalstage.dto.PersonalStageJumpDto" parameterType="long">
SELECT
a.id,
a.personal_stage_id personalStageId,
a.jump_type jumpType,
a.after_personal_stage_id afterPersonalStageId,
a.open_email openEmail,
a.transfer_message transferMessage,
a.transfer_money transferMoney,
b.name personalStageName
FROM personal_stage_jump a LEFT JOIN personal_stage b ON a.after_personal_stage_id = b.id
WHERE a.personal_stage_id = #{personalStageId,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_jump
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStage" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_id,
jump_type,
after_personal_stage_id,
open_email,
transfer_message,
transfer_money,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageId,jdbcType=BIGINT},
#{jumpType,jdbcType=INTEGER},
#{afterPersonalStageId,jdbcType=BIGINT},
#{openEmail,jdbcType=BOOLEAN},
#{transferMessage,jdbcType=VARCHAR},
#{transferMoney,jdbcType=DOUBLE},
NOW()
</trim>
</insert>
<select id="getCountByPersonalStageId" parameterType="long" resultType="integer">
select count(1) from personal_stage_jump
where personal_stage_id=#{personalStageId}
</select>
<update id="update" parameterType="com.pcloud.book.personalstage.entity.PersonalStageJump">
UPDATE personal_stage_jump
<set>
<if test="personalStageId != null">
personal_stage_id = #{personalStageId},
</if>
<if test="jumpType != null">
jump_type = #{jumpType},
</if>
<if test="afterPersonalStageId != null">
after_personal_stage_id = #{afterPersonalStageId},
</if>
<if test="openEmail != null" >
open_email = #{openEmail,jdbcType=BOOLEAN},
</if>
<if test="transferMessage != null">
transfer_message = #{transferMessage},
</if>
<if test="transferMoney != null">
transfer_money = #{transferMoney},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
</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.personalstage.dao.impl.PersonalStageJumpEmailDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageJumpEmail">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="personalStageJumpId" column="personal_stage_jump_id" jdbcType="BIGINT"/>
<result property="email" column="email" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_jump_id, email, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_email
where id = #{id,jdbcType=BIGINT}
</select>
<select id="listBy" resultMap="BaseResultMap" parameterType="map">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_email
where personal_stage_jump_id IN
<foreach collection="jumpIds" item="jumpId" separator="," open="(" close=")">
${jumpId}
</foreach>
</select>
<select id="getByJumpId" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_email
where personal_stage_jump_id = #{jumpId,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_jump_email
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByJumpId" parameterType="long">
delete from personal_stage_jump_email
where personal_stage_jump_id = #{jumpId,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageJumpEmail" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump_email
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_jump_id,
email,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageJumpId,jdbcType=BIGINT},
#{email,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
<insert id="batchInsert" parameterType="list" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump_email
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_jump_id,
email,
create_time
</trim>
values
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.personalStageJumpId,jdbcType=BIGINT},
#{item.email,jdbcType=VARCHAR},
NOW()
</trim>
</foreach>
</insert>
</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.personalstage.dao.impl.PersonalStageJumpKeywordDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageJumpKeyword">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/>
<result property="personalStageJumpId" column="personal_stage_jump_id" jdbcType="BIGINT"/>
<result property="keyword" column="keyword" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_id, personal_stage_jump_id, keyword, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_keyword
where id = #{id,jdbcType=BIGINT}
</select>
<select id="listBy" resultMap="BaseResultMap" parameterType="map">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_keyword
where personal_stage_jump_id IN
<foreach collection="jumpIds" item="jumpId" separator="," open="(" close=")">
${jumpId}
</foreach>
</select>
<select id="getByKeyword" resultType="com.pcloud.book.personalstage.dto.PersonalStageJumpKeywordDto" parameterType="map">
SELECT
a.id, a.personal_stage_id personalStageId, a.personal_stage_jump_id personalStageJumpId,
a.keyword, b.jump_type jumpType, b.after_personal_stage_id afterPersonalStageId
FROM personal_stage_jump_keyword a,personal_stage_jump b
WHERE a.personal_stage_jump_id = b.id AND a.keyword = #{keyword,jdbcType=VARCHAR}
AND a.personal_stage_id = #{personalStageId,jdbcType=BIGINT}
AND b.jump_type = #{jumpType,jdbcType=INTEGER}
LIMIT 0,1
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_jump_keyword
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByJumpId" parameterType="long">
delete from personal_stage_jump_keyword
where personal_stage_jump_id = #{jumpId,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageJumpKeyword" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump_keyword
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_id,
personal_stage_jump_id,
keyword,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageId, jdbcType=BIGINT},
#{personalStageJumpId,jdbcType=BIGINT},
#{keyword,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
<insert id="batchInsert" parameterType="list" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump_keyword
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_id,
personal_stage_jump_id,
keyword,
create_time
</trim>
values
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.personalStageId, jdbcType=BIGINT},
#{item.personalStageJumpId,jdbcType=BIGINT},
#{item.keyword,jdbcType=VARCHAR},
NOW()
</trim>
</foreach>
</insert>
<select id="getStageKeywordByKeywords" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from personal_stage_jump_keyword
where personal_stage_id = #{personalStageId}
and keyword in
<foreach collection="keywords" item="item" open="(" close=")" separator=",">
'${item}'
</foreach>
limit 1
</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.personalstage.dao.impl.PersonalStageJumpLinkupDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageJumpLinkup">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="personalStageJumpId" column="personal_stage_jump_id" jdbcType="BIGINT"/>
<result property="linkupContent" column="linkup_content" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_jump_id, linkup_content
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_linkup
where id = #{id,jdbcType=BIGINT}
</select>
<select id="getByJumpId" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_linkup
where personal_stage_jump_id = #{jumpId,jdbcType=BIGINT}
</select>
<select id="listBy" resultMap="BaseResultMap" parameterType="map">
select
<include refid="Base_Column_List"/>
from personal_stage_jump_linkup
where personal_stage_jump_id IN
<foreach collection="jumpIds" item="jumpId" separator="," open="(" close=")">
${jumpId}
</foreach>
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_jump_linkup
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByJumpId" parameterType="long">
delete from personal_stage_jump_linkup
where personal_stage_jump_id = #{personalStageJumpId,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageJumpLinkup" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump_linkup
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_jump_id,
linkup_content
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageJumpId,jdbcType=BIGINT},
#{linkupContent,jdbcType=VARCHAR}
</trim>
</insert>
<insert id="batchInsert" parameterType="list" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump_linkup
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_jump_id,
linkup_content
</trim>
values
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
#{item.personalStageJumpId,jdbcType=BIGINT},
#{item.linkupContent,jdbcType=VARCHAR}
</trim>
</foreach>
</insert>
</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.personalstage.dao.impl.PersonalStageReplyDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageReply">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/>
<result property="relevanceId" column="relevance_id" jdbcType="BIGINT"/>
<result property="relevanceType" column="relevance_type" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, name, personal_stage_id, relevance_id, relevance_type, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_reply
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_reply
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageReply" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_reply
<trim prefix="(" suffix=")" suffixOverrides=",">
name,
personal_stage_id,
relevance_id,
relevance_type,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{name,jdbcType=VARCHAR},
#{personalStageId,jdbcType=BIGINT},
#{relevanceId,jdbcType=BIGINT},
#{relevanceType,jdbcType=INTEGER},
NOW()
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageReply" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_reply (
name,
personal_stage_id,
relevance_id,
relevance_type,
create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.name,jdbcType=VARCHAR},
#{item.personalStageId,jdbcType=BIGINT},
#{item.relevanceId,jdbcType=BIGINT},
#{item.relevanceType,jdbcType=INTEGER},
NOW()
)
</foreach>
</insert>
<select id="getIdsByPersonalStageId" parameterType="long" resultType="long">
select id from personal_stage_reply
where personal_stage_id=#{personalStageId}
</select>
<delete id="deleteByIds" parameterType="long">
delete from personal_stage_reply
where id in
<foreach collection="list" item="item" open="(" separator="," close=")">
${item}
</foreach>
</delete>
<select id="getListByPersonalStageId" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from personal_stage_reply
where personal_stage_id=#{personalStageId}
</select>
<select id="getIdsByRelevance" parameterType="map" resultType="long">
select id from personal_stage_reply
where relevance_id=#{relevanceId}
and relevance_type=#{relevanceType}
</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.personalstage.dao.impl.PersonalStageReplyItemDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageReplyItem">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="personalStageReplyId" column="personal_stage_reply_id" jdbcType="BIGINT"/>
<result property="replyType" column="reply_type" jdbcType="INTEGER"/>
<result property="content" column="content" jdbcType="VARCHAR"/>
<result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_reply_id, reply_type, content, pic_url, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_reply_item
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_reply_item
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageReplyItem" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_reply_item
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_reply_id,
reply_type,
content,
pic_url,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageReplyId,jdbcType=BIGINT},
#{replyType,jdbcType=INTEGER},
#{content,jdbcType=VARCHAR},
#{picUrl,jdbcType=VARCHAR},
NOW()
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageReplyItem" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_reply_item (
personal_stage_reply_id,
reply_type,
content,
pic_url,
create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.personalStageReplyId,jdbcType=BIGINT},
#{item.replyType,jdbcType=INTEGER},
#{item.content,jdbcType=VARCHAR},
#{item.picUrl,jdbcType=VARCHAR},
NOW()
)
</foreach>
</insert>
<delete id="deleteByReplyIds" parameterType="long">
delete from personal_stage_reply_item
where personal_stage_reply_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
${item}
</foreach>
</delete>
<select id="getListByReplyIds" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from personal_stage_reply_item
where personal_stage_reply_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
${item}
</foreach>
</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.personalstage.dao.impl.PersonalStageUserDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageUser">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/>
<result property="wxId" column="wx_id" jdbcType="VARCHAR"/>
<result property="robotId" column="robot_id" jdbcType="VARCHAR"/>
<result property="robotClassifyId" column="robot_classify_id" jdbcType="BIGINT"/>
<result property="state" column="state" jdbcType="INTEGER"/>
<result property="notKeywordSendCount" column="not_keyword_send_count" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_id, wx_id, robot_id, robot_classify_id, state, not_keyword_send_count, create_time,update_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_user
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_user
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageUser" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_user
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_id,
wx_id,
robot_id,
robot_classify_id,
state,
not_keyword_send_count,
create_time,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageId,jdbcType=BIGINT},
#{wxId,jdbcType=VARCHAR},
#{robotId,jdbcType=VARCHAR},
#{robotClassifyId,jdbcType=BIGINT},
#{state,jdbcType=INTEGER},
#{notKeywordSendCount,jdbcType=INTEGER},
NOW(),
now()
</trim>
</insert>
<update id="update" parameterType="com.pcloud.book.personalstage.entity.PersonalStageUser">
update personal_stage_user
<set>
<if test="personalStageId != null">
personal_stage_id = #{personalStageId,jdbcType=BIGINT},
</if>
<if test="wxId != null">
wx_id = #{wxId,jdbcType=VARCHAR},
</if>
<if test="robotId != null">
robot_id = #{robotId,jdbcType=VARCHAR},
</if>
<if test="robotClassifyId != null">
robot_classify_id = #{robotClassifyId,jdbcType=BIGINT},
</if>
<if test="state != null">
state = #{state,jdbcType=INTEGER},
</if>
<if test="notKeywordSendCount != null">
not_keyword_send_count = #{notKeywordSendCount,jdbcType=INTEGER},
</if>
update_time=now()
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getLast" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from personal_stage_user
where 1=1
<if test="wxId!=null">
and wx_id=#{wxId}
</if>
<if test="robotId!=null">
and robot_id = #{robotId}
</if>
<if test="personalStageId!=null">
and personal_stage_id=#{personalStageId}
</if>
order by create_time desc
LIMIT 0,1
</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.personalstage.dao.impl.PersonalStageWakeupDaoImpl">
<resultMap id="BaseResultMap" type="com.pcloud.book.personalstage.entity.PersonalStageWakeup">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/>
<result property="toStageStartTime" column="to_stage_start_time" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_id, to_stage_start_time, create_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from personal_stage_wakeup
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteById" parameterType="long">
delete from personal_stage_wakeup
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageWakeup" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_wakeup
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_id,
to_stage_start_time,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageId,jdbcType=BIGINT},
#{toStageStartTime,jdbcType=INTEGER},
NOW()
</trim>
</insert>
<insert id="batchInsert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageWakeup" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_wakeup (
personal_stage_id,
to_stage_start_time,
create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.personalStageId,jdbcType=BIGINT},
#{item.toStageStartTime,jdbcType=INTEGER},
NOW()
)
</foreach>
</insert>
<delete id="deleteByPersonalStageId" parameterType="long">
delete from personal_stage_wakeup
where personal_stage_id =#{personalStageId}
</delete>
<select id="getListByPersonalStageId" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from personal_stage_wakeup
where personal_stage_id=#{personalStageId}
order by to_stage_start_time
</select>
<select id="getFirstWakeup" parameterType="long" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from personal_stage_wakeup
where personal_stage_id=#{personalStageId}
order by to_stage_start_time
limit 1
</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