浏览代码

Merge branch 'dev' of chenyongxing/jw2.0 into dev

chenweida 8 年之前
父节点
当前提交
fcb24fa62d
共有 44 个文件被更改,包括 2959 次插入109 次删除
  1. 85 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/WlyyContants.java
  2. 23 7
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/WxContants.java
  3. 33 1
      common/common-swagger/src/main/java/com/yihu/jw/config/SwaggerConfig.java
  4. 644 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/WechatResponse.java
  5. 8 7
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxGraphicMessageController.java
  6. 6 7
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxMenuController.java
  7. 21 12
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxTemplateController.java
  8. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxMenuDao.java
  9. 15 13
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxMenu.java
  10. 13 7
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WechatService.java
  11. 15 5
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxAccessTokenService.java
  12. 8 1
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java
  13. 113 14
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java
  14. 14 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxTemplateService.java
  15. 1 1
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/SvrWlyyApplication.java
  16. 126 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/WlyyAgreementController.java
  17. 126 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/WlyyAgreementKpiController.java
  18. 99 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/WlyyAgreementKpiLogController.java
  19. 21 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/WlyyAgreementDao.java
  20. 22 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/WlyyAgreementKpiDao.java
  21. 15 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/WlyyAgreementKpiLogDao.java
  22. 157 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/WlyyAgreement.java
  23. 136 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/WlyyAgreementKpi.java
  24. 99 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/WlyyAgreementKpiLog.java
  25. 38 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/base/IdEntity.java
  26. 51 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/WlyyAgreementKpiLogService.java
  27. 84 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/WlyyAgreementKpiService.java
  28. 85 0
      svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/WlyyAgreementService.java
  29. 45 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatAccessTokenController.java
  30. 61 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatContants.java
  31. 20 8
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatController.java
  32. 129 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatGraphicMessageController.java
  33. 128 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatMenuController.java
  34. 135 0
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatTemplateControlle.java
  35. 25 0
      web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/AccessTokenFegin.java
  36. 57 0
      web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/GraphicMessageFegin.java
  37. 5 4
      web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/WechatFegin.java
  38. 53 0
      web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/WechatMenuFegin.java
  39. 58 0
      web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/WechatTemplateFegin.java
  40. 0 22
      web-gateway/src/main/java/com/yihu/jw/fegin/fallback/base/wx/WechatFeginFallback.java
  41. 24 0
      web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/AccessTokenFeginFallbackFactory.java
  42. 54 0
      web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/GraphicMessageFeginFallbackFactory.java
  43. 52 0
      web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/WechatMenuFeginFallbackFactory.java
  44. 53 0
      web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/WechatTemplateFeginFallbackFactory.java

+ 85 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/WlyyContants.java

@ -0,0 +1,85 @@
package com.yihu.jw.restmodel.wlyy;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class WlyyContants {
    //协议模块常量
    public static class Agreement{
        public static final String api_common="agreement";
        public static final String api_create="create";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_queryPage="queryPage";
        public static final String api_getList="getList";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_price_is_null="price is null";
        public static final String message_fail_wlyyAgreement_is_no_exist="wlyyAgreement is no exist";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_status_is_null="status is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_exist="code exist";
        public static final String message_success_update="agreement update success";
        public static final String message_success_delete="agreement delete success";
        public static final String message_success_find="agreement find success";
        public static final String message_success_create="agreement create success";
        public static final String message_success_find_functions="agreement find success";
    }
    //协议模块常量
    public static class AgreementKpi{
        public static final String api_common="agreementKpi";
        public static final String api_create="create";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_queryPage="queryPage";
        public static final String api_getList="getList";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_wlyyAgreementKpi_is_no_exist="wlyyAgreementKpi is no exist";
        public static final String message_fail_status_is_null="status is null";
        public static final String message_fail_kpiName_is_null="kpiName is null";
        public static final String message_fail_type_is_null="type is null";
        public static final String message_fail_patientCode_is_null="patientCode is null";
        public static final String message_fail_signCode_is_null="signCode is null";
        public static final String message_fail_kpiCode_is_null="kpiCode is null";
        public static final String message_fail_agreementCode_is_null="agreementCode is null";
        public static final String message_success_update="agreementKpi update success";
        public static final String message_success_delete="agreementKpi delete success";
        public static final String message_success_find="agreementKpi find success";
        public static final String message_success_create="agreementKpi create success";
        public static final String message_success_find_functions="agreementKpi find success";
    }
    //协议模块常量
    public static class AgreementKpiLog{
        public static final String api_common="agreementKpiLog";
        public static final String api_create="create";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_queryPage="queryPage";
        public static final String api_getList="getList";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_wlyyAgreementKpi_is_no_exist="wlyyAgreementKpi is no exist";
        public static final String message_success_update="agreementKpiLog update success";
        public static final String message_success_delete="agreementKpiLog delete success";
        public static final String message_success_find="agreementKpiLog find success";
        public static final String message_success_create="agreementKpiLog create success";
        public static final String message_success_find_functions="agreementKpiLog find success";
    }
}

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

