+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-09
+ */
+@Data
+public class PersonalTemplateDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ private String id;
+
+ /**
+ * 客户ID
+ */
+ private String customerId;
+
+ /**
+ * 小程序类型 居民端resi,工作端work
+ */
+ private String clientType;
+
+ /**
+ * APPID
+ */
+ private String appId;
+
+ /**
+ * 主模板ID
+ */
+ private String pid;
+
+ /**
+ * 添加至帐号下的模板id
+ */
+ private String priTmplId;
+
+ /**
+ * 模板类型,2 代表一次性订阅,3 代表长期订阅
+ */
+ private String type;
+
+ /**
+ * 模板ID
+ */
+ private String tid;
+
+ /**
+ * 模板标题
+ */
+ private String title;
+
+ /**
+ * 关键词ID
+ */
+ private String keyIds;
+
+ /**
+ * 关键词
+ */
+ private String keyWords;
+
+ /**
+ * 服务场景描述,15个字以内
+ */
+ private String sceneDesc;
+
+ /**
+ * 乐观锁
+ */
+ private Integer revision;
+
+ /**
+ * 是否删除
+ */
+ private String delFlag;
+
+ /**
+ * 创建人
+ */
+ private String createdBy;
+
+ /**
+ * 创建时间
+ */
+ private Date createdTime;
+
+ /**
+ * 更新人
+ */
+ private String updatedBy;
+
+ /**
+ * 更新时间
+ */
+ private Date updatedTime;
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PublicTemplateDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PublicTemplateDTO.java
new file mode 100644
index 0000000000..b4c8b1d7f7
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PublicTemplateDTO.java
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-11
+ */
+@Data
+public class PublicTemplateDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ private String id;
+
+ /**
+ *
+ */
+ private String tid;
+
+ /**
+ *
+ */
+ private String title;
+
+ /**
+ *
+ */
+ private String type;
+
+ /**
+ *
+ */
+ private String categoryId;
+
+ /**
+ *
+ */
+ private Integer revision;
+
+ /**
+ *
+ */
+ private String delFlag;
+
+ /**
+ *
+ */
+ private String createdBy;
+
+ /**
+ *
+ */
+ private Date createdTime;
+
+ /**
+ *
+ */
+ private String updatedBy;
+
+ /**
+ *
+ */
+ private Date updatedTime;
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java
new file mode 100644
index 0000000000..edb391eb73
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java
@@ -0,0 +1,51 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:20
+ */
+@NoArgsConstructor
+@Data
+public class AddTemplateFormDTO implements Serializable {
+
+ private static final long serialVersionUID = 8721859887464107897L;
+ /**
+ * appId
+ */
+ private String appId;
+ /**
+ * 公共模板标题 id
+ */
+ private String tid;
+ /**
+ * 公共模板标题
+ */
+ private String title;
+ /**
+ * 服务场景描述,15个字以内
+ */
+ private String sceneDesc;
+ /**
+ * 工作端(gov),居民端(resi)
+ */
+ private String clientType;
+ /**
+ * 模板类型,2 代表一次性订阅,3 代表长期订阅
+ */
+ private String type;
+ /**
+ * 关键词id,最多支持5个,最少2个关键词组合
+ */
+ private List kidList;
+ /**
+ * 关键字名称
+ */
+ private List nameList;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelTemplateFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelTemplateFormDTO.java
new file mode 100644
index 0000000000..e3cc9b4e48
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelTemplateFormDTO.java
@@ -0,0 +1,17 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:23
+ */
+@Data
+public class DelTemplateFormDTO implements Serializable {
+ private static final long serialVersionUID = -3468604475671634840L;
+ private String appId;
+ private String priTmplId;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java
new file mode 100644
index 0000000000..ab154a196a
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java
@@ -0,0 +1,39 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/10 16:22
+ */
+@NoArgsConstructor
+@Data
+public class InitFormDTO implements Serializable {
+
+ private static final long serialVersionUID = -7120483520014483199L;
+ /**
+ * 客户ID
+ */
+ private String customerId;
+ /**
+ * 居民端测试号AppID
+ */
+ private String resiAppId;
+ /**
+ * 工作端测试号AppID
+ */
+ private String workAppId;
+ /**
+ * 居民端需要同步的模板id数组
+ */
+ private List resiTempIdList;
+ /**
+ * 工作端需要同步的模板id数组
+ */
+ private List workTempIdList;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PubTemplateFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PubTemplateFormDTO.java
new file mode 100644
index 0000000000..c0431067b4
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PubTemplateFormDTO.java
@@ -0,0 +1,26 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:58
+ */
+@NoArgsConstructor
+@Data
+public class PubTemplateFormDTO implements Serializable {
+
+ private static final long serialVersionUID = 9023183147998651076L;
+ private String appId;
+ /**
+ * 类目 id,多个用逗号隔开
+ */
+ private String ids;
+ private String title;
+ private Integer pageNo;
+ private Integer pageSize;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubscribeFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubscribeFormDTO.java
new file mode 100644
index 0000000000..574f64689f
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubscribeFormDTO.java
@@ -0,0 +1,19 @@
+package com.epmet.dto.form;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:19
+ */
+@NoArgsConstructor
+@Data
+public class SubscribeFormDTO implements Serializable {
+ private static final long serialVersionUID = -4637357527979131441L;
+ private String appId;
+ private String titleId;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTempResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTempResultDTO.java
new file mode 100644
index 0000000000..d75387bfb6
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTempResultDTO.java
@@ -0,0 +1,18 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/11 14:02
+ */
+@NoArgsConstructor
+@Data
+public class CustomerTempResultDTO {
+ private List workList;
+ private List resiList;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateResultDTO.java
new file mode 100644
index 0000000000..fca432b8b7
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateResultDTO.java
@@ -0,0 +1,47 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:36
+ */
+@NoArgsConstructor
+@Data
+public class GetTemplateResultDTO implements Serializable {
+
+ private static final long serialVersionUID = -3558254681242362668L;
+ /**
+ * 添加至帐号下的模板 id,发送小程序订阅消息时所需
+ */
+ private String priTmplId;
+ /**
+ * 模板标题
+ */
+ private String title;
+ /**
+ * 模板内容
+ */
+ private String content;
+ /**
+ * 模板内容示例
+ */
+ private String example;
+ /**
+ * 模板类型,2 代表一次性订阅,3 代表长期订阅
+ */
+ private String type;
+ /**
+ * 关键词名称,逗号隔开
+ */
+ private String kidNames;
+
+ /**
+ * 场景说明
+ */
+ private String sceneDesc;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/KeyWordsResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/KeyWordsResultDTO.java
new file mode 100644
index 0000000000..7291a415c0
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/KeyWordsResultDTO.java
@@ -0,0 +1,34 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:34
+ */
+@NoArgsConstructor
+@Data
+public class KeyWordsResultDTO implements Serializable {
+
+ private static final long serialVersionUID = 3082505411447366845L;
+ /**
+ * 关键词 id
+ */
+ private Integer kid;
+ /**
+ * 关键词内容
+ */
+ private String name;
+ /**
+ * 关键词内容对应的示例
+ */
+ private String example;
+ /**
+ * 参数类型
+ */
+ private String rule;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PubTemplateResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PubTemplateResultDTO.java
new file mode 100644
index 0000000000..ae28b3bfb0
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PubTemplateResultDTO.java
@@ -0,0 +1,39 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:27
+ */
+@NoArgsConstructor
+@Data
+public class PubTemplateResultDTO implements Serializable {
+
+ private static final long serialVersionUID = -1563615907119995448L;
+ /**
+ * 模板标题 id
+ */
+ private Integer tid;
+ /**
+ * 模板标题
+ */
+ private String title;
+ /**
+ * 模板类型,2 为一次性订阅,3 为长期订阅
+ */
+ private Integer type;
+ /**
+ * 模板所属类目 id
+ */
+ private String categoryId;
+ /**
+ * 关键词
+ */
+ private List keywords;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SubscribeCategoryResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SubscribeCategoryResultDTO.java
new file mode 100644
index 0000000000..057394c552
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SubscribeCategoryResultDTO.java
@@ -0,0 +1,17 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 14:25
+ */
+@Data
+public class SubscribeCategoryResultDTO implements Serializable {
+ private static final long serialVersionUID = -2539495405169212998L;
+ private Integer id;
+ private String name;
+}
diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java
new file mode 100644
index 0000000000..0229316e01
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java
@@ -0,0 +1,31 @@
+package com.epmet.dto.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/11 14:38
+ */
+@Data
+public class TemplateDTO implements Serializable {
+ private static final long serialVersionUID = 1709155656984339643L;
+ /**
+ * 模板ID
+ */
+ private String id;
+ /**
+ * 模板ID
+ */
+ private String tmplId;
+ /**
+ * 标题
+ */
+ private String title;
+ /**
+ * 同步状态 0未同步 1同步
+ */
+ private String state;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java
new file mode 100644
index 0000000000..47d3b6d653
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java
@@ -0,0 +1,149 @@
+package com.epmet.controller;
+
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.dto.form.*;
+import com.epmet.dto.result.CustomerTempResultDTO;
+import com.epmet.dto.result.GetTemplateResultDTO;
+import com.epmet.dto.result.KeyWordsResultDTO;
+import com.epmet.dto.result.SubscribeCategoryResultDTO;
+import com.epmet.service.SubscribeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/10 13:44
+ */
+@RestController
+@RequestMapping("subscribe")
+public class SubscribeController {
+
+ @Autowired
+ private SubscribeService subscribeService;
+
+ /**
+ * 获取当前帐号所设置的类目信息
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.SubscribeCategoryResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 14:57
+ */
+ @PostMapping("getcategory")
+ public Result> getCategory(@RequestBody SubscribeFormDTO formDTO) {
+ List result = subscribeService.getCategory(formDTO);
+ return new Result>().ok(result);
+ }
+
+
+ /**
+ * 获取模板标题列表
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.PubTemplateResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:00
+ */
+ @PostMapping("getpubtemplatetitles")
+ public Result getPubTemplateTitles(@RequestBody PubTemplateFormDTO formDTO) {
+ PageData result = subscribeService.getPubTemplateTitles(formDTO);
+ return new Result().ok(result);
+ }
+
+ /**
+ * 同步微信公共模板
+ *
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @author zhaoqifeng
+ * @date 2020/9/11 16:11
+ */
+ @PostMapping("syncpubtemplatetitles")
+ public Result syncPubTemplateTitles(@RequestBody PubTemplateFormDTO formDTO) {
+ subscribeService.syncPubTemplateTitles(formDTO);
+ return new Result();
+ }
+
+ /**
+ * 获取模板标题下的关键词库
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.KeyWordsResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:10
+ */
+ @PostMapping("getkeywords")
+ public Result> getKeyWords(@RequestBody SubscribeFormDTO formDTO) {
+ List result = subscribeService.getKeyWords(formDTO);
+ return new Result>().ok(result);
+ }
+
+ /**
+ * 获取帐号下的模板列表
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.GetTemplateResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:12
+ */
+ @PostMapping("gettemplate")
+ public Result> getTemplate(@RequestBody SubscribeFormDTO formDTO) {
+ List result = subscribeService.getTemplate(formDTO);
+ return new Result>().ok(result);
+ }
+
+ /**
+ * 添加个人模板
+ *
+ * @param formDTO
+ * @return void
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:13
+ */
+ @PostMapping("addtemplate")
+ public Result addTemplate(@RequestBody AddTemplateFormDTO formDTO) {
+ subscribeService.addTemplate(formDTO);
+ return new Result();
+ }
+
+ /**
+ * 删除账号下模板
+ *
+ * @param formDTO
+ * @return void
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:13
+ */
+ @PostMapping("deltemplate")
+ public Result delTemplate(@RequestBody DelTemplateFormDTO formDTO) {
+ subscribeService.delTemplate(formDTO);
+ return new Result();
+ }
+
+ /**
+ * 客户初始化
+ *
+ * @param formDTO
+ * @return com.epmet.commons.tools.utils.Result
+ * @author zhaoqifeng
+ * @date 2020/9/11 9:25
+ */
+ @PostMapping("init")
+ public Result init(@RequestBody InitFormDTO formDTO) {
+ subscribeService.init(formDTO);
+ return new Result();
+ }
+
+ @PostMapping("getcustomerlist")
+ public Result getCustomerTemplate(@RequestBody InitFormDTO formDTO) {
+ CustomerTempResultDTO result = subscribeService.getCustomerTemplate(formDTO);
+ return new Result().ok(result);
+ }
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
index 882a091b1b..ccd9802432 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
@@ -118,4 +118,13 @@ public interface AuthorizationInfoDao extends BaseDao {
* @date 2020.08.25 15:24
**/
List selectClientToken(@Param("customerId") String customerId);
+
+ /**
+ * 根据APPID获取auth信息
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:23
+ * @param appId
+ * @return com.epmet.dto.AuthorizationInfoDTO
+ */
+ AuthorizationInfoDTO selectInfoByAppId(@Param("appId") String appId);
}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java
index 573ad48cf3..ac24fb4ac2 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java
@@ -120,4 +120,13 @@ public interface PaCustomerDao extends BaseDao {
* @date 2020.08.26 10:59
**/
String selectSourceById(@Param("customerId") String customerId,@Param("source") String source);
+
+ /**
+ * 根据测试号查询同源的客户列表
+ * @author zhaoqifeng
+ * @date 2020/9/9 17:23
+ * @param customerId
+ * @return java.util.List
+ */
+ List selectCustomerListByTestId(@Param("customerId") String customerId);
}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java
new file mode 100644
index 0000000000..bd77f6ffea
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.dto.PersonalTemplateDTO;
+import com.epmet.dto.result.CustomerTempResultDTO;
+import com.epmet.dto.result.TemplateDTO;
+import com.epmet.entity.PersonalTemplateEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-09
+ */
+@Mapper
+public interface PersonalTemplateDao extends BaseDao {
+ /**
+ * 获取个人模板列表
+ *
+ * @param pid
+ * @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/9/9 17:56
+ */
+ List selectListByPid(@Param("pid") String pid);
+
+ /**
+ * 根据AppID获取模板列表
+ *
+ * @param appId
+ * @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/9/10 10:49
+ */
+ List selectListByAppId(@Param("appId") String appId);
+
+ /**
+ * 获取已配置的模板
+ *
+ * @param customerId
+ * @param pid
+ * @return com.epmet.dto.PersonalTemplateDTO
+ * @author zhaoqifeng
+ * @date 2020/9/11 9:42
+ */
+ PersonalTemplateDTO selectSetTemp(@Param("customerId") String customerId, @Param("pid") String pid);
+
+ /**
+ * 根据客户Id获取模板列表
+ *
+ * @param appId
+ * @param customerId
+ * @param clientType
+ * @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/9/11 14:35
+ */
+ List selectListByCustomerId(@Param("appId") String appId, @Param("customerId") String customerId,
+ @Param("clientType") String clientType);
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PublicTemplateDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PublicTemplateDao.java
new file mode 100644
index 0000000000..b51596e20e
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PublicTemplateDao.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.dao;
+
+import com.epmet.commons.mybatis.dao.BaseDao;
+import com.epmet.dto.form.PubTemplateFormDTO;
+import com.epmet.dto.result.PubTemplateResultDTO;
+import com.epmet.entity.PublicTemplateEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-11
+ */
+@Mapper
+public interface PublicTemplateDao extends BaseDao {
+
+ /**
+ * 根据类目Id删除模板
+ * @author zhaoqifeng
+ * @date 2020/9/11 16:22
+ * @param list
+ * @return void
+ */
+ void deleteTempByCategoryId(List list);
+
+ /**
+ * 获取公共模板列表
+ * @author zhaoqifeng
+ * @date 2020/9/11 16:57
+ * @param dto
+ * @return java.util.List
+ */
+ List getPubTempList(PubTemplateFormDTO dto);
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PersonalTemplateEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PersonalTemplateEntity.java
new file mode 100644
index 0000000000..022c2982a5
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PersonalTemplateEntity.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-09
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("personal_template")
+public class PersonalTemplateEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 客户ID
+ */
+ private String customerId;
+
+ /**
+ * 小程序类型 居民端resi,工作端work
+ */
+ private String clientType;
+
+ /**
+ * APPID
+ */
+ private String appId;
+
+ /**
+ * 主模板ID
+ */
+ private String pid;
+
+ /**
+ * 添加至帐号下的模板id
+ */
+ private String priTmplId;
+
+ /**
+ * 模板类型,2 代表一次性订阅,3 代表长期订阅
+ */
+ private String type;
+
+ /**
+ * 模板ID
+ */
+ private String tid;
+
+ /**
+ * 模板标题
+ */
+ private String title;
+
+ /**
+ * 关键词ID
+ */
+ private String keyIds;
+
+ /**
+ * 关键词
+ */
+ private String keyWords;
+
+ /**
+ * 服务场景描述,15个字以内
+ */
+ private String sceneDesc;
+
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PublicTemplateEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PublicTemplateEntity.java
new file mode 100644
index 0000000000..62cac50b92
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PublicTemplateEntity.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-11
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("public_template")
+public class PublicTemplateEntity extends BaseEpmetEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ private String tid;
+
+ /**
+ *
+ */
+ private String title;
+
+ /**
+ *
+ */
+ private String type;
+
+ /**
+ *
+ */
+ private String categoryId;
+
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
index a1b30bd255..ecdf6cfe25 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
@@ -233,4 +233,13 @@ public interface PaCustomerService extends BaseService {
* @date 2020.08.25 15:46
**/
void clearPublicCustomer(CommonCustomerIdAndSrcFormDTO param);
+
+ /**
+ * 根据测试号查询同源的客户列表
+ * @author zhaoqifeng
+ * @date 2020/9/9 17:32
+ * @param customerId
+ * @return java.util.List
+ */
+ List getCustomerListByTestId(String customerId);
}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java
new file mode 100644
index 0000000000..447e6dd388
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java
@@ -0,0 +1,126 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service;
+
+import com.epmet.commons.mybatis.service.BaseService;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.dto.PersonalTemplateDTO;
+import com.epmet.dto.result.TemplateDTO;
+import com.epmet.entity.PersonalTemplateEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-09
+ */
+public interface PersonalTemplateService extends BaseService {
+
+ /**
+ * 默认分页
+ *
+ * @param params
+ * @return PageData
+ * @author generator
+ * @date 2020-09-09
+ */
+ PageData page(Map params);
+
+ /**
+ * 默认查询
+ *
+ * @param params
+ * @return java.util.List
+ * @author generator
+ * @date 2020-09-09
+ */
+ List list(Map params);
+
+ /**
+ * 单条查询
+ *
+ * @param id
+ * @return PersonalTemplateDTO
+ * @author generator
+ * @date 2020-09-09
+ */
+ PersonalTemplateDTO get(String id);
+
+ /**
+ * 默认保存
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2020-09-09
+ */
+ void save(PersonalTemplateDTO dto);
+
+ /**
+ * 默认更新
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2020-09-09
+ */
+ void update(PersonalTemplateDTO dto);
+
+ /**
+ * 批量删除
+ *
+ * @param ids
+ * @return void
+ * @author generator
+ * @date 2020-09-09
+ */
+ void delete(String[] ids);
+
+ /**
+ * 获取个人模板列表
+ *
+ * @param pid
+ * @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/9/9 17:59
+ */
+ List getListByPid(String pid);
+
+ /**
+ * 根据AppID获取模板列表
+ *
+ * @param appId
+ * @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/9/10 10:48
+ */
+ List getListByAppId(String appId);
+
+ /**
+ * 根据客户Id获取模板列表
+ *
+ * @param appId
+ * @param customerId
+ * @param clientType
+ * @return java.util.List
+ * @author zhaoqifeng
+ * @date 2020/9/11 14:43
+ */
+ List getListByCustomer(String appId, String customerId, String clientType);
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PublicTemplateService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PublicTemplateService.java
new file mode 100644
index 0000000000..25ed0174ec
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PublicTemplateService.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service;
+
+import com.epmet.commons.mybatis.service.BaseService;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.dto.PublicTemplateDTO;
+import com.epmet.dto.form.PubTemplateFormDTO;
+import com.epmet.dto.result.PubTemplateResultDTO;
+import com.epmet.entity.PublicTemplateEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-11
+ */
+public interface PublicTemplateService extends BaseService {
+
+ /**
+ * 默认分页
+ *
+ * @param params
+ * @return PageData
+ * @author generator
+ * @date 2020-09-11
+ */
+ PageData page(Map params);
+
+ /**
+ * 默认查询
+ *
+ * @param params
+ * @return java.util.List
+ * @author generator
+ * @date 2020-09-11
+ */
+ List list(Map params);
+
+ /**
+ * 单条查询
+ *
+ * @param id
+ * @return PublicTemplateDTO
+ * @author generator
+ * @date 2020-09-11
+ */
+ PublicTemplateDTO get(String id);
+
+ /**
+ * 默认保存
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2020-09-11
+ */
+ void save(PublicTemplateDTO dto);
+
+ /**
+ * 默认更新
+ *
+ * @param dto
+ * @return void
+ * @author generator
+ * @date 2020-09-11
+ */
+ void update(PublicTemplateDTO dto);
+
+ /**
+ * 批量删除
+ *
+ * @param ids
+ * @return void
+ * @author generator
+ * @date 2020-09-11
+ */
+ void delete(String[] ids);
+
+ /**
+ * 根据类目Id删除模板
+ * @author zhaoqifeng
+ * @date 2020/9/11 16:29
+ * @param categoryIds
+ * @return void
+ */
+ void deleteTempByCategoryId(List categoryIds);
+
+ /**
+ * 获取公共模板列表
+ * @author zhaoqifeng
+ * @date 2020/9/11 17:01
+ * @param dto
+ * @return java.util.List
+ */
+ List getPubTempList(PubTemplateFormDTO dto);
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java
new file mode 100644
index 0000000000..c56d17487a
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java
@@ -0,0 +1,105 @@
+package com.epmet.service;
+
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.dto.form.*;
+import com.epmet.dto.result.*;
+
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 11:02
+ */
+public interface SubscribeService {
+
+ /**
+ * 获取当前帐号所设置的类目信息
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.SubscribeCategoryResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 14:57
+ */
+ List getCategory(SubscribeFormDTO formDTO);
+
+ /**
+ * 获取模板标题列表
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.PubTemplateResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:00
+ */
+ PageData getPubTemplateTitles(PubTemplateFormDTO formDTO);
+
+ /**
+ * 同步微信公共模板
+ * @author zhaoqifeng
+ * @date 2020/9/11 15:26
+ * @param formDTO
+ * @return void
+ */
+ void syncPubTemplateTitles(PubTemplateFormDTO formDTO);
+
+ /**
+ * 获取模板标题下的关键词库
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.KeyWordsResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:10
+ */
+ List getKeyWords(SubscribeFormDTO formDTO);
+
+ /**
+ * 获取帐号下的模板列表
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.GetTemplateResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:12
+ */
+ List getTemplate(SubscribeFormDTO formDTO);
+
+ /**
+ * 添加个人模板
+ *
+ * @param formDTO
+ * @return void
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:13
+ */
+ void addTemplate(AddTemplateFormDTO formDTO);
+
+ /**
+ * 删除账号下模板
+ *
+ * @param formDTO
+ * @return void
+ * @author zhaoqifeng
+ * @date 2020/9/9 15:13
+ */
+ void delTemplate(DelTemplateFormDTO formDTO);
+
+ /**
+ * 客户初始化
+ *
+ * @param formDTO
+ * @return void
+ * @author zhaoqifeng
+ * @date 2020/9/10 16:25
+ */
+ void init(InitFormDTO formDTO);
+
+ /**
+ * 获取客户模板列表
+ *
+ * @param formDTO
+ * @return com.epmet.dto.result.CustomerTempResultDTO
+ * @author zhaoqifeng
+ * @date 2020/9/11 14:04
+ */
+ CustomerTempResultDTO getCustomerTemplate(InitFormDTO formDTO);
+
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
index 9a5640f22d..f0526f95b9 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
@@ -15,6 +15,7 @@ import com.epmet.dao.MiniInfoDao;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
+import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.*;
import com.epmet.wxapi.param.*;
@@ -68,6 +69,8 @@ public class CodeServiceImpl implements CodeService {
private PaCustomerService paCustomerService;
@Autowired
private MiniInfoDao miniInfoDao;
+ @Autowired
+ private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Override
public List templateList() {
@@ -97,11 +100,7 @@ public class CodeServiceImpl implements CodeService {
@Override
public String getExtJson(CodeUploadFormDTO formDTO) {
- CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType());
- if (null == codeExtDTO) {
- return codeExtService.getExtTemplate(formDTO.getClientType());
- }
- return codeExtDTO.getExtJson();
+ return codeExtService.getExtTemplate(formDTO.getClientType());
}
@@ -118,15 +117,27 @@ public class CodeServiceImpl implements CodeService {
if (null == authInfo) {
throw new RenException("未授权");
}
+ CustomerDTO customerFormDTO = new CustomerDTO();
+ customerFormDTO.setId(formDTO.getCustomerId());
+ Result result = operCrmOpenFeignClient.getCustomerInfo(customerFormDTO);
+ if (!result.success()) {
+ throw new RenException(result.getCode(), result.getMsg());
+ }
//获取小程序居民端与工作端名称
- String resiName = miniInfoDao.getNickName(formDTO.getCustomerId(), "resi");
- String workName = miniInfoDao.getNickName(formDTO.getCustomerId(), "work");
+ String resiName = miniInfoDao.getNickName(formDTO.getCustomerId(), CodeConstant.RESI);
+ String workName = miniInfoDao.getNickName(formDTO.getCustomerId(), CodeConstant.WORK);
String extJson = getExtJson(formDTO);
WxExtJson wxExtJson = JSONObject.parseObject(extJson, WxExtJson.class);
wxExtJson.setExtAppid(authInfo.getAuthorizerAppid());
wxExtJson.getExt().setExtAppid(authInfo.getAuthorizerAppid());
wxExtJson.getExt().setResiName(resiName);
wxExtJson.getExt().setWorkName(workName);
+ wxExtJson.getExt().setCustomerName(null == result.getData().getCustomerName()?"":result.getData().getCustomerName());
+ if (CodeConstant.RESI.equals(formDTO.getClientType())) {
+ wxExtJson.getWindow().setNavigationBarTitleText(resiName);
+ } else {
+ wxExtJson.getWindow().setNavigationBarTitleText(workName);
+ }
extJson = JSON.toJSONString(wxExtJson);
CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType());
if (null == codeExtDTO) {
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
index 5b683027b5..11dd6bad81 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
@@ -697,4 +697,9 @@ public class PaCustomerServiceImpl extends BaseServiceImpl getCustomerListByTestId(String customerId) {
+ return baseDao.selectCustomerListByTestId(customerId);
+ }
+
}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java
new file mode 100644
index 0000000000..f7b5589f43
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java
@@ -0,0 +1,119 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.FieldConstant;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.dao.PersonalTemplateDao;
+import com.epmet.dto.PersonalTemplateDTO;
+import com.epmet.dto.result.TemplateDTO;
+import com.epmet.entity.PersonalTemplateEntity;
+import com.epmet.service.PersonalTemplateService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-09
+ */
+@Service
+public class PersonalTemplateServiceImpl extends BaseServiceImpl implements PersonalTemplateService {
+
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, PersonalTemplateDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, PersonalTemplateDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String id = (String)params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
+
+ return wrapper;
+ }
+
+ @Override
+ public PersonalTemplateDTO get(String id) {
+ PersonalTemplateEntity entity = baseDao.selectById(id);
+ return ConvertUtils.sourceToTarget(entity, PersonalTemplateDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(PersonalTemplateDTO dto) {
+ PersonalTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PersonalTemplateEntity.class);
+ insert(entity);
+ //copy主键值到dto
+ BeanUtils.copyProperties(entity, dto);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(PersonalTemplateDTO dto) {
+ PersonalTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PersonalTemplateEntity.class);
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String[] ids) {
+ // 逻辑删除(@TableLogic 注解)
+ baseDao.deleteBatchIds(Arrays.asList(ids));
+ }
+
+ @Override
+ public List getListByPid(String pid) {
+ return baseDao.selectListByPid(pid);
+ }
+
+ @Override
+ public List getListByAppId(String appId) {
+ return baseDao.selectListByAppId(appId);
+ }
+
+ @Override
+ public List getListByCustomer(String appId, String customerId, String clientType) {
+ return baseDao.selectListByCustomerId(appId, customerId, clientType);
+ }
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PublicTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PublicTemplateServiceImpl.java
new file mode 100644
index 0000000000..d59297f700
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PublicTemplateServiceImpl.java
@@ -0,0 +1,112 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.epmet.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
+import com.epmet.commons.tools.constant.FieldConstant;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.dao.PublicTemplateDao;
+import com.epmet.dto.PublicTemplateDTO;
+import com.epmet.dto.form.PubTemplateFormDTO;
+import com.epmet.dto.result.PubTemplateResultDTO;
+import com.epmet.entity.PublicTemplateEntity;
+import com.epmet.service.PublicTemplateService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ *
+ * @author generator generator@elink-cn.com
+ * @since v1.0.0 2020-09-11
+ */
+@Service
+public class PublicTemplateServiceImpl extends BaseServiceImpl implements PublicTemplateService {
+
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, PublicTemplateDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, PublicTemplateDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params){
+ String id = (String)params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
+
+ return wrapper;
+ }
+
+ @Override
+ public PublicTemplateDTO get(String id) {
+ PublicTemplateEntity entity = baseDao.selectById(id);
+ return ConvertUtils.sourceToTarget(entity, PublicTemplateDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(PublicTemplateDTO dto) {
+ PublicTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PublicTemplateEntity.class);
+ insert(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(PublicTemplateDTO dto) {
+ PublicTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PublicTemplateEntity.class);
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(String[] ids) {
+ // 逻辑删除(@TableLogic 注解)
+ baseDao.deleteBatchIds(Arrays.asList(ids));
+ }
+
+ @Override
+ public void deleteTempByCategoryId(List categoryIds) {
+ baseDao.deleteTempByCategoryId(categoryIds);
+ }
+
+ @Override
+ public List getPubTempList(PubTemplateFormDTO formDTO) {
+ return baseDao.getPubTempList(formDTO);
+ }
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java
new file mode 100644
index 0000000000..1521aa508a
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java
@@ -0,0 +1,445 @@
+package com.epmet.service.impl;
+
+import com.epmet.commons.tools.constant.NumConstant;
+import com.epmet.commons.tools.exception.RenException;
+import com.epmet.commons.tools.page.PageData;
+import com.epmet.commons.tools.utils.ConvertUtils;
+import com.epmet.dao.AuthorizationInfoDao;
+import com.epmet.dto.AuthorizationInfoDTO;
+import com.epmet.dto.PaCustomerDTO;
+import com.epmet.dto.PersonalTemplateDTO;
+import com.epmet.dto.PublicTemplateDTO;
+import com.epmet.dto.form.*;
+import com.epmet.dto.result.*;
+import com.epmet.entity.PublicTemplateEntity;
+import com.epmet.service.PaCustomerService;
+import com.epmet.service.PersonalTemplateService;
+import com.epmet.service.PublicTemplateService;
+import com.epmet.service.SubscribeService;
+import com.epmet.wxapi.param.WxAddTemplateReq;
+import com.epmet.wxapi.param.WxDelTemplateReq;
+import com.epmet.wxapi.param.WxSubTemplateReq;
+import com.epmet.wxapi.result.*;
+import com.epmet.wxapi.service.WxMaSubscribeService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 11:02
+ */
+@Slf4j
+@Service
+public class SubscribeServiceImpl implements SubscribeService {
+ @Autowired
+ private AuthorizationInfoDao authorizationInfoDao;
+ @Autowired
+ private WxMaSubscribeService wxMaSubscribeService;
+ @Autowired
+ private PersonalTemplateService personalTemplateService;
+ @Autowired
+ private PaCustomerService paCustomerService;
+ @Autowired
+ private PublicTemplateService publicTemplateService;
+
+
+ @Override
+ public List getCategory(SubscribeFormDTO formDTO) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId());
+ WxGetCategoryResult wxResult = getCategoryResult(authInfo.getAuthorizerAccessToken());
+
+ List list = wxResult.getData().stream().map(category -> {
+ SubscribeCategoryResultDTO resultDTO = new SubscribeCategoryResultDTO();
+ resultDTO.setId(category.getId());
+ resultDTO.setName(category.getName());
+ return resultDTO;
+ }).collect(Collectors.toList());
+
+ return list;
+ }
+
+ @Override
+ public PageData getPubTemplateTitles(PubTemplateFormDTO formDTO) {
+ PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
+ List list = publicTemplateService.getPubTempList(formDTO);
+ PageInfo pageInfo = new PageInfo<>(list);
+ return new PageData<>(list, pageInfo.getTotal());
+ }
+
+ @Override
+ public void syncPubTemplateTitles(PubTemplateFormDTO formDTO) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId());
+ //获取类目ID
+ WxGetCategoryResult wxGetCategoryResult = getCategoryResult(authInfo.getAuthorizerAccessToken());
+ List idList = wxGetCategoryResult.getData().stream().map(a -> a.getId().toString()).collect(Collectors.toList());
+ publicTemplateService.deleteTempByCategoryId(idList);
+ String ids = String.join(",", idList);
+ WxSubTemplateReq request = new WxSubTemplateReq();
+ request.setIds(ids);
+ request.setLimit(NumConstant.THIRTY);
+ request.setStart(NumConstant.ZERO);
+ WxResult wxResult = wxMaSubscribeService.getPubTemplateTitles(authInfo.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ Integer total = wxResult.getData().getCount();
+ List list = wxResult.getData().getData().stream().map(template -> {
+ PublicTemplateDTO dto = new PublicTemplateDTO();
+ dto.setTid(template.getTid().toString());
+ dto.setTitle(template.getTitle());
+ dto.setCategoryId(template.getCategoryId());
+ dto.setType(template.getType().toString());
+ return dto;
+ }).collect(Collectors.toList());
+ if (total > NumConstant.THIRTY) {
+ for (int i = NumConstant.THIRTY; i < total; i= i + NumConstant.THIRTY) {
+ request.setStart(i);
+ wxResult = wxMaSubscribeService.getPubTemplateTitles(authInfo.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ List pubList = wxResult.getData().getData().stream().map(template -> {
+ PublicTemplateDTO dto = new PublicTemplateDTO();
+ dto.setTid(template.getTid().toString());
+ dto.setTitle(template.getTitle());
+ dto.setCategoryId(template.getCategoryId());
+ dto.setType(template.getType().toString());
+ return dto;
+ }).collect(Collectors.toList());
+ list.addAll(pubList);
+ }
+ }
+ publicTemplateService.insertBatch(ConvertUtils.sourceToTarget(list, PublicTemplateEntity.class));
+ }
+
+ @Override
+ public List getKeyWords(SubscribeFormDTO formDTO) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId());
+ WxKeyWordsResult keyWordsResult = getTitleKeyWords(authInfo.getAuthorizerAccessToken(), formDTO.getTitleId());
+ List list = keyWordsResult.getData().stream().map(keyWord -> {
+ KeyWordsResultDTO dto = new KeyWordsResultDTO();
+ dto.setExample(keyWord.getExample());
+ dto.setKid(keyWord.getKid());
+ dto.setName(keyWord.getName());
+ dto.setRule(keyWord.getRule());
+ return dto;
+ }).collect(Collectors.toList());
+ return list;
+ }
+
+ @Override
+ public List getTemplate(SubscribeFormDTO formDTO) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId());
+ List list = personalTemplateService.getListByAppId(formDTO.getAppId());
+ WxResult wxResult = wxMaSubscribeService.getTemplate(authInfo.getAuthorizerAccessToken());
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+
+ List resultList = new ArrayList<>();
+ if (null != list && list.size() > 0) {
+ resultList =
+ list.stream().flatMap(dto -> wxResult.getData().getData().stream().filter(bean ->
+ dto.getPriTmplId().equals(bean.getPriTmplId())).map(template -> {
+ GetTemplateResultDTO tempDTO = new GetTemplateResultDTO();
+ tempDTO.setPriTmplId(dto.getPriTmplId());
+ tempDTO.setTitle(dto.getTitle());
+ tempDTO.setType(dto.getType());
+ tempDTO.setKidNames(dto.getKeyWords());
+ tempDTO.setSceneDesc(dto.getSceneDesc());
+ tempDTO.setContent(template.getContent());
+ tempDTO.setExample(template.getExample());
+ return tempDTO;
+ })).collect(Collectors.toList());
+ }
+ return resultList;
+ }
+
+ @Override
+ public void addTemplate(AddTemplateFormDTO formDTO) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId());
+ WxAddTemplateReq request = new WxAddTemplateReq();
+ request.setTid(formDTO.getTid());
+ request.setKidList(formDTO.getKidList());
+ request.setSceneDesc(formDTO.getSceneDesc());
+ WxResult wxResult = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ String priTmplId = wxResult.getData();
+ String keywords = String.join(",", formDTO.getNameList());
+ List keyIdList = formDTO.getKidList().stream().map(Object::toString).collect(Collectors.toList());
+ String keyIds = String.join(",", keyIdList);
+ //将公共模板存入数据库
+ PersonalTemplateDTO personalTemplateDTO = new PersonalTemplateDTO();
+ personalTemplateDTO.setCustomerId(authInfo.getCustomerId());
+ personalTemplateDTO.setClientType(authInfo.getClientType());
+ personalTemplateDTO.setAppId(formDTO.getAppId());
+ personalTemplateDTO.setPid(priTmplId);
+ personalTemplateDTO.setPriTmplId(priTmplId);
+ personalTemplateDTO.setTid(formDTO.getTid());
+ personalTemplateDTO.setKeyIds(keyIds);
+ personalTemplateDTO.setTitle(formDTO.getTitle());
+ personalTemplateDTO.setSceneDesc(formDTO.getSceneDesc());
+ personalTemplateDTO.setKeyWords(keywords);
+ personalTemplateDTO.setType(formDTO.getType());
+ personalTemplateService.save(personalTemplateDTO);
+ //获取客户列表
+ List customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId());
+ List customerNames = new ArrayList<>();
+ if (null != customerList && customerList.size() > NumConstant.ZERO) {
+ for (PaCustomerDTO paCustomerDTO : customerList) {
+ //获取小程序调用令牌
+ AuthorizationInfoDTO authDTO = authorizationInfoDao.getAuthInfoByCustomer(paCustomerDTO.getId(), authInfo.getClientType());
+ if (null == authDTO) {
+ log.error("客户[" + paCustomerDTO.getCustomerName() + "]未授权");
+ customerNames.add(paCustomerDTO.getCustomerName());
+ continue;
+ }
+ WxResult wxResult1 = wxMaSubscribeService.addTemplate(authDTO.getAuthorizerAccessToken(), request);
+ if (!wxResult1.success()) {
+ log.error("客户[" + paCustomerDTO.getCustomerName() + "]添加模板失败,原因:" + wxResult1.getErrorCode() + wxResult1.getErrorMsg());
+ customerNames.add(paCustomerDTO.getCustomerName());
+ continue;
+ }
+ String tmplId = wxResult1.getData();
+ PersonalTemplateDTO templateDTO = new PersonalTemplateDTO();
+ templateDTO.setCustomerId(paCustomerDTO.getId());
+ templateDTO.setClientType(authInfo.getClientType());
+ templateDTO.setAppId(authDTO.getAuthorizerAppid());
+ templateDTO.setPid(priTmplId);
+ templateDTO.setPriTmplId(tmplId);
+ templateDTO.setTid(formDTO.getTid());
+ templateDTO.setKeyIds(keyIds);
+ templateDTO.setTitle(formDTO.getTitle());
+ templateDTO.setSceneDesc(formDTO.getSceneDesc());
+ templateDTO.setKeyWords(keywords);
+ templateDTO.setType(formDTO.getType());
+ personalTemplateService.save(templateDTO);
+ }
+ }
+
+ if (customerNames.size() > NumConstant.ZERO) {
+ String names = String.join(",", customerNames);
+ throw new RenException("客户[" + names + "]添加模板失败");
+ }
+
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delTemplate(DelTemplateFormDTO formDTO) {
+ List list = personalTemplateService.getListByPid(formDTO.getPriTmplId());
+ for (PersonalTemplateDTO dto : list) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(dto.getCustomerId(), dto.getClientType());
+ if (null == authInfo) {
+ log.error("客户[" + dto.getCustomerId() + "]未授权");
+ continue;
+ }
+ WxDelTemplateReq request = new WxDelTemplateReq();
+ request.setPriTmplId(dto.getPriTmplId());
+ WxResult wxResult = wxMaSubscribeService.delTemplate(authInfo.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ personalTemplateService.deleteById(dto.getId());
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void init(InitFormDTO formDTO) {
+ if (null != formDTO.getResiTempIdList() && !formDTO.getResiTempIdList().isEmpty()) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "resi");
+ if (null == authInfo) {
+ throw new RenException("居民端未授权或token已过期");
+ }
+ formDTO.getResiTempIdList().forEach(tempId -> {
+ PersonalTemplateDTO templateDTO = personalTemplateService.get(tempId);
+ List keyIds = Arrays.asList(templateDTO.getKeyIds().split(","));
+ List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList());
+ WxAddTemplateReq request = new WxAddTemplateReq();
+ request.setTid(templateDTO.getTid());
+ request.setKidList(keyIdList);
+ request.setSceneDesc(templateDTO.getSceneDesc());
+ WxResult wxResult = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ log.error("居民端添加模板失败,原因:" + wxResult.getErrorCode() + wxResult.getErrorMsg());
+ return;
+ }
+ String tmplId = wxResult.getData();
+ PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class);
+ personalTemplate.setPriTmplId(tmplId);
+ personalTemplate.setCustomerId(formDTO.getCustomerId());
+ personalTemplate.setClientType("resi");
+ personalTemplate.setAppId(authInfo.getAuthorizerAppid());
+ personalTemplateService.save(personalTemplate);
+ });
+ }
+
+ if (null != formDTO.getWorkTempIdList() && !formDTO.getWorkTempIdList().isEmpty()) {
+ AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work");
+ if (null == authInfo) {
+ throw new RenException("工作端未授权或token已过期");
+ }
+ formDTO.getWorkTempIdList().forEach(tempId -> {
+ PersonalTemplateDTO templateDTO = personalTemplateService.get(tempId);
+ List keyIds = Arrays.asList(templateDTO.getKeyIds().split(","));
+ List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList());
+ WxAddTemplateReq request = new WxAddTemplateReq();
+ request.setTid(templateDTO.getTid());
+ request.setKidList(keyIdList);
+ request.setSceneDesc(templateDTO.getSceneDesc());
+ WxResult wxResult = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ log.error("工作端添加模板失败,原因:" + wxResult.getErrorCode() + wxResult.getErrorMsg());
+ return;
+ }
+ String tmplId = wxResult.getData();
+ PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class);
+ personalTemplate.setPriTmplId(tmplId);
+ personalTemplate.setCustomerId(formDTO.getCustomerId());
+ personalTemplate.setClientType("resi");
+ personalTemplate.setAppId(authInfo.getAuthorizerAppid());
+ personalTemplateService.save(personalTemplate);
+ });
+ }
+
+ }
+
+ @Override
+ public CustomerTempResultDTO getCustomerTemplate(InitFormDTO formDTO) {
+ CustomerTempResultDTO resultDTO = new CustomerTempResultDTO();
+ AuthorizationInfoDTO resiAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "resi");
+ if (null == resiAuthDTO) {
+ throw new RenException("居民端未授权");
+ }
+ WxResult wxResiResult = wxMaSubscribeService.getTemplate(resiAuthDTO.getAuthorizerAccessToken());
+ if (!wxResiResult.success()) {
+ throw new RenException(wxResiResult.getErrorCode(), wxResiResult.getErrorMsg());
+ }
+ List resiPubTmplIds =
+ wxResiResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList());
+ List resiList = personalTemplateService.getListByCustomer(formDTO.getResiAppId(), formDTO.getCustomerId(), "resi");
+ List resiTmplIds = resiList.stream().map(TemplateDTO::getTmplId).collect(Collectors.toList());
+ List resiReduce = resiPubTmplIds.stream().filter(item -> !resiTmplIds.contains(item)).collect(Collectors.toList());
+ resiReduce.forEach(tmplId -> {
+ WxDelTemplateReq request = new WxDelTemplateReq();
+ request.setPriTmplId(tmplId);
+ WxResult wxResult = wxMaSubscribeService.delTemplate(resiAuthDTO.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ log.error("居民端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg());
+ }
+ });
+ resultDTO.setResiList(resiList);
+
+ AuthorizationInfoDTO workAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work");
+ if (null == workAuthDTO) {
+ throw new RenException("工作端未授权");
+ }
+ WxResult wxWorkResult = wxMaSubscribeService.getTemplate(workAuthDTO.getAuthorizerAccessToken());
+ if (!wxWorkResult.success()) {
+ throw new RenException(wxWorkResult.getErrorCode(), wxWorkResult.getErrorMsg());
+ }
+ List workPubTmplIds =
+ wxWorkResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList());
+ List workList = personalTemplateService.getListByCustomer(formDTO.getWorkAppId(), formDTO.getCustomerId(), "work");
+ List workTmplIds = workList.stream().map(TemplateDTO::getTmplId).collect(Collectors.toList());
+ List workReduce = workPubTmplIds.stream().filter(item -> !workTmplIds.contains(item)).collect(Collectors.toList());
+ workReduce.forEach(tmplId -> {
+ WxDelTemplateReq request = new WxDelTemplateReq();
+ request.setPriTmplId(tmplId);
+ WxResult wxResult = wxMaSubscribeService.delTemplate(resiAuthDTO.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ log.error("工作端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg());
+ }
+ });
+ resultDTO.setWorkList(workList);
+ return resultDTO;
+ }
+
+ private WxGetCategoryResult getCategoryResult(String accessToken) {
+ WxResult wxResult = wxMaSubscribeService.getCategory(accessToken);
+
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ return wxResult.getData();
+ }
+
+ private WxKeyWordsResult getTitleKeyWords(String accessToken, String tId) {
+ WxResult wxResult = wxMaSubscribeService.getPubTemplateKeywords(accessToken, tId);
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ return wxResult.getData();
+ }
+
+ public void sync(InitFormDTO formDTO) {
+ AuthorizationInfoDTO resiAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "resi");
+ if (null == resiAuthDTO) {
+ throw new RenException("居民端未授权");
+ }
+ AuthorizationInfoDTO workAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work");
+ if (null == workAuthDTO) {
+ throw new RenException("工作端未授权");
+ }
+ //居民端初始化
+ List resiList = personalTemplateService.getListByAppId(formDTO.getResiAppId());
+ if (null != resiList && resiList.size() > 0) {
+ resiList.forEach(templateDTO -> {
+ List keyIds = Arrays.asList(templateDTO.getKeyIds().split(","));
+ List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList());
+ WxAddTemplateReq request = new WxAddTemplateReq();
+ request.setTid(templateDTO.getTid());
+ request.setKidList(keyIdList);
+ request.setSceneDesc(templateDTO.getSceneDesc());
+ WxResult wxResult = wxMaSubscribeService.addTemplate(resiAuthDTO.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ String tmplId = wxResult.getData();
+ PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class);
+ personalTemplate.setPriTmplId(tmplId);
+ personalTemplate.setCustomerId(formDTO.getCustomerId());
+ personalTemplate.setClientType("resi");
+ personalTemplate.setAppId(resiAuthDTO.getAuthorizerAppid());
+ personalTemplateService.save(personalTemplate);
+ });
+ }
+ //工作端初始化
+ List workList = personalTemplateService.getListByAppId(formDTO.getWorkAppId());
+ if (null != workList && workList.size() > 0) {
+ workList.forEach(templateDTO -> {
+ List keyIds = Arrays.asList(templateDTO.getKeyIds().split(","));
+ List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList());
+ WxAddTemplateReq request = new WxAddTemplateReq();
+ request.setTid(templateDTO.getTid());
+ request.setKidList(keyIdList);
+ request.setSceneDesc(templateDTO.getSceneDesc());
+ WxResult wxResult = wxMaSubscribeService.addTemplate(workAuthDTO.getAuthorizerAccessToken(), request);
+ if (!wxResult.success()) {
+ throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
+ }
+ String tmplId = wxResult.getData();
+ PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class);
+ personalTemplate.setPriTmplId(tmplId);
+ personalTemplate.setCustomerId(formDTO.getCustomerId());
+ personalTemplate.setClientType("work");
+ personalTemplate.setAppId(workAuthDTO.getAuthorizerAppid());
+ personalTemplateService.save(personalTemplate);
+ });
+ }
+ }
+
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxSubscribeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxSubscribeConstant.java
new file mode 100644
index 0000000000..e0c27129b5
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxSubscribeConstant.java
@@ -0,0 +1,38 @@
+package com.epmet.wxapi.constant;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 10:34
+ */
+public interface WxSubscribeConstant {
+ /**
+ * 获取当前帐号所设置的类目信息
+ */
+ String GET_CATEGORY_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/getcategory";
+
+ /**
+ * 获取模板标题列表
+ */
+ String GET_PUB_TEMPLATE_TITLES_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles";
+
+ /**
+ * 获取模板标题下的关键词库
+ */
+ String GET_KEY_WORDS_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords";
+
+ /**
+ * 组合模板并添加到个人模板库
+ */
+ String ADD_TEMPLATE_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate";
+
+ /**
+ * 获取帐号下的模板列表
+ */
+ String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate";
+
+ /**
+ * 删除帐号下的某个模板
+ */
+ String DEL_TEMPLATE_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate";
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java
index 23e1077e7c..29e341df7a 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java
@@ -519,6 +519,26 @@ public enum WxMaErrorMsgEnum {
CODE_43101(43101, "用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系"),
CODE_47003(47003, "模板参数不准确,可能为空或者不满足规则,errmsg会提示具体是哪个字段出错"),
+
+ CODE_200011(200011, "此账号已被封禁,无法操作"),
+
+ CODE_200012(200012, "个人模板数已达上限,上限25个"),
+
+ CODE_200013(200013, "此模板已被封禁,无法选用"),
+
+ CODE_200014(200014, "模板 tid 参数错误"),
+
+ CODE_200016(200016, "start 参数错误"),
+
+ CODE_200017(200017, "limit 参数错误"),
+
+ CODE_200018(200018, "类目 ids 缺失"),
+
+ CODE_200019(200019, "类目 ids 不合法"),
+
+ CODE_200020(200020, "关键词列表 kidList 参数错误"),
+
+ CODE_200021(200021, "场景描述 sceneDesc 参数错误"),
;
private int code;
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddTemplateReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddTemplateReq.java
new file mode 100644
index 0000000000..ae083f7702
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddTemplateReq.java
@@ -0,0 +1,31 @@
+package com.epmet.wxapi.param;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 9:33
+ */
+@NoArgsConstructor
+@Data
+public class WxAddTemplateReq implements Serializable {
+
+ private static final long serialVersionUID = -9163397048982502051L;
+ /**
+ * 模板标题 id
+ */
+ private String tid;
+ /**
+ * 关键词id
+ */
+ private String sceneDesc;
+ /**
+ * 服务场景描述,15个字以内
+ */
+ private List kidList;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDelTemplateReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDelTemplateReq.java
new file mode 100644
index 0000000000..4bb8be5958
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDelTemplateReq.java
@@ -0,0 +1,22 @@
+package com.epmet.wxapi.param;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 9:43
+ */
+@NoArgsConstructor
+@Data
+public class WxDelTemplateReq implements Serializable {
+
+ private static final long serialVersionUID = 195634574947498628L;
+ /**
+ * 要删除的模板id
+ */
+ private String priTmplId;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java
index 4ba45e37cf..6a22908d9b 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java
@@ -24,6 +24,8 @@ public class WxExtJson implements Serializable {
private boolean directCommit;
@JSONField(ordinal = 4)
private ExtBean ext;
+ @JSONField(ordinal = 5)
+ private WindowBean window;
@NoArgsConstructor
@Data
@@ -31,10 +33,12 @@ public class WxExtJson implements Serializable {
@JSONField(ordinal = 1)
private String extAppid;
@JSONField(ordinal = 2)
- private String resiName;
+ private String customerName;
@JSONField(ordinal = 3)
- private String workName;
+ private String resiName;
@JSONField(ordinal = 4)
+ private String workName;
+ @JSONField(ordinal = 5)
private FootbarBean footbar;
@NoArgsConstructor
@Data
@@ -119,4 +123,12 @@ public class WxExtJson implements Serializable {
}
}
}
+
+ @NoArgsConstructor
+ @Data
+ public static class WindowBean {
+ @JSONField(ordinal = 1)
+ private String navigationBarTitleText;
+ }
+
}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxSubTemplateReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxSubTemplateReq.java
new file mode 100644
index 0000000000..48ac4c482e
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxSubTemplateReq.java
@@ -0,0 +1,30 @@
+package com.epmet.wxapi.param;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/8 16:30
+ */
+@NoArgsConstructor
+@Data
+public class WxSubTemplateReq implements Serializable {
+ private static final long serialVersionUID = 4133480686759651875L;
+
+ /**
+ * 类目 id,多个用逗号隔开
+ */
+ private String ids;
+ /**
+ * 用于分页,表示从 start 开始。从 0 开始计数
+ */
+ private Integer start;
+ /**
+ * 用于分页,表示拉取 limit 条记录。最大为 30
+ */
+ private Integer limit;
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetCategoryResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetCategoryResult.java
new file mode 100644
index 0000000000..085b9e3a1d
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetCategoryResult.java
@@ -0,0 +1,41 @@
+package com.epmet.wxapi.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/8 16:03
+ */
+@NoArgsConstructor
+@Data
+public class WxGetCategoryResult implements Serializable {
+
+ private static final long serialVersionUID = 6785111976796640604L;
+ /**
+ * 错误码
+ */
+ private Integer errcode;
+ /**
+ * 错误信息
+ */
+ private String errmsg;
+ /**
+ * 类目列表
+ */
+ private List data;
+
+ @NoArgsConstructor
+ @Data
+ public static class DataBean {
+ /**
+ * id : 616
+ */
+ private Integer id;
+ private String name;
+ }
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetTemplateResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetTemplateResult.java
new file mode 100644
index 0000000000..c6a4101ea7
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetTemplateResult.java
@@ -0,0 +1,56 @@
+package com.epmet.wxapi.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/9 9:36
+ */
+@NoArgsConstructor
+@Data
+public class WxGetTemplateResult implements Serializable {
+
+ private static final long serialVersionUID = 1796638032203448934L;
+ /**
+ * 错误码
+ */
+ private Integer errcode;
+ /**
+ * 错误信息
+ */
+ private String errmsg;
+ /**
+ * 个人模板列表
+ */
+ private List data;
+
+ @NoArgsConstructor
+ @Data
+ public static class DataBean {
+ /**
+ * 添加至帐号下的模板 id
+ */
+ private String priTmplId;
+ /**
+ * 模板标题
+ */
+ private String title;
+ /**
+ * 模板内容
+ */
+ private String content;
+ /**
+ * 模板内容示例
+ */
+ private String example;
+ /**
+ * 模板类型,2 代表一次性订阅,3 代表长期订阅
+ */
+ private Integer type;
+ }
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxKeyWordsResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxKeyWordsResult.java
new file mode 100644
index 0000000000..fca92e0b42
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxKeyWordsResult.java
@@ -0,0 +1,52 @@
+package com.epmet.wxapi.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/8 16:42
+ */
+@NoArgsConstructor
+@Data
+public class WxKeyWordsResult implements Serializable {
+
+ private static final long serialVersionUID = -7867379425609113193L;
+ /**
+ * 错误码
+ */
+ private Integer errcode;
+ /**
+ * 错误信息
+ */
+ private String errmsg;
+ /**
+ * 关键词列表
+ */
+ private List data;
+
+ @NoArgsConstructor
+ @Data
+ public static class DataBean {
+ /**
+ * 关键词 id
+ */
+ private Integer kid;
+ /**
+ * 关键词内容
+ */
+ private String name;
+ /**
+ * 关键词内容对应的示例
+ */
+ private String example;
+ /**
+ * 参数类型
+ */
+ private String rule;
+ }
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxSubTemplateResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxSubTemplateResult.java
new file mode 100644
index 0000000000..db5989187e
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxSubTemplateResult.java
@@ -0,0 +1,56 @@
+package com.epmet.wxapi.result;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/8 16:12
+ */
+@NoArgsConstructor
+@Data
+public class WxSubTemplateResult implements Serializable {
+
+ private static final long serialVersionUID = 5581168509440371239L;
+ /**
+ * 错误码
+ */
+ private Integer errcode;
+ /**
+ * 错误信息
+ */
+ private String errmsg;
+ /**
+ * 列表总数
+ */
+ private Integer count;
+ /**
+ * 标题列表
+ */
+ private List data;
+
+ @NoArgsConstructor
+ @Data
+ public static class DataBean {
+ /**
+ * 模板标题 id
+ */
+ private Integer tid;
+ /**
+ * 模板标题
+ */
+ private String title;
+ /**
+ * 模板类型,2 为一次性订阅,3 为长期订阅
+ */
+ private Integer type;
+ /**
+ * 模板所属类目 id
+ */
+ private String categoryId;
+ }
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaSubscribeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaSubscribeService.java
new file mode 100644
index 0000000000..6f426b0c0e
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaSubscribeService.java
@@ -0,0 +1,78 @@
+package com.epmet.wxapi.service;
+
+import com.epmet.wxapi.param.WxAddTemplateReq;
+import com.epmet.wxapi.param.WxDelTemplateReq;
+import com.epmet.wxapi.param.WxSubTemplateReq;
+import com.epmet.wxapi.result.*;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/8 15:55
+ */
+public interface WxMaSubscribeService {
+
+ /**
+ * 获取当前帐号所设置的类目信息
+ *
+ * @param accessToken
+ * @return com.epmet.wxapi.result.WxResult
+ * @author zhaoqifeng
+ * @date 2020/9/8 16:06
+ */
+ WxResult getCategory(String accessToken);
+
+ /**
+ * 获取模板标题列表
+ *
+ * @param accessToken
+ * @param request
+ * @return com.epmet.wxapi.result.WxSubTemplateResult
+ * @author zhaoqifeng
+ * @date 2020/9/8 16:34
+ */
+ WxResult getPubTemplateTitles(String accessToken, WxSubTemplateReq request);
+
+ /**
+ * 获取模板标题下的关键词库
+ *
+ * @param accessToken
+ * @param tId
+ * @return com.epmet.wxapi.result.WxResult
+ * @author zhaoqifeng
+ * @date 2020/9/8 16:45
+ */
+ WxResult getPubTemplateKeywords(String accessToken, String tId);
+
+ /**
+ * 组合模板并添加到个人模板库
+ *
+ * @param accessToken
+ * @param request
+ * @return com.epmet.wxapi.result.WxResult
+ * @author zhaoqifeng
+ * @date 2020/9/9 9:35
+ */
+ WxResult addTemplate(String accessToken, WxAddTemplateReq request);
+
+ /**
+ * 获取帐号下的模板列表
+ *
+ * @param accessToken
+ * @return com.epmet.wxapi.result.WxResult
+ * @author zhaoqifeng
+ * @date 2020/9/9 9:42
+ */
+ WxResult getTemplate(String accessToken);
+
+ /**
+ * 删除帐号下的某个模板
+ *
+ * @param accessToken
+ * @param request
+ * @return com.epmet.wxapi.result.WxResult
+ * @author zhaoqifeng
+ * @date 2020/9/9 9:44
+ */
+ WxResult delTemplate(String accessToken, WxDelTemplateReq request);
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaSubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaSubscribeServiceImpl.java
new file mode 100644
index 0000000000..6826f70fd2
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaSubscribeServiceImpl.java
@@ -0,0 +1,146 @@
+package com.epmet.wxapi.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.epmet.commons.tools.utils.HttpClientManager;
+import com.epmet.commons.tools.utils.Result;
+import com.epmet.wxapi.constant.WxSubscribeConstant;
+import com.epmet.wxapi.enums.WxMaErrorMsgEnum;
+import com.epmet.wxapi.param.WxAddTemplateReq;
+import com.epmet.wxapi.param.WxDelTemplateReq;
+import com.epmet.wxapi.param.WxSubTemplateReq;
+import com.epmet.wxapi.result.*;
+import com.epmet.wxapi.service.WxMaSubscribeService;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author zhaoqifeng
+ * @dscription
+ * @date 2020/9/8 15:56
+ */
+@Service
+public class WxMaSubscribeServiceImpl implements WxMaSubscribeService {
+
+ private static final String ERR_CODE = "errcode";
+ private static final String ERR_MSG = "errmsg";
+
+ @Override
+ public WxResult getCategory(String accessToken) {
+ WxResult result = new WxResult<>();
+ String url = WxSubscribeConstant.GET_CATEGORY_URL + "?" + "access_token=" + accessToken;
+
+ Result httpResult = HttpClientManager.getInstance().sendGet(url, null);
+ if (!httpResult.success()) {
+ result.setErrorCode(httpResult.getCode());
+ result.setErrorMsg(httpResult.getMsg());
+ return result;
+ }
+ Gson gson = new Gson();
+ WxGetCategoryResult getCategoryResult = gson.fromJson(httpResult.getData(), WxGetCategoryResult.class);
+ result.setErrorCode(getCategoryResult.getErrcode());
+ result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(getCategoryResult.getErrcode()));
+ result.setData(getCategoryResult);
+ return result;
+ }
+
+ @Override
+ public WxResult getPubTemplateTitles(String accessToken, WxSubTemplateReq request) {
+ WxResult result = new WxResult<>();
+ String url = WxSubscribeConstant.GET_PUB_TEMPLATE_TITLES_URL + "?" + "access_token=" + accessToken + "&ids=" + request.getIds()
+ + "&start=" + request.getStart() + "&limit=" + request.getLimit();
+
+ Result httpResult = HttpClientManager.getInstance().sendGet(url, null);
+ if (!httpResult.success()) {
+ result.setErrorCode(httpResult.getCode());
+ result.setErrorMsg(httpResult.getMsg());
+ return result;
+ }
+ Gson gson = new Gson();
+ WxSubTemplateResult subTemplateResult = gson.fromJson(httpResult.getData(), WxSubTemplateResult.class);
+ result.setErrorCode(subTemplateResult.getErrcode());
+ result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(subTemplateResult.getErrcode()));
+ result.setData(subTemplateResult);
+ return result;
+ }
+
+ @Override
+ public WxResult getPubTemplateKeywords(String accessToken, String tId) {
+ WxResult result = new WxResult<>();
+ String url = WxSubscribeConstant.GET_KEY_WORDS_URL + "?" + "access_token=" + accessToken + "&tid=" + tId;
+
+ Result httpResult = HttpClientManager.getInstance().sendGet(url, null);
+ if (!httpResult.success()) {
+ result.setErrorCode(httpResult.getCode());
+ result.setErrorMsg(httpResult.getMsg());
+ return result;
+ }
+ Gson gson = new Gson();
+ WxKeyWordsResult keyWordsResult = gson.fromJson(httpResult.getData(), WxKeyWordsResult.class);
+ result.setErrorCode(keyWordsResult.getErrcode());
+ result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(keyWordsResult.getErrcode()));
+ result.setData(keyWordsResult);
+ return result;
+ }
+
+ @Override
+ public WxResult addTemplate(String accessToken, WxAddTemplateReq request) {
+ WxResult result = new WxResult<>();
+ String url = WxSubscribeConstant.ADD_TEMPLATE_URL + "?" + "access_token=" + accessToken;
+
+ Result httpResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
+ if (!httpResult.success()) {
+ result.setErrorCode(httpResult.getCode());
+ result.setErrorMsg(httpResult.getMsg());
+ return result;
+ }
+ JSONObject jsonObject = JSONObject.parseObject(httpResult.getData());
+ result.setErrorCode(jsonObject.getInteger(ERR_CODE));
+ result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
+ result.setData(jsonObject.getString("priTmplId"));
+ return result;
+ }
+
+ @Override
+ public WxResult getTemplate(String accessToken) {
+ WxResult result = new WxResult<>();
+ String url = WxSubscribeConstant.GET_TEMPLATE_URL + "?" + "access_token=" + accessToken;
+
+ Result httpResult = HttpClientManager.getInstance().sendGet(url, null);
+ if (!httpResult.success()) {
+ result.setErrorCode(httpResult.getCode());
+ result.setErrorMsg(httpResult.getMsg());
+ return result;
+ }
+ Gson gson = new Gson();
+ WxGetTemplateResult templateResult = gson.fromJson(httpResult.getData(), WxGetTemplateResult.class);
+ result.setErrorCode(templateResult.getErrcode());
+ result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(templateResult.getErrcode()));
+ result.setData(templateResult);
+ return result;
+ }
+
+ @Override
+ public WxResult delTemplate(String accessToken, WxDelTemplateReq request) {
+ WxResult result = new WxResult<>();
+ String url = WxSubscribeConstant.DEL_TEMPLATE_URL + "?" + "access_token=" + accessToken;
+
+ Result httpResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
+ if (!httpResult.success()) {
+ result.setErrorCode(httpResult.getCode());
+ result.setErrorMsg(httpResult.getMsg());
+ return result;
+ }
+ JSONObject jsonObject = JSONObject.parseObject(httpResult.getData());
+ result.setErrorCode(jsonObject.getInteger(ERR_CODE));
+ result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
+ return result;
+ }
+
+ private String toJson(Object object) {
+ GsonBuilder gsonBuilder = new GsonBuilder();
+ gsonBuilder.setPrettyPrinting();
+ Gson gson = gsonBuilder.create();
+ return gson.toJson(object);
+ }
+}
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.10__thirdUpdate.sql b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.10__thirdUpdate.sql
new file mode 100644
index 0000000000..ebf69013cf
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.10__thirdUpdate.sql
@@ -0,0 +1,36 @@
+CREATE TABLE `personal_template` (
+ `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `CUSTOMER_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `CLIENT_TYPE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `APP_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `PID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `PRI_TMPL_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `TYPE` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `TID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `TITLE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `KEY_IDS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `KEY_WORDS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `SCENE_DESC` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `REVISION` int(11) NULL DEFAULT NULL,
+ `DEL_FLAG` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `CREATED_TIME` datetime(0) NULL DEFAULT NULL,
+ `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `UPDATED_TIME` datetime(0) NULL DEFAULT NULL,
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
+
+CREATE TABLE `public_template` (
+ `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+ `TID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `TITLE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `TYPE` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `CATEGORY_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `REVISION` int(11) NULL DEFAULT NULL,
+ `DEL_FLAG` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `CREATED_TIME` datetime(0) NULL DEFAULT NULL,
+ `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
+ `UPDATED_TIME` datetime(0) NULL DEFAULT NULL,
+ PRIMARY KEY (`ID`) USING BTREE
+) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
index 77e38472e8..f2cbc173f7 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
@@ -132,5 +132,16 @@
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
+
+ SELECT
+ CUSTOMER_ID,
+ CLIENT_TYPE,
+ AUTHORIZER_ACCESS_TOKEN
+ FROM
+ authorization_info
+ WHERE
+ DEL_FLAG = 0
+ AND AUTHORIZER_APPID = #{appId}
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
index 11d1b50262..9926104565 100644
--- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml
@@ -196,4 +196,16 @@
AND
SOURCE = #{source}
+
+ SELECT
+ pc.ID,
+ pc.CUSTOMER_NAME
+ FROM
+ pa_customer pc
+ INNER JOIN ( SELECT SOURCE FROM pa_customer WHERE ID = #{customerId} ) t ON pc.SOURCE = t.SOURCE
+ WHERE
+ pc.DEL_FLAG = 0
+ AND IS_INITIALIZE = 1
+ AND pc.ID != #{customerId}
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml
new file mode 100644
index 0000000000..f3b46b3c42
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT ID,
+ CUSTOMER_ID,
+ CLIENT_TYPE,
+ PRI_TMPL_ID
+ FROM personal_template
+ WHERE DEL_FLAG = '0'
+ AND PID = #{pid}
+
+
+ SELECT *
+ FROM personal_template
+ WHERE DEL_FLAG = '0'
+ AND APP_ID = #{appId}
+
+
+ SELECT ID,
+ TITLE
+ FROM personal_template
+ WHERE DEL_FLAG = '0'
+ AND CUSTOMER_ID = #{customerId}
+ AND PID = #{pid}
+
+
+ SELECT
+ t1.ID AS id,
+ t1.PRI_TMPL_ID AS tmplId,
+ t1.TITLE AS title,
+ IF(ISNULL(t2.ID),'0','1') AS state
+ FROM
+ (SELECT
+ ID,
+ TITLE,
+ PRI_TMPL_ID
+ FROM
+ personal_template
+ WHERE
+ DEL_FLAG = '0'
+ AND APP_ID = #{appId}) t1
+ LEFT JOIN
+ (SELECT
+ ID,
+ TITLE,
+ PID,
+ PRI_TMPL_ID
+ FROM
+ personal_template
+ WHERE
+ DEL_FLAG = '0'
+ AND CUSTOMER_ID = #{customerId}
+ AND CLIENT_TYPE = #{clientType}) t2
+ ON t1.PRI_TMPL_ID = t2.PID
+
+
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PublicTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PublicTemplateDao.xml
new file mode 100644
index 0000000000..a1baf39ef4
--- /dev/null
+++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PublicTemplateDao.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DELETE FROM public_template WHERE 1=1
+
+ CATEGORY_ID = #{item}
+
+
+
+ select TID,
+ TITLE,
+ TYPE,
+ CATEGORY_ID
+ from public_template
+ where 1=1
+
+ AND TITLE LIKE CONCAT('%',#{title},'%')
+
+
+ AND CATEGORY_ID = #{ids}
+
+
+
+
+
\ No newline at end of file
diff --git a/epmet-module/gov-project/gov-project-server/Dockerfile b/epmet-module/gov-project/gov-project-server/Dockerfile
index 88b6575415..372d5097ca 100644
--- a/epmet-module/gov-project/gov-project-server/Dockerfile
+++ b/epmet-module/gov-project/gov-project-server/Dockerfile
@@ -4,7 +4,7 @@ RUN export LANG="zh_CN.UTF-8"
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' > /etc/timezone
-COPY ./target/*.jar ./app.jar
+COPY ./target/*.jar ./gov-project.jar
EXPOSE 8102