Browse Source

[模板消息管理][修改]:删除时添加检查

release
Stormeye Wu 7 years ago
parent
commit
dba246c6c6
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      mlWechatOpen/src/main/java/com/iformall/controller/WechatWeappMsgTemplateController.java

+ 26
- 0
mlWechatOpen/src/main/java/com/iformall/controller/WechatWeappMsgTemplateController.java View File

@@ -8,9 +8,13 @@ import cn.binarywang.wx.miniapp.bean.template.WxMaTemplateListResult;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.Result; import com.iformall.common.Result;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxAuthorizerInfo; import com.iformall.domain.po.WxAuthorizerInfo;
import com.iformall.domain.po.WxTemplateMsg;
import com.iformall.enums.EnumWxAuthorizationStatus; import com.iformall.enums.EnumWxAuthorizationStatus;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxAuthorizerInfoService; import com.iformall.service.WxAuthorizerInfoService;
import com.iformall.service.WxTemplateMsgService;
import com.iformall.service.wechat.FmOpenService; import com.iformall.service.wechat.FmOpenService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@@ -39,6 +43,12 @@ public class WechatWeappMsgTemplateController {
@Autowired @Autowired
private WxAuthorizerInfoService authorizerInfoService; private WxAuthorizerInfoService authorizerInfoService;


@Autowired
private WxAppinfoService appinfoService;

@Autowired
private WxTemplateMsgService templateMsgService;

@ApiOperation("获取小程序模板库标题列表") @ApiOperation("获取小程序模板库标题列表")
@GetMapping("getTmpLibList") @GetMapping("getTmpLibList")
@ApiImplicitParams({ @ApiImplicitParams({
@@ -123,6 +133,22 @@ public class WechatWeappMsgTemplateController {
@ApiOperation("删除帐号下的某个模板") @ApiOperation("删除帐号下的某个模板")
@PostMapping("delTemplate") @PostMapping("delTemplate")
public ResultData delTemplate(@RequestParam(value = "appId") String appId, @RequestParam(value = "templateId") String templateId) { 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 { try {
WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); WxMaService maService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appId);
maService.getTemplateService().delTemplate(templateId); maService.getTemplateService().delTemplate(templateId);


Loading…
Cancel
Save