57 changed files with 2859 additions and 22 deletions
@ -0,0 +1,126 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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; |
|||
|
|||
} |
@ -0,0 +1,91 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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; |
|||
|
|||
} |
@ -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<Integer> kidList; |
|||
/** |
|||
* 关键字名称 |
|||
*/ |
|||
private List<String> nameList; |
|||
} |
@ -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; |
|||
} |
@ -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<String> resiTempIdList; |
|||
/** |
|||
* 工作端需要同步的模板id数组 |
|||
*/ |
|||
private List<String> workTempIdList; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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<TemplateDTO> workList; |
|||
private List<TemplateDTO> resiList; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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<String> keywords; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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<List<SubscribeCategoryResultDTO>> getCategory(@RequestBody SubscribeFormDTO formDTO) { |
|||
List<SubscribeCategoryResultDTO> result = subscribeService.getCategory(formDTO); |
|||
return new Result<List<SubscribeCategoryResultDTO>>().ok(result); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 获取模板标题列表 |
|||
* |
|||
* @param formDTO |
|||
* @return com.epmet.dto.result.PubTemplateResultDTO |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/9 15:00 |
|||
*/ |
|||
@PostMapping("getpubtemplatetitles") |
|||
public Result<PageData> getPubTemplateTitles(@RequestBody PubTemplateFormDTO formDTO) { |
|||
PageData result = subscribeService.getPubTemplateTitles(formDTO); |
|||
return new Result<PageData>().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<List<KeyWordsResultDTO>> getKeyWords(@RequestBody SubscribeFormDTO formDTO) { |
|||
List<KeyWordsResultDTO> result = subscribeService.getKeyWords(formDTO); |
|||
return new Result<List<KeyWordsResultDTO>>().ok(result); |
|||
} |
|||
|
|||
/** |
|||
* 获取帐号下的模板列表 |
|||
* |
|||
* @param formDTO |
|||
* @return com.epmet.dto.result.GetTemplateResultDTO |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/9 15:12 |
|||
*/ |
|||
@PostMapping("gettemplate") |
|||
public Result<List<GetTemplateResultDTO>> getTemplate(@RequestBody SubscribeFormDTO formDTO) { |
|||
List<GetTemplateResultDTO> result = subscribeService.getTemplate(formDTO); |
|||
return new Result<List<GetTemplateResultDTO>>().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<CustomerTempResultDTO> getCustomerTemplate(@RequestBody InitFormDTO formDTO) { |
|||
CustomerTempResultDTO result = subscribeService.getCustomerTemplate(formDTO); |
|||
return new Result<CustomerTempResultDTO>().ok(result); |
|||
} |
|||
} |
@ -0,0 +1,79 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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<PersonalTemplateEntity> { |
|||
/** |
|||
* 获取个人模板列表 |
|||
* |
|||
* @param pid |
|||
* @return java.util.List<com.epmet.dto.PersonalTemplateDTO> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/9 17:56 |
|||
*/ |
|||
List<PersonalTemplateDTO> selectListByPid(@Param("pid") String pid); |
|||
|
|||
/** |
|||
* 根据AppID获取模板列表 |
|||
* |
|||
* @param appId |
|||
* @return java.util.List<com.epmet.dto.PersonalTemplateDTO> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/10 10:49 |
|||
*/ |
|||
List<PersonalTemplateDTO> 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<com.epmet.dto.PersonalTemplateDTO> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/11 14:35 |
|||
*/ |
|||
List<TemplateDTO> selectListByCustomerId(@Param("appId") String appId, @Param("customerId") String customerId, |
|||
@Param("clientType") String clientType); |
|||
} |
@ -0,0 +1,56 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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<PublicTemplateEntity> { |
|||
|
|||
/** |
|||
* 根据类目Id删除模板 |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/11 16:22 |
|||
* @param list |
|||
* @return void |
|||
*/ |
|||
void deleteTempByCategoryId(List<String> list); |
|||
|
|||
/** |
|||
* 获取公共模板列表 |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/11 16:57 |
|||
* @param dto |
|||
* @return java.util.List<com.epmet.dto.result.PubTemplateResultDTO> |
|||
*/ |
|||
List<PubTemplateResultDTO> getPubTempList(PubTemplateFormDTO dto); |
|||
|
|||
} |
@ -0,0 +1,96 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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; |
|||
|
|||
} |
@ -0,0 +1,61 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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; |
|||
|
|||
} |
@ -0,0 +1,126 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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<PersonalTemplateEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<PersonalTemplateDTO> |
|||
* @author generator |
|||
* @date 2020-09-09 |
|||
*/ |
|||
PageData<PersonalTemplateDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<PersonalTemplateDTO> |
|||
* @author generator |
|||
* @date 2020-09-09 |
|||
*/ |
|||
List<PersonalTemplateDTO> list(Map<String, Object> 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<com.epmet.dto.PersonalTemplateDTO> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/9 17:59 |
|||
*/ |
|||
List<PersonalTemplateDTO> getListByPid(String pid); |
|||
|
|||
/** |
|||
* 根据AppID获取模板列表 |
|||
* |
|||
* @param appId |
|||
* @return java.util.List<com.epmet.dto.PersonalTemplateDTO> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/10 10:48 |
|||
*/ |
|||
List<PersonalTemplateDTO> getListByAppId(String appId); |
|||
|
|||
/** |
|||
* 根据客户Id获取模板列表 |
|||
* |
|||
* @param appId |
|||
* @param customerId |
|||
* @param clientType |
|||
* @return java.util.List<com.epmet.dto.result.TemplateDTO> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/11 14:43 |
|||
*/ |
|||
List<TemplateDTO> getListByCustomer(String appId, String customerId, String clientType); |
|||
} |
@ -0,0 +1,115 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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<PublicTemplateEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<PublicTemplateDTO> |
|||
* @author generator |
|||
* @date 2020-09-11 |
|||
*/ |
|||
PageData<PublicTemplateDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<PublicTemplateDTO> |
|||
* @author generator |
|||
* @date 2020-09-11 |
|||
*/ |
|||
List<PublicTemplateDTO> list(Map<String, Object> 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<String> categoryIds); |
|||
|
|||
/** |
|||
* 获取公共模板列表 |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/11 17:01 |
|||
* @param dto |
|||
* @return java.util.List<com.epmet.dto.result.PubTemplateResultDTO> |
|||
*/ |
|||
List<PubTemplateResultDTO> getPubTempList(PubTemplateFormDTO dto); |
|||
} |
@ -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<SubscribeCategoryResultDTO> 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<KeyWordsResultDTO> getKeyWords(SubscribeFormDTO formDTO); |
|||
|
|||
/** |
|||
* 获取帐号下的模板列表 |
|||
* |
|||
* @param formDTO |
|||
* @return com.epmet.dto.result.GetTemplateResultDTO |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/9 15:12 |
|||
*/ |
|||
List<GetTemplateResultDTO> 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); |
|||
|
|||
} |
@ -0,0 +1,119 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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<PersonalTemplateDao, PersonalTemplateEntity> implements PersonalTemplateService { |
|||
|
|||
|
|||
@Override |
|||
public PageData<PersonalTemplateDTO> page(Map<String, Object> params) { |
|||
IPage<PersonalTemplateEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, PersonalTemplateDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<PersonalTemplateDTO> list(Map<String, Object> params) { |
|||
List<PersonalTemplateEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PersonalTemplateDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PersonalTemplateEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PersonalTemplateEntity> 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<PersonalTemplateDTO> getListByPid(String pid) { |
|||
return baseDao.selectListByPid(pid); |
|||
} |
|||
|
|||
@Override |
|||
public List<PersonalTemplateDTO> getListByAppId(String appId) { |
|||
return baseDao.selectListByAppId(appId); |
|||
} |
|||
|
|||
@Override |
|||
public List<TemplateDTO> getListByCustomer(String appId, String customerId, String clientType) { |
|||
return baseDao.selectListByCustomerId(appId, customerId, clientType); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,112 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* 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. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
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<PublicTemplateDao, PublicTemplateEntity> implements PublicTemplateService { |
|||
|
|||
|
|||
@Override |
|||
public PageData<PublicTemplateDTO> page(Map<String, Object> params) { |
|||
IPage<PublicTemplateEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, PublicTemplateDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<PublicTemplateDTO> list(Map<String, Object> params) { |
|||
List<PublicTemplateEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, PublicTemplateDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<PublicTemplateEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<PublicTemplateEntity> 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<String> categoryIds) { |
|||
baseDao.deleteTempByCategoryId(categoryIds); |
|||
} |
|||
|
|||
@Override |
|||
public List<PubTemplateResultDTO> getPubTempList(PubTemplateFormDTO formDTO) { |
|||
return baseDao.getPubTempList(formDTO); |
|||
} |
|||
|
|||
} |
@ -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<SubscribeCategoryResultDTO> getCategory(SubscribeFormDTO formDTO) { |
|||
AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); |
|||
WxGetCategoryResult wxResult = getCategoryResult(authInfo.getAuthorizerAccessToken()); |
|||
|
|||
List<SubscribeCategoryResultDTO> 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<PubTemplateResultDTO> list = publicTemplateService.getPubTempList(formDTO); |
|||
PageInfo<PubTemplateResultDTO> 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<String> 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<WxSubTemplateResult> wxResult = wxMaSubscribeService.getPubTemplateTitles(authInfo.getAuthorizerAccessToken(), request); |
|||
if (!wxResult.success()) { |
|||
throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); |
|||
} |
|||
Integer total = wxResult.getData().getCount(); |
|||
List<PublicTemplateDTO> 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<PublicTemplateDTO> 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<KeyWordsResultDTO> getKeyWords(SubscribeFormDTO formDTO) { |
|||
AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); |
|||
WxKeyWordsResult keyWordsResult = getTitleKeyWords(authInfo.getAuthorizerAccessToken(), formDTO.getTitleId()); |
|||
List<KeyWordsResultDTO> 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<GetTemplateResultDTO> getTemplate(SubscribeFormDTO formDTO) { |
|||
AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); |
|||
List<PersonalTemplateDTO> list = personalTemplateService.getListByAppId(formDTO.getAppId()); |
|||
WxResult<WxGetTemplateResult> wxResult = wxMaSubscribeService.getTemplate(authInfo.getAuthorizerAccessToken()); |
|||
if (!wxResult.success()) { |
|||
throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); |
|||
} |
|||
|
|||
List<GetTemplateResultDTO> 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<String> 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<String> 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<PaCustomerDTO> customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId()); |
|||
List<String> 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<String> 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<PersonalTemplateDTO> 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<String> keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); |
|||
List<Integer> 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<String> 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<String> keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); |
|||
List<Integer> 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<String> 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<WxGetTemplateResult> wxResiResult = wxMaSubscribeService.getTemplate(resiAuthDTO.getAuthorizerAccessToken()); |
|||
if (!wxResiResult.success()) { |
|||
throw new RenException(wxResiResult.getErrorCode(), wxResiResult.getErrorMsg()); |
|||
} |
|||
List<String> resiPubTmplIds = |
|||
wxResiResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList()); |
|||
List<TemplateDTO> resiList = personalTemplateService.getListByCustomer(formDTO.getResiAppId(), formDTO.getCustomerId(), "resi"); |
|||
List<String> resiTmplIds = resiList.stream().map(TemplateDTO::getTmplId).collect(Collectors.toList()); |
|||
List<String> 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<WxGetTemplateResult> wxWorkResult = wxMaSubscribeService.getTemplate(workAuthDTO.getAuthorizerAccessToken()); |
|||
if (!wxWorkResult.success()) { |
|||
throw new RenException(wxWorkResult.getErrorCode(), wxWorkResult.getErrorMsg()); |
|||
} |
|||
List<String> workPubTmplIds = |
|||
wxWorkResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList()); |
|||
List<TemplateDTO> workList = personalTemplateService.getListByCustomer(formDTO.getWorkAppId(), formDTO.getCustomerId(), "work"); |
|||
List<String> workTmplIds = workList.stream().map(TemplateDTO::getTmplId).collect(Collectors.toList()); |
|||
List<String> 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<WxGetCategoryResult> 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<WxKeyWordsResult> 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<PersonalTemplateDTO> resiList = personalTemplateService.getListByAppId(formDTO.getResiAppId()); |
|||
if (null != resiList && resiList.size() > 0) { |
|||
resiList.forEach(templateDTO -> { |
|||
List<String> keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); |
|||
List<Integer> 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<String> 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<PersonalTemplateDTO> workList = personalTemplateService.getListByAppId(formDTO.getWorkAppId()); |
|||
if (null != workList && workList.size() > 0) { |
|||
workList.forEach(templateDTO -> { |
|||
List<String> keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); |
|||
List<Integer> 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<String> 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); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
} |
@ -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"; |
|||
} |
@ -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<Integer> kidList; |
|||
} |
@ -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; |
|||
} |
@ -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; |
|||
} |
@ -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<DataBean> data; |
|||
|
|||
@NoArgsConstructor |
|||
@Data |
|||
public static class DataBean { |
|||
/** |
|||
* id : 616 |
|||
*/ |
|||
private Integer id; |
|||
private String name; |
|||
} |
|||
} |
@ -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<DataBean> 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; |
|||
} |
|||
} |
@ -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<DataBean> data; |
|||
|
|||
@NoArgsConstructor |
|||
@Data |
|||
public static class DataBean { |
|||
/** |
|||
* 关键词 id |
|||
*/ |
|||
private Integer kid; |
|||
/** |
|||
* 关键词内容 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 关键词内容对应的示例 |
|||
*/ |
|||
private String example; |
|||
/** |
|||
* 参数类型 |
|||
*/ |
|||
private String rule; |
|||
} |
|||
} |
@ -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<DataBean> data; |
|||
|
|||
@NoArgsConstructor |
|||
@Data |
|||
public static class DataBean { |
|||
/** |
|||
* 模板标题 id |
|||
*/ |
|||
private Integer tid; |
|||
/** |
|||
* 模板标题 |
|||
*/ |
|||
private String title; |
|||
/** |
|||
* 模板类型,2 为一次性订阅,3 为长期订阅 |
|||
*/ |
|||
private Integer type; |
|||
/** |
|||
* 模板所属类目 id |
|||
*/ |
|||
private String categoryId; |
|||
} |
|||
} |
@ -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<com.epmet.wxapi.result.WxGetCategoryResult> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/8 16:06 |
|||
*/ |
|||
WxResult<WxGetCategoryResult> getCategory(String accessToken); |
|||
|
|||
/** |
|||
* 获取模板标题列表 |
|||
* |
|||
* @param accessToken |
|||
* @param request |
|||
* @return com.epmet.wxapi.result.WxSubTemplateResult |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/8 16:34 |
|||
*/ |
|||
WxResult<WxSubTemplateResult> getPubTemplateTitles(String accessToken, WxSubTemplateReq request); |
|||
|
|||
/** |
|||
* 获取模板标题下的关键词库 |
|||
* |
|||
* @param accessToken |
|||
* @param tId |
|||
* @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxKeyWordsResult> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/8 16:45 |
|||
*/ |
|||
WxResult<WxKeyWordsResult> getPubTemplateKeywords(String accessToken, String tId); |
|||
|
|||
/** |
|||
* 组合模板并添加到个人模板库 |
|||
* |
|||
* @param accessToken |
|||
* @param request |
|||
* @return com.epmet.wxapi.result.WxResult<java.lang.String> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/9 9:35 |
|||
*/ |
|||
WxResult<String> addTemplate(String accessToken, WxAddTemplateReq request); |
|||
|
|||
/** |
|||
* 获取帐号下的模板列表 |
|||
* |
|||
* @param accessToken |
|||
* @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxGetTemplateResult> |
|||
* @author zhaoqifeng |
|||
* @date 2020/9/9 9:42 |
|||
*/ |
|||
WxResult<WxGetTemplateResult> 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); |
|||
} |
@ -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<WxGetCategoryResult> getCategory(String accessToken) { |
|||
WxResult<WxGetCategoryResult> result = new WxResult<>(); |
|||
String url = WxSubscribeConstant.GET_CATEGORY_URL + "?" + "access_token=" + accessToken; |
|||
|
|||
Result<String> 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<WxSubTemplateResult> getPubTemplateTitles(String accessToken, WxSubTemplateReq request) { |
|||
WxResult<WxSubTemplateResult> result = new WxResult<>(); |
|||
String url = WxSubscribeConstant.GET_PUB_TEMPLATE_TITLES_URL + "?" + "access_token=" + accessToken + "&ids=" + request.getIds() |
|||
+ "&start=" + request.getStart() + "&limit=" + request.getLimit(); |
|||
|
|||
Result<String> 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<WxKeyWordsResult> getPubTemplateKeywords(String accessToken, String tId) { |
|||
WxResult<WxKeyWordsResult> result = new WxResult<>(); |
|||
String url = WxSubscribeConstant.GET_KEY_WORDS_URL + "?" + "access_token=" + accessToken + "&tid=" + tId; |
|||
|
|||
Result<String> 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<String> addTemplate(String accessToken, WxAddTemplateReq request) { |
|||
WxResult<String> result = new WxResult<>(); |
|||
String url = WxSubscribeConstant.ADD_TEMPLATE_URL + "?" + "access_token=" + accessToken; |
|||
|
|||
Result<String> 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<WxGetTemplateResult> getTemplate(String accessToken) { |
|||
WxResult<WxGetTemplateResult> result = new WxResult<>(); |
|||
String url = WxSubscribeConstant.GET_TEMPLATE_URL + "?" + "access_token=" + accessToken; |
|||
|
|||
Result<String> 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<String> 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); |
|||
} |
|||
} |
@ -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; |
@ -0,0 +1,79 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.PersonalTemplateDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.PersonalTemplateEntity" id="personalTemplateMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="clientType" column="CLIENT_TYPE"/> |
|||
<result property="appId" column="APP_ID"/> |
|||
<result property="pid" column="PID"/> |
|||
<result property="priTmplId" column="PRI_TMPL_ID"/> |
|||
<result property="type" column="TYPE"/> |
|||
<result property="title" column="TITLE"/> |
|||
<result property="keyWords" column="KEY_WORDS"/> |
|||
<result property="sceneDesc" column="SCENE_DESC"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
<select id="selectListByPid" resultType="com.epmet.dto.PersonalTemplateDTO"> |
|||
SELECT ID, |
|||
CUSTOMER_ID, |
|||
CLIENT_TYPE, |
|||
PRI_TMPL_ID |
|||
FROM personal_template |
|||
WHERE DEL_FLAG = '0' |
|||
AND PID = #{pid} |
|||
</select> |
|||
<select id="selectListByAppId" resultType="com.epmet.dto.PersonalTemplateDTO"> |
|||
SELECT * |
|||
FROM personal_template |
|||
WHERE DEL_FLAG = '0' |
|||
AND APP_ID = #{appId} |
|||
</select> |
|||
<select id="selectSetTemp" resultType="com.epmet.dto.PersonalTemplateDTO"> |
|||
SELECT ID, |
|||
TITLE |
|||
FROM personal_template |
|||
WHERE DEL_FLAG = '0' |
|||
AND CUSTOMER_ID = #{customerId} |
|||
AND PID = #{pid} |
|||
</select> |
|||
<select id="selectListByCustomerId" resultType="com.epmet.dto.result.TemplateDTO"> |
|||
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 |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
@ -0,0 +1,41 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.PublicTemplateDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.PublicTemplateEntity" id="publicTemplateMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="tid" column="TID"/> |
|||
<result property="title" column="TITLE"/> |
|||
<result property="type" column="TYPE"/> |
|||
<result property="categoryId" column="CATEGORY_ID"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
<delete id="deleteTempByCategoryId" parameterType="list"> |
|||
DELETE FROM public_template WHERE 1=1 |
|||
<foreach collection="list" item="item" open="AND( " separator=" OR " index="index" close=")"> |
|||
CATEGORY_ID = #{item} |
|||
</foreach> |
|||
</delete> |
|||
<select id="getPubTempList" resultType="com.epmet.dto.result.PubTemplateResultDTO" parameterType="com.epmet.dto.form.PubTemplateFormDTO"> |
|||
select TID, |
|||
TITLE, |
|||
TYPE, |
|||
CATEGORY_ID |
|||
from public_template |
|||
where 1=1 |
|||
<if test="title != null and title.trim() != ''"> |
|||
AND TITLE LIKE CONCAT('%',#{title},'%') |
|||
</if> |
|||
<if test="ids != null and ids.trim() != ''"> |
|||
AND CATEGORY_ID = #{ids} |
|||
</if> |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue