Import complete SCRM project

This commit is contained in:
2026-07-29 16:20:57 +08:00
parent 86665d9c26
commit e27b758795
984 changed files with 282038 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
# Operating-system metadata
.DS_Store
Thumbs.db
Desktop.ini
# IDE and editor-local state
**/.idea/
**/.vscode/
*.iml
*.iws
*.ipr
*.suo
*.user
*.swp
*.swo
*~
# Local AI-assistant settings
**/.claude/settings.local.json
# Java / Maven build output
**/target/
*.class
*.jar
*.war
*.ear
hs_err_pid*
# Node / frontend dependencies and build output
**/node_modules/
**/dist/
**/coverage/
.npm-cache/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime logs and temporary files
*.log
*.log.*
*.tmp
*.bak
# Local environment overrides
.env.local
.env.*.local
+154429
View File
File diff suppressed because one or more lines are too long
+30
View File
@@ -0,0 +1,30 @@
# ---> Java
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
.idea/.gitignore
.idea/azureSettings.xml
.idea/codeStyles/
.idea/compiler.xml
.idea/encodings.xml
.idea/inspectionProfiles/
.idea/libraries/
.idea/misc.xml
.idea/modules.xml
.idea/vcs.xml
src/test/java/io/
wxcontractbotabeieragent.log
wxcontractbotabeieragent.log.2020-06-03.0.gz
wxcontractbotagent.iml
wxcontractbotbitcokeagent.log
+72
View File
@@ -0,0 +1,72 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+9
View File
@@ -0,0 +1,9 @@
# contractbotagent
部署项目时如果websocket连接不上,需要修改服务器的hosts
参照连接:
https://blog.csdn.net/qq_38345296/article/details/106478262
修改/etc/hosts后内容不生效,需要重启下网络服务,
重启网络服务之后需要重启下应用服务;
https://blog.csdn.net/hguisu/article/details/49278355
+132
View File
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>io.xiaoxi</groupId>
<artifactId>wxcontractbotagent</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
<elasticsearch.version>7.8.0</elasticsearch.version>
</properties>
<dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.30</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<!--websocket start-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!--websocket end-->
<dependency>
<groupId>com.yy</groupId>
<artifactId>android-util</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!-- HttpClinet HTTP请求 -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<!-- Jsoup 解析HTML文本 -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
<finalName>agent</finalName>
</build>
</project>
@@ -0,0 +1,103 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi;
import io.xiaoxi.job.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import io.xiaoxi.jedis.RedisUtil;
import io.xiaoxi.utils.GlobalConfig;
import io.xiaoxi.utils.KafkaProduce;
import io.xiaoxi.utils.MysqlUtil;
/**
* @ClassName: AppRunner
* @Description: TODO
* @date: 2019年5月11日 下午4:20:01
*/
@Component
public class AppRunner implements ApplicationRunner{
private static final Logger log = LoggerFactory.getLogger(AppRunner.class.getName());
@Autowired
private Environment env;
@Autowired
public RedisUtil redis;
@Autowired
public MysqlUtil mysql;
/*
* @Title: run
* @param args
* @throws Exception
* @see org.springframework.boot.ApplicationRunner#run(org.springframework.boot.ApplicationArguments)
*/
@Override
public void run(ApplicationArguments args) throws Exception {
// 初始一份全局的配置信息
log.info("Reading config file.");
GlobalConfig.Init(env);
// init redis
log.info("Init redis");
RedisUtil.util = redis;
// init mysql
log.info("Init mysql");
MysqlUtil.util = mysql;
// checking bot
log.info("start bot checking");
BotManager.startBotChecking();
GetBotChatAndFriendsCntHandler.start();
BotChatJob.start();
GetBotChatAndFriendsCntHandler.start();
// AskQaHandler.start();
// MysqlUtil.util.cSrv.initQACache();
// SendSnsHandler.start();
// ChatMessageProcessHandler.start();
// ChatMsgFilterConfig.start();
// KfgztBotInfoUpdateJob.updateValidChatsStatus();
// KfgztBotInfoUpdateJob.updateValidFriendsStatus();
// KfgztBotInfoUpdateJob.updateChatList();
// KfgztBotInfoUpdateJob.updateFriendList();
// 初始化kafka producer
// log.info("Init kafka producer");
// KafkaProduce.init(GlobalConfig.Instance.getKafkaBrokers(), "fttokenprice");
}
}
@@ -0,0 +1,376 @@
package io.xiaoxi;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.xiaoxi.db.model.ChatInfo;
import io.xiaoxi.db.model.ChatMessageRecordsEntity;
import io.xiaoxi.db.model.UserAddBotAsFriendEntity;
import io.xiaoxi.db.model.common.CommandInfo;
import io.xiaoxi.db.model.common.SendCard;
import io.xiaoxi.db.model.friendreply.AddedFriendReply;
import io.xiaoxi.utils.*;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.xiaoxi.jedis.RedisUtil;
/**
* @ClassName: BotHandler
* @Description: TODO
* @date: 2019年5月14日 上午9:49:17
*/
public class AskBotHandler {
public final Logger log = LoggerFactory.getLogger(BotHandler.class.getName());
public String wxid;
public JSONObject userInfo;
public Queue<String[]> sendMsgQueue;
public AskBotHandler(String wxid) {
this.wxid = wxid;
proc = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
SendProc = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
}
public ScheduledExecutorService proc;
public ScheduledExecutorService SendProc;
public void setUserInfo(String info) {
userInfo = JSON.parseObject(info);
}
/** 固定使用 127.0.0.1,不使用 status 中的 IP(如 10.35.x */
public String getServerAddr() {
return "127.0.0.1:50012";
// String addr = userInfo.getString("status");
// if (addr==null) return null;
// return addr.split("_")[0];
}
public String getNickname() {
return userInfo.getString("nickname");
}
public String getPhone() {
return userInfo.getString("phone");
}
public List<ChatInfo> getChats() {
List<ChatInfo> chatInfoList = new ArrayList<ChatInfo>();
try {
String server = getServerAddr();
if (server == null || server.isEmpty()||StringUtils.isEmpty(wxid)) {
log.warn("server is null or wxid is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String, String> bodyInfo = new HashMap<String, String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getChats");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
JSONObject jsonObject = JSON.parseObject(rsp);
if(jsonObject==null){
return chatInfoList;
}
if (jsonObject.containsKey("errmsg")) {
log.info("get chats 【机器人非正常状态】:设备 " + wxid + "错误信息:" + JSON.parseObject(rsp).get("errmsg"));
return chatInfoList;
}
chatInfoList = JSON.parseArray(jsonObject.getString("info"), ChatInfo.class);
return chatInfoList;
} catch (Exception ex) {
log.info("getChats error:{}", ex);
}
return chatInfoList;
}
public class ProcMsgJob implements Runnable {
@Override
public void run() {
try {
String rsp = recvMsg();
if (rsp != null && rsp.isEmpty()==false) {
if (JSON.parseObject(rsp).containsKey("errmsg")) {
log.info("recv: {},{}",wxid, rsp);
return;
}
JSONArray msgs = JSON.parseObject(rsp).getJSONArray("msgs");
if (msgs!=null) {
log.info("recv: {},{}",wxid, rsp);
for (String strMsg : msgs.toJavaList(String.class)) {
JSONObject msg = JSON.parseObject(strMsg);
String msgKafka=strMsg;
if (isChatMsg(msg)) {
msg.put("chatName",getChatName(msg.getString("toID")));
msgKafka = JSONObject.toJSONString(msg);
}
try {
KafkaProduce.sendWithDefaultTopic(wxid, msgKafka);
} catch (Exception e) {
e.printStackTrace();
log.warn("send to kafka failed,{}",e.getMessage());
}
//2分钟以前的消息不处理
Long createTime = msg.getLong("create_time");
if (createTime != null) {
if ((System.currentTimeMillis()-createTime)/1000 > 60*2) {
continue;
}
}
//系统通知
String content = msg.getString("content").trim();
Integer type = msg.getInteger("type");
switch (type) {
case 99://添加好友
MysqlUtil.util.cSrv.updateKfgztFriendList(wxid);
if (content.startsWith("你已添加了")) {
//查看被加好友用户开关
String botaddEnable = RedisUtil.util.get(CommonPropertiesReader.getValue("BOT_ADD_FRIEND_ENABLE"));
if("1".equals(botaddEnable)){
List<AddedFriendReply> listAddFriend=MysqlUtil.util.cSrv.getAddedFriendReply();
for (int i = 0; i < listAddFriend.size(); i++) {
AddedFriendReply addedFriendReply = listAddFriend.get(i);
if(addedFriendReply!=null&&!org.apache.commons.lang3.StringUtils.isEmpty(addedFriendReply.getContent())){
sendTextMsg(msg.getString("toID"),addedFriendReply.getContent(),addedFriendReply.getType(),"1");
}
}
}
UserAddBotAsFriendEntity addBotAsFriendEntity=new UserAddBotAsFriendEntity();
addBotAsFriendEntity.setBotWxid(wxid);
addBotAsFriendEntity.setWxid(msg.getString("toID"));
MysqlUtil.util.cSrv.saveUserAddBotAsFriend(addBotAsFriendEntity);
}
break;
case 15:
MysqlUtil.util.cSrv.updateKfgztChatList(wxid);
break;
case 1:
case 2:
if(!org.springframework.util.StringUtils.isEmpty(content)){
content=content.trim();
}
//客服工作台消息处理;
MysqlUtil.util.cSrv.processReceiveMessage(type,wxid,msg,content);
//不处理自己的发送的消息
if (msg.getInteger("isSend")==1) continue;
//群聊
if (isChatMsg(msg)) {
ChatMessageRecordsEntity chatMessageRecordsEntity=new ChatMessageRecordsEntity();
chatMessageRecordsEntity.setChatId(msg.getString("toID"));
chatMessageRecordsEntity.setContent(content);
chatMessageRecordsEntity.setWxId(wxid);
BotManager.chatMessage.add(chatMessageRecordsEntity);
}else{
ChatMessageRecordsEntity chatMessageRecordsEntity=new ChatMessageRecordsEntity();
chatMessageRecordsEntity.setChatId(msg.getString("fromID"));
chatMessageRecordsEntity.setContent(content);
chatMessageRecordsEntity.setWxId(wxid);
chatMessageRecordsEntity.setFromId(msg.getString("toID"));
BotManager.chatMessgeAddFriend.add(chatMessageRecordsEntity);
}
default:
}
}
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
public void startProc() {
sendMsgQueue = new ConcurrentLinkedQueue<String[]>();
proc.scheduleWithFixedDelay( new ProcMsgJob(), 5, 1, TimeUnit.SECONDS);
SendProc.scheduleWithFixedDelay( new SendMsgJob(), 1, 2, TimeUnit.SECONDS);
}
public class SendMsgJob implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
synchronized (SendMsgJob.class) {
try {
String[] data = sendMsgQueue.poll();
if (data != null) {
String url = data[0];
String body = data[1];
if (body != null) {
log.info("sendTextMsg: {}, {}", url, body);
Thread.currentThread().sleep(RandomUtils.nextLong(1, 2) * 1000);
HttpUtil.post(url, body);
}
}
}
catch (Exception e) {
e.printStackTrace();
log.warn(e.getMessage());
}
}
}
}
public String recvMsg() {
String server = getServerAddr();
if (server ==null || server.isEmpty()) {
log.warn("server is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getMsg");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public void sendTextMsg(String toId, String content,String contentType,String isSleep) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "sendMsg");
bodyInfo.put("to", toId);
if("1".equals(contentType)){
bodyInfo.put("contentType", "img");
bodyInfo.put("url", content);
}else if("2".equals(contentType)){
if(StringUtils.isEmpty(content)) return;
SendCard sendCard = JSON.parseObject(content, SendCard.class);
if(sendCard==null) return;
bodyInfo.put("cmdType", "sendCardUrl");
bodyInfo.put("title", sendCard.getTitle());
bodyInfo.put("desc", sendCard.getSummary());
bodyInfo.put("url", sendCard.getLink());
bodyInfo.put("img", sendCard.getImageUrl());
}else{
bodyInfo.put("contentType", "text");
if(StringUtils.isEmpty(content)) return;
bodyInfo.put("content",content);
}
String body = JSON.toJSONString(bodyInfo);
String[] data =new String[]{url,body,isSleep};
sendMsgQueue.add(data);
}
public String getUserInfo(String uid) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return null;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getUserInfo");
bodyInfo.put("uid", uid);
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public String getChatName(String chatId) {
String chatName = BotHandler.chatNames.get(chatId);
if (chatName != null) return chatName;
//担心刚拉入群,群名称等消息还没写入获取不到
try {
Thread.sleep(1000L*1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String rsp = getChat(chatId);
if (rsp==null) return "";
JSONObject jsonObj = JSON.parseObject(rsp).getJSONObject("info");
log.info("{},{}",chatId, rsp);
chatName = jsonObj.getString("nickname");
if(!org.apache.commons.lang3.StringUtils.isEmpty(chatName)){
BotHandler.chatNames.put(chatId, chatName);
}
return chatName;
}
public String getChat(String chatId) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return null;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getChat");
bodyInfo.put("chatId", chatId);
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
log.info("\n\ngetChats:{}\n\n", rsp);
return rsp;
}
public static boolean isMobiPhoneNum(String telNum){
String regex = "^1\\d{10}$";
Pattern p = Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(telNum);
return m.matches();
}
public static boolean isChatMsg(JSONObject msg) {
return msg.getString("fromID").endsWith("@chatroom") || msg.getString("toID").endsWith("@chatroom");
}
public static String getFtPriceTail() {
return RedisUtil.util.get("fttokenpricetail");
}
}
@@ -0,0 +1,661 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import io.xiaoxi.db.model.ChatInfo;
import io.xiaoxi.db.model.common.BotFriend;
import io.xiaoxi.db.model.common.ChatMemberInfo;
import io.xiaoxi.db.model.common.SendCard;
import io.xiaoxi.db.model.marketing.*;
import io.xiaoxi.db.model.marketingrecord.MarketingChat;
import io.xiaoxi.db.model.marketingrecord.MarketingTask;
import io.xiaoxi.jedis.RedisUtil;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.xiaoxi.db.model.BotChat;
import io.xiaoxi.db.model.common.BotRoleInfo;
import io.xiaoxi.utils.BotConfigConst;
import io.xiaoxi.utils.HttpUtil;
import io.xiaoxi.utils.MysqlUtil;
public class AskQaHandler {
public static final Logger log = LoggerFactory.getLogger(AskQaHandler.class.getName());
public static boolean isCancel = false;
public static ScheduledExecutorService es = Executors.newSingleThreadScheduledExecutor(r -> {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
});
public static ExecutorService handlerChatMessageThread = Executors.newCachedThreadPool( r -> {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
});
public static void start() {
es.scheduleWithFixedDelay(new ProcJob(), 30, 5, TimeUnit.SECONDS);
}
public static class HandlerFunction implements Runnable{
private List<List<SendMsgInfo>> sendMsgQueue;
public HandlerFunction(List<List<SendMsgInfo>> sendMsgQueue) {
this.sendMsgQueue = sendMsgQueue;
}
public void run() {
try {
for (int i = 0; i < sendMsgQueue.size(); i++) {
List<SendMsgInfo> sendMsgInfoList = sendMsgQueue.get(i);
if (sendMsgInfoList != null && !sendMsgInfoList.isEmpty()) {
Set<String> botName=new HashSet<String>();
for (int j = 0; j < sendMsgInfoList.size(); j++) {
SendMsgInfo sendMsgInfo = sendMsgInfoList.get(j);
if(sendMsgInfo!=null && !StringUtils.isEmpty(sendMsgInfo.getMarketingId())){
MarketingChat findByChatMarketingId = MysqlUtil.util.cSrv.findByChatMarketingId(sendMsgInfo.getMarketingId());
if(findByChatMarketingId==null) continue;
String botId = sendMsgInfo.getBotId();
String chatId = sendMsgInfo.getChatId();
String content = sendMsgInfo.getContent();
String role = sendMsgInfo.getRole();
String type = sendMsgInfo.getType();
String intervalType = sendMsgInfo.getIntervalType();
String nickname ="";
if (!StringUtils.isEmpty(chatId) && !StringUtils.isEmpty(botId) && !StringUtils.isEmpty(content)) {
if ("echo".equals(role)) {
EchoBotHandler echoBotHandler = BotManager.echoBotManager.get(botId);
if(echoBotHandler!=null){
nickname = echoBotHandler.getNickname();
}
} else {
if("ask".equals(role)){
AskBotHandler askBotHandler = BotManager.askBotManager.get(botId);
if(askBotHandler!=null){
nickname = askBotHandler.getNickname();
}
}else{
BotHandler botHandler = BotManager.botManager.get(botId);
if(botHandler!=null){
nickname = botHandler.getNickname();
}
}
}
if("2".equals(intervalType)){
Thread.currentThread().sleep(RandomUtils.nextLong(45, 50) * 1000);
}else{
Thread.currentThread().sleep(RandomUtils.nextLong(15, 20) * 1000);
}
sendTextMsg(botId, chatId, content,type);
if(!StringUtils.isEmpty(nickname)){
botName.add(nickname);
}
if(findByChatMarketingId.getStartDate()==null){
MysqlUtil.util.cSrv.startMarketingChat(findByChatMarketingId,botId);
}
}
String botNameStr = Arrays.toString(botName.toArray(new String[botName.size()]));
String name="";
if(botNameStr.length()>2){
name=botNameStr.substring(1,botNameStr.length()-1);
}
//插入单个群营销执行结果
if (StringUtils.isNotEmpty(sendMsgInfo.getStatus())) {
if ("start".equals(sendMsgInfo.getStatus())&&findByChatMarketingId.getEndDate()==null) {
MysqlUtil.util.cSrv.startMarketingChat(findByChatMarketingId,botId);
}
if ("end".equals(sendMsgInfo.getStatus())) {
MysqlUtil.util.cSrv.endMarketingChat(findByChatMarketingId,name);
}
}
//最后一轮 未结束时结束一轮营销
if(j==sendMsgInfoList.size()-1 || "endId".equals(botId)){
if(findByChatMarketingId.getEndDate()==null){
MysqlUtil.util.cSrv.endMarketingChat(findByChatMarketingId,name);
}
}
}
}
}
}
} catch (Exception e) {
log.info("错误信息11"+e.getMessage());
e.printStackTrace();
}
}
}
public static class ProcJob implements Runnable {
@Override
public void run() {
try {
List<MarketingTask> tasklist = MysqlUtil.util.cSrv.getMarketingTaskList();
if(tasklist==null||tasklist.isEmpty()) return;
Map<String, List<String>> BotList = getBotList();
for (int i = 0; i < tasklist.size(); i++) {
List<List<SendMsgInfo>> sendMsgQueueTask = new ArrayList<List<SendMsgInfo>>();
MarketingTask marketingTask = tasklist.get(i);
if(marketingTask!=null&&marketingTask.getMarketingChatList()!=null&&!marketingTask.getMarketingChatList().isEmpty()){
String intervalType = marketingTask.getIntervalType();
List<MarketingChat> marketingChatList = marketingTask.getMarketingChatList();
List<String> chatCollect = marketingTask.getMarketingChatList().stream().map(item ->item.getChatId()).collect(Collectors.toList());
List<Marketing> listMarket = MysqlUtil.util.cSrv.findAllData(marketingTask.getId());
marketingTask.setStatus("2");
if (listMarket == null || listMarket.isEmpty()) {
log.info("BotMarketing list is empty");
marketingTask.setStatus("4");
MysqlUtil.util.cSrv.saveMarketingTask(marketingTask);
return;
}
MysqlUtil.util.cSrv.saveMarketingTask(marketingTask);
//3.获取群内有报价机器人的群列表
List<BotChat> botChatList = MysqlUtil.util.cSrv.findByChatIds(chatCollect);
Map<String, List<MarketingAsk>> marketAskMap = new HashMap<>();
Map<String, List<MarketingAnswer>> marketAnswerMap = new HashMap<>();
Map<String, List<MarketingEcho>> marketEchoMap = new HashMap<>();
for (int j = 0; j < marketingChatList.size(); j++) {
List<SendMsgInfo> sendMsgQueue = new ArrayList<SendMsgInfo>();
MarketingChat marketingChat = marketingChatList.get(j);
if(marketingChat!=null&&"0".equals(marketingChat.getStatus())){
if (BotList == null || BotList.size() == 0) {
marketingChat.setStatus("4");
marketingChat.setErrorMsg("机器人列表为空,请检查账号");
MysqlUtil.util.cSrv.saveMarketingChat(marketingChat);
continue;
}
List<String> askList = BotList.get("askList");
List<String> askCollect = botChatList.stream().filter(item -> item.getChatId().equals(marketingChat.getChatId())).collect(Collectors.toList()).stream().filter(item ->askList.contains(item.getWxId())).collect(Collectors.toList()).stream().map(item ->item.getWxId()).collect(Collectors.toList());
if(askCollect==null ||askCollect.isEmpty()){
marketingChat.setStatus("4");
marketingChat.setErrorMsg("问询机器人列表为空,请检查账号");
MysqlUtil.util.cSrv.saveMarketingChat(marketingChat);
continue;
}
List<String> answerList = BotList.get("answerList");
List<String> answerCollect = botChatList.stream().filter(item -> item.getChatId().equals(marketingChat.getChatId())).collect(Collectors.toList()).stream().filter(item ->answerList.contains(item.getWxId())).collect(Collectors.toList()).stream().map(item ->item.getWxId()).collect(Collectors.toList());
if(answerCollect==null ||answerCollect.isEmpty()){
marketingChat.setStatus("4");
marketingChat.setErrorMsg("报价机器人列表为空,请检查账号");
MysqlUtil.util.cSrv.saveMarketingChat(marketingChat);
continue;
}
List<String> echoList = BotList.get("echoList");
List<String> echoCollect = botChatList.stream().filter(item -> item.getChatId().equals(marketingChat.getChatId())).collect(Collectors.toList()).stream().filter(item ->echoList.contains(item.getWxId())).collect(Collectors.toList()).stream().map(item ->item.getWxId()).collect(Collectors.toList());
//
// if(echoCollect==null ||echoCollect.isEmpty()){
// marketingChat.setStatus("4");
// marketingChat.setErrorMsg("附和机器人列表为空,请检查账号");
// MysqlUtil.util.cSrv.saveMarketingChat(marketingChat);
// continue;
// }
marketingChat.setStatus("1");
MysqlUtil.util.cSrv.saveMarketingChat(marketingChat);
String askbotId = askCollect.get(0);
for (int h = 0; h < listMarket.size(); h++) {
Marketing botMarketing = listMarket.get(h);
if (botMarketing == null || StringUtils.isEmpty(botMarketing.getId())) {
continue;
}
for (int k = 0; k <botMarketing.getAskGroupList().size() ; k++) {
MarketingAskGroup marketingAskGroup = botMarketing.getAskGroupList().get(k);
List<MarketingAsk> list2 = marketAskMap.get(marketingAskGroup.getId()+"ask");
if (list2 == null || list2.isEmpty()) {
marketAskMap.put(marketingAskGroup.getId()+"ask", new ArrayList<>(marketingAskGroup.getAskList()));
}
List<MarketingAsk> listAskFromMap = marketAskMap.get(marketingAskGroup.getId()+"ask");
if (listAskFromMap == null || listAskFromMap.size() == 0) {
continue;
}
MarketingAsk botMarketingAsk = listAskFromMap.get(RandomUtils.nextInt(0, listAskFromMap.size()));
if (botMarketingAsk == null || StringUtils.isEmpty(botMarketingAsk.getName())) {
continue;
}
String typeAsk = botMarketingAsk.getContentType();
SendMsgInfo sendMsgInfo = new SendMsgInfo(askbotId, marketingChat.getChatId(), botMarketingAsk.getName(), typeAsk, "ask", "", marketingChat.getId(),intervalType);
if (h == 0 && k == 0) {
sendMsgInfo = new SendMsgInfo(askbotId, marketingChat.getChatId(), botMarketingAsk.getName(), typeAsk, "ask", "start", marketingChat.getId(),intervalType);
}
sendMsgQueue.add(sendMsgInfo);
}
String answerBotId = answerCollect.get(0);
for (int k = 0; k < botMarketing.getAnswerGroupList().size(); k++) {
MarketingAnswerGroup marketingAnswerGroup = botMarketing.getAnswerGroupList().get(k);
if (!StringUtils.isEmpty(answerBotId)) {
List<MarketingAnswer> listAnswer = marketAnswerMap.get(marketingAnswerGroup.getId() + "answer");
if (listAnswer == null || listAnswer.isEmpty()) {
marketAnswerMap.put(marketingAnswerGroup.getId() + "answer", new ArrayList<>(marketingAnswerGroup.getAnswerList()));
}
List<MarketingAnswer> listAnswerFromMap = marketAnswerMap.get(marketingAnswerGroup.getId() + "answer");
if (listAnswerFromMap != null && listAnswerFromMap.size() != 0) {
MarketingAnswer botMarketingAnswer = listAnswerFromMap.get(RandomUtils.nextInt(0, listAnswerFromMap.size()));
String typeAnswer = botMarketingAnswer.getContentType();
sendMsgQueue.add(new SendMsgInfo(answerBotId, marketingChat.getChatId(), botMarketingAnswer.getName(), typeAnswer, "answer", "", marketingChat.getId(),intervalType));
}
}
}
for (int k = 0; k < botMarketing.getEchoGroupList().size(); k++) {
MarketingEchoGroup botMarketingEchoGroup = botMarketing.getEchoGroupList().get(k);
if (k == echoCollect.size()) {
/*if(h == (listMarket.size() - 1)){
SendMsgInfo sendMsgInfo1 = new SendMsgInfo("endId", marketingChat.getChatId(), "", "", "echo", "end", marketingChat.getId(),intervalType);
sendMsgQueue.add(sendMsgInfo1);
}*/
break;
}
String echoBotId = echoCollect.get(k);
if (!StringUtils.isEmpty(echoBotId)) {
List<MarketingEcho> listEcho = marketEchoMap.get(botMarketingEchoGroup.getId() + "echo");
if (listEcho == null || listEcho.isEmpty()) {
marketEchoMap.put(botMarketingEchoGroup.getId() + "echo", new ArrayList<>(botMarketingEchoGroup.getEchoList()));
}
List<MarketingEcho> listEchoFromMap = marketEchoMap.get(botMarketingEchoGroup.getId() + "echo");
if (listEchoFromMap != null && listEchoFromMap.size() != 0) {
MarketingEcho botMarketingEcho = listEchoFromMap.get(RandomUtils.nextInt(0, listEchoFromMap.size()));
String typeEcho = botMarketingEcho.getContentType();
List<MarketingEchoGroup> children = botMarketingEchoGroup.getChildren();
SendMsgInfo sendMsgInfo1 = new SendMsgInfo(echoBotId, marketingChat.getChatId(), botMarketingEcho.getName(), typeEcho, "echo", "", marketingChat.getId(),intervalType);
/* if (k == (botMarketing.getEchoGroupList().size() - 1) && h == (listMarket.size() - 1) && (children==null || children.isEmpty()) {
sendMsgInfo1 = new SendMsgInfo(echoBotId, marketingChat.getChatId(), botMarketingEcho.getName(), typeEcho, "echo", "end", marketingChat.getId(),intervalType);
}*/
sendMsgQueue.add(sendMsgInfo1);
if (children != null && !children.isEmpty()){
for (int l = 0; l < children.size() ; l++) {
MarketingEchoGroup marketingEchoGroup = children.get(l);
List<MarketingEcho> listEchoChildren = marketEchoMap.get(marketingEchoGroup.getId() + "echo");
if (listEchoChildren == null || listEchoChildren.isEmpty()) {
marketEchoMap.put(marketingEchoGroup.getId() + "echo", new ArrayList<>(marketingEchoGroup.getEchoList()));
}
List<MarketingEcho> listEchoFromMapChildren = marketEchoMap.get(marketingEchoGroup.getId() + "echo");
if (listEchoFromMapChildren != null && listEchoFromMapChildren.size() != 0) {
MarketingEcho botMarketingEchoChildren = listEchoFromMapChildren.get(RandomUtils.nextInt(0, listEchoFromMapChildren.size()));
String typeEchoChildren = botMarketingEchoChildren.getContentType();
SendMsgInfo sendMsgInfoChildren = new SendMsgInfo(echoBotId, marketingChat.getChatId(), botMarketingEchoChildren.getName(), typeEchoChildren, "echo", "", marketingChat.getId(),intervalType);
/* if (l == (children.size() - 1) && h == (listMarket.size() - 1)) {
sendMsgInfoChildren = new SendMsgInfo(echoBotId, marketingChat.getChatId(), botMarketingEchoChildren.getName(), typeEchoChildren, "echo", "end", marketingChat.getId(),intervalType);
}*/
sendMsgQueue.add(sendMsgInfoChildren);
}
}
}
}
}
}
if(h == (listMarket.size() - 1)){
SendMsgInfo sendMsgInfo1 = new SendMsgInfo("endId", marketingChat.getChatId(), "", "", "echo", "end", marketingChat.getId(),intervalType);
sendMsgQueue.add(sendMsgInfo1);
break;
}
}
sendMsgQueueTask.add(sendMsgQueue);
}
}
handlerChatMessageThread.execute(new HandlerFunction(sendMsgQueueTask));
}//任务循环
}
} catch (
Exception e) {
log.error("handle push message failed, {}", e);
}
}
}
/** 固定使用 127.0.0.1,不使用 status 中的 IP(如 10.35.x */
public static String getServerAddr(String wxid) {
return "127.0.0.1:50012";
// if (StringUtils.isEmpty(wxid)) return null;
// String botMsg = BotManager.botAllManager.get(wxid);
// if (!StringUtils.isEmpty(botMsg)) {
// JSONObject parseObject = JSON.parseObject(botMsg);
// String addr = parseObject.getString("status");
// if (addr == null) return null;
// return addr.split("_")[0];
// }
// return null;
}
/**
* 获取当前系统所有
*
* @return
*/
private static Map<String,List<String>> getBotList() {
try {
Map<String, String> roleMap = RedisUtil.util.hgetAll(BotConfigConst.BOT_ROLE_KEY);
Map<String, String> botMap = RedisUtil.util.hgetAll(BotConfigConst.BOT_KEY);
List<String> answerBotRoleInfoList = new ArrayList<String>();
List<String> askBotRoleInfoList = new ArrayList<String>();
List<String> echoBotRoleInfoList = new ArrayList<String>();
for (String value : roleMap.values()) {
BotRoleInfo botRoleInfo = JSON.parseObject(value, BotRoleInfo.class);
if (botRoleInfo != null && "wx".equals(botRoleInfo.getService()) && "r_answer".equals(botRoleInfo.getRole())) {
answerBotRoleInfoList.add(botRoleInfo.getId());
}
if (botRoleInfo != null && "wx".equals(botRoleInfo.getService()) && "r_echo".equals(botRoleInfo.getRole())) {
echoBotRoleInfoList.add(botRoleInfo.getId());
}
if (botRoleInfo != null && "wx".equals(botRoleInfo.getService()) && "r_ask".equals(botRoleInfo.getRole())) {
askBotRoleInfoList.add(botRoleInfo.getId());
}
}
List<String> collectAnswer = answerBotRoleInfoList.stream().filter(item -> botMap.keySet().contains(item)).collect(Collectors.toList());
if(collectAnswer==null){
collectAnswer = new ArrayList<String>();
}
List<String> collectEcho = echoBotRoleInfoList.stream().filter(item -> botMap.keySet().contains(item)).collect(Collectors.toList());
if(collectEcho==null){
collectEcho = new ArrayList<String>();
}
List<String> collectAsk = askBotRoleInfoList.stream().filter(item -> botMap.keySet().contains(item)).collect(Collectors.toList());
if(collectAsk==null){
collectAsk = new ArrayList<String>();
}
Map<String,List<String>> map =new HashMap<String,List<String>>();
map.put("answerList", collectAnswer);
map.put("echoList", collectEcho);
map.put("askList", collectAsk);
return map;
} catch (Exception ex) {
log.info("getAskBotList error:{}", ex);
}
return null;
}
public static boolean sendTextMsg(String botId,String toId, String content,String type) {
String server = getServerAddr(botId);
if (server ==null || server.isEmpty() || StringUtils.isEmpty(content)) return false;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", botId);
bodyInfo.put("cmdType", "sendMsg");
bodyInfo.put("to", toId);
if("1".equals(type)){
bodyInfo.put("contentType", "img");
bodyInfo.put("url", content);
}else if("2".equals(type)){
if(StringUtils.isEmpty(content)) return false;
SendCard sendCard = JSON.parseObject(content, SendCard.class);
if(sendCard==null) return false;
bodyInfo.put("cmdType", "sendCardUrl");
bodyInfo.put("title", sendCard.getTitle());
bodyInfo.put("desc", sendCard.getSummary());
bodyInfo.put("url", sendCard.getLink());
bodyInfo.put("img", sendCard.getImageUrl());
}else{
bodyInfo.put("contentType", "text");
if(StringUtils.isEmpty(content)) return false;
bodyInfo.put("content",content);
}
String body = JSON.toJSONString(bodyInfo);
log.info("sendTextMsg: {}, {}", url, body);
String res=HttpUtil.post(url, body);
JSONObject jsonObject = JSON.parseObject(res);
if (jsonObject == null) {
return false;
}
if (jsonObject.containsKey("errmsg")) {
return false;
}
return true;
}
public static String sendMsg(String botId, HashMap<String, String> bodyInfo) {
String server = getServerAddr(botId);
if (server ==null || server.isEmpty()) return "server is null";
String url = BotConfigConst.CMD_API_URL;
String body = JSON.toJSONString(bodyInfo);
String post = HttpUtil.post(url, body);
log.info("AskQaHandler sendMsg:{}\r\n\r\n{},",body,url);
log.info("AskQaHandler sendMsg post:{},",post);
return post;
}
public static String sendMsgString(String botId, String bodyInfo) {
String server = getServerAddr(botId);
if (server ==null || server.isEmpty()) return "server is null";
String url = BotConfigConst.CMD_API_URL;
String post = HttpUtil.post(url, bodyInfo);
log.info("sendTextMsg: {}, {}", url, bodyInfo);
return post;
}
public static List<ChatMemberInfo> getChatMemberList(String wxid, String chatId) {
List<ChatMemberInfo> chatInfoList = new ArrayList<ChatMemberInfo>();
try {
String server = getServerAddr(wxid);
if (server == null || server.isEmpty() || StringUtils.isEmpty(wxid)) {
log.warn("server is null or wxid is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String, String> bodyInfo = new HashMap<String, String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("chatId", chatId);
bodyInfo.put("cmdType", "getChatMembersDetail");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
JSONObject jsonObject = JSON.parseObject(rsp);
if (jsonObject == null) {
return chatInfoList;
}
if (jsonObject.containsKey("errmsg")) {
log.info("get chats 【机器人非正常状态】:设备 " + wxid + "错误信息:" + JSON.parseObject(rsp).get("errmsg"));
return chatInfoList;
}
chatInfoList = JSON.parseArray(jsonObject.getString("info"), ChatMemberInfo.class);
return chatInfoList;
} catch (Exception ex) {
log.info("getChats error:{}", ex);
}
return chatInfoList;
}
public static List<ChatInfo> getChats(String wxid) {
List<ChatInfo> chatInfoList = new ArrayList<ChatInfo>();
try {
String server = getServerAddr(wxid);
if (server == null || server.isEmpty() || StringUtils.isEmpty(wxid)) {
log.warn("server is null or wxid is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String, String> bodyInfo = new HashMap<String, String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getChats");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
JSONObject jsonObject = JSON.parseObject(rsp);
if (jsonObject == null) {
return chatInfoList;
}
if (jsonObject.containsKey("errmsg")) {
log.info("get chats 【机器人非正常状态】:设备 " + wxid + "错误信息:" + JSON.parseObject(rsp).get("errmsg"));
return chatInfoList;
}
chatInfoList = JSON.parseArray(jsonObject.getString("info"), ChatInfo.class);
return chatInfoList;
} catch (Exception ex) {
log.info("getChats error:{}", ex);
}
return chatInfoList;
}
/**
* 获取机器人好友列表
*/
public static List<BotFriend> getFriends(String wxid) {
String server = getServerAddr(wxid);
if (server == null || server.isEmpty() || StringUtils.isEmpty(wxid)) {
log.warn("server is null or wxid is null, {}", wxid);
return null;
}
List<BotFriend> list = new ArrayList<>();
if (server == null || server.isEmpty()) return list;
String url = BotConfigConst.CMD_API_URL;
HashMap<String, Object> bodyInfo = new HashMap<String, Object>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getFriends");
String body = JSON.toJSONString(bodyInfo);
try {
String resp = HttpUtil.post(url, body);
if (StringUtils.isNotEmpty(resp)) {
JSONObject jsonObject = JSON.parseObject(resp);
if (jsonObject == null) return list;
if (jsonObject.containsKey("errmsg")) {
return list;
}
list = JSON.parseArray(jsonObject.getString("info"), BotFriend.class);
}
} catch (Exception ex) {
log.error("getFriends error:{}", ex);
}
return list;
}
public static class SendMsgInfo {
public SendMsgInfo(String botId, String chatId, String content, String type, String role, String status, String marketingId,String intervalType) {
this.botId = botId;
this.chatId = chatId;
this.content = content;
this.type = type;
this.role = role;
this.status = status;
this.marketingId = marketingId;
this.intervalType = intervalType;
}
private String botId;
private String chatId;
private String content;
private String type;
private String role;
private String status;
private String marketingId;
private String intervalType;
public String getBotId() {
return botId;
}
public void setBotId(String botId) {
this.botId = botId;
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getMarketingId() {
return marketingId;
}
public void setMarketingId(String marketingId) {
this.marketingId = marketingId;
}
public String getIntervalType() {
return intervalType;
}
public void setIntervalType(String intervalType) {
this.intervalType = intervalType;
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,130 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.*;
import io.xiaoxi.db.model.ChatMessageRecordsEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import io.xiaoxi.jedis.RedisUtil;
import io.xiaoxi.utils.BotConfigConst;
import io.xiaoxi.utils.MysqlUtil;
/**
* @ClassName: BotManager
* @Description: TODO
* @date: 2019年5月14日 上午9:48:31
*/
public class BotManager {
public static final Logger log = LoggerFactory.getLogger(BotManager.class.getName());
public static ScheduledExecutorService checkEs;
public static ConcurrentHashMap<String, BotHandler> botManager = new ConcurrentHashMap<String,BotHandler>();
public static ConcurrentHashMap<String, String> botAllManager = new ConcurrentHashMap<String, String>();
public static ConcurrentHashMap<String, AskBotHandler> askBotManager = new ConcurrentHashMap<String, AskBotHandler>();
public static ConcurrentHashMap<String, EchoBotHandler> echoBotManager = new ConcurrentHashMap<String, EchoBotHandler>();
public static ConcurrentHashMap<String, DataBotHandler> dataBotManager = new ConcurrentHashMap<String, DataBotHandler>();
public static Queue<ChatMessageRecordsEntity> chatMessage = new LinkedList<>();
public static Queue<ChatMessageRecordsEntity> chatMessgeAddFriend = new LinkedList<>();
public static Queue<JSONObject> chatMessgeFilter = new LinkedList<>();
public static void check() {
Map<String,String> bots = getBots();
Map<String, String> roleBots = getBotRoles();
for (String key : bots.keySet()) {
// 仅当 key 在 t_wxcb_device 表的 appid 中存在时才启动或更新
if (StringUtils.isEmpty(key) || StringUtils.isEmpty(MysqlUtil.util.cSrv.getDevice(key).getAppid())) {
log.debug("skip bot not in t_wxcb_device, key={}", key);
continue;
}
if (botAllManager.containsKey(key) == false) {
botAllManager.put(key, bots.get(key));
log.info("【检测启动机器人】 已启动机器人ID:{}", key);
BotHandler handler = new BotHandler(key);
handler.setUserInfo(bots.get(key));
handler.startProc();
log.info("【r_answer】 已启动机器人ID:{}", key);
botManager.put(key, handler);
log.info("add bot handler,{}",bots.get(key));
}
else{
BotHandler botHandler = botManager.get(key);
if (botHandler != null) {
botHandler.setUserInfo(bots.get(key));
log.info("update bot handler,{}",bots.get(key));
}
}
}
}
public static Map<String,String> getBots() {
return RedisUtil.util.hgetAll(BotConfigConst.BOT_KEY);
}
/**
* 获取所有机器人角色
*
* @return
*/
public static Map<String, String> getBotRoles() {
Map<String, String> roleMap = RedisUtil.util.hgetAll(BotConfigConst.BOT_ROLE_KEY);
return roleMap;
}
public static void startBotChecking() {
checkEs = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
checkEs.scheduleWithFixedDelay( new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
check();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}), 3, 20, TimeUnit.SECONDS);
}
}
@@ -0,0 +1,372 @@
package io.xiaoxi;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.xiaoxi.db.model.ChatInfo;
import io.xiaoxi.db.model.ChatMessageRecordsEntity;
import io.xiaoxi.db.model.UserAddBotAsFriendEntity;
import io.xiaoxi.db.model.common.CommandInfo;
import io.xiaoxi.db.model.common.SendCard;
import io.xiaoxi.db.model.friendreply.AddedFriendReply;
import io.xiaoxi.utils.*;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.xiaoxi.jedis.RedisUtil;
/**
* @ClassName: BotHandler
* @Description: TODO
* @date: 2019年5月14日 上午9:49:17
*/
public class DataBotHandler {
public final Logger log = LoggerFactory.getLogger(BotHandler.class.getName());
public String wxid;
public JSONObject userInfo;
public Queue<String[]> sendMsgQueue;
public DataBotHandler(String wxid) {
this.wxid = wxid;
proc = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
SendProc = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
}
public ScheduledExecutorService proc;
public ScheduledExecutorService SendProc;
public void setUserInfo(String info) {
userInfo = JSON.parseObject(info);
}
/** 固定使用 127.0.0.1,不使用 status 中的 IP(如 10.35.x */
public String getServerAddr() {
return "127.0.0.1:50012";
// String addr = userInfo.getString("status");
// if (addr==null) return null;
// return addr.split("_")[0];
}
public String getNickname() {
return userInfo.getString("nickname");
}
public String getPhone() {
return userInfo.getString("phone");
}
public List<ChatInfo> getChats() {
List<ChatInfo> chatInfoList = new ArrayList<ChatInfo>();
try {
String server = getServerAddr();
if (server == null || server.isEmpty()||StringUtils.isEmpty(wxid)) {
log.warn("server is null or wxid is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String, String> bodyInfo = new HashMap<String, String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getChats");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
JSONObject jsonObject = JSON.parseObject(rsp);
if(jsonObject==null){
return chatInfoList;
}
if (jsonObject.containsKey("errmsg")) {
log.info("get chats 【机器人非正常状态】:设备 " + wxid + "错误信息:" + JSON.parseObject(rsp).get("errmsg"));
return chatInfoList;
}
chatInfoList = JSON.parseArray(jsonObject.getString("info"), ChatInfo.class);
return chatInfoList;
} catch (Exception ex) {
log.info("getChats error:{}", ex);
}
return chatInfoList;
}
public class ProcMsgJob implements Runnable {
@Override
public void run() {
try {
String rsp = recvMsg();
if (rsp != null && rsp.isEmpty()==false) {
if (JSON.parseObject(rsp).containsKey("errmsg")) {
log.info("recv: {},{}",wxid, rsp);
return;
}
JSONArray msgs = JSON.parseObject(rsp).getJSONArray("msgs");
if (msgs!=null) {
log.info("recv: {},{}",wxid, rsp);
for (String strMsg : msgs.toJavaList(String.class)) {
JSONObject msg = JSON.parseObject(strMsg);
String msgKafka=strMsg;
if (isChatMsg(msg)) {
msg.put("chatName",getChatName(msg.getString("toID")));
msgKafka = JSONObject.toJSONString(msg);
}
try {
KafkaProduce.sendWithDefaultTopic(wxid, msgKafka);
} catch (Exception e) {
e.printStackTrace();
log.warn("send to kafka failed,{}",e.getMessage());
}
//2分钟以前的消息不处理
Long createTime = msg.getLong("create_time");
if (createTime != null) {
if ((System.currentTimeMillis()-createTime)/1000 > 60*2) {
continue;
}
}
//系统通知
String content = msg.getString("content").trim();
Integer type = msg.getInteger("type");
switch (type) {
case 99://添加好友
MysqlUtil.util.cSrv.updateKfgztFriendList(wxid);
if (content.startsWith("你已添加了")) {
//查看被加好友用户开关
String botaddEnable = RedisUtil.util.get(CommonPropertiesReader.getValue("BOT_ADD_FRIEND_ENABLE"));
if("1".equals(botaddEnable)){
List<AddedFriendReply> listAddFriend=MysqlUtil.util.cSrv.getAddedFriendReply();
for (int i = 0; i < listAddFriend.size(); i++) {
AddedFriendReply addedFriendReply = listAddFriend.get(i);
if(addedFriendReply!=null&&!org.apache.commons.lang3.StringUtils.isEmpty(addedFriendReply.getContent())){
sendTextMsg(msg.getString("toID"),addedFriendReply.getContent(),addedFriendReply.getType(),"1");
}
}
}
UserAddBotAsFriendEntity addBotAsFriendEntity=new UserAddBotAsFriendEntity();
addBotAsFriendEntity.setBotWxid(wxid);
addBotAsFriendEntity.setWxid(msg.getString("toID"));
MysqlUtil.util.cSrv.saveUserAddBotAsFriend(addBotAsFriendEntity);
}
break;
case 15:
MysqlUtil.util.cSrv.updateKfgztChatList(wxid);
break;
case 1:
case 2:
if(!org.springframework.util.StringUtils.isEmpty(content)){
content=content.trim();
}
//客服工作台消息处理;
MysqlUtil.util.cSrv.processReceiveMessage(type,wxid,msg,content);
//不处理自己的发送的消息
if (msg.getInteger("isSend")==1) continue;
//群聊
if (isChatMsg(msg)) {
ChatMessageRecordsEntity chatMessageRecordsEntity=new ChatMessageRecordsEntity();
chatMessageRecordsEntity.setChatId(msg.getString("toID"));
chatMessageRecordsEntity.setContent(content);
chatMessageRecordsEntity.setWxId(wxid);
BotManager.chatMessage.add(chatMessageRecordsEntity);
}
default:
}
}
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
public String getChatName(String chatId) {
String chatName = BotHandler.chatNames.get(chatId);
if (chatName != null) return chatName;
//担心刚拉入群,群名称等消息还没写入获取不到
try {
Thread.sleep(1000L*1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String rsp = getChat(chatId);
if (rsp==null) return "";
JSONObject jsonObj = JSON.parseObject(rsp).getJSONObject("info");
// log.info("{},{}",chatId, rsp);
chatName = jsonObj.getString("nickname");
if(!org.apache.commons.lang3.StringUtils.isEmpty(chatName)){
BotHandler.chatNames.put(chatId, chatName);
}
return chatName;
}
public String getChat(String chatId) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return null;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getChat");
bodyInfo.put("chatId", chatId);
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public void startProc() {
sendMsgQueue = new ConcurrentLinkedQueue<String[]>();
proc.scheduleWithFixedDelay( new ProcMsgJob(), 5, 1, TimeUnit.SECONDS);
SendProc.scheduleWithFixedDelay( new SendMsgJob(), 1, 2, TimeUnit.SECONDS);
}
public class SendMsgJob implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
synchronized (SendMsgJob.class) {
try {
String[] data = sendMsgQueue.poll();
if (data != null) {
String url = data[0];
String body = data[1];
if (body != null) {
log.info("sendTextMsg: {}, {}", url, body);
Thread.currentThread().sleep(RandomUtils.nextLong(1, 2) * 1000);
HttpUtil.post(url, body);
}
}
}
catch (Exception e) {
e.printStackTrace();
log.warn(e.getMessage());
}
}
}
}
public String recvMsg() {
String server = getServerAddr();
if (server ==null || server.isEmpty()) {
log.warn("server is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getMsg");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public void sendTextMsg(String toId, String content,String contentType,String isSleep) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "sendMsg");
bodyInfo.put("to", toId);
if("1".equals(contentType)){
bodyInfo.put("contentType", "img");
bodyInfo.put("url", content);
}else if("2".equals(contentType)){
if(StringUtils.isEmpty(content)) return;
SendCard sendCard = JSON.parseObject(content, SendCard.class);
if(sendCard==null) return;
bodyInfo.put("cmdType", "sendCardUrl");
bodyInfo.put("title", sendCard.getTitle());
bodyInfo.put("desc", sendCard.getSummary());
bodyInfo.put("url", sendCard.getLink());
bodyInfo.put("img", sendCard.getImageUrl());
}else{
bodyInfo.put("contentType", "text");
if(StringUtils.isEmpty(content)) return;
bodyInfo.put("content",content);
}
String body = JSON.toJSONString(bodyInfo);
String[] data =new String[]{url,body,isSleep};
sendMsgQueue.add(data);
}
public String getUserInfo(String uid) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return null;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getUserInfo");
bodyInfo.put("uid", uid);
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public static boolean isMobiPhoneNum(String telNum){
String regex = "^1\\d{10}$";
Pattern p = Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(telNum);
return m.matches();
}
public static boolean isChatMsg(JSONObject msg) {
return msg.getString("fromID").endsWith("@chatroom") || msg.getString("toID").endsWith("@chatroom");
}
public static String getFtPriceTail() {
return RedisUtil.util.get("fttokenpricetail");
}
}
@@ -0,0 +1,378 @@
package io.xiaoxi;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.xiaoxi.db.model.ChatInfo;
import io.xiaoxi.db.model.ChatMessageRecordsEntity;
import io.xiaoxi.db.model.UserAddBotAsFriendEntity;
import io.xiaoxi.db.model.common.CommandInfo;
import io.xiaoxi.db.model.common.SendCard;
import io.xiaoxi.db.model.friendreply.AddedFriendReply;
import io.xiaoxi.utils.*;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.xiaoxi.jedis.RedisUtil;
/**
* @ClassName: BotHandler
* @Description: TODO
* @date: 2019年5月14日 上午9:49:17
*/
public class EchoBotHandler {
public final Logger log = LoggerFactory.getLogger(BotHandler.class.getName());
public String wxid;
public JSONObject userInfo;
public Queue<String[]> sendMsgQueue;
public EchoBotHandler(String wxid) {
this.wxid = wxid;
proc = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
SendProc = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// TODO Auto-generated method stub
Thread t = new Thread(r);
t.setDaemon(true);
return t;
}
});
}
public ScheduledExecutorService proc;
public ScheduledExecutorService SendProc;
public void setUserInfo(String info) {
userInfo = JSON.parseObject(info);
}
/** 固定使用 127.0.0.1,不使用 status 中的 IP(如 10.35.x */
public String getServerAddr() {
return "127.0.0.1:50012";
// String addr = userInfo.getString("status");
// if (addr==null) return null;
// return addr.split("_")[0];
}
public String getNickname() {
return userInfo.getString("nickname");
}
public String getPhone() {
return userInfo.getString("phone");
}
public List<ChatInfo> getChats() {
List<ChatInfo> chatInfoList = new ArrayList<ChatInfo>();
try {
String server = getServerAddr();
if (server == null || server.isEmpty()||StringUtils.isEmpty(wxid)) {
log.warn("server is null or wxid is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String, String> bodyInfo = new HashMap<String, String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getChats");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
JSONObject jsonObject = JSON.parseObject(rsp);
if(jsonObject==null){
return chatInfoList;
}
if (jsonObject.containsKey("errmsg")) {
log.info("get chats 【机器人非正常状态】:设备 " + wxid + "错误信息:" + JSON.parseObject(rsp).get("errmsg"));
return chatInfoList;
}
chatInfoList = JSON.parseArray(jsonObject.getString("info"), ChatInfo.class);
return chatInfoList;
} catch (Exception ex) {
log.info("getChats error:{}", ex);
}
return chatInfoList;
}
public class ProcMsgJob implements Runnable {
@Override
public void run() {
try {
String rsp = recvMsg();
if (rsp != null && rsp.isEmpty()==false) {
if (JSON.parseObject(rsp).containsKey("errmsg")) {
log.info("recv: {},{}",wxid, rsp);
return;
}
JSONArray msgs = JSON.parseObject(rsp).getJSONArray("msgs");
if (msgs!=null) {
log.info("recv: {},{}",wxid, rsp);
for (String strMsg : msgs.toJavaList(String.class)) {
JSONObject msg = JSON.parseObject(strMsg);
String msgKafka=strMsg;
if (isChatMsg(msg)) {
msg.put("chatName",getChatName(msg.getString("toID")));
msgKafka = JSONObject.toJSONString(msg);
}
try {
KafkaProduce.sendWithDefaultTopic(wxid, msgKafka);
} catch (Exception e) {
e.printStackTrace();
log.warn("send to kafka failed,{}",e.getMessage());
}
//2分钟以前的消息不处理
Long createTime = msg.getLong("create_time");
if (createTime != null) {
if ((System.currentTimeMillis()-createTime)/1000 > 60*2) {
continue;
}
}
//系统通知
String content = msg.getString("content");
Integer type = msg.getInteger("type");
switch (type) {
case 99://添加好友
MysqlUtil.util.cSrv.updateKfgztFriendList(wxid);
if (content.startsWith("你已添加了")) {
//查看被加好友用户开关
String botaddEnable = RedisUtil.util.get(CommonPropertiesReader.getValue("BOT_ADD_FRIEND_ENABLE"));
if("1".equals(botaddEnable)){
List<AddedFriendReply> listAddFriend=MysqlUtil.util.cSrv.getAddedFriendReply();
for (int i = 0; i < listAddFriend.size(); i++) {
AddedFriendReply addedFriendReply = listAddFriend.get(i);
if(addedFriendReply!=null&&!org.apache.commons.lang3.StringUtils.isEmpty(addedFriendReply.getContent())){
sendTextMsg(msg.getString("toID"),addedFriendReply.getContent(),addedFriendReply.getType(),"1");
}
}
}
UserAddBotAsFriendEntity addBotAsFriendEntity=new UserAddBotAsFriendEntity();
addBotAsFriendEntity.setBotWxid(wxid);
addBotAsFriendEntity.setWxid(msg.getString("toID"));
MysqlUtil.util.cSrv.saveUserAddBotAsFriend(addBotAsFriendEntity);
}
break;
case 15:
MysqlUtil.util.cSrv.updateKfgztChatList(wxid);
break;
case 1:
case 2:
if(!org.springframework.util.StringUtils.isEmpty(content)){
content=content.trim();
}
//客服工作台消息处理;
MysqlUtil.util.cSrv.processReceiveMessage(type,wxid,msg,content);
//不处理自己的发送的消息
if (msg.getInteger("isSend")==1) continue;
//群聊
if (isChatMsg(msg)) {
ChatMessageRecordsEntity chatMessageRecordsEntity=new ChatMessageRecordsEntity();
chatMessageRecordsEntity.setChatId(msg.getString("toID"));
chatMessageRecordsEntity.setContent(content);
chatMessageRecordsEntity.setWxId(wxid);
BotManager.chatMessage.add(chatMessageRecordsEntity);
}else{
ChatMessageRecordsEntity chatMessageRecordsEntity=new ChatMessageRecordsEntity();
chatMessageRecordsEntity.setChatId(msg.getString("fromID"));
chatMessageRecordsEntity.setContent(content);
chatMessageRecordsEntity.setWxId(wxid);
chatMessageRecordsEntity.setFromId(msg.getString("toID"));
BotManager.chatMessgeAddFriend.add(chatMessageRecordsEntity);
}
default:
}
}
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
public String getChatName(String chatId) {
String chatName = BotHandler.chatNames.get(chatId);
if (chatName != null) return chatName;
//担心刚拉入群,群名称等消息还没写入获取不到
try {
Thread.sleep(1000L*1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String rsp = getChat(chatId);
if (rsp==null) return "";
JSONObject jsonObj = JSON.parseObject(rsp).getJSONObject("info");
// log.info("{},{}",chatId, rsp);
chatName = jsonObj.getString("nickname");
if(!org.apache.commons.lang3.StringUtils.isEmpty(chatName)){
BotHandler.chatNames.put(chatId, chatName);
}
return chatName;
}
public String getChat(String chatId) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return null;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getChat");
bodyInfo.put("chatId", chatId);
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public void startProc() {
sendMsgQueue = new ConcurrentLinkedQueue<String[]>();
proc.scheduleWithFixedDelay( new ProcMsgJob(), 5, 1, TimeUnit.SECONDS);
SendProc.scheduleWithFixedDelay( new SendMsgJob(), 1, 2, TimeUnit.SECONDS);
}
public class SendMsgJob implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
synchronized (SendMsgJob.class) {
try {
String[] data = sendMsgQueue.poll();
if (data != null) {
String url = data[0];
String body = data[1];
if (body != null) {
log.info("sendTextMsg: {}, {}", url, body);
Thread.currentThread().sleep(RandomUtils.nextLong(1, 2) * 1000);
HttpUtil.post(url, body);
}
}
}
catch (Exception e) {
e.printStackTrace();
log.warn(e.getMessage());
}
}
}
}
public String recvMsg() {
String server = getServerAddr();
if (server ==null || server.isEmpty()) {
log.warn("server is null, {}", wxid);
return null;
}
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getMsg");
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public void sendTextMsg(String toId, String content,String contentType,String isSleep) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "sendMsg");
bodyInfo.put("to", toId);
if("1".equals(contentType)){
bodyInfo.put("contentType", "img");
bodyInfo.put("url", content);
}else if("2".equals(contentType)){
if(StringUtils.isEmpty(content)) return;
SendCard sendCard = JSON.parseObject(content, SendCard.class);
if(sendCard==null) return;
bodyInfo.put("cmdType", "sendCardUrl");
bodyInfo.put("title", sendCard.getTitle());
bodyInfo.put("desc", sendCard.getSummary());
bodyInfo.put("url", sendCard.getLink());
bodyInfo.put("img", sendCard.getImageUrl());
}else{
bodyInfo.put("contentType", "text");
if(StringUtils.isEmpty(content)) return;
bodyInfo.put("content",content);
}
String body = JSON.toJSONString(bodyInfo);
String[] data =new String[]{url,body,isSleep};
sendMsgQueue.add(data);
}
public String getUserInfo(String uid) {
String server = getServerAddr();
if (server ==null || server.isEmpty()) return null;
String url = BotConfigConst.CMD_API_URL;
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", wxid);
bodyInfo.put("cmdType", "getUserInfo");
bodyInfo.put("uid", uid);
String body = JSON.toJSONString(bodyInfo);
String rsp = HttpUtil.post(url, body);
return rsp;
}
public static boolean isMobiPhoneNum(String telNum){
String regex = "^1\\d{10}$";
Pattern p = Pattern.compile(regex,Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(telNum);
return m.matches();
}
public static boolean isChatMsg(JSONObject msg) {
return msg.getString("fromID").endsWith("@chatroom") || msg.getString("toID").endsWith("@chatroom");
}
public static String getFtPriceTail() {
return RedisUtil.util.get("fttokenpricetail");
}
}
@@ -0,0 +1,13 @@
package io.xiaoxi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WxcontractbotagentApplication {
public static void main(String[] args) {
SpringApplication.run(WxcontractbotagentApplication.class, args);
}
}
@@ -0,0 +1,46 @@
package io.xiaoxi.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* @Des : 拦截器实现跨域配置
*
* @Date : 2019/7/12 11:48
* @Author : Lgo
*/
@Component
public class CorsInterceptor implements Filter {
@Value("${allow.domain}")
private String allowDomain;
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
HttpServletRequest request = (HttpServletRequest) req;
String[] allowDomainArray = allowDomain.split(",");
Set<String> allowedOrigins = new HashSet<String>(Arrays.asList(allowDomainArray));
String originHeader = request.getHeader("Origin");
if (allowedOrigins.contains(originHeader)) {
response.setHeader("Access-Control-Allow-Origin", originHeader);
//不同域下面,服务端需要设置cookie所在的域;否则也会有session id不同情况
response.setHeader("Access-Control-Allow-Credentials", "true");//若要返回cookie、携带seesion等信息则将此项设置我true
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Content-type");
}
chain.doFilter(req, res);
}
public void init(FilterConfig filterConfig) {}
public void destroy() {}
}
@@ -0,0 +1,35 @@
//package io.xiaoxi.config;
//
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.messaging.simp.config.MessageBrokerRegistry;
//import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
//import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
//import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
//
//@Configuration
//@EnableWebSocketMessageBroker
//public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
//
// @Value("${allow.domain}")
// private String allowDomain;
//
// @Override
// public void registerStompEndpoints(StompEndpointRegistry registry) {
// registry.addEndpoint("/workbench")
// .setAllowedOrigins(allowDomain.split(","))
// .withSockJS()
// .setHeartbeatTime(1000);
//// .setStreamBytesLimit(512 * 3000000)
//// .setHttpMessageCacheSize(3000000)
//// .setDisconnectDelay(300* 3000000)
//
// }
//
// @Override
// public void configureMessageBroker(MessageBrokerRegistry registry) {
// registry.configureBrokerChannel().taskExecutor().keepAliveSeconds(100000000).maxPoolSize(100000);
// registry.setApplicationDestinationPrefixes("/cmd");
//
// }
//}
@@ -0,0 +1,28 @@
//package io.xiaoxi.config;
//
//import com.alibaba.fastjson.JSON;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.context.event.EventListener;
//import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
//import org.springframework.stereotype.Component;
//import org.springframework.web.socket.messaging.SessionConnectedEvent;
//import org.springframework.web.socket.messaging.SessionDisconnectEvent;
//
//@Component
//public class WebSocketEventListener {
// private final Logger logger = LoggerFactory.getLogger(WebSocketEventListener.class);
//
// @EventListener
// public void handleWebSocketConnectListener(SessionConnectedEvent event) {
// StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
// logger.info("connect:{}", JSON.toJSONString(headerAccessor));
// }
//
//
// @EventListener
// public void handleWebSocketDisconnectListener(SessionDisconnectEvent event) {
// StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
// logger.info("disconnect:{}", JSON.toJSONString(headerAccessor));
// }
//}
@@ -0,0 +1,305 @@
package io.xiaoxi.db.controller;
import io.xiaoxi.AskQaHandler;
import io.xiaoxi.db.model.BaseResponse;
import io.xiaoxi.db.model.BotMessageEntity;
import io.xiaoxi.db.model.common.CommandInfo;
import io.xiaoxi.db.service.CommonService;
import io.xiaoxi.utils.MysqlUtil;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@RestController
@RequestMapping("api/v1")
public class CommonController {
private Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private CommonService commonService;
/**
* 修改机器人头像头像
* @param
* @param
* @return
*/
@RequestMapping(value = "setBotAvatar", method = RequestMethod.POST)
public BaseResponse setBotAvatar(String botId, String img) {
BaseResponse brp=new BaseResponse();
try {
if(StringUtils.isEmpty(botId)){
brp.setSuccess(false);
brp.setError_message("机器人id不为空");
return brp;
}
if(StringUtils.isEmpty(img)){
brp.setSuccess(false);
brp.setError_message("头像不为空");
return brp;
}
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", botId);
bodyInfo.put("cmdType", "setMyAvatar");
bodyInfo.put("img",img);
String sendMsg = AskQaHandler.sendMsg(botId, bodyInfo);
if("server is null".equals(sendMsg)){
brp.setSuccess(false);
brp.setError_message(sendMsg);
return brp;
}
MysqlUtil.util.cSrv.updateBotMsg(botId);
brp.setData(sendMsg);
brp.setSuccess(true);
} catch (Exception e) {
log.info("setBotAvatar------------"+e.getMessage());
brp.setSuccess(false);
brp.setError_message(e.getMessage());
}
return brp;
}
/**
* 设置机器人昵称
* @param
* @param
* @return
*/
@RequestMapping(value = "setBotNickname", method = RequestMethod.POST)
public BaseResponse setBotNickname(String botId, String nickname) {
BaseResponse brp=new BaseResponse();
try {
if(StringUtils.isEmpty(botId)){
brp.setSuccess(false);
brp.setError_message("机器人id不为空");
return brp;
}
if(StringUtils.isEmpty(nickname)){
brp.setSuccess(false);
brp.setError_message("昵称不为空");
return brp;
}
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", botId);
bodyInfo.put("cmdType", "setMyNickname");
bodyInfo.put("nickname",nickname);
String sendMsg = AskQaHandler.sendMsg(botId, bodyInfo);
if("server is null".equals(sendMsg)){
brp.setSuccess(false);
brp.setError_message(sendMsg);
return brp;
}
MysqlUtil.util.cSrv.updateBotMsg(botId);
brp.setData(sendMsg);
brp.setSuccess(true);
} catch (Exception e) {
log.info("setBotNickname------------"+e.getMessage());
brp.setSuccess(false);
brp.setError_message(e.getMessage());
}
return brp;
}
/**
* 获取自己的二维码
* @param
* @param
* @return
*/
@RequestMapping(value = "getQrcode", method = RequestMethod.POST)
public BaseResponse getQrcode(String botId) {
BaseResponse brp=new BaseResponse();
try {
if(StringUtils.isEmpty(botId)){
brp.setSuccess(false);
brp.setError_message("机器人id不为空");
return brp;
}
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", botId);
bodyInfo.put("uid", botId);
bodyInfo.put("cmdType", "getQrcode");
String sendMsg = AskQaHandler.sendMsg(botId, bodyInfo);
if("server is null".equals(sendMsg)){
brp.setSuccess(false);
brp.setError_message(sendMsg);
return brp;
}
brp.setData(sendMsg);
brp.setSuccess(true);
} catch (Exception e) {
log.info("getQrcode------------"+e.getMessage());
brp.setSuccess(false);
brp.setError_message(e.getMessage());
}
return brp;
}
/**
* 退群
* @param
* @param
* @return
*/
@RequestMapping(value = "quitChat", method = RequestMethod.POST)
public BaseResponse quitChat(String botId,String chatId) {
BaseResponse brp=new BaseResponse();
try {
if(StringUtils.isEmpty(botId)){
brp.setSuccess(false);
brp.setError_message("机器人id不为空");
return brp;
}
if(StringUtils.isEmpty(chatId)){
brp.setSuccess(false);
brp.setError_message("群id 不能为空");
return brp;
}
HashMap<String,String> bodyInfo = new HashMap<String,String>();
bodyInfo.put("wxid", botId);
bodyInfo.put("cmdType", "quitChat");
bodyInfo.put("chatId",chatId);
String sendMsg = AskQaHandler.sendMsg(botId, bodyInfo);
if("server is null".equals(sendMsg)){
brp.setSuccess(false);
brp.setError_message(sendMsg);
return brp;
}
brp.setData(sendMsg);
brp.setSuccess(true);
} catch (Exception e) {
log.info("quitChat------------"+e.getMessage());
brp.setSuccess(false);
brp.setError_message(e.getMessage());
}
return brp;
}
/**
* 发送消息
*
* @param
* @param
* @return
*/
@RequestMapping(value = "sendMsg", method = RequestMethod.POST)
public BaseResponse sendMsg(@RequestBody CommandInfo commandInfo) {
return commonService.sendMsg(commandInfo);
}
/**
* 获取最近聊天
*
* @param
* @param
* @return
*/
@RequestMapping(value = "getRecentChat", method = RequestMethod.POST)
public BaseResponse getRecentChat(@RequestBody CommandInfo commandInfo) {
return commonService.getRecentChatList(commandInfo);
}
/**
* 获取好友列表
*
* @param
* @param
* @return
*/
@RequestMapping(value = "getFriendList", method = RequestMethod.POST)
public BaseResponse getFriendList(@RequestBody CommandInfo commandInfo) {
return commonService.getFriendList(commandInfo);
}
/**
* 获取群列表
*
* @param
* @param
* @return
*/
@RequestMapping(value = "getChatList", method = RequestMethod.POST)
public BaseResponse getChatList(@RequestBody CommandInfo commandInfo) {
return commonService.getChatList(commandInfo);
}
/**
* 获取机器人列表
*
* @param
* @param
* @return
*/
@RequestMapping(value = "getBotList", method = RequestMethod.POST)
public BaseResponse getBotList(@RequestBody CommandInfo commandInfo) {
return commonService.getBotList(commandInfo);
}
/**
* 获取群成员信息
*
* @param
* @param
* @return
*/
@RequestMapping(value = "getChatMemberDetail", method = RequestMethod.POST)
public BaseResponse getChatMemberDetail(@RequestBody CommandInfo commandInfo) {
return commonService.getChatMemberDetail(commandInfo);
}
/**
* 设置群聊提醒
*
* @param
* @param
* @return
*/
@RequestMapping(value = "setChatNotification", method = RequestMethod.POST)
public BaseResponse setChatNotification(@RequestBody CommandInfo commandInfo) {
return commonService.setChatNotification(commandInfo);
}
/**
* 获取群聊提醒
*
* @param
* @param
* @return
*/
@RequestMapping(value = "getChatNotification", method = RequestMethod.POST)
public BaseResponse getChatNotification(@RequestBody CommandInfo commandInfo) {
return commonService.getChatNotification(commandInfo);
}
/**
* 置顶
*
* @param
* @param
* @return
*/
@RequestMapping(value = "chatToTop", method = RequestMethod.POST)
public BaseResponse chatToTop(@RequestBody CommandInfo commandInfo) {
return commonService.chatToTop(commandInfo);
}
/**
* 取消置顶
*
* @param
* @param
* @return
*/
@RequestMapping(value = "cancelChatToTop", method = RequestMethod.POST)
public BaseResponse cancelChatToTop(@RequestBody CommandInfo commandInfo) {
return commonService.cancelChatToTop(commandInfo);
}
}
@@ -0,0 +1,42 @@
package io.xiaoxi.db.controller;
import io.xiaoxi.db.model.common.CommandInfo;
import io.xiaoxi.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import javax.websocket.server.ServerEndpoint;
/**
* Websocket收发消息接口
*
* @author xuelei.wang
* @create time 2020-07-09 09:13:31
*/
@Controller
public class WebSocketMessageController {
@Autowired
private CommonService commonService;
/**
* 执行命令
* 0.发送文本消息
* 1.发送图片消息
* 2.卡片;
* <p>
* 20.更新机器人群列表;
* 21.更新机器人好友列表;
* 22.更新机器人列表
*
* @param cmdInfo 命令内容
*/
@MessageMapping({"/executeCommand"})
public void executeCommand(@Payload CommandInfo cmdInfo) {
commonService.executeCommand(cmdInfo);
}
}
@@ -0,0 +1,33 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import io.xiaoxi.db.model.AnswerDetailEntity;
/**
* @ClassName: HookTokenPriceAnswerDetailDao
* @Description: TODO
* @date: 2019年5月13日 下午4:10:37
*/
public interface AnswerDetailDao extends JpaRepository<AnswerDetailEntity,String>,JpaSpecificationExecutor<AnswerDetailEntity>{
}
@@ -0,0 +1,42 @@
package io.xiaoxi.db.dao;
import io.xiaoxi.db.model.BotChat;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
import javax.transaction.Transactional;
@Repository
public interface BotChatMapper extends JpaRepository<BotChat,String>, JpaSpecificationExecutor<BotChat> {
@Query(value = "from BotChat t where t.wxId=?1 and t.chatId=?2")
List<BotChat> findByChatIdAndWxId(String lineid, String chatId);
@Query(value = "from BotChat t where t.chatId=?1")
List<BotChat> findByChatId(String chatId);
@Query(value = "select t.wxId from BotChat t where t.chatId=?1")
List<String> getBotListByChatId(String chatId);
@Query(value = "select t from BotChat t where t.chatId in (?1)")
List<BotChat> findByChatIds(List<String> chatIdList);
@Modifying
@Transactional
@Query(value="DELETE FROM t_wxcb_bot_chat WHERE update_date IS NULL OR update_date <= DATE_SUB(NOW(),INTERVAL 300 DAY)",nativeQuery=true)
void deleteByUpdateData();
}
@@ -0,0 +1,34 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import io.xiaoxi.db.model.ChatOwnerEntity;
@Repository
public interface BotChatOwnerDao extends JpaRepository<ChatOwnerEntity,String>,JpaSpecificationExecutor<ChatOwnerEntity>{
@Query("select count(1) from ChatOwnerEntity c where c.chatId=?1")
public Integer chatOwned(String chatId);
}
@@ -0,0 +1,44 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import io.xiaoxi.db.model.BotMessageEntity;
@Repository
public interface BotMessageDao extends JpaRepository<BotMessageEntity,String>,JpaSpecificationExecutor<BotMessageEntity>{
@Query("select t from BotMessageEntity t where t.wxId=?1")
public List<BotMessageEntity> findByBotId(String botId);
@Query("select t from BotMessageEntity t")
public List<BotMessageEntity> findBotList();
}
@@ -0,0 +1,37 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import io.xiaoxi.db.model.ChatAiConfig;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ChatAiConfigDao extends JpaRepository<ChatAiConfig, String>, JpaSpecificationExecutor<ChatAiConfig> {
@Query("select t from ChatAiConfig t where t.chatId=?1 and t.delFlag='0'")
ChatAiConfig findByChatId(String chatId);
@Query("select t from ChatAiConfig t where t.delFlag='0'")
List<ChatAiConfig> findAllActive();
}
@@ -0,0 +1,41 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import io.xiaoxi.db.model.ChatMessageEntity;
@Repository
public interface ChatMessageDao extends JpaRepository<ChatMessageEntity,String>,JpaSpecificationExecutor<ChatMessageEntity>{
@Query("select t from ChatMessageEntity t where t.chatId=?1")
public List<ChatMessageEntity> findByChatId(String chatId);
}
@@ -0,0 +1,29 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import io.xiaoxi.db.model.ChatMessageRecordsEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface ChatMessageRecordsDao extends JpaRepository<ChatMessageRecordsEntity,String>, JpaSpecificationExecutor<ChatMessageRecordsEntity> {
}
@@ -0,0 +1,49 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import io.xiaoxi.db.model.DeviceEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public interface DeviceDao extends JpaRepository<DeviceEntity,String>, JpaSpecificationExecutor<DeviceEntity> {
@Query("select t from DeviceEntity t where t.appid=?1")
List<DeviceEntity> findByAppId(String appid);
@Query(value = "select appid appid,region_id regionId,head_img_url headImgUrl,nick_name nickName,user_name userName from t_wxcb_device", nativeQuery = true)
List<Map> getAll();
@Query(value = "select appid appid,region_id regionId,head_img_url headImgUrl,nick_name nickName,user_name userName from t_wxcb_device order by id asc limit ?1, ?2", nativeQuery = true)
List<Map> getPage(int start, int number);
@Query(value = "select count(1) from t_wxcb_device", nativeQuery = true)
Long getCount();
@Query("select device from DeviceEntity device")
Page<DeviceEntity> list(Pageable page);
}
@@ -0,0 +1,40 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import io.xiaoxi.db.model.ManageUserEntity;
@Repository
public interface ManageUserDao extends JpaRepository<ManageUserEntity,String>,JpaSpecificationExecutor<ManageUserEntity>{
@Query("select t from ManageUserEntity t where t.inviteCodes=?1")
public ManageUserEntity findByInviteCodes(String codeOnly);
@Query("select count(1) from ManageUserEntity c where c.wxid=?1 or c.phone=?2")
public Integer userOrPhoneExisted(String wxid, String phone);
}
@@ -0,0 +1,36 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import io.xiaoxi.db.model.ManageUserRelation;
@Repository
public interface ManageUserRelationDao extends JpaRepository<ManageUserRelation,String>,JpaSpecificationExecutor<ManageUserRelation>{
@Query("select count(1) from ManageUserRelation")
int findUserRelationCount();
@Query("select count(1) from ManageUserRelation where subWxid=?1")
int getSubwxid(String fromUserId);
}
@@ -0,0 +1,29 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import io.xiaoxi.db.model.MarketingTriggerRecordsEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface MarketingTriggerRecordsDao extends JpaRepository<MarketingTriggerRecordsEntity,String>, JpaSpecificationExecutor<MarketingTriggerRecordsEntity> {
}
@@ -0,0 +1,15 @@
package io.xiaoxi.db.dao;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import io.xiaoxi.db.model.Moments;
import java.util.List;
public interface MomentsDao extends JpaRepository<Moments, String> {
@Query(value = "select * from t_wxcb_moments where status='0' and del_flag = '0'", nativeQuery = true)
List<Moments> findSendSnsByStatus();
}
@@ -0,0 +1,28 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import io.xiaoxi.db.model.StrategyTriggerRecordsEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface StrategyTriggerRecordsDao extends JpaRepository<StrategyTriggerRecordsEntity,String>, JpaSpecificationExecutor<StrategyTriggerRecordsEntity> {
}
@@ -0,0 +1,79 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao;
import io.xiaoxi.db.model.UserAddBotAsFriendEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @ClassName: TokenPriceManageUserDao
* @Description: TODO
* @date: 2019年5月13日 下午4:09:40
*/
@Repository
public interface UserAddBotAsFriendDao extends JpaRepository<UserAddBotAsFriendEntity,String>, JpaSpecificationExecutor<UserAddBotAsFriendEntity> {
/**
* 检查是否已经加好友
*
* @param wxid 微信ID
* @param botWxId 机器人ID
* @return
* @author xuelei.wang 2019-10-31
*/
@Query("select count(1) from UserAddBotAsFriendEntity c where c.wxid=?1 and c.botWxid=?2 ")
Integer checkExists(String wxid, String botWxId);
/**
* 获取已经添加机器人为好友的数量
*
* @return
* @author xuelei.wang 2019-10-31
*/
@Query("select count(c.wxid) from UserAddBotAsFriendEntity c group by c.wxid ")
long getAddBotAsFriendCount();
/**
* @auth:zp
* @Title: getParentWxInfo
* @Description: TODO
* @param parentInvitationCode
* @return Collection<UserEntity>
* @date 2019年11月13日下午2:32:36
*/
@Query(value = "select f.* from t_line_saas_user u " +
" inner join t_line_saas_user_add_bot_as_friend f on u.wxid=f.wxid " +
" where u.invitation_code=?1 ",nativeQuery =true)
List<UserAddBotAsFriendEntity> getParentWxInfo(String parentInvitationCode);
/**
* @auth:zp
* @Title: findByWxId
* @Description: TODO
* @param wxid
* @return UserAddBotAsFriendEntity
* @date 2019年11月15日下午4:34:45
*/
@Query("select t from UserAddBotAsFriendEntity t where t.wxid=?1")
List<UserAddBotAsFriendEntity> findByWxId(String wxid);
}
@@ -0,0 +1,22 @@
package io.xiaoxi.db.dao.chatowner;
import io.xiaoxi.db.model.chatowner.ChatOwnerConfigComment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 占领群配置-文案配置表(ChatOwnerConfigComment)表数据库访问层
*
* @author xuelei.wang
* @create time 2020-06-05 11:21:02
*/
@Repository
public interface ChatOwnerConfigCommentDao extends JpaRepository<ChatOwnerConfigComment,String>, JpaSpecificationExecutor<ChatOwnerConfigComment> {
@Query(value = "select t from ChatOwnerConfigComment t order by t.sortNum")
List<ChatOwnerConfigComment> getChatOwnerConfigCommentList();
}
@@ -0,0 +1,18 @@
package io.xiaoxi.db.dao.faq;
import io.xiaoxi.db.model.faq.FaqEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface FaqDao extends JpaRepository<FaqEntity, String>, JpaSpecificationExecutor<FaqEntity> {
@Query(value = "select max(t.sortNum) from FaqEntity t ")
Integer getMaxSortNum();
@Query(value = "select t from FaqEntity t order by t.sortNum asc ")
Page<FaqEntity> findAllByPage(Pageable pageable);
}
@@ -0,0 +1,11 @@
package io.xiaoxi.db.dao.faq;
import io.xiaoxi.db.model.faq.FaqTriggerRecords;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface FaqTriggerRecordsDao extends JpaRepository<FaqTriggerRecords, String>, JpaSpecificationExecutor<FaqTriggerRecords> {
}
@@ -0,0 +1,19 @@
package io.xiaoxi.db.dao.filter;
import io.xiaoxi.db.model.filter.SpamMessageFilterConfigBlackList;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SpamMessageFilterConfigBlackListDao extends JpaRepository<SpamMessageFilterConfigBlackList, String>, JpaSpecificationExecutor<SpamMessageFilterConfigBlackList> {
@Query(value = "select * from t_spam_message_filter_config_black_list where del_flag = '0' and wxid=?1", nativeQuery = true)
List<SpamMessageFilterConfigBlackList> getSpamMessageFilterConfigBlackListList(String wxid);
}
@@ -0,0 +1,36 @@
/*
*
* * Copyright 2020-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.dao.friendreply;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import io.xiaoxi.db.model.friendreply.AddedFriendReply;
/**
* @ClassName: AddedFriendReplyDao
* @Description: TODO
* @date: 2020年5月20日 下午5:31:01
*/
public interface AddedFriendReplyDao extends JpaRepository<AddedFriendReply,String>,JpaSpecificationExecutor<AddedFriendReply>{
@Query(value = "select * from t_added_friend_reply where del_flag = '0' order by sort_num", nativeQuery = true)
List<AddedFriendReply> getAddedFriendReply();
}
@@ -0,0 +1,31 @@
package io.xiaoxi.db.dao.kfgzt;
import io.xiaoxi.db.model.kfgzt.KfgztBotChat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* 机器人群(WxBotChat)表数据库访问层
*
* @author xuelei.wang
* @create time 2020-07-08 11:13:31
*/
@Repository
public interface KfgztBotChatDao extends JpaRepository<KfgztBotChat,String>, JpaSpecificationExecutor<KfgztBotChat> {
@Query("select t from KfgztBotChat t where t.wxId=?1 and t.chatId=?2")
List<KfgztBotChat> findByWxIdAndChatId(String wxId, String chatId);
@Query("select t from KfgztBotChat t where t.wxId=?1 ")
List<KfgztBotChat> findAllByWxId(String wxId);
@Modifying
@Query(value = "update t_kfgzt_bot_chat set status='2' where status='1' and update_date<?1", nativeQuery = true)
void updateValidChatsStatus(Date addDays);
}
@@ -0,0 +1,31 @@
package io.xiaoxi.db.dao.kfgzt;
import io.xiaoxi.db.model.kfgzt.KfgztBotFriends;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* 机器人好友信息(WxBotFriends)表数据库访问层
*
* @author xuelei.wang
* @create time 2020-07-08 11:13:31
*/
@Repository
public interface KfgztBotFriendsDao extends JpaRepository<KfgztBotFriends, String>, JpaSpecificationExecutor<KfgztBotFriends> {
@Query("select t from KfgztBotFriends t where t.wxId=?1 and t.friendWxId=?2")
List<KfgztBotFriends> findByWxIdAndFriendsId(String botWxId, String friendWxId);
@Query("select t from KfgztBotFriends t where t.wxId=?1 ")
List<KfgztBotFriends> findAllByWxId(String wxId);
@Modifying
@Query(value = "update t_kfgzt_bot_friends set status='2' where status='1' and update_date<?1", nativeQuery = true)
void updateValidFriendsStatus(Date date);
}
@@ -0,0 +1,22 @@
package io.xiaoxi.db.dao.marketing;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import io.xiaoxi.db.model.marketing.MarketingAnswer;
/**
* 模块编号:io.icc.mappers QuestionAnswerMapper
* 作 者:xuelei.wang
* 创建时间:2019/11/7 15:58
* 修改编号:1
* 描 述:应答机器人
*/
@Repository
public interface OrderMarketingAnswerMapper extends JpaRepository<MarketingAnswer,String>, JpaSpecificationExecutor<MarketingAnswer> {
}
@@ -0,0 +1,21 @@
package io.xiaoxi.db.dao.marketing;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import io.xiaoxi.db.model.marketing.MarketingAsk;
/**
* 模块编号:io.icc.mappers QuestionAnswerMapper
* 作 者:xuelei.wang
* 创建时间:2019/11/7 15:58
* 修改编号:1
* 描 述:问答机器人
*/
@Repository
public interface OrderMarketingAskMapper extends JpaRepository<MarketingAsk,String>, JpaSpecificationExecutor<MarketingAsk> {
}
@@ -0,0 +1,19 @@
package io.xiaoxi.db.dao.marketing;
import io.xiaoxi.db.model.marketing.MarketingEchoGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* 模块编号:io.icc.mappers QuestionAnswerMapper
* 作 者:xuelei.wang
* 创建时间:2019/11/7 15:58
* 修改编号:1
* 描 述:附和机器人
*/
@Repository
public interface OrderMarketingEchoGroupMapper extends JpaRepository<MarketingEchoGroup,String>, JpaSpecificationExecutor<MarketingEchoGroup> {
}
@@ -0,0 +1,20 @@
package io.xiaoxi.db.dao.marketing;
import io.xiaoxi.db.model.marketing.MarketingEcho;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
/**
* 模块编号:io.icc.mappers QuestionAnswerMapper
* 作 者:xuelei.wang
* 创建时间:2019/11/7 15:58
* 修改编号:1
* 描 述:附和机器人
*/
@Repository
public interface OrderMarketingEchoMapper extends JpaRepository<MarketingEcho,String>, JpaSpecificationExecutor<MarketingEcho> {
}
@@ -0,0 +1,18 @@
package io.xiaoxi.db.dao.marketing;
import io.xiaoxi.db.model.marketing.Marketing;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface OrderMarketingMapper extends JpaRepository<Marketing, String>, JpaSpecificationExecutor<Marketing> {
@Query(value = "select t from Marketing t where marketingTaskId =?1 order by t.sortNum asc")
List<Marketing> findByOrderId(String marketingTaskId);
}
@@ -0,0 +1,22 @@
package io.xiaoxi.db.dao.marketingrecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import io.xiaoxi.db.model.marketingrecord.MarketingChat;
public interface MarketingChatDao extends JpaRepository<MarketingChat, String> {
@Query(value = "select * from t_marketing_chat where id = :id", nativeQuery = true)
MarketingChat getById(@Param("id") String id);
@Modifying
@Transactional
@Query(value="update t_marketing_chat set status='2' and end_date=now() and bot=?2 where id=?1",nativeQuery=true)
void updateMarketingChat(String id, String botName);
}
@@ -0,0 +1,15 @@
package io.xiaoxi.db.dao.marketingrecord;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import io.xiaoxi.db.model.marketingrecord.MarketingTask;
public interface MarketingTaskDao extends JpaRepository<MarketingTask, String> {
@Query("select t from MarketingTask t where t.status='0' and t.pushDate<=now()")
List<MarketingTask> getMarketingTaskList();
}
@@ -0,0 +1,162 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* @ClassName: HookTokenPriceAnswerDetailEntity
* @Description: TODO
* @date: 2019年5月13日 下午3:43:39
*/
@Entity
@Table(name="t_wxcb_answer_detail")
public class AnswerDetailEntity extends BaseEntity {
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public AnswerDetailEntity() {}
@Column(name = "bot_wxid")
private String botWxid;
@Column(name = "chat_id")
private String chatId;
@Column(name = "chat_name")
private String chatName;
@Column(name = "answer_wxid")
private String answerWxid;
@Column(name = "answer_type")
private String answerType;
@Column(name = "answer_nickname")
private String answerNickname;
@Column(name = "content")
private String content;
/**
* @return botWxid
*/
public String getBotWxid() {
return botWxid;
}
/**
* @param botWxid 要设置的 botWxid
*/
public void setBotWxid(String botWxid) {
this.botWxid = botWxid;
}
/**
* @return chatId
*/
public String getChatId() {
return chatId;
}
/**
* @param chatId 要设置的 chatId
*/
public void setChatId(String chatId) {
this.chatId = chatId;
}
/**
* @return chatName
*/
public String getChatName() {
return chatName;
}
/**
* @param chatName 要设置的 chatName
*/
public void setChatName(String chatName) {
this.chatName = chatName;
}
/**
* @return answerWxid
*/
public String getAnswerWxid() {
return answerWxid;
}
/**
* @param answerWxid 要设置的 answerWxid
*/
public void setAnswerWxid(String answerWxid) {
this.answerWxid = answerWxid;
}
/**
* @return answerNickname
*/
public String getAnswerNickname() {
return answerNickname;
}
/**
* @param answerNickname 要设置的 answerNickname
*/
public void setAnswerNickname(String answerNickname) {
this.answerNickname = answerNickname;
}
/**
* @return content
*/
public String getContent() {
return content;
}
/**
* @param content 要设置的 content
*/
public void setContent(String content) {
this.content = content;
}
/**
* @return answerType
*/
public String getAnswerType() {
return answerType;
}
/**
* @param answerType 要设置的 answerType
*/
public void setAnswerType(String answerType) {
this.answerType = answerType;
}
}
@@ -0,0 +1,152 @@
/*
*
* * Copyright 2018-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import io.xiaoxi.utils.IdGen;
/**
* @ClassName: BaseEntity
* @Description: TODO
* @date: 2018年4月24日 下午2:22:36
*/
@MappedSuperclass
public abstract class BaseEntity implements Serializable{
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public BaseEntity(){};
@Id
@Column(name = "id")
protected String id; // 主键
@Column(name = "create_by")
protected String createBy; // 创建者
@Column(name = "create_date")
protected Date createDate; // 创建日期
@Column(name = "update_by")
protected String updateBy; // 更新者
@Column(name = "update_date")
protected Date updateDate; // 更新日期
@Column(name = "del_flag")
protected String delFlag; // 删除标记(0:正常;1:删除;)
@PrePersist
public void preInsert() {
this.id=IdGen.uuid();
this.createDate = new Date();//Calendar.getInstance().getTime();
this.delFlag="0";
}
@PreUpdate
public void preUpdate() {
this.updateDate = new Date();//Calendar.getInstance().getTime();
}
/**
* @return id
*/
public String getId() {
return id;
}
/**
* @param id 要设置的 id
*/
public void setId(String id) {
this.id = id;
}
/**
* @return createBy
*/
public String getCreateBy() {
return createBy;
}
/**
* @param createBy 要设置的 createBy
*/
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
/**
* @return createDate
*/
public Date getCreateDate() {
return createDate;
}
/**
* @param createDate 要设置的 createDate
*/
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
/**
* @return updateBy
*/
public String getUpdateBy() {
return updateBy;
}
/**
* @param updateBy 要设置的 updateBy
*/
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
/**
* @return updateDate
*/
public Date getUpdateDate() {
return updateDate;
}
/**
* @param updateDate 要设置的 updateDate
*/
public void setUpdateDate(Date updateDate) {
this.updateDate = updateDate;
}
/**
* @return delFlag
*/
public String getDelFlag() {
return delFlag;
}
/**
* @param delFlag 要设置的 delFlag
*/
public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
}
@@ -0,0 +1,63 @@
package io.xiaoxi.db.model;
public class BaseResponse {
private Boolean success;
private Integer error_code;
private String error_message;
private Object data;
public BaseResponse(Boolean success, String error_message, Object data) {
this.success = success;
this.error_message = error_message;
this.data = data;
}
public BaseResponse(String error_message) {
this.success = false;
this.error_message = error_message;
}
public BaseResponse(Object data) {
this.success = true;
this.data = data;
}
public BaseResponse() {
}
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public Integer getError_code() {
return error_code;
}
public void setError_code(Integer error_code) {
this.error_code = error_code;
}
public String getError_message() {
return error_message;
}
public void setError_message(String error_message) {
this.error_message = error_message;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
@@ -0,0 +1,199 @@
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* 模块编号:io.xiaoxi.db.model
* 作 者:xuelei.wang
* 创建时间:2019/11/19 15:07
* 修改编号:1
* 描 述:问询机器人
*/
@Entity
@Table(name = "t_wxcb_bot_chat")
public class BotChat extends BaseEntity {
public BotChat() {
}
public BotChat(String chatId, Integer botCount, String title, Integer usrCnt, String botNickname) {
this.chatId = chatId;
this.title = title;
this.usrCnt = usrCnt;
this.botNickname = botNickname;
}
@Transient
private String relationId;
@Column(name = "wx_id")
private String wxId;
@Column(name = "chat_id")
private String chatId;
@Column(name = "usr_cnt")
private Integer usrCnt;
@Column(name = "title")
private String title;
@Column(name = "username")
private String userName;
@Column(name = "bot_nickname")
private String botNickname;
/**
* 1:自动获取,0:手动添加
*/
@Column(name = "status")
private String chatStatus;
/**
* 0:需要验证,1:禁言,2:封号,3:正常
*/
@Transient
private String botStatus;
/**
* 是否可发言
*/
@Transient
private boolean canSendMsg;
/**
* 可发言机器人数量
*/
@Transient
private long canSendMsgCount;
/**
* 不可发言机器人数量
*/
@Transient
private long canNotSendMsgCount;
/**
* 机器人进群数量
*/
@Transient
private int joinChatCount;
public int getJoinChatCount() {
return joinChatCount;
}
public void setJoinChatCount(int joinChatCount) {
this.joinChatCount = joinChatCount;
}
public String getWxId() {
return wxId;
}
public void setWxId(String wxId) {
this.wxId = wxId;
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public Integer getUsrCnt() {
return usrCnt;
}
public void setUsrCnt(Integer usrCnt) {
this.usrCnt = usrCnt;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getBotNickname() {
return botNickname;
}
public void setBotNickname(String botNickname) {
this.botNickname = botNickname;
}
public String getChatStatus() {
return chatStatus;
}
public void setChatStatus(String chatStatus) {
this.chatStatus = chatStatus;
}
public String getBotStatus() {
return botStatus;
}
public void setBotStatus(String botStatus) {
this.botStatus = botStatus;
}
public boolean isCanSendMsg() {
return canSendMsg;
}
public void setCanSendMsg(boolean canSendMsg) {
this.canSendMsg = canSendMsg;
}
public long getCanSendMsgCount() {
return canSendMsgCount;
}
public void setCanSendMsgCount(long canSendMsgCount) {
this.canSendMsgCount = canSendMsgCount;
}
public long getCanNotSendMsgCount() {
return canNotSendMsgCount;
}
public void setCanNotSendMsgCount(long canNotSendMsgCount) {
this.canNotSendMsgCount = canNotSendMsgCount;
}
public String getRelationId() {
return relationId;
}
public void setRelationId(String relationId) {
this.relationId = relationId;
}
}
@@ -0,0 +1,170 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name="t_wxcb_bot_message")
public class BotMessageEntity extends BaseEntity {
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public BotMessageEntity() {}
@Column(name = "friend_cnt")
private String friendCnt;
@Column(name = "wx_id")
private String wxId;
@Column(name = "bot_img")
private String botImg;
@Column(name = "bot_nickname")
private String botNickname;
/**
* 进群最大上限
*/
@Column(name = "max_chat")
private Integer maxChat;
/**
* 进群超过上限后提示
*/
@Column(name = "max_chat_resp")
private String maxChatResp;
/**
* 机器人总的未读消息数量
*/
@Transient
private long unreadMessage;
/**
* 是否在线:1:在线,0:不在线
*/
@Transient
private String online;
/**
* @return friend_cnt
*/
public String getFriendCnt() {
return friendCnt;
}
/**
* @param friend_cnt 要设置的 friend_cnt
*/
public void setFriendCnt(String friendCnt) {
this.friendCnt = friendCnt;
}
/**
* @return wxId
*/
public String getWxId() {
return wxId;
}
/**
* @param wxId 要设置的 wxId
*/
public void setWxId(String wxId) {
this.wxId = wxId;
}
/**
* @return botImg
*/
public String getBotImg() {
return botImg;
}
/**
* @param botImg 要设置的 botImg
*/
public void setBotImg(String botImg) {
this.botImg = botImg;
}
/**
* @return botNickname
*/
public String getBotNickname() {
return botNickname;
}
/**
* @param botNickname 要设置的 botNickname
*/
public void setBotNickname(String botNickname) {
this.botNickname = botNickname;
}
/**
* @return maxChat
*/
public Integer getMaxChat() {
return maxChat;
}
/**
* @param maxChat 要设置的 maxChat
*/
public void setMaxChat(Integer maxChat) {
this.maxChat = maxChat;
}
/**
* @return maxChatResp
*/
public String getMaxChatResp() {
return maxChatResp;
}
/**
* @param maxChatResp 要设置的 maxChatResp
*/
public void setMaxChatResp(String maxChatResp) {
this.maxChatResp = maxChatResp;
}
public long getUnreadMessage() {
return unreadMessage;
}
public void setUnreadMessage(long unreadMessage) {
this.unreadMessage = unreadMessage;
}
public String getOnline() {
return online;
}
public void setOnline(String online) {
this.online = online;
}
}
@@ -0,0 +1,90 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 群AI配置实体类
* 用于保存群的ai_key配置,即使机器人掉线后记录被删除,配置仍然保留
*/
@Entity
@Table(name = "t_wxcb_chat_ai_config")
public class ChatAiConfig extends BaseEntity {
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public ChatAiConfig() {}
@Column(name = "chat_id")
private String chatId;
@Column(name = "ai_key")
private String aiKey;
@Column(name = "ai_key_name")
private String aiKeyName;
/**
* @return chatId
*/
public String getChatId() {
return chatId;
}
/**
* @param chatId 要设置的 chatId
*/
public void setChatId(String chatId) {
this.chatId = chatId;
}
/**
* @return aiKey
*/
public String getAiKey() {
return aiKey;
}
/**
* @param aiKey 要设置的 aiKey
*/
public void setAiKey(String aiKey) {
this.aiKey = aiKey;
}
/**
* @return aiKeyName
*/
public String getAiKeyName() {
return aiKeyName;
}
/**
* @param aiKeyName 要设置的 aiKeyName
*/
public void setAiKeyName(String aiKeyName) {
this.aiKeyName = aiKeyName;
}
}
@@ -0,0 +1,101 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import java.io.Serializable;
/**
* @ClassName: ChatInfo
* @Description: TODO
* @date: 2019年12月18日 下午4:02:48
*/
public class ChatInfo implements Serializable{
private static final long serialVersionUID = 1L;
public String id;
public String title;
public int cnt;
public String username;
public String nickname;
public String wxid;
public String avatar;
private String account;
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getCnt() {
return cnt;
}
public void setCnt(int cnt) {
this.cnt = cnt;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
}
@@ -0,0 +1,105 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="t_wxcb_chat_message")
public class ChatMessageEntity extends BaseEntity {
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public ChatMessageEntity() {}
@Column(name = "chat_type")//0 公域 1 私域
private String chayType="0";
@Column(name = "chat_id")
private String chatId;
@Column(name = "chat_name")
private String chatName;
@Column(name = "chatMember_cnt")
private String chatMemberCnt;
/**
* @return chayType
*/
public String getChayType() {
return chayType;
}
/**
* @param chayType 要设置的 chayType
*/
public void setChayType(String chayType) {
this.chayType = chayType;
}
/**
* @return chatId
*/
public String getChatId() {
return chatId;
}
/**
* @param chatId 要设置的 chatId
*/
public void setChatId(String chatId) {
this.chatId = chatId;
}
/**
* @return chatName
*/
public String getChatName() {
return chatName;
}
/**
* @param chatName 要设置的 chatName
*/
public void setChatName(String chatName) {
this.chatName = chatName;
}
/**
* @return chatMemberCnt
*/
public String getChatMemberCnt() {
return chatMemberCnt;
}
/**
* @param chatMemberCnt 要设置的 chatMemberCnt
*/
public void setChatMemberCnt(String chatMemberCnt) {
this.chatMemberCnt = chatMemberCnt;
}
}
@@ -0,0 +1,82 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name="t_wxcb_bot_message_records")
public class ChatMessageRecordsEntity extends BaseEntity {
@Column(name = "wxid")
private String wxId;
@Column(name = "chat_id")
private String chatId;
@Column(name = "content")
private String content;
@Transient
private String fromId;
public String getWxId() {
return wxId;
}
public void setWxId(String wxId) {
this.wxId = wxId;
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getFromId() {
return fromId;
}
public void setFromId(String fromId) {
this.fromId = fromId;
}
public ChatMessageRecordsEntity() {
}
public ChatMessageRecordsEntity(String wxId, String chatId, String content, String fromId) {
this.wxId = wxId;
this.chatId = chatId;
this.content = content;
this.fromId = fromId;
}
}
@@ -0,0 +1,73 @@
/*
*
* * Copyright 2020-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import java.util.ArrayList;
import java.util.List;
/**
* @ClassName: ChatMsg
* @Description: TODO
* @date: 2020年1月14日 下午3:11:26
*/
public class ChatMsgHandler {
private String askBotId;
private String answerBotId;
public List<String> echoBotId=new ArrayList<>();
private String chatId;
/**
* @return askBotId
*/
public String getAskBotId() {
return askBotId;
}
/**
* @param askBotId 要设置的 askBotId
*/
public void setAskBotId(String askBotId) {
this.askBotId = askBotId;
}
/**
* @return answerBotId
*/
public String getAnswerBotId() {
return answerBotId;
}
/**
* @param answerBotId 要设置的 answerBotId
*/
public void setAnswerBotId(String answerBotId) {
this.answerBotId = answerBotId;
}
/**
* @return chatId
*/
public String getChatId() {
return chatId;
}
/**
* @param chatId 要设置的 chatId
*/
public void setChatId(String chatId) {
this.chatId = chatId;
}
}
@@ -0,0 +1,124 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="t_wxcb_chat_owner")
public class ChatOwnerEntity extends BaseEntity{
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public ChatOwnerEntity() {}
@Column(name = "chat_id")
private String chatId;
@Column(name = "chat_name")
private String chatName;
@Column(name = "wxid")
private String wxid;
@Column(name = "nickname")
private String nickname;
@Column(name = "bot_wxid")
private String botWxid;
/**
* @return chatId
*/
public String getChatId() {
return chatId;
}
/**
* @param chatId 要设置的 chatId
*/
public void setChatId(String chatId) {
this.chatId = chatId;
}
/**
* @return chatName
*/
public String getChatName() {
return chatName;
}
/**
* @param chatName 要设置的 chatName
*/
public void setChatName(String chatName) {
this.chatName = chatName;
}
/**
* @return wxid
*/
public String getWxid() {
return wxid;
}
/**
* @param wxid 要设置的 wxid
*/
public void setWxid(String wxid) {
this.wxid = wxid;
}
/**
* @return nickname
*/
public String getNickname() {
return nickname;
}
/**
* @param nickname 要设置的 nickname
*/
public void setNickname(String nickname) {
this.nickname = nickname;
}
/**
* @return botWxid
*/
public String getBotWxid() {
return botWxid;
}
/**
* @param botWxid 要设置的 botWxid
*/
public void setBotWxid(String botWxid) {
this.botWxid = botWxid;
}
}
@@ -0,0 +1,235 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name = "t_wxcb_device")
public class DeviceEntity extends BaseEntity {
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public DeviceEntity() {
}
@Column(name = "appid")
private String appid;
@Column(name = "region_id")
private Integer regionId;
@Column(name = "nick_name")
private String nickName;
@Column(name = "user_name")
private String userName;
@Column(name = "head_img_url")
private String headImgUrl;
@Column(name = "nkey")
private String nkey;
@Column(name = "uuid")
private String uuid;
@Column(name = "wxid")
private String wxid;
@Column(name = "status")
private Integer status;
@Column(name = "ai_channel")
private Integer aiChannel;
@Column(name = "ai_key")
private String key;
@Column(name = "current_chat_room_contact_seq")
private Long currentChatRoomContactSeq;
@Column(name = "current_wxcontact_seq")
private Long currentWxcontactSeq;
@Column(name = "enable_private_chat")
private Integer enablePrivateChat;
@Column(name = "enable_group_chat")
private Integer enableGroupChat;
@Column(name = "enable_join_friend_welcome")
private Integer enableJoinFriendWelcome;
public Integer getEnablePrivateChat() {
return enablePrivateChat;
}
public void setEnablePrivateChat(Integer enablePrivateChat) {
this.enablePrivateChat = enablePrivateChat;
}
public Integer getEnableGroupChat() {
return enableGroupChat;
}
public void setEnableGroupChat(Integer enableGroupChat) {
this.enableGroupChat = enableGroupChat;
}
public Integer getEnableJoinFriendWelcome() {
return enableJoinFriendWelcome;
}
public void setEnableJoinFriendWelcome(Integer enableJoinFriendWelcome) {
this.enableJoinFriendWelcome = enableJoinFriendWelcome;
}
public String getJoinFriendWelcome() {
return joinFriendWelcome;
}
public void setJoinFriendWelcome(String joinFriendWelcome) {
this.joinFriendWelcome = joinFriendWelcome;
}
@Column(name = "join_friend_welcome")
private String joinFriendWelcome;
public Long getCurrentChatRoomContactSeq() {
return currentChatRoomContactSeq;
}
public void setCurrentChatRoomContactSeq(Long currentChatRoomContactSeq) {
this.currentChatRoomContactSeq = currentChatRoomContactSeq;
}
public Long getCurrentWxcontactSeq() {
return currentWxcontactSeq;
}
public void setCurrentWxcontactSeq(Long currentWxcontactSeq) {
this.currentWxcontactSeq = currentWxcontactSeq;
}
public Integer getAiChannel() {
return aiChannel;
}
public void setAiChannel(Integer aiChannel) {
this.aiChannel = aiChannel;
}
@Transient
private String code;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getNkey() {
return nkey;
}
public void setNkey(String nkey) {
this.nkey = nkey;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public Integer getRegionId() {
return regionId;
}
public void setRegionId(Integer regionId) {
this.regionId = regionId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getHeadImgUrl() {
return headImgUrl;
}
public void setHeadImgUrl(String headImgUrl) {
this.headImgUrl = headImgUrl;
}
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
@@ -0,0 +1,178 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="t_wxcb_manage_user")
public class ManageUserEntity extends BaseEntity {
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = 1L;
public ManageUserEntity() {}
@Column(name = "phone")
private String phone;
@Column(name = "wxid")
private String wxid;
@Column(name = "username")
private String username;
@Column(name = "nickname")
private String nickname;
@Column(name = "avatar")
private String avatar;
@Column(name = "wallet")
private String wallet;
@Column(name = "supflag")
private String supflag;
@Column(name = "invite_codes")
private String inviteCodes;
/**
* @return phone
*/
public String getPhone() {
return phone;
}
/**
* @param phone 要设置的 phone
*/
public void setPhone(String phone) {
this.phone = phone;
}
/**
* @return wxid
*/
public String getWxid() {
return wxid;
}
/**
* @param wxid 要设置的 wxid
*/
public void setWxid(String wxid) {
this.wxid = wxid;
}
/**
* @return username
*/
public String getUsername() {
return username;
}
/**
* @param username 要设置的 username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return nickname
*/
public String getNickname() {
return nickname;
}
/**
* @param nickname 要设置的 nickname
*/
public void setNickname(String nickname) {
this.nickname = nickname;
}
/**
* @return avatar
*/
public String getAvatar() {
return avatar;
}
/**
* @param avatar 要设置的 avatar
*/
public void setAvatar(String avatar) {
this.avatar = avatar;
}
/**
* @return wallet
*/
public String getWallet() {
return wallet;
}
/**
* @param wallet 要设置的 wallet
*/
public void setWallet(String wallet) {
this.wallet = wallet;
}
/**
* @return supflag
*/
public String getSupflag() {
return supflag;
}
/**
* @param supflag 要设置的 supflag
*/
public void setSupflag(String supflag) {
this.supflag = supflag;
}
/**
* @return inviteCodes
*/
public String getInviteCodes() {
return inviteCodes;
}
/**
* @param inviteCodes 要设置的 inviteCodes
*/
public void setInviteCodes(String inviteCodes) {
this.inviteCodes = inviteCodes;
}
}
@@ -0,0 +1,39 @@
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="t_wxcb_manage_user_relation")
public class ManageUserRelation extends BaseEntity {
/**
*
*/
private static final long serialVersionUID = -6922942014121312621L;
@Column(name = "sup_wxid")
private String supWxid;
@Column(name = "sub_wxid")
private String subWxid;
public String getSupWxid() {
return supWxid;
}
public void setSupWxid(String supWxid) {
this.supWxid = supWxid;
}
public String getSubWxid() {
return subWxid;
}
public void setSubWxid(String subWxid) {
this.subWxid = subWxid;
}
}
@@ -0,0 +1,60 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="t_wxcb_marketing_trigger_records")
public class MarketingTriggerRecordsEntity extends BaseEntity {
@Column(name = "chat_id")
private String chatId;
@Column(name = "wxid")
private String wxid;
@Column(name = "trigger_key")
private String triggerKey;
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getTriggerKey() {
return triggerKey;
}
public void setTriggerKey(String triggerKey) {
this.triggerKey = triggerKey;
}
}
@@ -0,0 +1,53 @@
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="t_wxcb_moments")
public class Moments extends BaseEntity {
@Column(name = "content")
private String content;
@Column(name = "image_url")
private String imageUrl;
@Column(name = "status")
private String status;
public Moments() {
}
public Moments(String content, String imageUrl, String status) {
this.content = content;
this.imageUrl = imageUrl;
this.status = status;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
@@ -0,0 +1,91 @@
/*
*
* * Copyright 2019-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="t_wxcb_strategy_trigger_records")
public class StrategyTriggerRecordsEntity extends BaseEntity {
@Column(name = "chat_id")
private String chatId;
@Column(name = "wxid")
private String wxid;
@Column(name = "trigger_key")
private String triggerKey;
@Column(name = "trigger_content")
private String triggerContent;
@Column(name = "question_id")
private String questionId;
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getTriggerKey() {
return triggerKey;
}
public void setTriggerKey(String triggerKey) {
this.triggerKey = triggerKey;
}
public String getTriggerContent() {
return triggerContent;
}
public void setTriggerContent(String triggerContent) {
this.triggerContent = triggerContent;
}
/**
* @return questionId
*/
public String getQuestionId() {
return questionId;
}
/**
* @param questionId 要设置的 questionId
*/
public void setQuestionId(String questionId) {
this.questionId = questionId;
}
}
@@ -0,0 +1,44 @@
package io.xiaoxi.db.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 模块编号:io.xiaoxi.db.model
* 作 者:xuelei.wang
* 创建时间:2019/10/27 23:07
* 修改编号:1
* 描 述:
*/
@Entity
@Table(name = "t_wxcb_user_add_bot_as_friend")
public class UserAddBotAsFriendEntity extends BaseEntity {
/**
* @Fields serialVersionUID : TODO
*/
private static final long serialVersionUID = -6377016029467317286L;
@Column(name = "wxid")
private String wxid;
@Column(name = "bot_wxid")
private String botWxid;
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getBotWxid() {
return botWxid;
}
public void setBotWxid(String botWxid) {
this.botWxid = botWxid;
}
}
@@ -0,0 +1,62 @@
package io.xiaoxi.db.model.chatowner;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 占领群配置-文案配置表(ChatOwnerConfigComment)实体类
*
* @author xuelei.wang
* @create time 2020-06-05 11:21:02
*/
@Entity
@Table(name = "t_chat_owner_config_comment")
public class ChatOwnerConfigComment extends BaseEntity {
private static final long serialVersionUID = 209384563583214034L;
/**
* 0:文字,1:图片
*/
@Column(name = "content_type")
private String contentType;
/**
* 名称
*/
@Column(name = "content")
private String content;
/**
* 问题排序
*/
@Column(name = "sort_num")
private Integer sortNum;
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
@@ -0,0 +1,41 @@
package io.xiaoxi.db.model.common;
public class BotFriend {
private String account;
private String wxid;
private String avatar;
private String nickname;
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
}
@@ -0,0 +1,47 @@
package io.xiaoxi.db.model.common;
/**
* 模块编号:io.icchain.wxcontractbot.entity.agent BotOnlineStatusInfo
* 作 者:xuelei.wang
* 创建时间:2020/4/21 20:20
* 修改编号:1
* 描 述:DES
*/
public class BotOnlineStatusInfo {
/**
* wx
*/
private String platformType;
/**
* 1:在线,0:不在线
*/
private String online="0";
/**
* 微信Id
*/
private String platformId;
public String getPlatformType() {
return platformType;
}
public void setPlatformType(String platformType) {
this.platformType = platformType;
}
public String getOnline() {
return online;
}
public void setOnline(String online) {
this.online = online;
}
public String getPlatformId() {
return platformId;
}
public void setPlatformId(String platformId) {
this.platformId = platformId;
}
}
@@ -0,0 +1,47 @@
package io.xiaoxi.db.model.common;
/**
* 模块编号:io.icchain.wxcontractbot.entity.common BotRoleInfo
* 作 者:xuelei.wang
* 创建时间:2020/5/19 17:30
* 修改编号:1
* 描 述:DES
*/
public class BotRoleInfo {
private String function;
private String id;
private String role;
private String service;
public String getFunction() {
return function;
}
public void setFunction(String function) {
this.function = function;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getService() {
return service;
}
public void setService(String service) {
this.service = service;
}
}
@@ -0,0 +1,48 @@
package io.xiaoxi.db.model.common;
/**
* 模块编号:io.xiaoxi.db.model.common ChatMemberInfo
* 作 者:xuelei.wang
* 创建时间:2020/7/10 14:39
* 修改编号:1
* 描 述:DES
*/
public class ChatMemberInfo {
private String wxid;
private String avatar;
private String nickname;
private String account;
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
}
@@ -0,0 +1,175 @@
package io.xiaoxi.db.model.common;
import com.alibaba.fastjson.JSON;
import io.xiaoxi.db.model.kfgzt.KfgztMessageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.DateFormat;
import java.util.Date;
/**
* 模块编号:io.xiaoxi.db.entity CommandInfo
* 作 者:xuelei.wang
* 创建时间:2020/7/9 9:13
* 修改编号:1
* 描 述:DES
*/
public class CommandInfo {
private Logger log = LoggerFactory.getLogger(CommandInfo.class);
public CommandInfo(String timeSpan) {
if (StringUtils.isNotEmpty(timeSpan)) {
try {
this.createTime = DateFormatUtils.format(NumberUtils.toLong(timeSpan, System.currentTimeMillis()), "yyyy-MM-dd HH:mm:ss");
this.timestamp = DateUtils.parseDate(this.createTime, "yyyy-MM-dd HH:mm:ss").getTime();
} catch (Exception ex) {
log.info("CommandInfo parse date error:{}", JSON.toJSON(ex));
}
} else {
Date now = new Date();
this.timestamp = now.getTime();
this.createTime = DateFormatUtils.format(now, "yyyy-MM-dd HH:mm:ss");
}
}
public CommandInfo() {
Date now = new Date();
this.timestamp = now.getTime();
this.createTime = DateFormatUtils.format(now, "yyyy-MM-dd HH:mm:ss");
}
/**
* 命令类型
* <p>
* 0.发送文本消息
* 1.发送图片消息
* 2.卡片;
* <p>
* 20.更新机器人群列表;
* 21.更新机器人好友列表;
* 22.更新机器人列表
*/
private String type;
/**
* 机器人ID
*/
private String wxId;
/**
* 要发送的人的ID或者群ID
*/
private String sendTo;
/**
* 是否是群聊0:不是,1:是
*/
private String isChat = "0";
private KfgztMessageInfo param;
public KfgztMessageInfo getParam() {
return param;
}
public void setParam(KfgztMessageInfo param) {
this.param = param;
}
/**
* 返回结果
*/
private Object content;
private String createTime;
private long timestamp;
private String fromId;
private String fromName;
private String fromAvatar;
public String getFromName() {
return fromName;
}
public void setFromName(String fromName) {
this.fromName = fromName;
}
public String getSendTo() {
return sendTo;
}
public void setSendTo(String sendTo) {
this.sendTo = sendTo;
}
public String getIsChat() {
return isChat;
}
public void setIsChat(String isChat) {
this.isChat = isChat;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getWxId() {
return wxId;
}
public void setWxId(String wxId) {
this.wxId = wxId;
}
public void setFromId(String fromId) {
this.fromId = fromId;
}
public String getFromId() {
return fromId;
}
public Object getContent() {
return content;
}
public void setContent(Object content) {
this.content = content;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getFromAvatar() {
return fromAvatar;
}
public void setFromAvatar(String fromAvatar) {
this.fromAvatar = fromAvatar;
}
}
@@ -0,0 +1,40 @@
package io.xiaoxi.db.model.common;
public class SendCard {
private String title;
private String summary;
private String imageUrl;
private String link;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getLink() {
return link;
}
public void setLink(String link) {
this.link = link;
}
}
@@ -0,0 +1,76 @@
package io.xiaoxi.db.model.faq;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* 模块编号:io.icchain.wxcontractbot.entity.faq
* 作 者:xuelei.wang
* 创建时间:2020/4/16 15:07
* 修改编号:1
* 描 述:问答组-答
*/
@Entity
@Table(name = "t_faq_answer")
public class FaqAnswerEntity extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "faq_id")
private String faqId;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "content_type")
private Integer contentType;
@Transient
private String askId;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFaqId() {
return faqId;
}
public void setFaqId(String faqId) {
this.faqId = faqId;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public Integer getContentType() {
return contentType;
}
public void setContentType(Integer contentType) {
this.contentType = contentType;
}
public String getAskId() {
return askId;
}
public void setAskId(String askId) {
this.askId = askId;
}
}
@@ -0,0 +1,64 @@
package io.xiaoxi.db.model.faq;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 模块编号:io.icchain.wxcontractbot.entity.faq
* 作 者:xuelei.wang
* 创建时间:2020/4/16 15:07
* 修改编号:1
* 描 述:问答组-问
*/
@Entity
@Table(name = "t_faq_ask")
public class FaqAskEntity extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "faq_id")
private String faqId;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "content_type")
private Integer contentType;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFaqId() {
return faqId;
}
public void setFaqId(String faqId) {
this.faqId = faqId;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public Integer getContentType() {
return contentType;
}
public void setContentType(Integer contentType) {
this.contentType = contentType;
}
}
@@ -0,0 +1,72 @@
package io.xiaoxi.db.model.faq;
import io.xiaoxi.db.model.BaseEntity;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.*;
import java.util.List;
/**
* 模块编号:io.icchain.wxcontractbot.entity.faq
* 作 者:xuelei.wang
* 创建时间:2020/4/16 15:07
* 修改编号:1
* 描 述:问答组
*/
@Entity
@Table(name = "t_faq")
public class FaqEntity extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_num")
private Integer sortNum;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name="faq_id", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<FaqAskEntity> askList;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name="faq_id", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<FaqAnswerEntity> answerList;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public List<FaqAskEntity> getAskList() {
return askList;
}
public void setAskList(List<FaqAskEntity> askList) {
this.askList = askList;
}
public List<FaqAnswerEntity> getAnswerList() {
return answerList;
}
public void setAnswerList(List<FaqAnswerEntity> answerList) {
this.answerList = answerList;
}
}
@@ -0,0 +1,72 @@
package io.xiaoxi.db.model.faq;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 智能问答_触发记录表(io.icchain.wxcontractbot.entity.agent.FaqTriggerRecords)实体类
*
* @author xuelei.wang
* @create time 2020-06-17 11:14:45
*/
@Entity
@Table(name = "t_faq_trigger_records")
public class FaqTriggerRecords extends BaseEntity {
private static final long serialVersionUID = -99187469663468838L;
/**
* 触发KEY
*/
@Column(name = "trigger_key")
private String triggerKey;
/**
* 触发答案
*/
@Column(name = "trigger_value")
private String triggerValue;
@Column(name = "chat_name")
private String chatName;
@Column(name = "chat_id")
private String chatId;
public String getTriggerKey() {
return triggerKey;
}
public void setTriggerKey(String triggerKey) {
this.triggerKey = triggerKey;
}
public String getTriggerValue() {
return triggerValue;
}
public void setTriggerValue(String triggerValue) {
this.triggerValue = triggerValue;
}
public String getChatName() {
return chatName;
}
public void setChatName(String chatName) {
this.chatName = chatName;
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
}
@@ -0,0 +1,372 @@
package io.xiaoxi.db.model.filter;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;
/**
* 垃圾检测配置表(SpamMessageFilterConfig)实体类
*
* @author xuelei.wang
* @create time 2020-06-19 15:19:45
*/
@Entity
@Table(name = "t_spam_message_filter_config")
public class SpamMessageFilterConfig extends BaseEntity {
private static final long serialVersionUID = 160516649118673749L;
/**
* 是否开启自动踢出并加入黑名单:0:不开启,1:开启
*/
@Column(name = "enable")
private String enable;
/**
* 启用白名单1:开启,0:不开启
*/
@Column(name = "enable_white_list")
private String enableWhiteList;
/**
* 启用链接白名单:0:不开启,1:开启
*/
@Column(name = "enable_link_white_list")
private String enableLinkWhiteList;
/**
* 开启黑名单:0:不开启,1:开启
*/
@Column(name = "enable_black_list")
private String enableBlackList;
/**
* 开启踢消息中包含关键词功能0:不开启,1:开启
*/
@Column(name = "enable_ad_custom_keyword_filter")
private String enableAdCustomKeywordFilter;
/**
* 消息关键词
*/
@Column(name = "ad_keywords")
private String adKeywords;
/**
* 开启踢消息中包含系默认敏感词功能0:不开启,1:开启
*/
@Column(name = "enable_ad_system_keyword_filter")
private String enableAdSystemKeywordFilter;
/**
* 开启踢发图片功能0:不开启,1:开启
*/
@Column(name = "enable_ad_image_filter")
private String enableAdImageFilter;
/**
* 开启踢发名片功能0:不开启,1:开启
*/
@Column(name = "enable_ad_business_card_filter")
private String enableAdBusinessCardFilter;
/**
* 开启踢发视频功能0:不开启,1:开启
*/
@Column(name = "enable_ad_video_filter")
private String enableAdVideoFilter;
/**
* 开启踢发链接功能0:不开启,1:开启
*/
@Column(name = "enable_ad_url_filter")
private String enableAdUrlFilter;
/**
* 开启踢发小程序功能0:不开启,1:开启
*/
@Column(name = "enable_ad_mini_program_filter")
private String enableAdMiniProgramFilter;
/**
* 是否开启防骚扰:0:不开启,1:开启
*/
@Column(name = "enable_spam_message_filter")
private String enableSpamMessageFilter;
/**
* 防骚扰-消息大于xx行
*/
@Column(name = "spam_message_line_size")
private Integer spamMessageLineSize;
/**
* 消息文本大于1000行
*/
@Column(name = "spam_message_character_size")
private Integer spamMessageCharacterSize;
/**
* 1分钟发10条及以上消息
*/
@Column(name = "spam_message_minute_send_count")
private Integer spamMessageMinuteSendCount;
/**
* 启用踢人公告:0:不启用,1:启用
*/
@Column(name = "enable_kick_user_notice")
private String enableKickUserNotice;
/**
* 踢人公告模板
*/
@Column(name = "kick_user_notice_template")
private String kickUserNoticeTemplate;
/**
* 启用踢人前给违规人员一次警告机会,如再次违规直接剔除,0:不启用,1:启用
*/
@Column(name = "enable_give_notice_before_kicking")
private String enableGiveNoticeBeforeKicking;
/**
* 踢人前警告模板
*/
@Column(name = "give_notice_before_kicking_template")
private String giveNoticeBeforeKickingTemplate;
@Transient
private List<SpamMessageFilterConfigBlackList> blackList;
@Transient
private List<SpamMessageFilterConfigChat> chatList;
@Transient
private List<SpamMessageFilterConfigLinkWhiteList> linkWhiteList;
@Transient
private List<SpamMessageFilterConfigWhiteList> whiteList;
public List<SpamMessageFilterConfigBlackList> getBlackList() {
return blackList;
}
public void setBlackList(List<SpamMessageFilterConfigBlackList> blackList) {
this.blackList = blackList;
}
public List<SpamMessageFilterConfigChat> getChatList() {
return chatList;
}
public void setChatList(List<SpamMessageFilterConfigChat> chatList) {
this.chatList = chatList;
}
public List<SpamMessageFilterConfigLinkWhiteList> getLinkWhiteList() {
return linkWhiteList;
}
public void setLinkWhiteList(List<SpamMessageFilterConfigLinkWhiteList> linkWhiteList) {
this.linkWhiteList = linkWhiteList;
}
public List<SpamMessageFilterConfigWhiteList> getWhiteList() {
return whiteList;
}
public void setWhiteList(List<SpamMessageFilterConfigWhiteList> whiteList) {
this.whiteList = whiteList;
}
public String getEnable() {
return enable;
}
public void setEnable(String enable) {
this.enable = enable;
}
public String getEnableWhiteList() {
return enableWhiteList;
}
public void setEnableWhiteList(String enableWhiteList) {
this.enableWhiteList = enableWhiteList;
}
public String getEnableLinkWhiteList() {
return enableLinkWhiteList;
}
public void setEnableLinkWhiteList(String enableLinkWhiteList) {
this.enableLinkWhiteList = enableLinkWhiteList;
}
public String getEnableBlackList() {
return enableBlackList;
}
public void setEnableBlackList(String enableBlackList) {
this.enableBlackList = enableBlackList;
}
public String getEnableAdCustomKeywordFilter() {
return enableAdCustomKeywordFilter;
}
public void setEnableAdCustomKeywordFilter(String enableAdCustomKeywordFilter) {
this.enableAdCustomKeywordFilter = enableAdCustomKeywordFilter;
}
public String getAdKeywords() {
return adKeywords;
}
public void setAdKeywords(String adKeywords) {
this.adKeywords = adKeywords;
}
public String getEnableAdSystemKeywordFilter() {
return enableAdSystemKeywordFilter;
}
public void setEnableAdSystemKeywordFilter(String enableAdSystemKeywordFilter) {
this.enableAdSystemKeywordFilter = enableAdSystemKeywordFilter;
}
public String getEnableAdImageFilter() {
return enableAdImageFilter;
}
public void setEnableAdImageFilter(String enableAdImageFilter) {
this.enableAdImageFilter = enableAdImageFilter;
}
public String getEnableAdBusinessCardFilter() {
return enableAdBusinessCardFilter;
}
public void setEnableAdBusinessCardFilter(String enableAdBusinessCardFilter) {
this.enableAdBusinessCardFilter = enableAdBusinessCardFilter;
}
public String getEnableAdVideoFilter() {
return enableAdVideoFilter;
}
public void setEnableAdVideoFilter(String enableAdVideoFilter) {
this.enableAdVideoFilter = enableAdVideoFilter;
}
public String getEnableAdUrlFilter() {
return enableAdUrlFilter;
}
public void setEnableAdUrlFilter(String enableAdUrlFilter) {
this.enableAdUrlFilter = enableAdUrlFilter;
}
public String getEnableAdMiniProgramFilter() {
return enableAdMiniProgramFilter;
}
public void setEnableAdMiniProgramFilter(String enableAdMiniProgramFilter) {
this.enableAdMiniProgramFilter = enableAdMiniProgramFilter;
}
public String getEnableSpamMessageFilter() {
return enableSpamMessageFilter;
}
public void setEnableSpamMessageFilter(String enableSpamMessageFilter) {
this.enableSpamMessageFilter = enableSpamMessageFilter;
}
public Integer getSpamMessageLineSize() {
return spamMessageLineSize;
}
public void setSpamMessageLineSize(Integer spamMessageLineSize) {
this.spamMessageLineSize = spamMessageLineSize;
}
public Integer getSpamMessageCharacterSize() {
return spamMessageCharacterSize;
}
public void setSpamMessageCharacterSize(Integer spamMessageCharacterSize) {
this.spamMessageCharacterSize = spamMessageCharacterSize;
}
public Integer getSpamMessageMinuteSendCount() {
return spamMessageMinuteSendCount;
}
public void setSpamMessageMinuteSendCount(Integer spamMessageMinuteSendCount) {
this.spamMessageMinuteSendCount = spamMessageMinuteSendCount;
}
public String getEnableKickUserNotice() {
return enableKickUserNotice;
}
public void setEnableKickUserNotice(String enableKickUserNotice) {
this.enableKickUserNotice = enableKickUserNotice;
}
public String getKickUserNoticeTemplate() {
return kickUserNoticeTemplate;
}
public void setKickUserNoticeTemplate(String kickUserNoticeTemplate) {
this.kickUserNoticeTemplate = kickUserNoticeTemplate;
}
public String getEnableGiveNoticeBeforeKicking() {
return enableGiveNoticeBeforeKicking;
}
public void setEnableGiveNoticeBeforeKicking(String enableGiveNoticeBeforeKicking) {
this.enableGiveNoticeBeforeKicking = enableGiveNoticeBeforeKicking;
}
public String getGiveNoticeBeforeKickingTemplate() {
return giveNoticeBeforeKickingTemplate;
}
public void setGiveNoticeBeforeKickingTemplate(String giveNoticeBeforeKickingTemplate) {
this.giveNoticeBeforeKickingTemplate = giveNoticeBeforeKickingTemplate;
}
public SpamMessageFilterConfig() {
}
public SpamMessageFilterConfig(String enable, String enableWhiteList, String enableLinkWhiteList, String enableBlackList, String enableAdCustomKeywordFilter, String adKeywords, String enableAdSystemKeywordFilter, String enableAdImageFilter, String enableAdBusinessCardFilter, String enableAdVideoFilter, String enableAdUrlFilter, String enableAdMiniProgramFilter, String enableSpamMessageFilter, Integer spamMessageLineSize, Integer spamMessageCharacterSize, Integer spamMessageMinuteSendCount, String enableKickUserNotice, String kickUserNoticeTemplate, String enableGiveNoticeBeforeKicking, String giveNoticeBeforeKickingTemplate, List<SpamMessageFilterConfigBlackList> blackList, List<SpamMessageFilterConfigChat> chatList, List<SpamMessageFilterConfigLinkWhiteList> linkWhiteList, List<SpamMessageFilterConfigWhiteList> whiteList) {
this.enable = enable;
this.enableWhiteList = enableWhiteList;
this.enableLinkWhiteList = enableLinkWhiteList;
this.enableBlackList = enableBlackList;
this.enableAdCustomKeywordFilter = enableAdCustomKeywordFilter;
this.adKeywords = adKeywords;
this.enableAdSystemKeywordFilter = enableAdSystemKeywordFilter;
this.enableAdImageFilter = enableAdImageFilter;
this.enableAdBusinessCardFilter = enableAdBusinessCardFilter;
this.enableAdVideoFilter = enableAdVideoFilter;
this.enableAdUrlFilter = enableAdUrlFilter;
this.enableAdMiniProgramFilter = enableAdMiniProgramFilter;
this.enableSpamMessageFilter = enableSpamMessageFilter;
this.spamMessageLineSize = spamMessageLineSize;
this.spamMessageCharacterSize = spamMessageCharacterSize;
this.spamMessageMinuteSendCount = spamMessageMinuteSendCount;
this.enableKickUserNotice = enableKickUserNotice;
this.kickUserNoticeTemplate = kickUserNoticeTemplate;
this.enableGiveNoticeBeforeKicking = enableGiveNoticeBeforeKicking;
this.giveNoticeBeforeKickingTemplate = giveNoticeBeforeKickingTemplate;
this.blackList = blackList;
this.chatList = chatList;
this.linkWhiteList = linkWhiteList;
this.whiteList = whiteList;
}
}
@@ -0,0 +1,86 @@
package io.xiaoxi.db.model.filter;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 垃圾检测-黑名单表(SpamMessageFilterConfigBlackList)实体类
*
* @author xuelei.wang
* @create time 2020-06-19 15:19:49
*/
@Entity
@Table(name = "t_spam_message_filter_config_black_list")
public class SpamMessageFilterConfigBlackList extends BaseEntity {
private static final long serialVersionUID = 660958357289569495L;
/**
* 微信ID
*/
@Column(name = "wxid")
private String wxid;
/**
* 微信昵称
*/
@Column(name = "nickname")
private String nickname;
/**
* 备注
*/
@Column(name = "remark")
private String remark;
/**
* 添加方式:1:自动添加,0:手动添加
*/
@Column(name = "add_type")
private String addType;
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getAddType() {
return addType;
}
public void setAddType(String addType) {
this.addType = addType;
}
public SpamMessageFilterConfigBlackList() {
}
public SpamMessageFilterConfigBlackList(String wxid, String nickname, String remark, String addType) {
this.wxid = wxid;
this.nickname = nickname;
this.remark = remark;
this.addType = addType;
}
}
@@ -0,0 +1,52 @@
package io.xiaoxi.db.model.filter;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 垃圾检测-群(SpamMessageFilterConfigChat)实体类
*
* @author xuelei.wang
* @create time 2020-06-19 15:19:49
*/
@Entity
@Table(name = "t_spam_message_filter_config_chat")
public class SpamMessageFilterConfigChat extends BaseEntity {
private static final long serialVersionUID = -31398926328428367L;
@Column(name = "chat_id")
private String chatId;
@Column(name = "chat_name")
private String chatName;
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public String getChatName() {
return chatName;
}
public void setChatName(String chatName) {
this.chatName = chatName;
}
public SpamMessageFilterConfigChat() {
}
public SpamMessageFilterConfigChat(String chatId, String chatName) {
this.chatId = chatId;
this.chatName = chatName;
}
}
@@ -0,0 +1,39 @@
package io.xiaoxi.db.model.filter;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 垃圾检测-链接白名单(SpamMessageFilterConfigLinkWhiteList)实体类
*
* @author xuelei.wang
* @create time 2020-06-19 15:19:49
*/
@Entity
@Table(name = "t_spam_message_filter_config_link_white_list")
public class SpamMessageFilterConfigLinkWhiteList extends BaseEntity {
private static final long serialVersionUID = -33382788379803971L;
@Column(name = "url")
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public SpamMessageFilterConfigLinkWhiteList() {
}
public SpamMessageFilterConfigLinkWhiteList(String url) {
this.url = url;
}
}
@@ -0,0 +1,54 @@
package io.xiaoxi.db.model.filter;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 垃圾检测-白名单表(SpamMessageFilterConfigWhiteList)实体类
*
* @author xuelei.wang
* @create time 2020-06-19 15:19:49
*/
@Entity
@Table(name = "t_spam_message_filter_config_white_list")
public class SpamMessageFilterConfigWhiteList extends BaseEntity {
private static final long serialVersionUID = 347535709899758457L;
/**
* 微信ID
*/
@Column(name = "wxid")
private String wxid;
/**
* 备注
*/
@Column(name = "remark")
private String remark;
public String getWxid() {
return wxid;
}
public void setWxid(String wxid) {
this.wxid = wxid;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public SpamMessageFilterConfigWhiteList() {
}
public SpamMessageFilterConfigWhiteList(String wxid, String remark) {
this.wxid = wxid;
this.remark = remark;
}
}
@@ -0,0 +1,79 @@
/*
*
* * Copyright 2020-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.db.model.friendreply;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import io.xiaoxi.db.model.BaseEntity;
/**
* @ClassName: AddedFriendReply
* @date: 2020年5月20日 下午5:26:59
*/
@Entity
@Table(name="t_added_friend_reply")
public class AddedFriendReply extends BaseEntity {
private static final long serialVersionUID = -6503459328748792790L;
@Column(name = "type")
private String type;
@Column(name = "content")
private String content;
@Column(name = "sort_num")
private Integer sortNum;
public AddedFriendReply() {
}
public AddedFriendReply(String type, String content, Integer sortNum) {
this.type = type;
this.content = content;
this.sortNum = sortNum;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
}
@@ -0,0 +1,114 @@
package io.xiaoxi.db.model.kfgzt;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* 机器人群(WxBotChat)实体类
*
* @author xuelei.wang
* @create time 2020-07-08 11:13:31
*/
@Entity
@Table(name = "t_kfgzt_bot_chat")
public class KfgztBotChat extends BaseEntity {
private static final long serialVersionUID = 444832135092443496L;
/**
* 群组的id
*/
@Column(name = "chat_id")
private String chatId;
/**
* 群组的id
*/
@Column(name = "wx_id")
private String wxId;
/**
* 是否置顶
*/
@Transient
private Integer isToTop=0;
/**
* 群人数
*/
@Column(name = "chat_member_cnt")
private String chatMemberCnt;
/**
* 状态:1:正常,2:已删除
*/
@Column(name = "status")
private String status;
/**
* 群名称
*/
@Column(name = "chat_name")
private String chatName;
@Column(name = "avatar")
private String avatar;
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getChatId() {
return chatId;
}
public void setChatId(String chatId) {
this.chatId = chatId;
}
public String getChatMemberCnt() {
return chatMemberCnt;
}
public void setChatMemberCnt(String chatMemberCnt) {
this.chatMemberCnt = chatMemberCnt;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getChatName() {
return chatName;
}
public void setChatName(String chatName) {
this.chatName = chatName;
}
public String getWxId() {
return wxId;
}
public void setWxId(String wxId) {
this.wxId = wxId;
}
public Integer getIsToTop() {
return isToTop;
}
public void setIsToTop(Integer isToTop) {
this.isToTop = isToTop;
}
}
@@ -0,0 +1,118 @@
package io.xiaoxi.db.model.kfgzt;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
* 机器人好友信息(WxBotFriends)实体类
*
* @author xuelei.wang
* @create time 2020-07-08 11:13:31
*/
@Entity
@Table(name = "t_kfgzt_bot_friends")
public class KfgztBotFriends extends BaseEntity {
private static final long serialVersionUID = 580162481454796655L;
/**
* 机器人id
*/
@Column(name = "wx_id")
private String wxId;
/**
* 机器人好友ID
*/
@Column(name = "friend_wx_id")
private String friendWxId;
/**
* 机器人头像
*/
@Column(name = "friend_img")
private String friendImg;
/**
* 机器人昵称
*/
@Column(name = "friend_nickname")
private String friendNickname;
/**
* 微信号
*/
@Column(name = "account")
private String account;
/**
* 状态:1,正常,2:已删除
*/
@Column(name = "status")
private String status;
/**
* 是否置顶
*/
@Transient
private Integer isToTop=0;
public String getWxId() {
return wxId;
}
public void setWxId(String wxId) {
this.wxId = wxId;
}
public String getFriendWxId() {
return friendWxId;
}
public void setFriendWxId(String friendWxId) {
this.friendWxId = friendWxId;
}
public String getFriendImg() {
return friendImg;
}
public void setFriendImg(String friendImg) {
this.friendImg = friendImg;
}
public String getFriendNickname() {
return friendNickname;
}
public void setFriendNickname(String friendNickname) {
this.friendNickname = friendNickname;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public Integer getIsToTop() {
return isToTop;
}
public void setIsToTop(Integer isToTop) {
this.isToTop = isToTop;
}
}
@@ -0,0 +1,50 @@
package io.xiaoxi.db.model.kfgzt;
import java.io.Serializable;
/**
* 模块编号:io.xiaoxi.db.model.kfgzt KfgztMessageInfof
* 作 者:xuelei.wang
* 创建时间:2020/7/13 10:53
* 修改编号:1
* 描 述:DES
*/
public class KfgztMessageInfo implements Serializable {
private String type;
private String content;
private Double startTimespan;
private Double endTimespan;
public Double getStartTimespan() {
return startTimespan;
}
public void setStartTimespan(Double startTimespan) {
this.startTimespan = startTimespan;
}
public Double getEndTimespan() {
return endTimespan;
}
public void setEndTimespan(Double endTimespan) {
this.endTimespan = endTimespan;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
@@ -0,0 +1,130 @@
package io.xiaoxi.db.model.kfgzt;
/**
* 模块编号:io.xiaoxi.db.model.kfgzt Message
* 作 者:xuelei.wang
* 创建时间:2020/7/13 11:18
* 修改编号:1
* 描 述:DES
*/
import com.alibaba.fastjson.annotation.JSONField;
import java.util.Date;
public class Message {
private String id;
private String chatType;
private String fromId;
private String fromUserName;
private String toId;
private String msgType;
private String content;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
public Message() {
}
public Message(String chatType, String fromId, String fromUserName, String toId, String msgType, String content, Date createTime) {
this.chatType = chatType;
this.fromId = fromId;
this.fromUserName = fromUserName;
this.toId = toId;
this.msgType = msgType;
this.content = content;
this.createTime = createTime;
}
public Message(String chatType, String fromId,String fromAvatar, String fromUserName, String toId, String msgType, String content, Date createTime) {
this.chatType = chatType;
this.fromId = fromId;
this.fromUserName = fromUserName;
this.toId = toId;
this.msgType = msgType;
this.content = content;
this.createTime = createTime;
this.fromAvatar=fromAvatar;
}
private String fromAvatar;
public String getFromAvatar() {
return fromAvatar;
}
public void setFromAvatar(String fromAvatar) {
this.fromAvatar = fromAvatar;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getChatType() {
return chatType;
}
public void setChatType(String chatType) {
this.chatType = chatType;
}
public String getFromId() {
return fromId;
}
public void setFromId(String fromId) {
this.fromId = fromId;
}
public String getFromUserName() {
return fromUserName;
}
public void setFromUserName(String fromUserName) {
this.fromUserName = fromUserName;
}
public String getToId() {
return toId;
}
public void setToId(String toId) {
this.toId = toId;
}
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
}
@@ -0,0 +1,93 @@
package io.xiaoxi.db.model.marketing;
import io.xiaoxi.db.model.BaseEntity;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "t_marketing_order")
public class Marketing extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "marketing_task_id")
private String marketingTaskId;
@Column(name = "sort_num")
private Integer sortNum;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name="marketing_id", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<MarketingAskGroup> askGroupList;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name="marketing_id", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<MarketingAnswerGroup> answerGroupList;
@OneToMany
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name="marketing_id", insertable = false, updatable = false,referencedColumnName = "id")
@Where(clause = "pid='' or pid is null")
@OrderBy("sortNum ASC")
private List<MarketingEchoGroup> echoGroupList;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public List<MarketingAskGroup> getAskGroupList() {
return askGroupList;
}
public void setAskGroupList(List<MarketingAskGroup> askGroupList) {
this.askGroupList = askGroupList;
}
public List<MarketingAnswerGroup> getAnswerGroupList() {
return answerGroupList;
}
public void setAnswerGroupList(List<MarketingAnswerGroup> answerGroupList) {
this.answerGroupList = answerGroupList;
}
public List<MarketingEchoGroup> getEchoGroupList() {
return echoGroupList!=null ? echoGroupList: new ArrayList<MarketingEchoGroup>();
}
public void setEchoGroupList(List<MarketingEchoGroup> echoGroupList) {
this.echoGroupList = echoGroupList;
}
public String getMarketingTaskId() {
return marketingTaskId;
}
public void setMarketingTaskId(String marketingTaskId) {
this.marketingTaskId = marketingTaskId;
}
}
@@ -0,0 +1,61 @@
package io.xiaoxi.db.model.marketing;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name = "t_marketing_order_answer")
public class MarketingAnswer extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "answer_group_id")
private String answerGroupId;
@Column(name = "content_type")
private String contentType;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getAnswerGroupId() {
return answerGroupId;
}
public void setAnswerGroupId(String answerGroupId) {
this.answerGroupId = answerGroupId;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
}
@@ -0,0 +1,61 @@
package io.xiaoxi.db.model.marketing;
import io.xiaoxi.db.model.BaseEntity;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.*;
import java.util.List;
@Entity
@Table(name = "t_marketing_order_answer_group")
public class MarketingAnswerGroup extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "marketing_id")
private String marketingId;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name="answer_group_id", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<MarketingAnswer> answerList;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getMarketingId() {
return marketingId;
}
public void setMarketingId(String marketingId) {
this.marketingId = marketingId;
}
public List<MarketingAnswer> getAnswerList() {
return answerList;
}
public void setAnswerList(List<MarketingAnswer> answerList) {
this.answerList = answerList;
}
}
@@ -0,0 +1,60 @@
package io.xiaoxi.db.model.marketing;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name = "t_marketing_order_ask")
public class MarketingAsk extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "ask_group_id")
private String askGroupId;
@Column(name = "content_type")
private String contentType;
public String getAskGroupId() {
return askGroupId;
}
public void setAskGroupId(String askGroupId) {
this.askGroupId = askGroupId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
}
@@ -0,0 +1,61 @@
package io.xiaoxi.db.model.marketing;
import io.xiaoxi.db.model.BaseEntity;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.*;
import java.util.List;
@Entity
@Table(name = "t_marketing_order_ask_group")
public class MarketingAskGroup extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "marketing_id")
private String marketingId;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name = "ask_group_id", insertable = false, updatable = false, referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<MarketingAsk> askList;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getMarketingId() {
return marketingId;
}
public void setMarketingId(String marketingId) {
this.marketingId = marketingId;
}
public List<MarketingAsk> getAskList() {
return askList;
}
public void setAskList(List<MarketingAsk> askList) {
this.askList = askList;
}
}
@@ -0,0 +1,31 @@
package io.xiaoxi.db.model.marketing;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import io.xiaoxi.db.model.BaseEntity;
/**
* 模块编号:io.xiaoxi.db.model
* 作 者:xuelei.wang
* 创建时间:2019/11/19 15:07
* 修改编号:1
* 描 述:
*/
@Entity
@Table(name = "t_marketing_bot_setting")
public class MarketingBotSetting extends BaseEntity {
@Column(name = "echo_bot_cnt")
private Integer echoBotCnt;
public Integer getEchoBotCnt() {
return echoBotCnt;
}
public void setEchoBotCnt(Integer echoBotCnt) {
this.echoBotCnt = echoBotCnt;
}
}
@@ -0,0 +1,58 @@
package io.xiaoxi.db.model.marketing;
import io.xiaoxi.db.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name = "t_marketing_order_echo")
public class MarketingEcho extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "echo_group_id")
private String echoGroupId;
@Column(name = "content_type")
private String contentType;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getEchoGroupId() {
return echoGroupId;
}
public void setEchoGroupId(String echoGroupId) {
this.echoGroupId = echoGroupId;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
}
@@ -0,0 +1,90 @@
package io.xiaoxi.db.model.marketing;
import io.xiaoxi.db.model.BaseEntity;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import javax.persistence.*;
import java.util.List;
@Entity
@Table(name = "t_marketing_order_echo_group")
public class MarketingEchoGroup extends BaseEntity {
@Column(name = "name")
private String name;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "marketing_id")
private String marketingId;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name="echo_group_id", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<MarketingEcho> echoList;
/**
* 由于附和机器人有组,pid相同的附和机器人为一个机器人说多句话
*/
@Column(name = "pid")
private String pid;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
@JoinColumn(name="pid", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<MarketingEchoGroup> children;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSortNum() {
return sortNum;
}
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
public String getMarketingId() {
return marketingId;
}
public void setMarketingId(String marketingId) {
this.marketingId = marketingId;
}
public List<MarketingEcho> getEchoList() {
return echoList;
}
public void setEchoList(List<MarketingEcho> echoList) {
this.echoList = echoList;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public List<MarketingEchoGroup> getChildren() {
return children;
}
public void setChildren(List<MarketingEchoGroup> children) {
this.children = children;
}
}
@@ -0,0 +1,239 @@
package io.xiaoxi.db.model.marketingrecord;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import io.xiaoxi.db.model.BaseEntity;
import java.util.Date;
@Entity
@Table(name="t_marketing_chat")
public class MarketingChat extends BaseEntity {
@Column(name = "task_id")
private String taskId;
@Column(name = "chat_id")
private String chatId;
@Column(name = "chat_type")
private String chatType;
@Column(name = "chat_name")
private String chatName;
@Column(name = "chat_member_cnt")
private Integer chatMemberCnt;
@Column(name = "bot")
private String bot;
@Column(name = "sort_num")
private Integer sortNum;
@Column(name = "start_date")
private Date startDate;
@Column(name = "end_date")
private Date endDate;
@Column(name = "status")
private String status;
@Column(name = "error_msg")
private String errorMsg;
public MarketingChat() {
}
/**
* @return taskId
*/
public String getTaskId() {
return taskId;
}
/**
* @param taskId 要设置的 taskId
*/
public void setTaskId(String taskId) {
this.taskId = taskId;
}
/**
* @return chatId
*/
public String getChatId() {
return chatId;
}
/**
* @param chatId 要设置的 chatId
*/
public void setChatId(String chatId) {
this.chatId = chatId;
}
/**
* @return chatType
*/
public String getChatType() {
return chatType;
}
/**
* @param chatType 要设置的 chatType
*/
public void setChatType(String chatType) {
this.chatType = chatType;
}
/**
* @return chatName
*/
public String getChatName() {
return chatName;
}
/**
* @param chatName 要设置的 chatName
*/
public void setChatName(String chatName) {
this.chatName = chatName;
}
/**
* @return chatMemberCnt
*/
public Integer getChatMemberCnt() {
return chatMemberCnt;
}
/**
* @param chatMemberCnt 要设置的 chatMemberCnt
*/
public void setChatMemberCnt(Integer chatMemberCnt) {
this.chatMemberCnt = chatMemberCnt;
}
/**
* @return bot
*/
public String getBot() {
return bot;
}
/**
* @param bot 要设置的 bot
*/
public void setBot(String bot) {
this.bot = bot;
}
/**
* @return sortNum
*/
public Integer getSortNum() {
return sortNum;
}
/**
* @param sortNum 要设置的 sortNum
*/
public void setSortNum(Integer sortNum) {
this.sortNum = sortNum;
}
/**
* @return startDate
*/
public Date getStartDate() {
return startDate;
}
/**
* @param startDate 要设置的 startDate
*/
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
/**
* @return endDate
*/
public Date getEndDate() {
return endDate;
}
/**
* @param endDate 要设置的 endDate
*/
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
/**
* @return status
*/
public String getStatus() {
return status;
}
/**
* @param status 要设置的 status
*/
public void setStatus(String status) {
this.status = status;
}
/**
* @return errorMsg
*/
public String getErrorMsg() {
return errorMsg;
}
/**
* @param errorMsg 要设置的 errorMsg
*/
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
@Override
public String toString() {
return "MarketingChat [taskId=" + taskId + ", chatId=" + chatId + ", chatType=" + chatType + ", chatName="
+ chatName + ", chatMemberCnt=" + chatMemberCnt + ", bot=" + bot + ", sortNum=" + sortNum
+ ", startDate=" + startDate + ", endDate=" + endDate + ", status=" + status + ", errorMsg=" + errorMsg
+ "]";
}
}
@@ -0,0 +1,144 @@
package io.xiaoxi.db.model.marketingrecord;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Where;
import io.xiaoxi.db.model.BaseEntity;
import java.util.Date;
import java.util.List;
@Entity
@Table(name="t_marketing_task")
public class MarketingTask extends BaseEntity {
@Column(name = "trigger_type")
private String triggerType;
@Column(name = "push_type")
private String pushType;
@Column(name = "push_date")
private Date pushDate;
@Column(name = "bot_num")
private Integer botNum;
@Column(name = "content_id")
private String contentId;
@Column(name = "chat_ids")
private String chatIds;
@Column(name = "status")
private String status;
@Column(name = "interval_type")
private String intervalType;
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "task_id", insertable = false, updatable = false,referencedColumnName = "id")
@OrderBy("sortNum ASC")
private List<MarketingChat> MarketingChatList;
public MarketingTask() {
}
public MarketingTask(String triggerType, String pushType, Date pushDate, Integer botNum, String contentId, String chatIds, String status) {
this.triggerType = triggerType;
this.pushType = pushType;
this.pushDate = pushDate;
this.botNum = botNum;
this.contentId = contentId;
this.chatIds = chatIds;
this.status = status;
}
public String getTriggerType() {
return triggerType;
}
public void setTriggerType(String triggerType) {
this.triggerType = triggerType;
}
public String getPushType() {
return pushType;
}
public void setPushType(String pushType) {
this.pushType = pushType;
}
public Date getPushDate() {
return pushDate;
}
public void setPushDate(Date pushDate) {
this.pushDate = pushDate;
}
public Integer getBotNum() {
return botNum;
}
public void setBotNum(Integer botNum) {
this.botNum = botNum;
}
public String getContentId() {
return contentId;
}
public void setContentId(String contentId) {
this.contentId = contentId;
}
public String getChatIds() {
return chatIds;
}
public void setChatIds(String chatIds) {
this.chatIds = chatIds;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
/**
* @return marketingChatList
*/
public List<MarketingChat> getMarketingChatList() {
return MarketingChatList;
}
/**
* @param marketingChatList 要设置的 marketingChatList
*/
public void setMarketingChatList(List<MarketingChat> marketingChatList) {
MarketingChatList = marketingChatList;
}
public String getIntervalType() {
return intervalType;
}
public void setIntervalType(String intervalType) {
this.intervalType = intervalType;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,64 @@
/*
*
* * Copyright 2018-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.jedis;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
* @ClassName: RedisConfiguration
* @Description: TODO
* @date: 2018年4月25日 下午4:18:26
*/
@Configuration
public class RedisConfiguration {
@Bean(name = "jedis.pool")
public JedisPool jedisPool(@Qualifier("jedis.pool.config") JedisPoolConfig config,
@Value("${jedis.pool.host}") String host,
@Value("${jedis.pool.port}") int port,
@Value("${jedis.pool.timeout}") int timeout,
@Value("${jedis.pool.password}") String password){
return new JedisPool(config,host,port,timeout,password);
}
@Bean(name = "jedis.pool.config")
public JedisPoolConfig jedisPoolConfig(
@Value("${jedis.pool.config.maxTotal}") int maxTotal,
@Value("${jedis.pool.config.maxIdle}") int maxIdle,
@Value("${jedis.pool.config.maxWaitMillis}") int maxWaitMillis,
@Value("${jedis.pool.config.testOnBorrow}") boolean testOnBorrow){
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(maxTotal);
config.setMaxIdle(maxIdle);
config.setMaxWaitMillis(maxWaitMillis);
config.setTestOnBorrow(testOnBorrow);
return config;
}
}
@@ -0,0 +1,755 @@
/*
*
* * Copyright 2018-2108 ICC (Intelligence Commerce Chain, https://icchain.io).
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/
package io.xiaoxi.jedis;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.params.SetParams;
/**
* @ClassName: RedisDao
* @Description: TODO
* @date: 2018年4月25日 下午4:34:55
*/
@Component
public class RedisUtil {
public static RedisUtil util;
private final Logger log = LoggerFactory.getLogger(this.getClass());
@Autowired
private JedisPool jedisPool;
/**
* string(字符串)
* set key value [EX seconds] [PX milliseconds] [NX|XX]
*
* @param key
* @param value
* @param cacheSeconds
* @return
*/
public String set(String key, String value, int cacheSeconds) {
Jedis jedis = null;
String result = null;
try {
jedis = jedisPool.getResource();
if (cacheSeconds > 0) {
result = jedis.setex(key, cacheSeconds, value);
} else {
result = jedis.set(key, value);
}
log.debug("setString {} = {}", key, value);
} catch (Exception e) {
log.warn("setString {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
public void delByPattern(String keyPattern) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
Set<String> keys = jedis.keys(keyPattern);
for (String key : keys) {
jedis.del(key);
log.debug("setSet {} = {}", key);
}
} catch (Exception e) {
log.warn("setSet {} = {}", keyPattern, e);
} finally {
jedis.close();
}
}
/**
* string(字符串)
* set key value [EX seconds] [PX milliseconds] [NX|XX]
*
* @param key
* @param value
* @param cacheSeconds
* @return
*/
public String setnx(String key, String value, int cacheSeconds) {
Jedis jedis = null;
String result = null;
try {
jedis = jedisPool.getResource();
result = jedis.set(key, value, SetParams.setParams().ex(cacheSeconds).nx());
log.debug("setString {} = {}", key, value);
} catch (Exception e) {
log.warn("setString {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
public Long incrBy(String key, Integer value) {
Jedis jedis = null;
Long result = null;
try {
jedis = jedisPool.getResource();
result = jedis.incrBy(key, value.longValue());
log.debug("incrBy {} = {}", key, value);
} catch (Exception e) {
log.warn("incrBy {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
/**
* string(字符串)
* exists key
*
* @param key
* @return
*/
public Boolean exists(String key) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
log.debug("exists {} = {}", key, true);
return true;
} else {
log.debug("exists {} = {}", key, false);
return false;
}
} catch (Exception e) {
log.warn("exists {} = {}", key, e);
} finally {
jedis.close();
}
return false;
}
/**
* string(字符串)
* get key
*
* @param key
* @return
*/
public String get(String key) {
Jedis jedis = null;
String value = null;
try {
jedis = jedisPool.getResource();
// if (jedis.exists(key)) {
value = jedis.get(key);
// value = StringUtils.isNotBlank(value) && !"nil".equalsIgnoreCase(value) ? value : null;
log.debug("getString {} = {}", key, value);
// }
} catch (Exception e) {
log.warn("getString {} = {}", key, value, e);
} finally {
jedis.close();
}
return value;
}
/**
* hash(哈希)
* hset key field value
*
* @param key
* @param value
* @return
*/
public long hset(String key, String field, String value) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
result = jedis.hset(key, field, value);
log.debug("hSet {} {} = {}", key, field, value);
} catch (Exception e) {
log.warn("hSet {} {} = {}", key, field, value, e);
} finally {
jedis.close();
}
return result;
}
/**
* hash(哈希)
* hmset key field value [field value ...]
*
* @param key
* @param value
* @param cacheSeconds
* @return
*/
public String hmset(String key, Map<String, String> value, int cacheSeconds) {
String result = null;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
jedis.del(key);
}
result = jedis.hmset(key, value);
if (cacheSeconds > 0) {
jedis.expire(key, cacheSeconds);
}
log.debug("setMap {} = {}", key, value);
} catch (Exception e) {
log.warn("setMap {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
/**
* hash(哈希)
* hgetall key
*
* @param key
* @return
*/
public Map<String, String> hgetAll(String key) {
Map<String, String> value = null;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
// if (jedis.exists(key)) {
value = jedis.hgetAll(key);
log.debug("getMap {} = {}", key, value);
// }
} catch (Exception e) {
log.warn("getMap {} = {}", key, value, e);
} finally {
jedis.close();
}
return value;
}
/**
* list(列表)
* rpush key value [value ...]
*
* @param key
* @param value
* @param cacheSeconds
* @return
*/
public long rpush(String key, List<String> value, int cacheSeconds) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
jedis.del(key);
}
result = jedis.rpush(key, value.toArray(new String[value.size()]));
if (cacheSeconds > 0) {
jedis.expire(key, cacheSeconds);
}
log.debug("setList {} = {}", key, value);
} catch (Exception e) {
log.warn("setList {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
/**
* list(列表)
* lrange key start stop
*
* @param key
* @return
*/
public List<String> lrange(String key) {
List<String> value = null;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
value = jedis.lrange(key, 0, -1);
log.debug("getList {} = {}", key, value);
}
} catch (Exception e) {
log.warn("getList {} = {}", key, value, e);
} finally {
jedis.close();
}
return value;
}
/**
* set(集合)
* sadd key member [member ...]
*
* @param key
* @param value
* @param cacheSeconds
* @return
*/
public long saddMany(String key, Set<String> value, int cacheSeconds) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
jedis.del(key);
}
result = jedis.sadd(key, value.toArray(new String[value.size()]));
if (cacheSeconds > 0) {
jedis.expire(key, cacheSeconds);
}
log.debug("setSet {} = {}", key, value);
} catch (Exception e) {
log.warn("setSet {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
public long sadd(String key, String value) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
result = jedis.sadd(key, value);
log.debug("setSet {} = {}", key, value);
} catch (Exception e) {
log.warn("setSet {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
/**
* set(集合)
* smembers key
*
* @param key
* @return
*/
public Set<String> smembers(String key) {
Set<String> value = null;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
value = jedis.smembers(key);
log.debug("getSet {} = {}", key, value);
}
} catch (Exception e) {
log.warn("getSet {} = {}", key, value, e);
} finally {
jedis.close();
}
return value;
}
public void del(String key) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
// if (jedis.exists(key)) {
jedis.del(key);
// value = StringUtils.isNotBlank(value) && !"nil".equalsIgnoreCase(value) ? value : null;
log.debug("delkey {} = {}", key);
// }
} catch (Exception e) {
log.warn("getString {} = {}", key, e);
} finally {
jedis.close();
}
}
/**
* 移除并返回集合中的一个随机元素
* <li>当set为空或者不存在时,返回Null</li>
*
* @param key
* @return String
*/
public String spop(String key) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.spop(key);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jedis != null) {
jedis.close();
}
}
return null;
}
/**
* @param key
* @param value
* @return boolean
* @Title: sIsMember
* @Description: TODO
* @date 2018年4月27日上午10:41:09
*/
public boolean sIsMember(String key, String value) {
boolean ret = false;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
ret = jedis.sismember(key, value);
log.debug("sIsMember {} = {}", key, value);
}
} catch (Exception e) {
log.warn("sIsMember {} = {}", key, value, e);
} finally {
jedis.close();
}
return ret;
}
/**
* zset(sorted set:有序集合)
* zadd key [NX|XX] [CH] [INCR] score member [score member ...]
*
* @param key
* @param value
* @param cacheSeconds
* @return
*/
public long zset(String key, Map<String, Double> value, int cacheSeconds) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
result = jedis.zadd(key, value);
if (cacheSeconds > 0) {
jedis.expire(key, cacheSeconds);
}
log.debug("setZset {} = {}", key, value);
} catch (Exception e) {
log.warn("setZset {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
/**
* zadd(sorted set:有序集合)
* zadd key [NX|XX] [CH] [INCR] score member [score member ...]
*
* @param key
* @param value
* @param cacheSeconds
* @return
*/
public long zadd(String key, double score, String value, int cacheSeconds) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
result = jedis.zadd(key, score, value);
if (cacheSeconds > 0) {
jedis.expire(key, cacheSeconds);
}
log.debug("zadd {} = {}", key, value);
} catch (Exception e) {
log.warn("zadd {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
/**
* zadd(sorted set:有序集合)
* zadd key [NX|XX] [CH] [INCR] score member [score member ...]
*
* @param key
* @return
*/
public long zcount(String key, double start, double end) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
Long res =jedis.zcount(key, start, end);
if (res == null) {
res = 0L;
}
result = res;
} catch (Exception e) {
log.warn("zadd {} = {}", key, start, e);
} finally {
jedis.close();
}
return result;
}
/**
* zadd(sorted set:有序集合)
* zadd key [NX|XX] [CH] [INCR] score member [score member ...]
*
* @param key
* @return
*/
public long zrevrank(String key, String member) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
Long res = jedis.zrevrank(key, member);
if (res == null) {
res = -1L;
}
result = res;
} catch (Exception e) {
log.warn("zrevrank {} = {}", key, e);
} finally {
jedis.close();
}
return result;
}
/**
* zadd(sorted set:有序集合)
* zadd key [NX|XX] [CH] [INCR] score member [score member ...]
*
* @param key
* @return
*/
public Double zscore(String key, String member) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.zscore(key, member);
} catch (Exception e) {
log.warn("zrevrank {} = {}", key, e);
} finally {
jedis.close();
}
return null;
}
/**
* zadd(sorted set:有序集合)
* zadd key [NX|XX] [CH] [INCR] score member [score member ...]
*
* @param key
* @return
*/
public long zremrangeByScore(String key, double start, double end) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
result = jedis.zremrangeByScore(key, start, end);
} catch (Exception e) {
log.warn("zadd {} = {}", key, start, e);
} finally {
jedis.close();
}
return result;
}
/**
* 支持*key*
*
* @param keyPattern
* @return
*/
public long zcountByKeyPattern(String keyPattern) {
Jedis jedis = null;
long sum = 0;
try {
jedis = jedisPool.getResource();
Set<String> keys = jedis.keys(keyPattern);
for (String key : keys) {
Long count = jedis.zcount(key, 0, System.currentTimeMillis());
if (count != null) {
sum = sum + count.longValue();
}
}
} catch (Exception e) {
log.warn("setSet {} = {}", keyPattern, e);
} finally {
jedis.close();
}
return sum;
}
/**
* 支持*key*
*
* @param keyPattern
* @return
*/
public Set<String> keys(String keyPattern) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
return jedis.keys(keyPattern);
} catch (Exception e) {
log.warn("keys {} = {}", keyPattern, e);
} finally {
jedis.close();
}
return new HashSet<>();
}
/**
* zadd(sorted set:有序集合)
* zadd key [NX|XX] [CH] [INCR] score member [score member ...]
*
* @param key
* @param value
* @return
*/
public long zrem(String key, String member) {
long result = 0;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
result = jedis.zrem(key, member);
log.debug("zrem {} = {}", key, member);
} catch (Exception e) {
log.warn("zrem {} = {}", key, member, e);
} finally {
jedis.close();
}
return result;
}
/**
* zset(sorted set:有序集合)
* zrange key min max [WITHSCORES] [LIMIT offset count]
*
* @param key
* @return
*/
public Set<String> zrange(String key, long min, long max) {
Set<String> value = null;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
value = jedis.zrange(key, min, max);
log.debug("getZset {} = {}", key, value);
}
} catch (Exception e) {
log.warn("getZset {} = {}", key, value, e);
} finally {
jedis.close();
}
return value;
}
/**
* zset(sorted set:有序集合)
* zrange key min max [WITHSCORES] [LIMIT offset count]
*
* @param key
* @return
*/
public Set<String> zrevrange(String key, long min, long max) {
Set<String> value = null;
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
if (jedis.exists(key)) {
value = jedis.zrevrange(key, min, max);
log.debug("getZset {} = {}", key, value);
}
} catch (Exception e) {
log.warn("getZset {} = {}", key, value, e);
} finally {
jedis.close();
}
return value;
}
public void pipeline(Map<String, String> map) {
Jedis jedis = null;
try {
jedis = jedisPool.getResource();
Pipeline pipeline = jedis.pipelined();
for (Map.Entry<String, String> entry : map.entrySet()) {
pipeline.set(entry.getKey().getBytes(), entry.getValue().getBytes());
}
pipeline.sync();
} catch (Exception e) {
log.warn("setPipeline {}", map, e);
} finally {
jedis.close();
}
}
public Long incrByExpired(String key, Integer value, int expireTime) {
Jedis jedis = null;
Long result = null;
try {
jedis = jedisPool.getResource();
result = jedis.incrBy(key, value.longValue());
if (result == 1) {
jedis.expire(key, expireTime);
}
log.debug("incrBy {} = {}", key, value);
} catch (Exception e) {
log.warn("incrBy {} = {}", key, value, e);
} finally {
jedis.close();
}
return result;
}
}
@@ -0,0 +1,30 @@
package io.xiaoxi.job;
import com.alibaba.fastjson.JSON;
import io.xiaoxi.utils.MysqlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class BotChatJob {
public static final Logger log = LoggerFactory.getLogger(BotChatJob.class.getName());
public static void start() {
Executors.newSingleThreadScheduledExecutor((r) -> {
Thread thread = new Thread(r);
thread.setDaemon(true);
return thread;
}).scheduleWithFixedDelay(() -> {
try {
log.info("======BotChatJob start...");
MysqlUtil.util.cSrv.updateBotChat();
} catch (Exception e) {
log.warn("error get bot chat..., {}", e);
}
}, 1, 5, TimeUnit.MINUTES);
}
}

Some files were not shown because too many files have changed in this diff Show More