From dba246c6c69e542d2e013ab286d1007213a037ec Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Tue, 9 Apr 2019 16:41:40 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=A8=A1=E6=9D=BF=E6=B6=88=E6=81=AF=E7=AE=A1?= =?UTF-8?q?=E7=90=86][=E4=BF=AE=E6=94=B9]:=E5=88=A0=E9=99=A4=E6=97=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WechatWeappMsgTemplateController.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mlWechatOpen/src/main/java/com/iformall/controller/WechatWeappMsgTemplateController.java b/mlWechatOpen/src/main/java/com/iformall/controller/WechatWeappMsgTemplateController.java index d92a73a..3aa36bf 100644 --- a/mlWechatOpen/src/main/java/com/iformall/controller/WechatWeappMsgTemplateController.java +++ b/mlWechatOpen/src/main/java/com/iformall/controller/WechatWeappMsgTemplateController.java @@ -8,9 +8,13 @@ import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult; import com.iformall.common.ErrorCode; import com.iformall.common.Result; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxAppinfo; import com.iformall.domain.po.WxAuthorizerInfo; +import com.iformall.domain.po.WxTemplateMsg; import com.iformall.enums.EnumWxAuthorizationStatus; +import com.iformall.service.WxAppinfoService; import com.iformall.service.WxAuthorizerInfoService; +import com.iformall.service.WxTemplateMsgService; import com.iformall.service.wechat.FmOpenService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -39,6 +43,12 @@ public class WechatWeappMsgTemplateController { @Autowired private WxAuthorizerInfoService authorizerInfoService; + @Autowired + private WxAppinfoService appinfoService; + + @Autowired + private WxTemplateMsgService templateMsgService; + @ApiOperation("获取小程序模板库标题列表") @GetMapping("getTmpLibList") @ApiImplicitParams({ @@ -123,6 +133,22 @@ public class WechatWeappMsgTemplateController { @ApiOperation("删除帐号下的某个模板") @PostMapping("delTemplate") public ResultData delTemplate(@RequestParam(value = "appId") String appId, @RequestParam(value = "templateId") String templateId) { + // check app + WxAppinfo appinfo = appinfoService.getByAppId(appId); + if(appinfo == null) { + String msg = "此appId未纳入管理,请联系管理员"; + logger.error(msg); + return new ResultData(Result.ERROR, msg); + } + WxTemplateMsg msgQ = new WxTemplateMsg(); + msgQ.setTemplateId(templateId); + msgQ.setTenantId(appinfo.getTenantId()); + WxTemplateMsg msg = templateMsgService.getByObj(msgQ); + if(msg != null) { + String msgStr = "此模板正被使用,请不要删除"; + logger.error(msgStr); + return new ResultData(Result.ERROR, msgStr); + } try { WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); maService.getTemplateService().delTemplate(templateId);