@ -28,17 +28,29 @@ public class WxContants {
        public static final String message_fail_code_is_null="code 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_key_is_null="key is null";
        public static final String message_fail_key_is_toLong="key is to long";
        public static final String message_fail_url_is_null="url is null";
        public static final String message_fail_appid_is_null="appid is null";
        public static final String message_fail_pagepath_is_null="pagepath is null";
        public static final String message_fail_url_is_toLong="url is to long";
        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_fail_supMenuCode_is_no_exist="supMenuCode is no exist";
        public static final String message_fail_mediaId_is_null="mediaId is null";
        public static final String message_fail_childMenu_is_to_much="childMenu is to much";//子菜单数目过多
        public static final String message_fail_parentMenu_is_to_much="parentMenu is to much";//子菜单数目过多
        public static final String message_fail_name_is_to_long="name is to long";
        public static final String message_fail_status_is_null="status is null";
        public static final String message_fail_WxMenu_is_no_exist="menu is 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_find_functions="wxMenu find success";
    }
    //微信模板消息
    public static class WxTemplate {
@ -58,12 +70,12 @@ public class WxContants {
        public static final String message_success_delete="wxTemplate 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_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 final String message_fail_template_is_no_exist="template is no exist";
    }
    //微信配置表
    public static class Wechat {
@ -72,21 +84,25 @@ public class WxContants {
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWechatNoPage="getWechatNoPage";
        public static final String api_getWechats="getWechats";
        public static final String api_getByCode="getByCode";
        public static final String message_success_create="wechat create success";
        public static final String message_success_update="wechat update success";
        public static final String message_success_find="wechat find success";
        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_code_is_null="code is null";
        public static final String message_fail_code_no_exist="code no exist";
        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 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_wxWechat_is_no_exist="wxWechat is no exist";//微信配置不存在
        public static final String message_fail_id_is_null="id is null";
    }
    //微信图文消息
    public static class WxGraphicMessage {
@ -96,9 +112,9 @@ public class WxContants {
        public static final String api_delete="delete";
        public static final String api_getWxGraphicMessageNoPage="getWxGraphicMessageNoPage";
        public static final String api_sendGraphicMessages="sendGraphicMessages";
        public static final String api_getWxGraphicMessages="getWxGraphicMessages";
        public static final String api_getByCode="getByCode";
        public static final String message_success_create="wxGraphicMessage create success";
        public static final String message_success_update="wxGraphicMessage update success";
        public static final String message_success_find="wxGraphicMessage find success";
@ -109,6 +125,6 @@ public class WxContants {
        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_status_is_null="status is null";
        public static final String message_fail_title_is_null="title is null";
    }
}

+ 33 - 1
common/common-swagger/src/main/java/com/yihu/jw/config/SwaggerConfig.java

@ -1,6 +1,7 @@
package com.yihu.jw.config;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@ -15,10 +16,11 @@ import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableSwagger2
@ComponentScan("com.yihu.jw.*.controller")
@ComponentScan("com.yihu.jw.**")
public class SwaggerConfig {
    public static final String PUBLIC_API = "Default";
    public static final String Base_API = "JwBase";
    public static final String Wlyy_API = "Wlyy";
    @Bean
@ -55,6 +57,36 @@ public class SwaggerConfig {
        return apiInfo;
    }
    @Bean
    public Docket wlyyAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(Wlyy_API)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(false)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/" + WlyyContants.Agreement.api_common + "/.*")
                        ,regex("/"+WlyyContants.AgreementKpi.api_common+"/.*")
                        ,regex("/"+WlyyContants.AgreementKpiLog.api_common+"/.*")
                ))
                .build()
                .apiInfo(wlyyApiInfo());
    }
    private ApiInfo wlyyApiInfo() {
        ApiInfo wlyyInfo = new ApiInfo("基卫2.0API",
                "基卫2.0API,提供基础卫生相关服务。",
                "1.0",
                "No terms of service",
                "wenfujian@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return wlyyInfo;
    }
    @Bean
    public Docket jwBaseAPI() {

+ 644 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/WechatResponse.java

@ -0,0 +1,644 @@
package com.yihu.jw.wx;
/**
 * Created by Administrator on 2017/5/27 0027.
 */
public class WechatResponse {
    /**
     * 微信返回值
     * 具体见   https://mp.weixin.qq.com/wiki
     *  -1       系统繁忙,此时请开发者稍候再试
     *  0        请求成功
     *  40001    获取access_token时AppSecret错误,或者access_token无效。请开发者认真比对AppSecret的正确性,或查看是否正在为恰当的公众号调用接口
     *  40002    不合法的凭证类型
     *  40003    不合法的OpenID,请开发者确认OpenID(该用户)是否已关注公众号,或是否是其他公众号的OpenID
     *  40004    不合法的媒体文件类型
     *  40005    不合法的文件类型
     *  40006    不合法的文件大小
     *  40007    不合法的媒体文件id
     *  40008    不合法的消息类型
     *  40009    不合法的图片文件大小
     *  40010    不合法的语音文件大小
     *  40011    不合法的视频文件大小
     *  40012    不合法的缩略图文件大小
     *  40013    不合法的AppID,请开发者检查AppID的正确性,避免异常字符,注意大小写
     *  40014    不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口
     *  40015    不合法的菜单类型
     *  40016    不合法的按钮个数
     *  40017    不合法的按钮个数
     *  40018    不合法的按钮名字长度
     *  40019    不合法的按钮KEY长度
     *  40020    不合法的按钮URL长度
     *  40021    不合法的菜单版本号
     *  40022    不合法的子菜单级数
     *  40023    不合法的子菜单按钮个数
     *  40024    不合法的子菜单按钮类型
     *  40025    不合法的子菜单按钮名字长度
     *  40026    不合法的子菜单按钮KEY长度
     *  40027    不合法的子菜单按钮URL长度
     *  40028    不合法的自定义菜单使用用户
     *  40029    不合法的oauth_code
     *  40030    不合法的refresh_token
     *  40031    不合法的openid列表
     *  40032    不合法的openid列表长度
     *  40033    不合法的请求字符,不能包含\  uxxxx格式的字符
     *  40035    不合法的参数
     *  40038    不合法的请求格式
     *  40039    不合法的URL长度
     *  40050    不合法的分组id
     *  40051    分组名字不合法
     *  40060    删除单篇图文时,指定的 article_idx 不合法
     *  40117    分组名字不合法
     *  40118    media_id大小不合法
     *  40119    button类型错误
     *  40120    button类型错误
     *  40121    不合法的media_id类型
     *  40132    微信号不合法
     *  40137    不支持的图片格式
     *  40155    请勿添加其他公众号的主页链接
     *  41001    缺少access_token参数
     *  41002    缺少appid参数
     *  41003    缺少refresh_token参数
     *  41004    缺少secret参数
     *  41005    缺少多媒体文件数据
     *  41006    缺少media_id参数
     *  41007    缺少子菜单数据
     *  41008    缺少oauth code
     *  41009    缺少openid
     *  42001    access_token超时,请检查access_token的有效期,请参考基础支持-获取access_token中,对access_token的详细机制说明
     *  42002    refresh_token超时
     *  42003    oauth_code超时
     *  42007    用户修改微信密码,accesstoken和refreshtoken失效,需要重新授权
     *  43001    需要GET请求
     *  43002    需要POST请求
     *  43003    需要HTTPS请求
     *  43004    需要接收者关注
     *  43005    需要好友关系
     *  43019    需要将接收者从黑名单中移除
     *  44001    多媒体文件为空
     *  44002    POST的数据包为空
     *  44003    图文消息内容为空
     *  44004    文本消息内容为空
     *  45001    多媒体文件大小超过限制
     *  45002    消息内容超过限制
     *  45003    标题字段超过限制
     *  45004    描述字段超过限制
     *  45005    链接字段超过限制
     *  45006    图片链接字段超过限制
     *  45007    语音播放时间超过限制
     *  45008    图文消息超过限制
     *  45009    接口调用超过限制
     *  45010    创建菜单个数超过限制
     *  45011    API调用太频繁,请稍候再试
     *  45015    回复时间超过限制
     *  45016    系统分组,不允许修改
     *  45017    分组名字过长
     *  45018    分组数量超过上限
     *  45047    客服接口下行条数超过上限
     *  46001    不存在媒体数据
     *  46002    不存在的菜单版本
     *  46003    不存在的菜单数据
     *  46004    不存在的用户
     *  47001    解析JSON/XML内容错误
     *  48001    api功能未授权,请确认公众号已获得该接口,可以在公众平台官网-开发者中心页中查看接口权限
     *  48002    粉丝拒收消息(粉丝在公众号选项中,关闭了“接收消息”)
     *  48004    api接口被封禁,请登录mp.weixin.qq.com查看详情
     *  48005    api禁止删除被自动回复和自定义菜单引用的素材
     *  48006    api禁止清零调用次数,因为清零次数达到上限
     *  50001    用户未授权该api
     *  50002    用户受限,可能是违规后接口被封禁
     *  61451    参数错误(invalid parameter)
     *  61452    无效客服账号(invalid kf_account)
     *  61453    客服帐号已存在(kf_account exsited)
     *  61454    客服帐号名长度超过限制(仅允许10个英文字符,不包括@及@后的公众号的微信号)(invalid   kf_acount length)
     *  61455    客服帐号名包含非法字符(仅允许英文+数字)(illegal character in     kf_account)
     *  61456    客服帐号个数超过限制(10个客服账号)(kf_account count exceeded)
     *  61457    无效头像文件类型(invalid   file type)
     *  61450    系统错误(system error)
     *  61500    日期格式错误
     *  65301    不存在此menuid对应的个性化菜单
     *  65302    没有相应的用户
     *  65303    没有默认菜单,不能创建个性化菜单
     *  65304    MatchRule信息为空
     *  65305    个性化菜单数量受限
     *  65306    不支持个性化菜单的帐号
     *  65307    个性化菜单信息为空
     *  65308    包含没有响应类型的button
     *  65309    个性化菜单开关处于关闭状态
     *  65310    填写了省份或城市信息,国家信息不能为空
     *  65311    填写了城市信息,省份信息不能为空
     *  65312    不合法的国家信息
     *  65313    不合法的省份信息
     *  65314    不合法的城市信息
     *  65316    该公众号的菜单设置了过多的域名外跳(最多跳转到3个域名的链接)
     *  65317    不合法的URL
     *  9001001    POST数据参数不合法
     *  9001002    远端服务不可用
     *  9001003    Ticket不合法
     *  9001004    获取摇周边用户信息失败
     *  9001005    获取商户信息失败
     *  9001006    获取OpenID失败
     *  9001007    上传文件缺失
     *  9001008    上传素材的文件类型不合法
     *  9001009    上传素材的文件尺寸不合法
     *  9001010    上传失败
     *  9001020    帐号不合法
     *  9001021    已有设备激活率低于50%,不能新增设备
     *  9001022    设备申请数不合法,必须为大于0的数字
     *  9001023    已存在审核中的设备ID申请
     *  9001024    一次查询设备ID数量不能超过50
     *  9001025    设备ID不合法
     *  9001026    页面ID不合法
     *  9001027    页面参数不合法
     *  9001028    一次删除页面ID数量不能超过10
     *  9001029    页面已应用在设备中,请先解除应用关系再删除
     *  9001030    一次查询页面ID数量不能超过50
     *  9001031    时间区间不合法
     *  9001032    保存设备与页面的绑定关系参数错误
     *  9001033    门店ID不合法
     *  9001034    设备备注信息过长
     *  9001035    设备申请参数不合法
     *  9001036    查询起始值begin不合法
     */
    private Integer resultCode;
    /** 返回码对应信息 ***/
    private String msg;
    public Integer getResultCode() {
        return resultCode;
    }
    public void setResultCode(Integer resultCode) {
        this.resultCode = resultCode;
    }
    public WechatResponse(Integer resultCode) {
        this.resultCode = resultCode;
    }
    public String getMsg() {
        switch (resultCode) {
        case -1:
            msg="系统繁忙,此时请开发者稍候再试";
            break;
        case 0:
            msg="请求成功";
            break;
        case 40001:
            msg="获取access_token时AppSecret错误,或者access_token无效。请开发者认真比对AppSecret的正确性,或查看是否正在为恰当的公众号调用接口";
            break;
        case 40002:
            msg="不合法的凭证类型";
            break;
        case 40003:
            msg="不合法的OpenID,请开发者确认OpenID(该用户)是否已关注公众号,或是否是其他公众号的OpenID";
            break;
        case 40004:
            msg="不合法的媒体文件类型";
            break;
        case 40005:
            msg="不合法的文件类型";
            break;
        case 40006:
            msg="不合法的文件大小";
            break;
        case 40007:
            msg="不合法的媒体文件id";
            break;
        case 40008:
            msg="不合法的消息类型";
            break;
        case 40009:
            msg="不合法的图片文件大小";
            break;
        case 40010:
            msg="不合法的语音文件大小";
            break;
        case 40011:
            msg="不合法的视频文件大小";
            break;
        case 40012:
            msg="不合法的缩略图文件大小";
            break;
        case 40013:
            msg="不合法的AppID,请开发者检查AppID的正确性,避免异常字符,注意大小写";
            break;
        case 40014:
            msg="不合法的access_token,请开发者认真比对access_token的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口";
            break;
        case 40015:
            msg="不合法的菜单类型";
            break;
        case 40016:
            msg="不合法的按钮个数";
            break;
        case 40017:
            msg="不合法的按钮个数";
            break;
        case 40018:
            msg="不合法的按钮名字长度";
            break;
        case 40019:
            msg="不合法的按钮KEY长度";
            break;
        case 40020:
            msg="不合法的按钮URL长度";
            break;
        case 40021:
            msg="不合法的菜单版本号";
            break;
        case 40022:
            msg="不合法的子菜单级数";
            break;
        case 40023:
            msg="不合法的子菜单按钮个数";
            break;
        case 40024:
            msg="不合法的子菜单按钮类型";
            break;
        case 40025:
            msg="不合法的子菜单按钮名字长度";
            break;
        case 40026:
            msg="不合法的子菜单按钮KEY长度";
            break;
        case 40027:
            msg="不合法的子菜单按钮URL长度";
            break;
        case 40028:
            msg="不合法的自定义菜单使用用户";
            break;
        case 40029:
            msg="不合法的oauth_code";
            break;
        case 40030:
            msg="不合法的refresh_token";
            break;
        case 40031:
            msg="不合法的openid列表";
            break;
        case 40032:
            msg="不合法的openid列表长度";
            break;
        case 40033:
            msg="不合法的请求字符,不能包含\\uxxxx格式的字符";
            break;
        case 40035:
            msg="不合法的参数";
            break;
        case 40038:
            msg="不合法的请求格式";
            break;
        case 40039:
            msg="不合法的URL长度";
            break;
        case 40050:
            msg="不合法的分组id";
            break;
        case 40051:
            msg="分组名字不合法";
            break;
        case 40060:
            msg="删除单篇图文时,指定的 article_idx 不合法";
            break;
        case 40117:
            msg="分组名字不合法";
            break;
        case 40118:
            msg="media_id大小不合法";
            break;
        case 40119:
            msg="button类型错误";
            break;
        case 40120:
            msg="button类型错误";
            break;
        case 40121:
            msg="不合法的media_id类型";
            break;
        case 40132:
            msg="微信号不合法";
            break;
        case 40137:
            msg="不支持的图片格式";
            break;
        case 40155:
            msg="请勿添加其他公众号的主页链接";
            break;
        case 41001:
            msg="缺少access_token参数";
            break;
        case 41002:
            msg="缺少appid参数";
            break;
        case 41003:
            msg="缺少refresh_token参数";
            break;
        case 41004:
            msg="缺少secret参数";
            break;
        case 41005:
            msg="缺少多媒体文件数据";
            break;
        case 41006:
            msg="缺少media_id参数";
            break;
        case 41007:
            msg="缺少子菜单数据";
            break;
        case 41008:
            msg="缺少oauth code";
            break;
        case 41009:
            msg="缺少openid";
            break;
        case 42001:
            msg="access_token超时,请检查access_token的有效期,请参考基础支持-获取access_token中,对access_token的详细机制说明";
            break;
        case 42002:
            msg="refresh_token超时";
            break;
        case 42003:
            msg="oauth_code超时";
            break;
        case 42007:
            msg="用户修改微信密码,accesstoken和refreshtoken失效,需要重新授权";
            break;
        case 43001:
            msg="需要GET请求";
            break;
        case 43002:
            msg="需要POST请求";
            break;
        case 43003:
            msg="需要HTTPS请求";
            break;
        case 43004:
            msg="需要接收者关注";
            break;
        case 43005:
            msg="需要好友关系";
            break;
        case 43019:
            msg="需要将接收者从黑名单中移除";
            break;
        case 44001:
            msg="多媒体文件为空";
            break;
        case 44002:
            msg="POST的数据包为空";
            break;
        case 44003:
            msg="图文消息内容为空";
            break;
        case 44004:
            msg="文本消息内容为空";
            break;
        case 45001:
            msg="多媒体文件大小超过限制";
            break;
        case 45002:
            msg="消息内容超过限制";
            break;
        case 45003:
            msg="标题字段超过限制";
            break;
        case 45004:
            msg="描述字段超过限制";
            break;
        case 45005:
            msg="链接字段超过限制";
            break;
        case 45006:
            msg="图片链接字段超过限制";
            break;
        case 45007:
            msg="语音播放时间超过限制";
            break;
        case 45008:
            msg="图文消息超过限制";
            break;
        case 45009:
            msg="接口调用超过限制";
            break;
        case 45010:
            msg="创建菜单个数超过限制";
            break;
        case 45011:
            msg="API调用太频繁,请稍候再试";
            break;
        case 45015:
            msg="回复时间超过限制";
            break;
        case 45016:
            msg="系统分组,不允许修改";
            break;
        case 45017:
            msg="分组名字过长";
            break;
        case 45018:
            msg="分组数量超过上限";
            break;
        case 45047:
            msg="客服接口下行条数超过上限";
            break;
        case 46001:
            msg="不存在媒体数据";
            break;
        case 46002:
            msg="不存在的菜单版本";
            break;
        case 46003:
            msg="不存在的菜单数据";
            break;
        case 46004:
            msg="不存在的用户";
            break;
        case 47001:
            msg="解析JSON/XML内容错误";
            break;
        case 48001:
            msg="api功能未授权,请确认公众号已获得该接口,可以在公众平台官网-开发者中心页中查看接口权限";
            break;
        case 48002:
            msg="粉丝拒收消息(粉丝在公众号选项中,关闭了“接收消息”)";
            break;
        case 48004:
            msg="api接口被封禁,请登录mp.weixin.qq.com查看详情";
            break;
        case 48005:
            msg="api禁止删除被自动回复和自定义菜单引用的素材";
            break;
        case 48006:
            msg="api禁止清零调用次数,因为清零次数达到上限";
            break;
        case 50001:
            msg="用户未授权该api";
            break;
        case 50002:
            msg="用户受限,可能是违规后接口被封禁";
            break;
        case 61451:
            msg="参数错误(invalid parameter)";
            break;
        case 61452:
            msg="无效客服账号(invalid kf_account)";
            break;
        case 61453:
            msg="客服帐号已存在(kf_account exsited)";
            break;
        case 61454:
            msg="客服帐号名长度超过限制(仅允许10个英文字符,不包括@及@后的公众号的微信号)(invalid kf_acount length)";
            break;
        case 61455:
            msg="客服帐号名包含非法字符(仅允许英文+数字)(illegal character in kf_account)";
            break;
        case 61456:
            msg="客服帐号个数超过限制(10个客服账号)(kf_account count exceeded)";
            break;
        case 61457:
            msg="无效头像文件类型(invalid file type)";
            break;
        case 61450:
            msg="系统错误(system error)";
            break;
        case 61500:
            msg="日期格式错误";
            break;
        case 65301:
            msg="不存在此menuid对应的个性化菜单";
            break;
        case 65302:
            msg="没有相应的用户";
            break;
        case 65303:
            msg="没有默认菜单,不能创建个性化菜单";
            break;
        case 65304:
            msg="MatchRule信息为空";
            break;
        case 65305:
            msg="个性化菜单数量受限";
            break;
        case 65306:
            msg="不支持个性化菜单的帐号";
            break;
        case 65307:
            msg="个性化菜单信息为空";
            break;
        case 65308:
            msg="包含没有响应类型的button";
            break;
        case 65309:
            msg="个性化菜单开关处于关闭状态";
            break;
        case 65310:
            msg="填写了省份或城市信息,国家信息不能为空";
            break;
        case 65311:
            msg="填写了城市信息,省份信息不能为空";
            break;
        case 65312:
            msg="不合法的国家信息";
            break;
        case 65313:
            msg="不合法的省份信息";
            break;
        case 65314:
            msg="不合法的城市信息";
            break;
        case 65316:
            msg="该公众号的菜单设置了过多的域名外跳(最多跳转到3个域名的链接)";
            break;
        case 65317:
            msg="不合法的URL";
            break;
        case 9001001:
            msg="POST数据参数不合法";
            break;
        case 9001002:
            msg="远端服务不可用";
            break;
        case 9001003:
            msg="Ticket不合法";
            break;
        case 9001004:
            msg="获取摇周边用户信息失败";
            break;
        case 9001005:
            msg="获取商户信息失败";
            break;
        case 9001006:
            msg="获取OpenID失败";
            break;
        case 9001007:
            msg="上传文件缺失";
            break;
        case 9001008:
            msg="上传素材的文件类型不合法";
            break;
        case 9001009:
            msg="上传素材的文件尺寸不合法";
            break;
        case 9001010:
            msg="上传失败";
            break;
        case 9001020:
            msg="帐号不合法";
            break;
        case 9001021:
            msg="已有设备激活率低于50%,不能新增设备";
            break;
        case 9001022:
            msg="设备申请数不合法,必须为大于0的数字";
            break;
        case 9001023:
            msg="已存在审核中的设备ID申请";
            break;
        case 9001024:
            msg="一次查询设备ID数量不能超过50";
            break;
        case 9001025:
            msg="设备ID不合法";
            break;
        case 9001026:
            msg="页面ID不合法";
            break;
        case 9001027:
            msg="页面参数不合法";
            break;
        case 9001028:
            msg="一次删除页面ID数量不能超过10";
            break;
        case 9001029:
            msg="页面已应用在设备中,请先解除应用关系再删除";
            break;
        case 9001030:
            msg="一次查询页面ID数量不能超过50";
            break;
        case 9001031:
            msg="时间区间不合法";
            break;
        case 9001032:
            msg="保存设备与页面的绑定关系参数错误";
            break;
        case 9001033:
            msg="门店ID不合法";
            break;
        case 9001034:
            msg="设备备注信息过长";
            break;
        case 9001035:
            msg="设备申请参数不合法";
            break;
        case 9001036:
            msg="查询起始值begin不合法";
            break;
        default:
            msg = resultCode+":其他错误";
            break;
        }
        return msg;
    }
}

+ 8 - 7
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxGraphicMessageController.java

@ -86,11 +86,11 @@ public class WxGraphicMessageController extends EnvelopRestController {
    @RequestMapping(value = WxContants.WxGraphicMessage.api_getWxGraphicMessages, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信图文消息列表(分页)")
    public Envelop getWxGraphicMessages(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,wechatCode,value,keyword,remark,status")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
@ -114,11 +114,11 @@ public class WxGraphicMessageController extends EnvelopRestController {
    @GetMapping(value = WxContants.WxGraphicMessage.api_getWxGraphicMessageNoPage)
    @ApiOperation(value = "获取图文消息列表,不分页")
    public Envelop getWxGraphicMessageNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,wechatCode,value,keyword,remark,status")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WxGraphicMessage> list = wxGraphicMessageService.search(fields,filters,sorts);
@ -127,7 +127,7 @@ public class WxGraphicMessageController extends EnvelopRestController {
        return Envelop.getSuccessList(WxContants.WxGraphicMessage.message_success_find_functions,mWxGraphicMessages);
    }
    //@GetMapping(value = WxContants.WxGraphicMessage.api_sendGraphicMessages)
    //@GetMapping(value = WlyyContants.WxGraphicMessage.api_sendGraphicMessages)
    //@ApiOperation(value = "发送图文消息")
    //public Envelop sendGraphicMessages(
    //        @ApiParam(name = "codes", value = "根据code发送微信图文消息,多个code用,分割")
@ -138,7 +138,8 @@ public class WxGraphicMessageController extends EnvelopRestController {
    @GetMapping(value = WxContants.WxGraphicMessage.api_sendGraphicMessages)
    @ApiOperation(value = "发送图文消息")
    public Envelop sendGraphicMessages(
    @ResponseBody
    public String sendGraphicMessages(
            @ApiParam(name = "codes", value = "根据code发送微信图文消息,多个code用,分割")
            @RequestParam(value = "codes", required = true) String codes,
            @ApiParam(name = "fromUserName", value = "用户openid")
@ -147,7 +148,7 @@ public class WxGraphicMessageController extends EnvelopRestController {
            @RequestParam(value = "toUserName", required = true) String toUserName
            ) throws Exception {
        String messages = wxGraphicMessageService.sendGraphicMessages(codes, fromUserName,toUserName);
        return Envelop.getSuccess("成功",messages);
        return messages;
    }

+ 6 - 7
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxMenuController.java

@ -5,6 +5,7 @@ import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wx.MWxMenu;
import com.yihu.jw.restmodel.wx.WxContants;
import com.yihu.jw.wx.WechatResponse;
import com.yihu.jw.wx.model.WxMenu;
import com.yihu.jw.wx.model.WxWechat;
import com.yihu.jw.wx.service.WxMenuService;
@ -136,19 +137,17 @@ public class WxMenuController extends EnvelopRestController {
     */
    @ApiOperation(value = "创建微信公众号菜单", notes = "创建微信公众号菜单")
    @RequestMapping(value = WxContants.WxMenu.api_createMenu ,method = RequestMethod.GET)
    @ResponseBody
    public Envelop createWechatMenu(
            @ApiParam(name = "wechatCode", value = "", defaultValue = "")
            @RequestParam(value = "wechatCode", required = true)String wechatCode){
        try{
            JSONObject result = wxMenuService.createWechatMenu(wechatCode);
            if(result != null && result.get("errcode").toString().equals("0") && result.getString("errmsg").equals("ok")){
                return Envelop.getSuccess("创建成功",result );
            }else{
                return Envelop.getSuccess("创建失败",result );
            }
            String errcode = result.get("errcode").toString();
            WechatResponse wechatResponse = new WechatResponse(Integer.valueOf(errcode));
            String msg = wechatResponse.getMsg();
            return Envelop.getSuccess("成功",msg);
        }catch (Exception e){
            return Envelop.getSuccess("创建成功",e );
            return Envelop.getSuccess("创建失败",e );
        }
    }

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

@ -5,6 +5,7 @@ import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wx.MWxTemplate;
import com.yihu.jw.restmodel.wx.WxContants;
import com.yihu.jw.wx.WechatResponse;
import com.yihu.jw.wx.model.Miniprogram;
import com.yihu.jw.wx.model.WxTemplate;
import com.yihu.jw.wx.service.WxTemplateService;
@ -88,11 +89,11 @@ public class WxTemplateController extends EnvelopRestController {
    @RequestMapping(value = WxContants.WxTemplate.api_getWxTemplates, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信模版列表(分页)")
    public Envelop getWechats(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
@ -116,11 +117,11 @@ public class WxTemplateController extends EnvelopRestController {
    @GetMapping(value = WxContants.WxTemplate.api_getWxTemplatesNoPage)
    @ApiOperation(value = "获取微信模版列表(不分页)")
    public Envelop getWechatNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WxTemplate> list = wxTemplateService.search(fields,filters,sorts);
@ -131,10 +132,11 @@ public class WxTemplateController extends EnvelopRestController {
    @GetMapping(value = WxContants.WxTemplate.api_sendTemplateMessage)
    @ApiOperation(value = "发送微信模板消息")
    @ResponseBody
    public Envelop sendTemplateMessage(
            @ApiParam(name="openid",value="微信用户的openid")
            @RequestParam String openid,
            @ApiParam(name="tempalteCode",value = "模板code")
            @ApiParam(name="templateCode",value = "模板code")
            @RequestParam String templateCode,
            @ApiParam(name="url",value="模板跳转链接")
            @RequestParam(required = false) String url,
@ -145,13 +147,20 @@ public class WxTemplateController extends EnvelopRestController {
            @ApiParam(name="data",value="json字符串")
            @RequestParam String data
    ){
        Miniprogram miniprogram = null;
        if(StringUtils.isNotBlank(appid)&&StringUtils.isNotBlank(pagepath)){
            miniprogram = new Miniprogram();
            miniprogram.setAppid(appid);
            miniprogram.setPagepath(pagepath);
        try {
            Miniprogram miniprogram = null;
            if(StringUtils.isNotBlank(appid)&&StringUtils.isNotBlank(pagepath)){
                miniprogram = new Miniprogram();
                miniprogram.setAppid(appid);
                miniprogram.setPagepath(pagepath);
            }
            JSONObject jsonObject = wxTemplateService.sendTemplateMessage(openid, templateCode, url, data, miniprogram);
            String errcode = jsonObject.get("errcode").toString();
            WechatResponse wechatResponse = new WechatResponse(Integer.valueOf(errcode));
            String msg = wechatResponse.getMsg();
            return Envelop.getSuccess("成功",msg);
        }catch (Exception exception) {
            return Envelop.getSuccess("error", exception);
        }
        JSONObject jsonObject = wxTemplateService.sendTemplateMessage(openid, templateCode, url, data, miniprogram);
        return Envelop.getSuccess("成功",jsonObject);
    }
}

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxMenuDao.java

@ -37,4 +37,6 @@ public interface WxMenuDao  extends PagingAndSortingRepository<WxMenu, Long>, Jp
    @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);
    @Query("from WxMenu m where m.wechatCode =?1 and m.status = 1 and m.supMenucode is null order by m.supMenucode ,m.sort")
    List<WxMenu> findParentMenuByWechatCode(String wechatCode);
}

+ 15 - 13
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxMenu.java

@ -18,7 +18,7 @@ public class WxMenu extends IdEntity implements java.io.Serializable {
    private String supMenucode;//父菜单id 如果是一级菜单 此字段为空
    private String type;//菜单类型
    private String name;//菜单名称
    private String key;//click等点击类型必须
    private String menuKey;//click等点击类型必须
    private Integer sort;//菜单排序 父菜单排序 不包含子菜单那
    private String url;//url
    private String mediaId;//点用新增永久素材接口返回的合法media_id
@ -32,13 +32,20 @@ public class WxMenu extends IdEntity implements java.io.Serializable {
    private Integer status; //状态 -1删除 0 冻结 1可用
    public WxMenu(String code, String wechatCode, String supMenucode, String type, String name, String key, Integer sort, String url, String mediaId, String appid, String pagepath, String updateUser, Date updateTime, Date createTime, String createUser, String remark, Integer status) {
    /**
     * default constructor
     */
    public WxMenu() {
    }
    public WxMenu(String code, String wechatCode, String supMenucode, String type, String name, String menuKey, Integer sort, String url, String mediaId, String appid, String pagepath, String updateUser, Date updateTime, Date createTime, String createUser, String remark, Integer status) {
        this.code = code;
        this.wechatCode = wechatCode;
        this.supMenucode = supMenucode;
        this.type = type;
        this.name = name;
        this.key = key;
        this.menuKey = menuKey;
        this.sort = sort;
        this.url = url;
        this.mediaId = mediaId;
@ -52,18 +59,13 @@ public class WxMenu extends IdEntity implements java.io.Serializable {
        this.status = status;
    }
    /**
     * default constructor
     */
    public WxMenu() {
    }
    public String getKey() {
        return key;
    @Column(name="menu_key")
    public String getMenuKey() {
        return menuKey;
    }
    public void setKey(String key) {
        this.key = key;
    public void setMenuKey(String menuKey) {
        this.menuKey = menuKey;
    }
    public String getMediaId() {

+ 13 - 7
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WechatService.java

@ -32,8 +32,11 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        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.getName())) {
            throw new ApiException(WxContants.Wechat.message_fail_name_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.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
@ -56,12 +59,18 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        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.getName())) {
            throw new ApiException(WxContants.Wechat.message_fail_name_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.getAppSecret())) {
            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());
        if(wechatTem!=null){
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
@ -71,9 +80,6 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
    public WxWechat findByCode(String code) {
        WxWechat wxWechat = wechatDao.findByCode(code);
        if (wxWechat == null) {
            throw new ApiException(WxContants.Wechat.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return wxWechat;
    }

+ 15 - 5
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxAccessTokenService.java

@ -1,6 +1,9 @@
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;
@ -9,6 +12,7 @@ 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.util.StringUtils;
import org.springside.modules.utils.Clock;
import java.util.List;
@ -33,6 +37,11 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessToken, WxAccess
     */
    public WxAccessToken getWxAccessTokenByCode(String wechatCode) {
        try {
            //根据wechatCode查找出appid和appSecret
            WxWechat wxWechat = wechatDao.findByCode(wechatCode);
            if(wxWechat==null){
                throw new ApiException(WxContants.Wechat.message_fail_wxWechat_is_no_exist, CommonContants.common_error_params_code);
            }
            List<WxAccessToken> wxAccessTokens =  wxAccessTokenDao.getWxAccessTokenByCode(wechatCode);
            if(wxAccessTokens!=null&&wxAccessTokens.size()>0){
                for (WxAccessToken accessToken : wxAccessTokens) {
@ -47,13 +56,14 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessToken, WxAccess
            String token_url = "https://api.weixin.qq.com/cgi-bin/token";
            String appId="";
            String appSecret="";
            //根据wechatCode查找出appid和appSecret
            WxWechat wxWechat = wechatDao.findByCode(wechatCode);
            if(wxWechat==null){
                return null;
            }
            appId = wxWechat.getAppId();
            appSecret = wxWechat.getAppSecret();
            if (StringUtils.isEmpty(appId)){
                throw new ApiException(WxContants.Wechat.message_fail_appId_is_null, CommonContants.common_error_params_code);
            }
            if (StringUtils.isEmpty(appSecret)){
                throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
            }
            String params = "grant_type=client_credential&appid=" + appId + "&secret=" + appSecret;
            String result = HttpUtil.sendGet(token_url, params);
            JSONObject json = new JSONObject(result);

+ 8 - 1
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java

@ -32,6 +32,9 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getTitle())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_title_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);
@ -47,6 +50,9 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            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);
    }
@ -108,9 +114,10 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
            Map<String, String> requestMap = MessageUtil.parseXml(request);
            //用户openid
            String fromUserName = requestMap.get("FromUserName");
            System.out.println("fromUserName+=   "+fromUserName);
            //微信公众号
            String toUserName = requestMap.get("ToUserName");
            System.out.println("ToUserName+=   "+toUserName);
            // 图文信息
            List<Map<String,String>> articles =  new ArrayList<>();
            if(codes!=null){

+ 113 - 14
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java

@ -8,6 +8,7 @@ import com.yihu.jw.util.HttpUtil;
import com.yihu.jw.wx.dao.WxMenuDao;
import com.yihu.jw.wx.model.WxAccessToken;
import com.yihu.jw.wx.model.WxMenu;
import com.yihu.jw.wx.model.WxWechat;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -26,6 +27,9 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    @Autowired
    private WxMenuDao wxMenuDao;
    @Autowired
    private WechatService wechatService;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
@ -44,6 +48,9 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    @Transient
    public WxMenu updateWxMenu(WxMenu 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 null;
@ -57,7 +64,7 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        }
        String supMenucode = wxMenu.getSupMenucode();
        if(StringUtils.isEmpty(supMenucode)) {//如果是空,则为父菜单
            List<WxMenu> childMenus = findChildMenus(wxMenu.getWechatCode(), wxMenu.getSupMenucode());
            List<WxMenu> childMenus = findChildMenus(wxMenu.getWechatCode(), wxMenu.getCode());
            if(childMenus!=null){
                for(WxMenu wxmenu:childMenus){
                    wxmenu.setStatus(-1);
@ -82,14 +89,31 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        return wxMenuDao.findByWechatCode(wechatCode);
    }
    /**
     * 根据wechatCode查找所有菜单
     * @param wechatCode
     * @return
     */
    public List<WxMenu> findParentMenuByWechatCode(String wechatCode){
        return wxMenuDao.findParentMenuByWechatCode(wechatCode);
    }
    /**
     * 根据wechatCode在微信公众号创建菜单
     * @param wechatCode
     * @return JSONObject
     */
    public JSONObject createWechatMenu(String wechatCode) {
        WxWechat wechat = wechatService.findByCode(wechatCode);
        if(wechat==null){
            throw new ApiException(WxContants.Wechat.message_fail_wxWechat_is_no_exist, CommonContants.common_error_params_code);
        }
        //首先根据wechatCode获取菜单,然后封装成json字符串
        List<WxMenu> menus = wxMenuDao.findByWechatCode(wechatCode);
        if(menus==null){
            throw new ApiException(WxContants.WxMenu.message_fail_WxMenu_is_no_exist, CommonContants.common_error_params_code);
        }
        String menuJsonString = getMenuToString(menus, wechatCode);
        WxAccessToken wxAccessTokenByCode = wxAccessTokenService.getWxAccessTokenByCode(wechatCode);
        String token = wxAccessTokenByCode.getAccessToken();
@ -145,8 +169,8 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        if(!StringUtils.isEmpty(menu.getType())){
            menuJsonStr += ",\"type\":\"" + menu.getType()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getKey())){
            menuJsonStr += ",\"key\":\"" + menu.getKey()+"\"";
        if(!StringUtils.isEmpty(menu.getMenuKey())){
            menuJsonStr += ",\"key\":\"" + menu.getMenuKey()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getUrl())){
            menuJsonStr += ",\"url\":\"" + menu.getUrl()+"\"";
@ -177,26 +201,101 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        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())) {
        String wechatCode = wxMenu.getWechatCode();
        if (StringUtils.isEmpty(wechatCode)) {
            throw new ApiException(WxContants.WxMenu.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getName())) {
        String name = wxMenu.getName();
        if (StringUtils.isEmpty(name)) {
            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 (StringUtils.isEmpty(wxMenu.getStatus())) {
            throw new ApiException(WxContants.WxMenu.message_fail_status_is_null, 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);
        }
        //根据wechatCode查找是否存在微信配置
        WxWechat wxWechat = wechatService.findByCode(wechatCode);
        if(wxWechat==null){
            throw new ApiException(WxContants.Wechat.message_fail_wxWechat_is_no_exist, CommonContants.common_error_params_code);
        }
        if("click".equals(wxMenu.getType().toUpperCase())){
            String key = wxMenu.getKey();
        String supMenucode = wxMenu.getSupMenucode();
        if (!StringUtils.isEmpty(supMenucode)) {//不为空,说明是子菜单,判断父菜单是否存在
            //说明是子菜单
            //判断父菜单是否存在
            WxMenu parentMenuCode = findByCode(supMenucode);
            if(parentMenuCode==null){
                throw new ApiException(WxContants.WxMenu.message_fail_supMenuCode_is_no_exist, CommonContants.common_error_params_code);
            }
            //查询已经存在的子菜单条数
            List<WxMenu> childMenus = findChildMenus(wechatCode, supMenucode);
            if(childMenus.size()==5){
                throw new ApiException(WxContants.WxMenu.message_fail_childMenu_is_to_much, CommonContants.common_error_params_code);
            }
            if(name.getBytes().length>60){
                throw new ApiException(WxContants.WxMenu.message_fail_name_is_to_long, 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);
            }
        }else{
            //查找父菜单
            List<WxMenu> parentMenus = findParentMenuByWechatCode(wechatCode);
            if(parentMenus!=null){
                if(parentMenus.size()==3){
                    throw new ApiException(WxContants.WxMenu.message_fail_parentMenu_is_to_much, CommonContants.common_error_params_code);
                }
            }
            //说明是父菜单
            if(name.getBytes().length>16){
                throw new ApiException(WxContants.WxMenu.message_fail_name_is_to_long, CommonContants.common_error_params_code);
            }
        }
        String type1=wxMenu.getType();
        if(type1==null){
            type1="";
        }
        String type = type1.toUpperCase();
        if("click".equals(type)){
            String key = wxMenu.getMenuKey();
            if(StringUtils.isEmpty(key)){
                throw new ApiException(WxContants.WxMenu.message_fail_wxMenuKey_is_null, CommonContants.common_error_params_code);
                throw new ApiException(WxContants.WxMenu.message_fail_key_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(key.getBytes().length>128){
                throw new ApiException(WxContants.WxMenu.message_fail_key_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);
        String url = wxMenu.getUrl();
        if("view".equals(type)){
            if(StringUtils.isEmpty(url)){
                throw new ApiException(WxContants.WxMenu.message_fail_url_is_null, CommonContants.common_error_params_code);
            }
            if(url.getBytes().length>128){
                throw new ApiException(WxContants.WxMenu.message_fail_url_is_toLong, CommonContants.common_error_params_code);
            }
        }
        if("miniprogram".equals(type)){
            if(StringUtils.isEmpty(url)){
                throw new ApiException(WxContants.WxMenu.message_fail_url_is_null, CommonContants.common_error_params_code);
            }
            if(url.getBytes().length>128){
                throw new ApiException(WxContants.WxMenu.message_fail_url_is_toLong, CommonContants.common_error_params_code);
            }
            if(StringUtils.isEmpty(wxMenu.getAppid())){
                throw new ApiException(WxContants.WxMenu.message_fail_appid_is_null, CommonContants.common_error_params_code);
            }
            if(StringUtils.isEmpty(wxMenu.getPagepath())){
                throw new ApiException(WxContants.WxMenu.message_fail_pagepath_is_null, CommonContants.common_error_params_code);
            }
        }
        if("media_id".equals(type)||"view_limited".equals(type)){
            if(StringUtils.isEmpty(wxMenu.getMediaId())){
                throw new ApiException(WxContants.WxMenu.message_fail_mediaId_is_null, CommonContants.common_error_params_code);
            }
        }
        WxMenu wxMenuTemp = null;
        if(StringUtils.isEmpty(wxMenu.getSupMenucode())){//如果是空,则为父菜单

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

@ -28,6 +28,9 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WechatService wechatService;
    public WxTemplate createWxTemplate(WxTemplate wxTemplate) {
        if (StringUtils.isEmpty(wxTemplate.getCode())) {
@ -36,6 +39,11 @@ 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);
        }
        //根据wechatCode查找是否存在微信配置
        WxWechat wxWechat = wechatService.findByCode(wxTemplate.getWechatCode());
        if(wxWechat==null){
            throw new ApiException(WxContants.Wechat.message_fail_wxWechat_is_no_exist, 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);
        }
@ -63,6 +71,9 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
        if (StringUtils.isEmpty(content)) {
            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}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
@ -90,6 +101,9 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
        try {
            //首先根据wechatTemplate获取微信模版
            WxTemplate wxTemplate = findByCode(templateCode);
            if(wxTemplate==null){
                throw new ApiException(WxContants.WxTemplate.message_fail_template_is_no_exist, CommonContants.common_error_params_code);
            }
            String wechatCode =  wxTemplate.getWechatCode();
            String content = wxTemplate.getContent().replaceAll(" ", "");//{{result.DATA}}领奖金额:{{withdrawMoney.DATA}   }领奖  时间:{ {withdrawTime.DATA} }银行信息:{ {cardInfo.DATA} }到账时间:{{arrivedTime.DATA}}{{remark.DATA}}
            String[] contentArray = content.split("\\{\\{");

+ 1 - 1
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/SvrWlyyApplication.java

@ -1,4 +1,4 @@
package com.yihu.jw.wlyy;
package com.yihu.jw;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

+ 126 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/WlyyAgreementController.java

@ -0,0 +1,126 @@
package com.yihu.jw.wlyy.controller;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.entity.WlyyAgreement;
import com.yihu.jw.wlyy.service.WlyyAgreementService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.Agreement.api_common)
@Api(value = "协议相关操作", description = "协议相关操作")
public class WlyyAgreementController extends EnvelopRestController {
    @Autowired
    private WlyyAgreementService wlyyAgreementService;
    @PostMapping(value = WlyyContants.Agreement.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建协议", notes = "创建协议")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreement wlyyAgreement = toEntity(jsonData, WlyyAgreement.class);
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_create, wlyyAgreementService.create(wlyyAgreement));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WlyyContants.Agreement.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改协议", notes = "修改协议")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreement wlyyAgreement = toEntity(jsonData, WlyyAgreement.class);
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_update, wlyyAgreementService.update(wlyyAgreement));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value =WlyyContants.Agreement.api_delete)
    @ApiOperation(value = "删除协议", notes = "删除协议")
    public Envelop delete(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wlyyAgreementService.delete(code);
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.Agreement.api_getByCode)
    @ApiOperation(value = "根据code查找协议", notes = "根据code查找协议")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.Agreement.message_success_find, wlyyAgreementService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.Agreement.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取协议")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<WlyyAgreement> list = wlyyAgreementService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wlyyAgreementService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WlyyAgreement> wlyyAgreement = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreement.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.Agreement.message_success_find_functions,wlyyAgreement, page, size,count);
    }
    @GetMapping(value =WlyyContants.Agreement.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WlyyAgreement> list = wlyyAgreementService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyyAgreement> wlyyAgreement = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreement.class, fields);
        return Envelop.getSuccessList(WlyyContants.Agreement.message_success_find_functions,wlyyAgreement);
    }
}

+ 126 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/WlyyAgreementKpiController.java

@ -0,0 +1,126 @@
package com.yihu.jw.wlyy.controller;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.entity.WlyyAgreementKpi;
import com.yihu.jw.wlyy.service.WlyyAgreementKpiService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.AgreementKpi.api_common)
@Api(value = "套餐指标相关操作", description = "套餐指标相关操作")
public class WlyyAgreementKpiController extends EnvelopRestController {
    @Autowired
    private WlyyAgreementKpiService wlyyAgreementKpiService;
    @PostMapping(value = WlyyContants.AgreementKpi.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建套餐指标", notes = "创建套餐指标")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreementKpi wlyyAgreementKpi = toEntity(jsonData, WlyyAgreementKpi.class);
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_create, wlyyAgreementKpiService.create(wlyyAgreementKpi));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WlyyContants.AgreementKpi.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改套餐指标", notes = "修改套餐指标")
    public Envelop update(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreementKpi wlyyAgreementKpi = toEntity(jsonData, WlyyAgreementKpi.class);
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_update, wlyyAgreementKpiService.update(wlyyAgreementKpi));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value =WlyyContants.AgreementKpi.api_delete)
    @ApiOperation(value = "删除套餐指标", notes = "删除套餐指标")
    public Envelop delete(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wlyyAgreementKpiService.delete(code);
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.AgreementKpi.api_getByCode)
    @ApiOperation(value = "根据code查找套餐指标", notes = "根据code查找套餐指标")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.AgreementKpi.message_success_find, wlyyAgreementKpiService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.AgreementKpi.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取套餐指标")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<WlyyAgreementKpi> list = wlyyAgreementKpiService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wlyyAgreementKpiService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WlyyAgreementKpi> wlyyAgreementKpi = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpi.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.AgreementKpi.message_success_find_functions,wlyyAgreementKpi, page, size,count);
    }
    @GetMapping(value =WlyyContants.AgreementKpi.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WlyyAgreementKpi> list = wlyyAgreementKpiService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyyAgreementKpi> wlyyAgreementKpi = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpi.class, fields);
        return Envelop.getSuccessList(WlyyContants.AgreementKpi.message_success_find_functions,wlyyAgreementKpi);
    }
}

+ 99 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/controller/WlyyAgreementKpiLogController.java

@ -0,0 +1,99 @@
package com.yihu.jw.wlyy.controller;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.entity.WlyyAgreementKpiLog;
import com.yihu.jw.wlyy.service.WlyyAgreementKpiLogService;
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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(WlyyContants.AgreementKpiLog.api_common)
@Api(value = "套餐指标相关操作", description = "套餐指标相关操作")
public class WlyyAgreementKpiLogController extends EnvelopRestController {
    @Autowired
    private WlyyAgreementKpiLogService wlyyAgreementKpiLogService;
    @PostMapping(value = WlyyContants.AgreementKpiLog.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建套餐指标", notes = "创建套餐指标")
    public Envelop create(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WlyyAgreementKpiLog wlyyAgreementKpiLog = toEntity(jsonData, WlyyAgreementKpiLog.class);
            return Envelop.getSuccess(WlyyContants.AgreementKpiLog.message_success_create, wlyyAgreementKpiLogService.create(wlyyAgreementKpiLog));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value =WlyyContants.AgreementKpiLog.api_getByCode)
    @ApiOperation(value = "根据code查找套餐指标", notes = "根据code查找套餐指标")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(WlyyContants.AgreementKpiLog.message_success_find, wlyyAgreementKpiLogService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value =WlyyContants.AgreementKpiLog.api_queryPage, method = RequestMethod.GET)
    @ApiOperation(value = "分页获取套餐指标")
    public Envelop queryPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        //得到list数据
        List<WlyyAgreementKpiLog> list = wlyyAgreementKpiLogService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wlyyAgreementKpiLogService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<WlyyAgreementKpiLog> wlyyAgreementKpiLog = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpiLog.class, fields);
        return Envelop.getSuccessListWithPage(WlyyContants.AgreementKpiLog.message_success_find_functions,wlyyAgreementKpiLog, page, size,count);
    }
    @GetMapping(value =WlyyContants.AgreementKpiLog.api_getList)
    @ApiOperation(value = "获取协议列表(不分页)")
    public Envelop getList(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        //得到list数据
        List<WlyyAgreementKpiLog> list = wlyyAgreementKpiLogService.search(fields,filters,sorts);
        //封装返回格式
        List<WlyyAgreementKpiLog> wlyyAgreementKpiLog = convertToModels(list, new ArrayList<>(list.size()), WlyyAgreementKpiLog.class, fields);
        return Envelop.getSuccessList(WlyyContants.AgreementKpiLog.message_success_find_functions,wlyyAgreementKpiLog);
    }
}

+ 21 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/WlyyAgreementDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.wlyy.dao;
import com.yihu.jw.wlyy.entity.WlyyAgreement;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
public interface WlyyAgreementDao extends PagingAndSortingRepository<WlyyAgreement, Long>, JpaSpecificationExecutor<WlyyAgreement> {
    @Query("from WlyyAgreement w where w.code =?1 and w.status!=-1")
    WlyyAgreement findByCode(String code);
    @Query("from WlyyAgreement w where w.id=?1 and w.status !=-1")
    WlyyAgreement findById(Long id);
    @Query("from WlyyAgreement w where w.id!=?2 and w.code = ?1 and w.status !=-1")
    WlyyAgreement findCodeExcludeId(String code, Long id);
}

+ 22 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/WlyyAgreementKpiDao.java

@ -0,0 +1,22 @@
package com.yihu.jw.wlyy.dao;
import com.yihu.jw.wlyy.entity.WlyyAgreement;
import com.yihu.jw.wlyy.entity.WlyyAgreementKpi;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
public interface WlyyAgreementKpiDao extends PagingAndSortingRepository<WlyyAgreementKpi, Long>, JpaSpecificationExecutor<WlyyAgreementKpi> {
    @Query("from WlyyAgreementKpi w where w.code =?1 and w.status!=-1")
    WlyyAgreementKpi findByCode(String code);
    @Query("from WlyyAgreementKpi w where w.id=?1 and w.status !=-1")
    WlyyAgreementKpi findById(Long id);
    @Query("from WlyyAgreementKpi w where w.id!=?2 and w.code = ?1 and w.status !=-1")
    WlyyAgreementKpi findCodeExcludeId(String code, Long id);
}

+ 15 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/dao/WlyyAgreementKpiLogDao.java

@ -0,0 +1,15 @@
package com.yihu.jw.wlyy.dao;
import com.yihu.jw.wlyy.entity.WlyyAgreementKpiLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
public interface WlyyAgreementKpiLogDao  extends PagingAndSortingRepository<WlyyAgreementKpiLog, Long>, JpaSpecificationExecutor<WlyyAgreementKpiLog> {
    @Query("from WlyyAgreementKpiLog w where w.code =?1")
    WlyyAgreementKpiLog findByCode(String code);
}

+ 157 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/WlyyAgreement.java

@ -0,0 +1,157 @@
package com.yihu.jw.wlyy.entity;
import com.yihu.jw.wlyy.entity.base.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
@Entity
@Table(name = "wlyy_agreement")
public class WlyyAgreement extends IdEntity implements Serializable{
    private static final long serialVersionUID = -4343130835307199266L;
    private String code;//业务code
    private String parentCode;//
    private String saasId;
    private String name;//套餐名称
    private BigDecimal price;//套餐价格
    private String posterPic;//海报图
    private String remark;//描述
    private String type;//类型
    private Timestamp createTime;
    private Timestamp updateTime;
    private String status;//状态
    private String createUser;
    public WlyyAgreement(String code, String parentCode, String saasId, String name, BigDecimal price, String posterPic, String remark, String type, Timestamp createTime, Timestamp updateTime, String status, String createUser) {
        this.code = code;
        this.parentCode = parentCode;
        this.saasId = saasId;
        this.name = name;
        this.price = price;
        this.posterPic = posterPic;
        this.remark = remark;
        this.type = type;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.status = status;
        this.createUser = createUser;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "parent_code")
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    @Column(name = "saas_id")
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "price")
    public BigDecimal getPrice() {
        return price;
    }
    public void setPrice(BigDecimal price) {
        this.price = price;
    }
    @Column(name = "poster_pic")
    public String getPosterPic() {
        return posterPic;
    }
    public void setPosterPic(String posterPic) {
        this.posterPic = posterPic;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }
    @Column(name = "update_time")
    public Timestamp getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
}

+ 136 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/WlyyAgreementKpi.java

@ -0,0 +1,136 @@
package com.yihu.jw.wlyy.entity;
import com.yihu.jw.wlyy.entity.base.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
@Entity
@Table(name = "wlyy_agreement_kpi")
public class WlyyAgreementKpi extends IdEntity {
    private String code;//业务code
    private String agreementCode;//套餐代码
    private String kpiName;//服务项名称
    private String type;//服务项类型
    private String kpiTimes;//服务次数
    private Integer status;//状态
    private Integer del;//删除状态
    private String kpiContent;//服务内容描述
    private String keyword;//关键字
    private Timestamp createTime;
    private String createUser;
    private Timestamp updaateTime;
    public String getAgreementCode() {
        return agreementCode;
    }
    public void setAgreementCode(String agreementCode) {
        this.agreementCode = agreementCode;
    }
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "kpi_name")
    public String getKpiName() {
        return kpiName;
    }
    public void setKpiName(String kpiName) {
        this.kpiName = kpiName;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "kpi_times")
    public String getKpiTimes() {
        return kpiTimes;
    }
    public void setKpiTimes(String kpiTimes) {
        this.kpiTimes = kpiTimes;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "del")
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "kpi_content")
    public String getKpiContent() {
        return kpiContent;
    }
    public void setKpiContent(String kpiContent) {
        this.kpiContent = kpiContent;
    }
    @Column(name = "keyword")
    public String getKeyword() {
        return keyword;
    }
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "updaate_time")
    public Timestamp getUpdaateTime() {
        return updaateTime;
    }
    public void setUpdaateTime(Timestamp updaateTime) {
        this.updaateTime = updaateTime;
    }
}

+ 99 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/WlyyAgreementKpiLog.java

@ -0,0 +1,99 @@
package com.yihu.jw.wlyy.entity;
import com.yihu.jw.wlyy.entity.base.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Timestamp;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
@Entity
@Table(name = "wlyy_agreement_kpi_log")
public class WlyyAgreementKpiLog extends IdEntity {
    private String code;//业务code
    private String patientCode;//患者code
    private String signCode;
    private String kpiCode;
    private String agreementCode;//套餐代码
    private String kpiName;//服务项名称
    private Timestamp createTime;
    private String createUser;
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "patient_code")
    public String getPatientCode() {
        return patientCode;
    }
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    @Column(name = "sign_code")
    public String getSignCode() {
        return signCode;
    }
    public void setSignCode(String signCode) {
        this.signCode = signCode;
    }
    @Column(name = "kpi_code")
    public String getKpiCode() {
        return kpiCode;
    }
    public void setKpiCode(String kpiCode) {
        this.kpiCode = kpiCode;
    }
    @Column(name = "agreement_code")
    public String getAgreementCode() {
        return agreementCode;
    }
    public void setAgreementCode(String agreementCode) {
        this.agreementCode = agreementCode;
    }
    @Column(name = "kpi_name")
    public String getKpiName() {
        return kpiName;
    }
    public void setKpiName(String kpiName) {
        this.kpiName = kpiName;
    }
    @Column(name = "create_time")
    public Timestamp getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
}

+ 38 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/entity/base/IdEntity.java

@ -0,0 +1,38 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.wlyy.entity.base;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
/**
 * 统一定义id的entity基类.
 * 
 * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
 * Oracle需要每个Entity独立定义id的SEQUCENCE时,不继承于本类而改为实现一个Idable的接口。
 * 
 * @author calvin
 */
// JPA 基类的标识
@MappedSuperclass
public abstract class IdEntity implements Serializable {
	private static final long serialVersionUID = 3673803562328635206L;
	protected Long id;  // 非业务主键
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
}

+ 51 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/WlyyAgreementKpiLogService.java

@ -0,0 +1,51 @@
package com.yihu.jw.wlyy.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.wlyy.WlyyContants;
import com.yihu.jw.wlyy.dao.WlyyAgreementKpiLogDao;
import com.yihu.jw.wlyy.entity.WlyyAgreementKpiLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
@Service
public class WlyyAgreementKpiLogService extends BaseJpaService<WlyyAgreementKpiLog, WlyyAgreementKpiLogDao> {
    @Autowired
    private WlyyAgreementKpiLogDao wlyyAgreementKpiLogDao;
    @Transient
    public WlyyAgreementKpiLog create(WlyyAgreementKpiLog wlyyAgreementKpiLog) {
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getPatientCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_patientCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getSignCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_signCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getKpiCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getAgreementCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        return wlyyAgreementKpiLogDao.save(wlyyAgreementKpiLog);
    }
    public WlyyAgreementKpiLog findByCode(String code) {
        return wlyyAgreementKpiLogDao.findByCode(code);
    }
}

+ 84 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/WlyyAgreementKpiService.java

@ -0,0 +1,84 @@
package com.yihu.jw.wlyy.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.wlyy.WlyyContants;
import com.yihu.jw.wlyy.dao.WlyyAgreementKpiDao;
import com.yihu.jw.wlyy.entity.WlyyAgreementKpi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
@Service
public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, WlyyAgreementKpiDao> {
    @Autowired
    private WlyyAgreementKpiDao wlyyAgreementKpiDao;
    @Transient
    public WlyyAgreementKpi create(WlyyAgreementKpi wlyyAgreementKpi) {
        if (StringUtils.isEmpty(wlyyAgreementKpi.getCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getType())){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getStatus())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        return wlyyAgreementKpiDao.save(wlyyAgreementKpi);
    }
    @Transient
    public WlyyAgreementKpi update(WlyyAgreementKpi wlyyAgreementKpi) {
        String code = wlyyAgreementKpi.getCode();
        if (StringUtils.isEmpty(code)) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getType())){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getStatus())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        Long id = wlyyAgreementKpi.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WlyyContants.Agreement.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreementKpi wlyyAgreementKpi1 = wlyyAgreementKpiDao.findById(id);
        if(wlyyAgreementKpi1==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        wlyyAgreementKpi1 = wlyyAgreementKpiDao.findCodeExcludeId(code,id);
        if(wlyyAgreementKpi1 !=null){
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
        }
        return wlyyAgreementKpiDao.save(wlyyAgreementKpi);
    }
    public WlyyAgreementKpi findByCode(String code) {
        return wlyyAgreementKpiDao.findByCode(code);
    }
    @Transient
    public void delete(String code) {
        WlyyAgreementKpi wlyyAgreementKpi = findByCode(code);
        if(wlyyAgreementKpi==null){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_wlyyAgreementKpi_is_no_exist, CommonContants.common_error_params_code);
        }
        wlyyAgreementKpi.setStatus(-1);
        wlyyAgreementKpiDao.save(wlyyAgreementKpi);
    }
}

+ 85 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/service/WlyyAgreementService.java

@ -0,0 +1,85 @@
package com.yihu.jw.wlyy.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.wlyy.WlyyContants;
import com.yihu.jw.wlyy.dao.WlyyAgreementDao;
import com.yihu.jw.wlyy.entity.WlyyAgreement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
/**
 * Created by Administrator on 2017/6/1 0001.
 */
@Service
public class WlyyAgreementService extends BaseJpaService<WlyyAgreement, WlyyAgreementDao> {
    @Autowired
    private WlyyAgreementDao wlyyAgreementDao;
    @Transient
    public WlyyAgreement create(WlyyAgreement wlyyAgreement) {
        if (StringUtils.isEmpty(wlyyAgreement.getCode())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getName())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getPrice())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_price_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getStatus())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        return wlyyAgreementDao.save(wlyyAgreement);
    }
    @Transient
    public WlyyAgreement update(WlyyAgreement wlyyAgreement) {
        String code = wlyyAgreement.getCode();
        if (StringUtils.isEmpty(code)) {
            throw new ApiException(WlyyContants.Agreement.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getName())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getPrice())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_price_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreement.getStatus())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        Long id = wlyyAgreement.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WlyyContants.Agreement.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreement wlyyAgreement1 = wlyyAgreementDao.findById(id);
        if(wlyyAgreement1==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
         wlyyAgreement1 = wlyyAgreementDao.findCodeExcludeId(code,id);
        if(wlyyAgreement1 !=null){
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
        }
        return wlyyAgreementDao.save(wlyyAgreement);
    }
    public WlyyAgreement findByCode(String code) {
        WlyyAgreement wlyyAgreement = wlyyAgreementDao.findByCode(code);
        return wlyyAgreement;
    }
    @Transient
    public void delete(String code) {
        WlyyAgreement wlyyAgreement = findByCode(code);
        if(wlyyAgreement==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        wlyyAgreement.setStatus("-1");
        wlyyAgreementDao.save(wlyyAgreement);
    }
}

+ 45 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatAccessTokenController.java

@ -0,0 +1,45 @@
package com.yihu.jw.controller.base.wx;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.fegin.base.wx.AccessTokenFegin;
import com.yihu.jw.restmodel.common.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
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 Administrator on 2017/5/31 0031.
 */
@RestController
@RequestMapping(WechatContants.AccessToken.api_common)
@Api(description = "微信token相关")
public class WechatAccessTokenController {
    private Logger logger= LoggerFactory.getLogger(WechatAccessTokenController.class);
    @Autowired
    private AccessTokenFegin accessTokenFegin;
    @Autowired
    private Tracer tracer;
    @GetMapping(value = WechatContants.AccessToken.api_get)
    @ApiOperation(value = "根据wechatCode获取最新的WxAccessToken")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getWxAccessToken(
            @ApiParam(name = "wechatCode", value = "wechatCode")
            @RequestParam(value = "wechatCode") String wechatCode) {
        return accessTokenFegin.getWxAccessToken(wechatCode);
    }
}

+ 61 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatContants.java

@ -0,0 +1,61 @@
package com.yihu.jw.controller.base.wx;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class WechatContants {
    //微信token模块常量
    public static class AccessToken{
        public static final String message_success_get="wxAccessToken get success";
        public static final String api_common="accessToken";
        public static final String api_create="create";
        public static final String api_get="get";
    }
    //微信按钮模块常量
    public static class Menu{
        public static final String api_common="menu";
        public static final String api_create="create";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_getWxMenus="getWxMenus";
        public static final String api_getWxMenuNoPage="getWxMenuNoPage";
        public static final String api_createMenu="createMenu";
    }
    //微信模板消息
    public static class Template {
        public static final String api_common="template";
        public static final String api_create="create";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_getWxTemplates="getWxTemplates";
        public static final String api_getWxTemplatesNoPage="getWxTemplatesNoPage";
        public static final String api_sendTemplateMessage="sendTemplateMessage";
    }
    //微信配置表
    public static class Config {
        public static final String api_common="wechatConfig";
        public static final String api_create="create";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWechatNoPage="getWechatNoPage";
        public static final String api_getWechats="getWechats";
        public static final String api_getByCode="getByCode";
    }
    //微信图文消息
    public static class GraphicMessage {
        public static final String api_common="graphicMessage";
        public static final String api_create="create";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWxGraphicMessageNoPage="getWxGraphicMessageNoPage";
        public static final String api_sendGraphicMessages="sendGraphicMessages";
        public static final String api_getWxGraphicMessages="getWxGraphicMessages";
        public static final String api_getByCode="getByCode";
    }
}

+ 20 - 8
web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatController.java

@ -4,7 +4,6 @@ import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.fegin.base.wx.WechatFegin;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.wx.WxContants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -19,8 +18,10 @@ import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping(WechatContants.Config.api_common)
@Api(description = "微信配置")
public class WechatController{
    private Logger logger= LoggerFactory.getLogger(WechatController.class);
    @Autowired
    private WechatFegin wechatFegin;
@ -29,7 +30,7 @@ public class WechatController{
    private Tracer tracer;
    @ApiOperation(value = "创建微信配置")
    @PostMapping(value = "/"+WxContants.Wechat.api_common+"/"+WxContants.Wechat.api_create)
    @PostMapping(value = WechatContants.Config.api_create)
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
@ -42,7 +43,7 @@ public class WechatController{
    }
    @ApiOperation(value = "更新微信配置")
    @PutMapping(value = "/"+WxContants.Wechat.api_common+"/"+WxContants.Wechat.api_update)
    @PutMapping(value = WechatContants.Config.api_update)
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
@ -53,8 +54,11 @@ public class WechatController{
        return wechat;
    }
    @DeleteMapping(value = "/"+WxContants.Wechat.api_common+"/"+WxContants.Wechat.api_delete)
    @DeleteMapping(value = WechatContants.Config.api_delete)
    @ApiOperation(value = "删除微信配置", notes = "删除微信配置")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop deleteWechat(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
@ -62,8 +66,11 @@ public class WechatController{
        return wechat;
    }
    @GetMapping(value = "/"+WxContants.Wechat.api_common+"/"+WxContants.Wechat.api_getByCode)
    @GetMapping(value = WechatContants.Config.api_getByCode)
    @ApiOperation(value = "根据code查找微信配置", notes = "根据code查找微信配置")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
@ -71,8 +78,11 @@ public class WechatController{
       return wechatFegin.findByCode(code);
    }
    @RequestMapping(value = "/"+WxContants.Wechat.api_common+"/"+WxContants.Wechat.api_getWechats, method = RequestMethod.GET)
    @RequestMapping(value = WechatContants.Config.api_getWechats, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信配置列表(分页)")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getWechats(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
@ -90,9 +100,11 @@ public class WechatController{
        return envelop;
    }
    @GetMapping(value = "/"+WxContants.Wechat.api_common+"/"+WxContants.Wechat.api_getWechatNoPage)
    @GetMapping(value = WechatContants.Config.api_getWechatNoPage)
    @ApiOperation(value = "获取微信列表配置,不分页")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getWechatNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,

+ 129 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatGraphicMessageController.java

@ -0,0 +1,129 @@
package com.yihu.jw.controller.base.wx;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.fegin.base.wx.GraphicMessageFegin;
import com.yihu.jw.restmodel.common.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@RestController
@RequestMapping(WechatContants.GraphicMessage.api_common)
@Api(description = "微信图文相关")
public class WechatGraphicMessageController {
    private Logger logger= LoggerFactory.getLogger(WechatGraphicMessageController.class);
    @Autowired
    private GraphicMessageFegin graphicMessageFegin;
    @Autowired
    private Tracer tracer;
    @PostMapping(value = WechatContants.GraphicMessage.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信图文消息", notes = "创建微信图文消息")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop createWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return graphicMessageFegin.createWxGraphicMessage(jsonData);
    }
    @PutMapping(value = WechatContants.GraphicMessage.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信图文消息", notes = "修改微信图文消息")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop updateWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return graphicMessageFegin.updateWxGraphicMessage(jsonData);
    }
    @DeleteMapping(value = WechatContants.GraphicMessage.api_delete)
    @ApiOperation(value = "删除微信图文消息", notes = "删除微信图文消息")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop deleteWxGraphicMessage(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        return graphicMessageFegin.deleteWxGraphicMessage(code);
    }
    @GetMapping(value = WechatContants.GraphicMessage.api_getByCode)
    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        return graphicMessageFegin.findByCode(code);
    }
    //@RequestMapping(value = WechatContants.GraphicMessage.api_getWxGraphicMessages, method = RequestMethod.GET)
    //@ApiOperation(value = "获取微信图文消息列表(分页)")
    //public Envelop getWxGraphicMessages(
    //        @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
    //        @RequestParam(value = "fields", required = false) String fields,
    //        @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
    //        @RequestParam(value = "filters", required = false) String filters,
    //        @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
    //        @RequestParam(value = "sorts", required = false) String sorts,
    //        @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
    //        @RequestParam(value = "size", required = false) int size,
    //        @ApiParam(name = "page", value = "页码", defaultValue = "1")
    //        @RequestParam(value = "page", required = false) int page,
    //        HttpServletRequest request,
    //        HttpServletResponse response) throws Exception {
    //    return graphicMessageFegin.getWxGraphicMessages(fields,filters,sorts,size,page,request,response);
    //}
    @GetMapping(value = WechatContants.GraphicMessage.api_getWxGraphicMessageNoPage)
    @ApiOperation(value = "获取图文消息列表,不分页")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getWxGraphicMessageNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,description,url,pic_url,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        return graphicMessageFegin.getWxGraphicMessageNoPage(fields,filters,sorts);
    }
    @GetMapping(value = WechatContants.GraphicMessage.api_sendGraphicMessages)
    @ApiOperation(value = "发送图文消息")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @ResponseBody
    public String sendGraphicMessages(
            @ApiParam(name = "codes", value = "根据code发送微信图文消息,多个code用,分割")
            @RequestParam(value = "codes", required = true) String codes,
            @ApiParam(name = "fromUserName", value = "用户openid")
            @RequestParam(value = "fromUserName", required = true) String fromUserName,
            @ApiParam(name = "toUserName", value = "公众号")
            @RequestParam(value = "toUserName", required = true) String toUserName
    ) throws Exception {
        return graphicMessageFegin.sendGraphicMessages(codes,fromUserName,toUserName);
    }
}

+ 128 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatMenuController.java

@ -0,0 +1,128 @@
package com.yihu.jw.controller.base.wx;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.fegin.base.wx.WechatMenuFegin;
import com.yihu.jw.restmodel.common.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@RestController
@RequestMapping(WechatContants.Menu.api_common)
@Api(description = "微信菜单配置")
public class WechatMenuController {
    private Logger logger= LoggerFactory.getLogger(WechatMenuController.class);
    @Autowired
    private WechatMenuFegin wechatMenuFegin;
    @Autowired
    private Tracer tracer;
    @PostMapping(value = WechatContants.Menu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "添加微信菜单", notes = "添加微信菜单")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop createWxMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return wechatMenuFegin.createWxMenu(jsonData);
    }
    @PutMapping(value = WechatContants.Menu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信菜单", notes = "修改微信菜单")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop updateWxMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return wechatMenuFegin.updateWxMenu(jsonData);
    }
    @DeleteMapping(value = WechatContants.Menu.api_delete)
    @ApiOperation(value = "删除微信菜单", notes = "删除微信菜单")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop deleteWxMenu(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        return wechatMenuFegin.deleteWxMenu(code);
    }
    @GetMapping(value = WechatContants.Menu.api_getByCode)
    @ApiOperation(value = "根据code查找微信菜单", notes = "根据code查找微信菜单")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        return wechatMenuFegin.findByCode(code);
    }
    //@RequestMapping(value = WechatContants.Menu.api_getWxMenus, method = RequestMethod.GET)
    //@ApiOperation(value = "获取微信菜单列表(分页)")
    //public Envelop getWxMenus(
    //        @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
    //        @RequestParam(value = "fields", required = false) String fields,
    //        @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
    //        @RequestParam(value = "filters", required = false) String filters,
    //        @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
    //        @RequestParam(value = "sorts", required = false) String sorts,
    //        @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
    //        @RequestParam(value = "size", required = false) int size,
    //        @ApiParam(name = "page", value = "页码", defaultValue = "1")
    //        @RequestParam(value = "page", required = false) int page,
    //        HttpServletRequest request,
    //        HttpServletResponse response) throws Exception {
    //    return wechatMenuFegin.getWxMenus(fields,filters,sorts,size,page,request,response);
    //}
    @GetMapping(value = WechatContants.Menu.api_getWxMenuNoPage)
    @ApiOperation(value = "获取微信菜单列表,不分页")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getWxMenuNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,name,saasId,appId,appSecret,baseUrl,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        return wechatMenuFegin.getWxMenuNoPage(fields,filters,sorts);
    }
    /**
     * 创建微信公众号菜单
     *
     * @return
     */
    @ApiOperation(value = "创建微信公众号菜单", notes = "创建微信公众号菜单")
    @RequestMapping(value = WechatContants.Menu.api_createMenu ,method = RequestMethod.GET)
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop createWechatMenu(
            @ApiParam(name = "wechatCode", value = "", defaultValue = "")
            @RequestParam(value = "wechatCode", required = true)String wechatCode){
        return wechatMenuFegin.createWechatMenu(wechatCode);
    }
}

+ 135 - 0
web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatTemplateControlle.java

@ -0,0 +1,135 @@
package com.yihu.jw.controller.base.wx;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.fegin.base.wx.WechatTemplateFegin;
import com.yihu.jw.restmodel.common.Envelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@RestController
@RequestMapping(WechatContants.Template.api_common)
@Api(description = "微信模板消息相关")
public class WechatTemplateControlle {
    private Logger logger= LoggerFactory.getLogger(WechatTemplateControlle.class);
    @Autowired
    private WechatTemplateFegin wechatTemplateFegin;
    @Autowired
    private Tracer tracer;
    @PostMapping(value = WechatContants.Template.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信模版", notes = "创建微信模版")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop createWxTemplate(
            @ApiParam(name = "json_data", value = "微信模版json字符串")
            @RequestBody String jsonData) {
        return wechatTemplateFegin.createWxTemplate(jsonData);
    }
    @PutMapping(value = WechatContants.Template.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信模版", notes = "修改微信模版")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop updateWxTemplate(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return wechatTemplateFegin.updateWxTemplate(jsonData);
    }
    @DeleteMapping(value = WechatContants.Template.api_delete)
    @ApiOperation(value = "删除微信模版", notes = "删除微信模版")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop deleteWxTemplate(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        return wechatTemplateFegin.deleteWxTemplate(code);
    }
    @GetMapping(value = WechatContants.Template.api_getByCode)
    @ApiOperation(value = "根据code查找微信模版", notes = "根据code查找微信模版")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        return wechatTemplateFegin.findByCode(code);
    }
    //@RequestMapping(value = WechatContants.Template.api_getWxTemplates, method = RequestMethod.GET)
    //@ApiOperation(value = "获取微信模版列表(分页)")
    //public Envelop getWechats(
    //        @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
    //        @RequestParam(value = "fields", required = false) String fields,
    //        @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
    //        @RequestParam(value = "filters", required = false) String filters,
    //        @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
    //        @RequestParam(value = "sorts", required = false) String sorts,
    //        @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
    //        @RequestParam(value = "size", required = false) int size,
    //        @ApiParam(name = "page", value = "页码", defaultValue = "1")
    //        @RequestParam(value = "page", required = false) int page,
    //        HttpServletRequest request,
    //        HttpServletResponse response) throws Exception {
    //    return wechatTemplateFegin.getWechats(fields,filters,sorts,size,page,request,response);
    //}
    @GetMapping(value = WechatContants.Template.api_getWxTemplatesNoPage)
    @ApiOperation(value = "获取微信模版列表(不分页)")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop getWechatNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "id,code,title,wechatCode,templateId,content,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+title,+createTime")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        return wechatTemplateFegin.getWechatNoPage(fields,filters,sorts);
    }
    @GetMapping(value = WechatContants.Template.api_sendTemplateMessage)
    @ApiOperation(value = "发送微信模板消息")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    @ResponseBody
    public Envelop sendTemplateMessage(
            @ApiParam(name="openid",value="微信用户的openid")
            @RequestParam String openid,
            @ApiParam(name="templateCode",value = "模板code")
            @RequestParam String templateCode,
            @ApiParam(name="url",value="模板跳转链接")
            @RequestParam(required = false) String url,
            @ApiParam(name="appid",value="所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系)")
            @RequestParam(required = false) String appid,
            @ApiParam(name="pagepath",value="所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar)")
            @RequestParam(required = false) String pagepath,
            @ApiParam(name="data",value="json字符串")
            @RequestParam String data
    ){
        return wechatTemplateFegin.sendTemplateMessage(openid,templateCode,url,appid,pagepath,data);
    }
}

+ 25 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/AccessTokenFegin.java

@ -0,0 +1,25 @@
package com.yihu.jw.fegin.base.wx;
import com.yihu.jw.fegin.fallbackfactory.base.wx.AccessTokenFeginFallbackFactory;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = AccessTokenFeginFallbackFactory.class
)
@RequestMapping(value = WxContants.WxAccessToken.api_common)
public interface AccessTokenFegin {
    @RequestMapping(value = WxContants.WxAccessToken.api_get, method = RequestMethod.GET)
    Envelop getWxAccessToken(@RequestParam(value = "wechatCode") String wechatCode) ;
}

+ 57 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/GraphicMessageFegin.java

@ -0,0 +1,57 @@
package com.yihu.jw.fegin.base.wx;
import com.yihu.jw.fegin.fallbackfactory.base.wx.GraphicMessageFeginFallbackFactory;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  = GraphicMessageFeginFallbackFactory.class
)
@RequestMapping(value = WxContants.WxGraphicMessage.api_common)
public interface GraphicMessageFegin {
    @RequestMapping(value = WxContants.WxGraphicMessage.api_create, method = RequestMethod.POST)
    Envelop createWxGraphicMessage( @RequestBody String jsonData);
    @RequestMapping(value = WxContants.WxGraphicMessage.api_update,method = RequestMethod.PUT)
    Envelop updateWxGraphicMessage( @RequestBody String jsonData);
    @RequestMapping(value = WxContants.WxGraphicMessage.api_delete,method = RequestMethod.DELETE)
    Envelop deleteWxGraphicMessage(String code);
    @RequestMapping(value = WxContants.WxGraphicMessage.api_getByCode,method = RequestMethod.GET)
    Envelop findByCode(String code);
    //@RequestMapping(value = WlyyContants.WxGraphicMessage.api_getWxGraphicMessages,method = RequestMethod.GET)
    //Envelop getWxGraphicMessages(
    //        @RequestParam(value = "fields", required = false) String fields,
    //        @RequestParam(value = "filters", required = false) String filters,
    //        @RequestParam(value = "sorts", required = false) String sorts,
    //        @RequestParam(value = "size", required = false) int size,
    //        @RequestParam(value = "page", required = false) int page,
    //        HttpServletRequest request,
    //        HttpServletResponse response);
    @RequestMapping(value = WxContants.WxGraphicMessage.api_getWxGraphicMessageNoPage,method = RequestMethod.GET)
    Envelop getWxGraphicMessageNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts);
    @RequestMapping(value = WxContants.WxGraphicMessage.api_sendGraphicMessages,method = RequestMethod.GET)
    String sendGraphicMessages(
            @RequestParam(value = "codes", required = true) String codes,
            @RequestParam(value = "fromUserName", required = true) String fromUserName,
            @RequestParam(value = "toUserName", required = true) String toUserName
    );
}

+ 5 - 4
web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/WechatFegin.java

@ -8,6 +8,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(
@ -24,14 +25,14 @@ public interface WechatFegin {
    Envelop updateWechat(String jsonData);
    @RequestMapping(value = WxContants.Wechat.api_delete,method = RequestMethod.DELETE)
    Envelop deleteWechat(String code);
    Envelop deleteWechat(@RequestParam(value = "code") String code);
    @RequestMapping(value = WxContants.Wechat.api_getByCode,method = RequestMethod.GET)
    Envelop findByCode(String code);
    Envelop findByCode(@RequestParam(value = "code") String code);
    @RequestMapping(value = WxContants.Wechat.api_getWechats ,method = RequestMethod.GET)
    Envelop getWechats(String fields, String filters, String sorts, int page, int size);
    Envelop getWechats(@RequestParam(value = "fields")String fields, @RequestParam(value = "filters") String filters, @RequestParam(value = "sorts")String sorts, @RequestParam(value = "page")int page,@RequestParam(value = "size") int size);
    @RequestMapping(value = WxContants.Wechat.api_getWechatNoPage,method = RequestMethod.GET )
    Envelop getWechatNoPage(String fields, String filters, String sorts);
    Envelop getWechatNoPage(@RequestParam(value = "code")String fields,@RequestParam(value = "code") String filters,@RequestParam(value = "code") String sorts);
}

+ 53 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/WechatMenuFegin.java

@ -0,0 +1,53 @@
package com.yihu.jw.fegin.base.wx;
import com.yihu.jw.fegin.fallbackfactory.base.wx.WechatMenuFeginFallbackFactory;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  =WechatMenuFeginFallbackFactory.class
)
@RequestMapping(value = WxContants.WxMenu.api_common)
public interface WechatMenuFegin {
    @RequestMapping(value = WxContants.WxMenu.api_create,method = RequestMethod.POST)
    Envelop createWxMenu( @RequestBody String jsonData) ;
    @RequestMapping(value = WxContants.WxMenu.api_update,method = RequestMethod.PUT)
    Envelop updateWxMenu( @RequestBody String jsonData);
    @RequestMapping(value = WxContants.WxMenu.api_delete,method = RequestMethod.DELETE)
    Envelop deleteWxMenu(@RequestParam(value="code")String code);
    @RequestMapping(value = WxContants.WxMenu.api_getByCode,method = RequestMethod.GET)
    Envelop findByCode(@RequestParam(value="code")String code);
    @RequestMapping(value = WxContants.WxMenu.api_getWxMenuNoPage,method = RequestMethod.GET)
    Envelop getWxMenuNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts);
    //@RequestMapping(value = WlyyContants.WxMenu.api_getWxMenus,method = RequestMethod.GET)
    //Envelop getWxMenus(
    //        @RequestParam(value = "fields", required = false) String fields,
    //        @RequestParam(value = "filters", required = false) String filters,
    //        @RequestParam(value = "sorts", required = false) String sorts,
    //        @RequestParam(value = "size", required = false) int size,
    //        @RequestParam(value = "page", required = false) int page,
    //        HttpServletRequest request,
    //        HttpServletResponse response);
    @RequestMapping(value = WxContants.WxMenu.api_createMenu ,method = RequestMethod.GET)
    Envelop createWechatMenu(@RequestParam(value = "wechatCode", required = true)String wechatCode);
}

+ 58 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/WechatTemplateFegin.java

@ -0,0 +1,58 @@
package com.yihu.jw.fegin.base.wx;
import com.yihu.jw.fegin.fallbackfactory.base.wx.WechatTemplateFeginFallbackFactory;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@FeignClient(
        name = CommonContants.svr_base // name值是eurika的实例名字
        ,fallbackFactory  =WechatTemplateFeginFallbackFactory.class
)
@RequestMapping(value = WxContants.WxTemplate.api_common)
public interface WechatTemplateFegin {
    @RequestMapping(value = WxContants.WxTemplate.api_create ,method = RequestMethod.POST)
    Envelop createWxTemplate(@RequestBody String jsonData);
    @RequestMapping(value = WxContants.WxTemplate.api_update ,method = RequestMethod.PUT)
    Envelop updateWxTemplate(@RequestBody String jsonData);
    @RequestMapping(value = WxContants.WxTemplate.api_delete ,method = RequestMethod.DELETE)
    Envelop deleteWxTemplate( @RequestParam(value = "code", required = true) String code);
    @RequestMapping(value = WxContants.WxTemplate.api_getByCode ,method = RequestMethod.GET)
    Envelop findByCode( @RequestParam(value = "code", required = true) String code);
    @RequestMapping(value = WxContants.WxTemplate.api_getWxTemplatesNoPage ,method = RequestMethod.GET)
    Envelop getWechatNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts);
    //@RequestMapping(value = WlyyContants.WxTemplate.api_getWxTemplates, method = RequestMethod.GET)
    //Envelop getWechats(
    //        @RequestParam(value = "fields", required = false) String fields,
    //        @RequestParam(value = "filters", required = false) String filters,
    //        @RequestParam(value = "sorts", required = false) String sorts,
    //        @RequestParam(value = "size", required = false) int size,
    //        @RequestParam(value = "page", required = false) int page,
    //        HttpServletRequest request,
    //        HttpServletResponse response);
    @RequestMapping(value = WxContants.WxTemplate.api_sendTemplateMessage ,method = RequestMethod.GET)
    @ResponseBody
    Envelop sendTemplateMessage(
            @RequestParam(value="openid") String openid,
            @RequestParam(value="templateCode") String templateCode,
            @RequestParam(value="url",required = false) String url,
            @RequestParam(value="appid",required = false) String appid,
            @RequestParam(value="pagepath",required = false) String pagepath,
            @RequestParam(value="data") String data
    );
}

+ 0 - 22
web-gateway/src/main/java/com/yihu/jw/fegin/fallback/base/wx/WechatFeginFallback.java

@ -1,22 +0,0 @@
package com.yihu.jw.fegin.fallback.base.wx;
import com.yihu.jw.fegin.PatientFegin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by chenweida on 2017/5/13.
 */
@Component
public class WechatFeginFallback implements PatientFegin {
    private Logger logger = LoggerFactory.getLogger(WechatFeginFallback.class);
    @Override
    public String findByCode( @RequestParam(value = "code", required = true) String code) {
        logger.info("进入断路器");
        return "断路器启动";
    }
}

+ 24 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/AccessTokenFeginFallbackFactory.java

@ -0,0 +1,24 @@
package com.yihu.jw.fegin.fallbackfactory.base.wx;
import com.yihu.jw.fegin.base.wx.AccessTokenFegin;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@Component
public class AccessTokenFeginFallbackFactory implements FallbackFactory< AccessTokenFegin> {
    @Override
    public AccessTokenFegin create(Throwable throwable) {
        return new AccessTokenFegin() {
            @Override
            public Envelop getWxAccessToken(@RequestParam(value = "wechatCode") String wechatCode) {
                return null;
            }
        };
    }
}

+ 54 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/GraphicMessageFeginFallbackFactory.java

@ -0,0 +1,54 @@
package com.yihu.jw.fegin.fallbackfactory.base.wx;
import com.yihu.jw.fegin.base.wx.GraphicMessageFegin;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@Component
public class GraphicMessageFeginFallbackFactory implements FallbackFactory<GraphicMessageFegin> {
    @Override
    public GraphicMessageFegin create(Throwable throwable) {
        return new GraphicMessageFegin() {
            @Override
            public Envelop createWxGraphicMessage(@RequestParam(value = "jsonData") String jsonData) {
                return null;
            }
            @Override
            public Envelop updateWxGraphicMessage(@RequestParam(value = "jsonData") String jsonData) {
                return null;
            }
            @Override
            public Envelop deleteWxGraphicMessage(String code) {
                return null;
            }
            @Override
            public Envelop findByCode(String code) {
                return null;
            }
            //@Override
            //public Envelop getWxGraphicMessages(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts, @RequestParam(value = "size", required = false) int size, @RequestParam(value = "page", required = false) int page, HttpServletRequest request, HttpServletResponse response) {
            //    return null;
            //}
            @Override
            public Envelop getWxGraphicMessageNoPage(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts) {
                return null;
            }
            @Override
            public String sendGraphicMessages(@RequestParam(value = "codes", required = true) String codes, @RequestParam(value = "fromUserName", required = true) String fromUserName, @RequestParam(value = "toUserName", required = true) String toUserName) {
                return null;
            }
        };
    }
}

+ 52 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/WechatMenuFeginFallbackFactory.java

@ -0,0 +1,52 @@
package com.yihu.jw.fegin.fallbackfactory.base.wx;
import com.yihu.jw.fegin.base.wx.WechatMenuFegin;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@Component
public class WechatMenuFeginFallbackFactory implements FallbackFactory<WechatMenuFegin> {
    @Override
    public WechatMenuFegin create(Throwable throwable) {
        return new WechatMenuFegin() {
            @Override
            public Envelop createWxMenu(String jsonData) {
                return null;
            }
            @Override
            public Envelop updateWxMenu(String jsonData) {
                return null;
            }
            @Override
            public Envelop deleteWxMenu(String code) {
                return null;
            }
            @Override
            public Envelop findByCode(String code) {
                return null;
            }
            @Override
            public Envelop getWxMenuNoPage(String fields, String filters, String sorts) {
                return null;
            }
            //@Override
            @Override
            public Envelop createWechatMenu(String wechatCode) {
                return null;
            }
            //public Envelop getWxMenus(String fields, String filters, String sorts, int size, int page, HttpServletRequest request, HttpServletResponse response) {
            //    return null;
            //}
        };
    }
}

+ 53 - 0
web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/WechatTemplateFeginFallbackFactory.java

@ -0,0 +1,53 @@
package com.yihu.jw.fegin.fallbackfactory.base.wx;
import com.yihu.jw.fegin.base.wx.WechatTemplateFegin;
import com.yihu.jw.restmodel.common.Envelop;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
/**
 * Created by Administrator on 2017/5/31 0031.
 */
@Component
public class WechatTemplateFeginFallbackFactory implements FallbackFactory<WechatTemplateFegin>{
    @Override
    public WechatTemplateFegin create(Throwable throwable) {
        return new WechatTemplateFegin() {
            @Override
            public Envelop createWxTemplate(String jsonData) {
                return null;
            }
            @Override
            public Envelop updateWxTemplate(String jsonData) {
                return null;
            }
            @Override
            public Envelop deleteWxTemplate(String code) {
                return null;
            }
            @Override
            public Envelop findByCode(String code) {
                return null;
            }
            @Override
            public Envelop sendTemplateMessage(String openid, String templateCode, String url, String appid, String pagepath, String data) {
                return null;
            }
            @Override
            public Envelop getWechatNoPage(String fields, String filters, String sorts) {
                return null;
            }
            //@Override
            //public Envelop getWechats(String fields, String filters, String sorts, int size, int page, HttpServletRequest request, HttpServletResponse response) {
            //    return null;
            //}
        };
    }
}