Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/chenweida/jw2.0 into dev

Conflicts:
	svr-lib-parent-pom/pom.xml
chenyongxing 8 years ago
parent
commit
24b54de975

+ 13 - 22
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/WxContants.java

@ -6,21 +6,17 @@ package com.yihu.jw.restmodel.wx;
public class WxContants {
    //微信token模块常量
    public static class WxAccessToken{
        public static final String message_success_create="wxAccessToken create success";
        public static final String message_success_get="wxAccessToken get success";
        public static final String api_common="wxAccessToken";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String message_fail_wechatCode_is_null="wechatCode is null";
        public static final String message_fail_expiresIn_is_null="expiresIn is null";
    }
    //微信按钮模块常量
    public static class WxMenu{
        public static final String api_common="wxMenu";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
@ -28,18 +24,19 @@ public class WxContants {
        public static final String api_getWxMenuNoPage="getWxMenuNoPage";
        public static final String message_fail_wechatCode_is_null="wechatCode is null";
        public static final String message_fail_wxMenuName_is_null="wxMenuName is null";
        public static final String message_fail_wechatcode_is_null="wechatCode is null";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="weChatMenuName is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="id is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_type_is_null="type is null";
        public static final String message_fail_wxMenuKey_is_null="key is null";
        public static final String message_fail_wxMenuKey_is_toLong="key is toLong";
        public static final String message_fail_sort_is_null="sort is null";
        public static final String message_fail_sort_is_repeat="sort is repeat";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_success_update="wxMenu update success";
        public static final String message_success_delete="wxMenu delete success";
        public static final String message_success_find="wxMenu find success";
        public static final String message_success_create="wxMenu create success";
        public static final String message_success_get="wxMenu get success";
        public static final String message_success_find_functions="wxMenu find success";
    }
    //微信模板消息
@ -58,18 +55,18 @@ public class WxContants {
        public static final String message_success_find_functions="wxTemplate find success";
        public static final String message_success_delete="wxTemplate delete success";
        public static final String message_fail_name_exist="wxTemplate name exist";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="wxTemplate is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_wechatCode_is_null="wechatCode is null";
        public static final String message_fail_templateid_is_null="templateid is null";
        public static final String message_fail_content_is_null="content is null";
        public static final String message_fail_content_format_is_not_right="content format is not right";
    }
    //微信配置表
    public static class Wechat {
        public static final String api_common="wechat";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWechatNoPage="getWechatNoPage";
@ -82,20 +79,17 @@ public class WxContants {
        public static final String message_success_find_functions="wechat find success";
        public static final String message_success_delete="wechat delete success";
        public static final String message_fail_name_exist="wechat name exist";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="wechat is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_appId_is_null="appId is null";
        public static final String message_fail_appSecret_is_null="appSecret is null";
        public static final String message_fail_appId_exist="wechat appId exist";
        public static final String message_fail_status_is_null="status is null";
        public static final String message_fail_type_is_null="type is null";
    }
    //微信图文消息
    public static class WxGraphicMessage {
        public static final String api_common="wxGraphicMessage";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWxGraphicMessageNoPage="getWxGraphicMessageNoPage";
@ -109,11 +103,8 @@ public class WxContants {
        public static final String message_success_find_functions="wxGraphicMessage find success";
        public static final String message_success_delete="wxGraphicMessage delete success";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_code_exist="code exist";
        public static final String message_fail_appSecret_is_null="appSecret is null";
        public static final String message_fail_appId_exist="wxGraphicMessage appId exist";
        public static final String message_fail_value_is_null="value is null";
        public static final String message_fail_status_is_null="status is null";
    }
}

+ 4 - 17
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxAccessTokenController.java

@ -10,8 +10,10 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by cyx on 2017/5/11.
@ -42,19 +44,4 @@ public class WxAccessTokenController extends EnvelopRestController {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PostMapping(value = WxContants.WxAccessToken.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建WxAccessToken")
    public Envelop createWxAccessToken(
            @ApiParam(name = "wxAccessToken", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String wxAccessTokenJson) throws Exception {
        try {
            WxAccessToken wxAccessToken = toEntity(wxAccessTokenJson, WxAccessToken.class);
            wxAccessToken = wxAccessTokenService.createWxAccessToken(wxAccessToken);
            return Envelop.getSuccess(WxContants.WxAccessToken.message_success_create, wxAccessToken);
        }catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

+ 1 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxGraphicMessageController.java

@ -42,6 +42,7 @@ public class WxGraphicMessageController extends EnvelopRestController {
        }
    }
    @PutMapping(value = WxContants.WxGraphicMessage.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信图文消息", notes = "修改微信图文消息")
    public Envelop updateWxGraphicMessage(

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxTemplateController.java

@ -35,7 +35,7 @@ public class WxTemplateController extends EnvelopRestController {
    @PostMapping(value = WxContants.WxTemplate.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信模版", notes = "创建微信模版")
    public Envelop createWxTemplate(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @ApiParam(name = "json_data", value = "微信模版json字符串")
            @RequestBody String jsonData) {
        try {
            WxTemplate WxTemplate = toEntity(jsonData, WxTemplate.class);

+ 18 - 1
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxMenuDao.java

@ -12,7 +12,7 @@ import java.util.List;
 */
public interface WxMenuDao  extends PagingAndSortingRepository<WxMenu, Long>, JpaSpecificationExecutor<WxMenu> {
    @Query("from WxMenu m where m.code = ?1")
    @Query("from WxMenu m where m.code = ?1 and m.status = 1")
    WxMenu findByCode(String code);
    @Query("from WxMenu m where m.wechatCode =?1 and m.status = 1 order  by m.supMenucode ,m.sort")
@ -20,4 +20,21 @@ public interface WxMenuDao  extends PagingAndSortingRepository<WxMenu, Long>, Jp
    @Query("from WxMenu m where m.wechatCode = ?1 and  m.supMenucode= ?2 and m.status =1 order by m.sort")
    List<WxMenu> findChildMenus(String wechatCode, String sup_menucode);
    /**
     * 根据wechatCode判断父菜单的sort是否重复
     * @param wechatCode
     * @param sort
     */
    @Query("from WxMenu m where m.wechatCode = ?1 and m.status =1 and m.sort =?2 and m.supMenucode is null and m.code != ?3")
    WxMenu findByWechatCodeExcludeSortFromParent(String wechatCode, Integer sort,String code);
    /**
     * 根据wechatCode,supMenucode判断子菜单的sort是否重复
     * @param wechatCode
     * @param sort
     */
    @Query("from WxMenu m where m.wechatCode = ?1 and m.status =1 and m.sort =?2 and m.supMenucode =?3 and m.code != ?4")
    WxMenu findByWechatCodeExcludeSortFromChild(String wechatCode, Integer sort,String supMenucode,String code);
}

+ 16 - 4
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WechatService.java

@ -26,8 +26,14 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        if (StringUtils.isEmpty(wechat.getCode())) {
            throw new ApiException(WxContants.Wechat.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getAppId())) {
            throw new ApiException(WxContants.Wechat.message_fail_appId_is_null, CommonContants.common_error_params_code);
        if (StringUtils.isEmpty(wechat.getStatus())) {
            throw new ApiException(WxContants.Wechat.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getType())) {
            throw new ApiException(WxContants.Wechat.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
@ -44,8 +50,14 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        if (StringUtils.isEmpty(wechat.getCode())) {
            throw new ApiException(WxContants.Wechat.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getAppId())) {
            throw new ApiException(WxContants.Wechat.message_fail_appId_is_null, CommonContants.common_error_params_code);
        if (StringUtils.isEmpty(wechat.getStatus())) {
            throw new ApiException(WxContants.Wechat.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getType())) {
            throw new ApiException(WxContants.Wechat.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);

+ 0 - 16
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxAccessTokenService.java

@ -1,9 +1,6 @@
package com.yihu.jw.wx.service;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wx.WxContants;
import com.yihu.jw.util.HttpUtil;
import com.yihu.jw.wx.dao.WechatDao;
import com.yihu.jw.wx.dao.WxAccessTokenDao;
@ -12,8 +9,6 @@ import com.yihu.jw.wx.model.WxWechat;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springside.modules.utils.Clock;
import java.util.List;
@ -82,15 +77,4 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessToken, WxAccess
            return null;
        }
    }
    @Transactional
    public WxAccessToken createWxAccessToken(WxAccessToken wxAccessToken) {
        if (StringUtils.isEmpty(wxAccessToken.getWechatCode())) {
            throw new ApiException(WxContants.WxAccessToken.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxAccessToken.getExpiresIn())) {
            throw new ApiException(WxContants.WxAccessToken.message_fail_expiresIn_is_null, CommonContants.common_error_params_code);
        }
        return wxAccessTokenDao.save(wxAccessToken);
    }
}

+ 14 - 12
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java

@ -29,6 +29,9 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
        if (StringUtils.isEmpty(wxGraphicMessage.getCode())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        WxGraphicMessage wxGraphicMessageTem = wxGraphicMessageDao.findByCode(wxGraphicMessage.getCode());
        if (wxGraphicMessageTem != null) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_exist, CommonContants.common_error_params_code);
@ -41,6 +44,9 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
        if (StringUtils.isEmpty(wxGraphicMessage.getCode())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
@ -61,16 +67,7 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
    /**
     * 回复图文消息
     *
     * @param toUser
     * @param fromUser
     * @param articles
     * @return
     * @throws Exception
     */
    public String replyNewsMessage(String toUser,String fromUser,List<Map<String,String>> articles) throws Exception {
    private String replyNewsMessage(String toUser,String fromUser,List<Map<String,String>> articles) throws Exception {
        if(articles == null || articles.size() < 1){
            throw new Exception("图文信息不能为空!");
        }
@ -99,6 +96,12 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
        return result.toString();
    }
    /**
     * 发送图文消息
     * @param codes
     * @param request
     * @return
     */
    public String sendGraphicMessages(String codes, HttpServletRequest request) {
        try {
            // xml请求解析
@ -123,8 +126,7 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
                }
            }
            // 构建回复消息XML
            String result = replyNewsMessage(fromUserName, toUserName, articles);
            return result;
            return replyNewsMessage(fromUserName, toUserName, articles);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();

+ 76 - 16
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java

@ -29,28 +29,24 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    /**
     * 将菜单保存至数据库(微信未创建)
     * @param wxMenu
     * @return
     */
    public WxMenu createWxMenu(WxMenu wxMenu) {
        if (StringUtils.isEmpty(wxMenu.getWechatCode())) {
            throw new ApiException(WxContants.WxMenu.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getName())) {
            throw new ApiException(WxContants.WxMenu.message_fail_wxMenuName_is_null, CommonContants.common_error_params_code);
        if(canSaveOrUpata(wxMenu)){
            return wxMenuDao.save(wxMenu);
        }
        return wxMenuDao.save(wxMenu);
        return null;
    }
    @Transient
    public WxMenu updateWxMenu(WxMenu wxMenu) {
        if (StringUtils.isEmpty(wxMenu.getWechatCode())) {
            throw new ApiException(WxContants.WxMenu.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getName())) {
            throw new ApiException(WxContants.WxMenu.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getId())) {
            throw new ApiException(WxContants.WxMenu.message_fail_id_is_null, CommonContants.common_error_params_code);
        if(canSaveOrUpata(wxMenu)){
            return wxMenuDao.save(wxMenu);
        }
        return wxMenuDao.save(wxMenu);
        return null;
    }
    @Transient
@ -59,6 +55,16 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        if (wxMenu == null) {
            throw new ApiException(WxContants.WxMenu.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        String supMenucode = wxMenu.getSupMenucode();
        if(StringUtils.isEmpty(supMenucode)) {//如果是空,则为父菜单
            List<WxMenu> childMenus = findChildMenus(wxMenu.getWechatCode(), wxMenu.getSupMenucode());
            if(childMenus!=null){
                for(WxMenu wxmenu:childMenus){
                    wxmenu.setStatus(-1);
                    wxMenuDao.save(wxmenu);
                }
            }
        }
        wxMenu.setStatus(-1);
        wxMenuDao.save(wxMenu);
    }
@ -67,10 +73,20 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        return wxMenuDao.findByCode(code);
    }
    /**
     * 根据wechatCode查找所有菜单
     * @param wechatCode
     * @return
     */
    public List<WxMenu> findByWechatCode(String wechatCode){
        return wxMenuDao.findByWechatCode(wechatCode);
    }
    /**
     * 根据wechatCode在微信公众号创建菜单
     * @param wechatCode
     * @return JSONObject
     */
    public JSONObject createWechatMenu(String wechatCode) {
        //首先根据wechatCode获取菜单,然后封装成json字符串
        List<WxMenu> menus = wxMenuDao.findByWechatCode(wechatCode);
@ -84,7 +100,7 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        return result;
    }
    public String getMenuToString(List<WxMenu> menus,String wechatCode){
    private String getMenuToString(List<WxMenu> menus,String wechatCode){
        String menuJsonStr = "";
        List<WxMenu> parentMenus = new ArrayList<WxMenu>();//存储父菜单
        if(menus!=null){
@ -147,7 +163,51 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        return menuJsonStr;
    }
    /**
     * 查找子菜单
     * @param wechatCode
     * @param sup_menucode
     * @return
     */
    public List<WxMenu> findChildMenus(String wechatCode,String sup_menucode ){
        return wxMenuDao.findChildMenus(wechatCode,sup_menucode);
    }
    private boolean canSaveOrUpata(WxMenu wxMenu){
        if (StringUtils.isEmpty(wxMenu.getCode())) {
            throw new ApiException(WxContants.WxMenu.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getWechatCode())) {
            throw new ApiException(WxContants.WxMenu.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getName())) {
            throw new ApiException(WxContants.WxMenu.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if(StringUtils.isEmpty(wxMenu.getType())){
            throw new ApiException(WxContants.WxMenu.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if("click".equals(wxMenu.getType().toUpperCase())){
            String key = wxMenu.getKey();
            if(StringUtils.isEmpty(key)){
                throw new ApiException(WxContants.WxMenu.message_fail_wxMenuKey_is_null, CommonContants.common_error_params_code);
            }
            if(key.length()>128){
                throw new ApiException(WxContants.WxMenu.message_fail_wxMenuKey_is_toLong, CommonContants.common_error_params_code);
            }
        }
        if(StringUtils.isEmpty(wxMenu.getSort())){
            throw new ApiException(WxContants.WxMenu.message_fail_sort_is_null, CommonContants.common_error_params_code);
        }
        WxMenu wxMenuTemp = null;
        if(StringUtils.isEmpty(wxMenu.getSupMenucode())){//如果是空,则为父菜单
            //判断sort是否重复
            wxMenuTemp = wxMenuDao.findByWechatCodeExcludeSortFromParent(wxMenu.getWechatCode(), wxMenu.getSort(),wxMenu.getCode());
        }else{//子菜单
            wxMenuTemp = wxMenuDao.findByWechatCodeExcludeSortFromChild(wxMenu.getWechatCode(), wxMenu.getSort(), wxMenu.getSupMenucode(), wxMenu.getCode());
        }
        if(null!=wxMenuTemp){
            throw new ApiException(WxContants.WxMenu.message_fail_sort_is_repeat, CommonContants.common_error_params_code);
        }
        return true;
    }
}

+ 19 - 3
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxTemplateService.java

@ -36,6 +36,16 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
        if (StringUtils.isEmpty(wxTemplate.getWechatCode())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_templateid_is_null, CommonContants.common_error_params_code);
        }
        String content = wxTemplate.getContent().replace(" ","");
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
        }
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
        return wxTemplateDao.save(wxTemplate);
    }
@ -46,11 +56,17 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
        if (StringUtils.isEmpty(wxTemplate.getWechatCode())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxTemplate.getId())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_id_is_null, CommonContants.common_error_params_code);
        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_templateid_is_null, CommonContants.common_error_params_code);
        }
        String content = wxTemplate.getContent().replace(" ","");
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
        }
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
        return wxTemplateDao.save(wxTemplate);
    }
    public void deleteWxTemplate(String code) {