Browse Source

更改时,需要id,新增对id判断

chenyongxing 8 years ago
parent
commit
b2576068b3

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

@ -102,6 +102,7 @@ public class WxContants {
        public static final String message_fail_appId_is_null="appId is null";
        public static final String message_fail_appId_is_null="appId is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_wxWechat_is_no_exist="wxWechat is no exist";//微信配置不存在
        public static final String message_fail_wxWechat_is_no_exist="wxWechat is no exist";//微信配置不存在
        public static final String message_fail_id_is_null="id is null";
    }
    }
    //微信图文消息
    //微信图文消息
    public static class WxGraphicMessage {
    public static class WxGraphicMessage {

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WechatService.java

@ -68,6 +68,9 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
        }
        }
        if (StringUtils.isEmpty(wechat.getId())) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        WxWechat wechatTem = wechatDao.findByAppIdExcludeCode(wechat.getAppId(),wechat.getCode());
        WxWechat wechatTem = wechatDao.findByAppIdExcludeCode(wechat.getAppId(),wechat.getCode());
        if(wechatTem!=null){
        if(wechatTem!=null){
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java

@ -50,6 +50,9 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getId())) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        return wxGraphicMessageDao.save(wxGraphicMessage);
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    }

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java

@ -48,6 +48,9 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    @Transient
    @Transient
    public WxMenu updateWxMenu(WxMenu wxMenu) {
    public WxMenu updateWxMenu(WxMenu wxMenu) {
        if(canSaveOrUpata(wxMenu)){
        if(canSaveOrUpata(wxMenu)){
            if (StringUtils.isEmpty(wxMenu.getId())) {
                throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
            }
            return wxMenuDao.save(wxMenu);
            return wxMenuDao.save(wxMenu);
        }
        }
        return null;
        return null;

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

@ -71,6 +71,9 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
        if (StringUtils.isEmpty(content)) {
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
        }
        }
        if (StringUtils.isEmpty(wxTemplate.getId())) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
        }