Browse Source

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

chenweida 8 years ago
parent
commit
cb0251eef1
100 changed files with 6667 additions and 606 deletions
  1. 2 1
      common-lib-parent-pom/pom.xml
  2. 1 0
      common/common-mysql/src/main/java/com/yihu/jw/mysql/query/BaseJpaService.java
  3. 1 9
      common/common-quartz/pom.xml
  4. 13 4
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/BaseContants.java
  5. 1 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/MFunction.java
  6. 1 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/MModule.java
  7. 56 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/BaseSmsContants.java
  8. 100 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/MSms.java
  9. 88 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/MSmsGateway.java
  10. 6 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/CommonContants.java
  11. 0 2
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java
  12. 116 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/agreement/WlyyAgreementContants.java
  13. 35 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/patient/WlyyPatientContants.java
  14. 135 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxGraphicMessage.java
  15. 173 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxMenu.java
  16. 135 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxTemplate.java
  17. 181 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxWechat.java
  18. 132 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/WxContants.java
  19. 43 2
      common/common-swagger/src/main/java/com/yihu/jw/config/SwaggerConfig.java
  20. 100 0
      manage-gateway/pom.xml
  21. 18 0
      manage-gateway/readme.MD
  22. 27 0
      manage-gateway/src/main/java/com/yihu/jw/manage/SvrManageAppliction.java
  23. 26 0
      manage-gateway/src/main/java/com/yihu/jw/manage/config/MvcConfig.java
  24. 57 0
      manage-gateway/src/main/resources/application.yml
  25. 8 0
      manage-gateway/src/main/resources/banner.txt
  26. 46 0
      manage-gateway/src/main/resources/bootstrap.yml
  27. 1 0
      readme.MD
  28. 11 0
      svr-configuration/src/main/resources/application.yml
  29. 2 1
      svr-configuration/src/main/resources/bootstrap.yml
  30. 77 2
      svr-lib-parent-pom/pom.xml
  31. 2 1
      svr/readme.MD
  32. 8 4
      svr/svr-base/pom.xml
  33. 14 0
      svr/svr-base/readme.MD
  34. 0 7
      svr/svr-base/src/main/java/com/yihu/jw/SvrBaseApplication.java
  35. 27 0
      svr/svr-base/src/main/java/com/yihu/jw/base/controller/FunctionController.java
  36. 29 0
      svr/svr-base/src/main/java/com/yihu/jw/base/controller/ModuleController.java
  37. 103 0
      svr/svr-base/src/main/java/com/yihu/jw/base/controller/sms/SmsController.java
  38. 128 0
      svr/svr-base/src/main/java/com/yihu/jw/base/controller/sms/SmsGatewayController.java
  39. 3 3
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/FunctionDao.java
  40. 3 3
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/ModuleDao.java
  41. 17 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/ModuleFunctionDao.java
  42. 3 3
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/SaasDao.java
  43. 17 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/SaasModuleDao.java
  44. 22 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/sms/SmsDao.java
  45. 21 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/sms/SmsGatewayDao.java
  46. 3 1
      svr/svr-base/src/main/java/com/yihu/jw/base/model/Function.java
  47. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/model/Module.java
  48. 148 0
      svr/svr-base/src/main/java/com/yihu/jw/base/model/sms/BaseSms.java
  49. 134 0
      svr/svr-base/src/main/java/com/yihu/jw/base/model/sms/BaseSmsGateway.java
  50. 32 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/FunctionService.java
  51. 33 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/ModuleService.java
  52. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/SaasService.java
  53. 72 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsGatewayService.java
  54. 29 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsService.java
  55. 0 10
      svr/svr-base/src/main/java/com/yihu/jw/user/service/PatientService.java
  56. 115 0
      svr/svr-base/src/main/java/com/yihu/jw/util/HttpUtil.java
  57. 109 0
      svr/svr-base/src/main/java/com/yihu/jw/util/MessageUtil.java
  58. 644 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/WechatResponse.java
  59. 120 5
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WechatController.java
  60. 47 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxAccessTokenController.java
  61. 155 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxGraphicMessageController.java
  62. 154 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxMenuController.java
  63. 166 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxTemplateController.java
  64. 26 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WechatDao.java
  65. 19 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxAccessTokenDao.java
  66. 25 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxGraphicMessageDao.java
  67. 46 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxMenuDao.java
  68. 19 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxTemplateDao.java
  69. 30 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/Miniprogram.java
  70. 58 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WechatTemplate.java
  71. 31 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WechatTemplateData.java
  72. 18 22
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxAccessToken.java
  73. 167 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxGraphicMessage.java
  74. 203 159
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxMenu.java
  75. 185 146
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxTemplate.java
  76. 212 216
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxWechat.java
  77. 119 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WechatService.java
  78. 90 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxAccessTokenService.java
  79. 189 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java
  80. 325 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java
  81. 164 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxTemplateService.java
  82. BIN
      svr/svr-quota/doc/统计架构.png
  83. 55 0
      svr/svr-quota/pom.xml
  84. 14 0
      svr/svr-quota/readme.MD
  85. 4 2
      svr/svr-quota/src/main/java/com/yihu/jw/SvrQuotaApplication.java
  86. 50 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/config/AsyncConfig.java
  87. 25 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/JobFactory.java
  88. 52 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/SchedulerConfig.java
  89. 436 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/BaseController.java
  90. 45 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/JobController.java
  91. 14 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaDao.java
  92. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaLogDao.java
  93. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictDao.java
  94. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictListDao.java
  95. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionMainDao.java
  96. 12 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionSlaveDao.java
  97. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionMainDao.java
  98. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionSlaveDao.java
  99. 11 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjDataSaveDao.java
  100. 0 0
      svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjQuotaDataSaveDao.java

+ 2 - 1
common-lib-parent-pom/pom.xml

@ -18,8 +18,9 @@
        <module>../common/common-swagger</module>
        <module>../common/common-quartz</module>
        <module>../common/common-log</module>
        <module>../common/common-rest-model</module>
        <module>../common/common-util</module>
        <module>../common/common-rest-model</module>
        <module>../common/common-mysql</module>
    </modules>
</project>

+ 1 - 0
common/common-mysql/src/main/java/com/yihu/jw/mysql/query/BaseJpaService.java

@ -42,6 +42,7 @@ public class BaseJpaService<T, R> {
    @PersistenceContext
    protected EntityManager entityManager;
    public BaseJpaService(){
        Type genType = getClass().getGenericSuperclass();
        if ((genType instanceof ParameterizedType)) {

+ 1 - 9
common/common-quartz/pom.xml

@ -12,16 +12,8 @@
    <groupId>com.yihu.jw</groupId>
    <artifactId>common-quartz</artifactId>
    <version>1.0-SNAPSHOT</version>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz-jobs</artifactId>
        </dependency>
    </dependencies>
</project>

+ 13 - 4
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/BaseContants.java

@ -5,30 +5,36 @@ package com.yihu.jw.restmodel.base;
 * 基础模块的静态变量
 */
public class BaseContants {
    //功能常量
    //功能模块常量
    public static class Function{
        public static final String message_success_create="function create success";
        public static final String message_success_update="function update success";
        public static final String message_success_find="function find success";
        public static final String message_success_find_functions="functions find success";
        public static final String message_success_delete="function delete success";
        public static final String message_success_assign_function=" assign function create success";
        public static final String message_success_find_functions_module="moduleFunctions find success";
        public static final String message_fail_name_exist="function name exist";
        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_name_is_null="function is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String api_common="function";
        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_getFunctions="getFunctions";
        public static final String api_getFunctionsNoPage="getFunctionsNoPage";
        public static final String api_assignFunction="assignFunction";
        public static final String api_getModuleFunctions="api_getModuleFunctions";
        public static final String api_getFunctionsNoPage="getFunctionsNoPage";
    }
    //模块常量
@ -38,6 +44,7 @@ public class BaseContants {
        public static final String message_success_find="Module find success";
        public static final String message_success_find_Modules="Module find success";
        public static final String message_success_delete="Module delete success";
        public static final String message_success_assign_module=" assign Module create success";
        public static final String message_fail_name_exist=" name exist";
@ -55,6 +62,8 @@ public class BaseContants {
        public static final String api_getByCode="getByCode";
        public static final String api_getModules="getModules";
        public static final String api_getModulesNoPage="getModulesNoPage";
        public static final String api_assignModule="assignModule";
        public static final String api_getSaasModules="api_getSaasModules";
    }

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/MFunction.java

@ -11,7 +11,7 @@ public class MFunction {
    private String name; //功能名称
    private String saasId; // saasid
    private String parentCode; //父功能code
    private Integer status; //状态 -1 已删除 0可用
    private Integer status; //状态 -1 删除 0 禁用 可用
    private String createUser;
    private String createUserName;
    private Date createTime;

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/MModule.java

@ -11,7 +11,7 @@ public class MModule {
    private String name; //模块名称
    private String saasId; //关联 Saas code
    private String parentCode;//父id
    private Integer status;
    private Integer status; //-1 删除 0 禁用 可用
    private String createUser;
    private String createUserName;
    private Date createTime;

+ 56 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/BaseSmsContants.java

@ -0,0 +1,56 @@
package com.yihu.jw.restmodel.base.sms;
/**
 * Created by chenweida on 2017/5/19.
 * 基础模块的静态变量
 */
public class BaseSmsContants {
    //短信常量
    public static class Sms{
        public static final String message_success_create="sms create success";
        public static final String message_success_update="sms update success";
        public static final String message_success_find="sms find success";
        public static final String message_success_find_smss="smss find success";
        public static final String message_success_delete="sms delete success";
        public static final String message_fail_name_exist="sms name exist";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="sms is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String api_common="sms";
        public static final String api_create="create";
        public static final String api_update="update";
        public static final String api_getSmss="getSmss";
        public static final String api_getSmssNoPage="getSmssNoPage";
    }
    //短信接口模块常量
    public static class SmsGateway{
        public static final String message_success_create="SmsGateway create success";
        public static final String message_success_update="SmsGateway update success";
        public static final String message_success_find="SmsGateway find success";
        public static final String message_success_find_SmsGateways="SmsGateways find success";
        public static final String message_success_delete="SmsGateway delete success";
        public static final String message_fail_name_exist="SmsGateway name exist";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="SmsGateway 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 api_common="smsGateway";
        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_getSmsGateways="getSmsGateways";
        public static final String api_getSmsGatewaysNoPage="getSmsGatewaysNoPage";
    }
}

+ 100 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/MSms.java

@ -0,0 +1,100 @@
package com.yihu.jw.restmodel.base.sms;
import java.util.Date;
/**
 * Created by chenweida on 2017/5/22.
 */
public class MSms {
    private Long id;
    private String saasId;	//saasid 关联base_saas code
    private String mobile;	//电话号码
    private String ip;	//发送短信的ip地址
    private Integer type;	//发送短信的类别
    private String captcha;	//验证码 1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录
    private String content;	// 短信内容
    private Date deadline;	//过期时间
    private Integer status;	//短信状态 状态,0未发送,1已发送
    private Date czrq; //操作时间
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getIp() {
        return ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getCaptcha() {
        return captcha;
    }
    public void setCaptcha(String captcha) {
        this.captcha = captcha;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Date getDeadline() {
        return deadline;
    }
    public void setDeadline(Date deadline) {
        this.deadline = deadline;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 88 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/MSmsGateway.java

@ -0,0 +1,88 @@
package com.yihu.jw.restmodel.base.sms;
/**
 * Created by chenweida on 2017/5/22.
 */
public class MSmsGateway {
    private Long id;
    private String code; //业务code
    private String name;//名称
    private String saasId; //关联 base_saas code
    private String orgCode; //机构code
    private String ip; // 短信接口的ip地址
    private String username;  //短信接口的账号
    private String password;	//短信接口的密码
    private String url;	//短信接口的url
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    public String getIp() {
        return ip;
    }
    public void setIp(String ip) {
        this.ip = ip;
    }
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}

+ 6 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/CommonContants.java

@ -5,6 +5,12 @@ package com.yihu.jw.restmodel.common;
 * 公共的常量类
 */
public class CommonContants {
    //微服务的id start
    public static final String svr_base = "svr-base";
    public static final String svr_wlyy = "svr-wlyy";
    public static final String svr_gateway = "svr-gateway";
    public static final Integer common_error_code= -10000; //系统异常
    public static final Integer common_error_params_code= -10100; //接口入参异常

+ 0 - 2
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java

@ -1,7 +1,5 @@
package com.yihu.jw.restmodel.common;
import com.yihu.jw.restmodel.base.MFunction;
import java.io.Serializable;
import java.util.List;

+ 116 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/agreement/WlyyAgreementContants.java

@ -0,0 +1,116 @@
package com.yihu.jw.restmodel.wlyy.agreement;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class WlyyAgreementContants {
    //协议模块常量
    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_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 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_fail_saasId_is_null="saasId is null";
    }
    //协议模块常量
    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_fail_agreement_is_null="agreement 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_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";
    }
    //协议模块常量
    public static class SignFamily{
        public static final String api_common="signFamily";
        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_status_is_null="status is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_type_is_null="type is null";
        public static final String message_fail_idCard_is_null="idCard is null";
        public static final String message_fail_ssc_is_null="ssc is null";
        public static final String message_fail_hospital_is_null="hospital is null";
        public static final String message_fail_hospitalName_is_null="hospitalName is null";
        public static final String message_fail_expense_is_null="expense is null";
        public static final String message_fail_expenseStatus_is_null="expenseStatus is null";
        public static final String message_fail_agreementCode_is_null="agreementCode is null";
        public static final String message_success_update="signFamily update success";
        public static final String message_success_delete="signFamily delete success";
        public static final String message_success_find="signFamily find success";
        public static final String message_success_create="signFamily create success";
        public static final String message_success_find_functions="signFamily find success";
    }
}

+ 35 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/patient/WlyyPatientContants.java

@ -0,0 +1,35 @@
package com.yihu.jw.restmodel.wlyy.patient;
/**
 * Created by Administrator on 2017/6/6 0006.
 */
public class WlyyPatientContants {
    public static class Advertisement{
        public static final String api_common="advertisement";
        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 api_getListByPatientCode="getListByPatientCode";
        public static final String api_getListByHttp="getListByHttp";
        public static final String api_getListByIp="getListByIp";
        public static final String message_success_update="advertisement update success";
        public static final String message_success_delete="advertisement delete success";
        public static final String message_success_find="advertisement find success";
        public static final String message_success_create="advertisement create success";
        public static final String message_success_find_functions="advertisement find success";
        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_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_fail_saasid_is_null="saasid is null";
        public static final String message_fail_picture_is_null="picture is null";
        public static final String message_fail_wlyyAdvertisement_is_not_exist="WlyyAdvertisement is not exist";
    }
}

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

@ -0,0 +1,135 @@
package com.yihu.jw.restmodel.wx;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/21 0021.
 */
public class MWxGraphicMessage {
    private Long id;
    private String code;//业务code
    private String title;//标题
    private String description;//描述
    private String url;//图文消息url值
    private String picUrl;//图片地址
    private String createUser;//创建人
    private String createUserName;//创建人名
    private Date createTime;//创建时间
    private String updateUser;//修改人
    private String updateUserName;//修改人名称
    private Date updateTime;//修改时间
    private String remark;//备注
    private Integer status;  //状态 -1删除 0 冻结 1可用
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getPicUrl() {
        return picUrl;
    }
    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

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

@ -0,0 +1,173 @@
package com.yihu.jw.restmodel.wx;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class MWxMenu {
    private Long id;//主键id
    private String code;//业务code
    private String wechatCode;//关联的微信code 关联表 Wx_Wechat
    private String supMenucode;//父菜单id 如果是一级菜单 此字段为空
    private String type;//菜单类型
    private String name;//菜单名称
    private String key;//click等点击类型必须
    private Integer sort;//菜单排序 父菜单排序 不包含子菜单那
    private String url;//url
    private String mediaId;//点用新增永久素材接口返回的合法media_id
    private String appid;//小程序的appid
    private String pagepath;//小程序的页面程序
    private String updateUser;//更新人
    private Date updateTime;//更新时间
    private Date createTime;//创建时间
    private String createUser;//创建人
    private String remark;//备注
    private Integer status; //状态 -1 已删除 0可用
    public String getKey() {
        return key;
    }
    public void setKey(String key) {
        this.key = key;
    }
    public String getMediaId() {
        return mediaId;
    }
    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }
    public String getAppid() {
        return appid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    public String getPagepath() {
        return pagepath;
    }
    public void setPagepath(String pagepath) {
        this.pagepath = pagepath;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getWechatCode() {
        return wechatCode;
    }
    public void setWechatCode(String wechatCode) {
        this.wechatCode = wechatCode;
    }
    public String getSupMenucode() {
        return supMenucode;
    }
    public void setSupMenucode(String supMenucode) {
        this.supMenucode = supMenucode;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

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

@ -0,0 +1,135 @@
package com.yihu.jw.restmodel.wx;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class MWxTemplate {
    private Long id;
    private String code;//模板code
    private String title;//模板标题
    private String wechatCode;//关联的微信code 关联表 Wx_Wechat
    private String templateId;//微信模板id
    private String content;//模板内容
    private String createUser;//创建人
    private String createUserName;//创建人名
    private Date createTime;//创建时间
    private String updateUser;//修改人
    private String updateUserName;//修改人名称
    private Date updateTime;//修改时间
    private String remark;
    private Integer status;  //状态 -1删除 0 冻结 1可用
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getWechatCode() {
        return wechatCode;
    }
    public void setWechatCode(String wechatCode) {
        this.wechatCode = wechatCode;
    }
    public String getTemplateId() {
        return templateId;
    }
    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

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

@ -0,0 +1,181 @@
package com.yihu.jw.restmodel.wx;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class MWxWechat {
    private Long id;
    private String code;//业务code
    private String saasId;//'saas配置id'
    private String name;//名称
    private String token;//token
    private String encodingAesKey;//加密密钥
    private Integer encType;//加密方式  0:明文模式   1:兼容模式   2:安全模式
    private Integer status;//'类型 -1 已删除 0待审核 1审核通过 2 审核不通过'
    private String type;//'1:服务号 2 订阅号
    private String appId;//'微信app_id'
    private String appSecret;//'微信app_secret'
    private String baseUrl;//'微信base_url'
    private String createUser;//'创建人'
    private String createUserName;//'创建人名'
    private Date createTime;//'创建时间'
    private String updateUser;//'修改人
    private String updateUserName;//'修改人名'
    private Date updateTime;//'修改时间'
    private String remark;//'备注'
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    public String getEncodingAesKey() {
        return encodingAesKey;
    }
    public void setEncodingAesKey(String encodingAesKey) {
        this.encodingAesKey = encodingAesKey;
    }
    public Integer getEncType() {
        return encType;
    }
    public void setEncType(Integer encType) {
        this.encType = encType;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getAppSecret() {
        return appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
    public String getBaseUrl() {
        return baseUrl;
    }
    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

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

@ -0,0 +1,132 @@
package com.yihu.jw.restmodel.wx;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class WxContants {
    //微信token模块常量
    public static class WxAccessToken{
        public static final String message_success_get="wxAccessToken get success";
        public static final String api_common="wxAccessToken";
        public static final String api_create="create";
        public static final String api_get="get";
    }
    //微信按钮模块常量
    public static class WxMenu{
        public static final String api_common="wxMenu";
        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 final String message_fail_wechatCode_is_null="wechatCode is null";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="name is null";
        public static final String message_fail_type_is_null="type is null";
        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 {
        public static final String api_common="wxTemplate";
        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 final String message_success_create="wxTemplate create success";
        public static final String message_success_update="wxTemplate update success";
        public static final String message_success_find="wxTemplate find success";
        public static final String message_success_find_functions="wxTemplate find success";
        public static final String message_success_delete="wxTemplate delete success";
        public static final String message_fail_code_is_null="code 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 {
        public static final String api_common="wechat";
        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 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 not 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 not exist";//微信配置不存在
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_saasId_is_null="saasId is null";
    }
    //微信图文消息
    public static class WxGraphicMessage {
        public static final String api_common="wxGraphicMessage";
        public static final String api_create="create";
        public static final String api_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";
        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";
        public static final String message_success_find_functions="wxGraphicMessage find success";
        public static final String message_success_delete="wxGraphicMessage delete success";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_code_no_exist="code not 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";
        public static final String message_fail_wxGraphicMessage_is_no_exist="wxGraphicMessage is not exist";
    }
}

+ 43 - 2
common/common-swagger/src/main/java/com/yihu/jw/config/SwaggerConfig.java

@ -1,6 +1,9 @@
package com.yihu.jw.config;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.wlyy.agreement.WlyyAgreementContants;
import com.yihu.jw.restmodel.wlyy.patient.WlyyPatientContants;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@ -14,10 +17,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
@ -30,7 +34,12 @@ public class SwaggerConfig {
                .select()
                .paths(or(
                        regex("/patient/.*")
                     //   , regex("/"+ BaseContants.Function.api_common+"/.*")
                        , regex("/"+ BaseContants.Function.api_common+"/.*")
                        ,regex("/"+ WxContants.Wechat.api_common+"/.*")
                        ,regex("/"+WxContants.WxAccessToken.api_common+"/.*")
                        ,regex("/"+WxContants.WxMenu.api_common+"/.*")
                        ,regex("/"+WxContants.WxTemplate.api_common+"/.*")
                        ,regex("/"+WxContants.WxGraphicMessage.api_common+"/.*")
                        ))
                .build()
                .apiInfo(publicApiInfo());
@ -49,6 +58,38 @@ 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("/" + WlyyAgreementContants.Agreement.api_common + "/.*")
                        , regex("/" + WlyyAgreementContants.AgreementKpi.api_common + "/.*")
                        , regex("/" + WlyyAgreementContants.AgreementKpiLog.api_common + "/.*")
                        , regex("/" + WlyyAgreementContants.SignFamily.api_common + "/.*")
                        , regex("/" + WlyyPatientContants.Advertisement.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() {

+ 100 - 0
manage-gateway/pom.xml

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.yihu.jw</groupId>
    <artifactId>svr-lib-parent-pom</artifactId>
    <version>1.0.0</version>
    <relativePath>../svr-lib-parent-pom/pom.xml</relativePath>
  </parent>
  <artifactId>manage-gateway</artifactId>
  <packaging>jar</packaging>
  <version>1.0.0</version>
  <dependencies>
    <dependency>
      <groupId>com.yihu.jw</groupId>
      <artifactId>common-swagger</artifactId>
    </dependency>
    <dependency>
      <groupId>com.yihu.jw</groupId>
      <artifactId>common-rest-model</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-aop</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-feign</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-hystrix</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-zuul</artifactId>
    </dependency>
    <!--zipkin支持分布式追踪系统-->
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-sleuth</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-sleuth-zipkin</artifactId>
    </dependency>
    <!--<dependency>-->
    <!--<groupId>org.springframework.cloud</groupId>-->
    <!--<artifactId>spring-cloud-starter-bus-kafka</artifactId>-->
    <!--</dependency>-->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
  </dependencies>
</project>

+ 18 - 0
manage-gateway/readme.MD

@ -0,0 +1,18 @@
此项目是后台管理系统的的网关项目
    网关调用微服务利用fegin(spring-cloud-starter-feign)
    
查看服务健康需要添加以下支持
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    
    localhost:8088/health
    
刷新配置
在有需要刷新配置的地方的类加上注解
    @RefreshScope
    访问以下路径刷新配置
    curl -X POST http://localhost:8088/refresh

+ 27 - 0
manage-gateway/src/main/java/com/yihu/jw/manage/SvrManageAppliction.java

@ -0,0 +1,27 @@
package com.yihu.jw.manage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
/**
 * Created by chenweida on 2017/5/31.
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
//@SpringBootApplication
@EnableDiscoveryClient//服务注册到发现服务
@EnableHystrix //启动断路器
@EnableZuulProxy //启动zuul代理 路由
@EnableFeignClients //声名式的客户端
@EnableCircuitBreaker
public class SvrManageAppliction {
    public static void main(String[] args) {
        SpringApplication.run(SvrManageAppliction.class, args);
    }
}

+ 26 - 0
manage-gateway/src/main/java/com/yihu/jw/manage/config/MvcConfig.java

@ -0,0 +1,26 @@
package com.yihu.jw.manage.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
 * Created by chenweida on 2017/5/31.
 */
@Configuration
public class MvcConfig extends WebMvcConfigurerAdapter {
    /**
     * 支持跨域问题
     * 资料:http://blog.csdn.net/dalangzhonghangxing/article/details/51994812
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowCredentials(true)
                .allowedMethods("GET", "POST", "DELETE", "PUT")
                .maxAge(3600);
    }
}

+ 57 - 0
manage-gateway/src/main/resources/application.yml

@ -0,0 +1,57 @@
##如果有配置服务的话,远程服务器和本地服务器配置不一致的情况下,优先远程的为主
spring:
  application:
    name:  manage-gateway  ##注册到发现服务的id 如果id一样 eurika会自动做负载
##开启feign断路器
feign:
  hystrix:
    enabled: true
management:
  security:
    enabled: false  ##关闭 refresh的权限认证
#zuul 默认会代理所有的微服务  路径 /{appliction.name}/**
zuul:
  ignored-services: '*'  ##忽略全部的代理  忽略单个微服务   ignored-services: svr-base 多个逗号分割
  routes:
    svr-base: /base/**  ##svr-base方向代理到/base下多层级的路径
#    svr-base:    这种方式和  svr-base: /base/**  一样  svr-base可以随便写 唯一即可
#      path: /base/**  path是代理后的路径
#      serviceId: svr-base  serviceId是微服务name
#   svr-base: 这种方式和 上面一样 就是serviceId改成具体的url 但是这种配置方法不能利用eurika的负载均衡
#     path: /base/**
#     url: http://localhost:10020/
#svr-base: 这边是微服务ID  配置负载均衡
#  ribbon:
#    listOfService: http://localhost:10020/,http://localhost:10021/
---
spring:
  profiles: jwdev
#  cloud:
#    stream:
#      kafka:
#        binder:
#          brokers: 172.17.110.201
#          defaultBrokerPort: 9092
#          zkNodes: 172.17.110.201
#          defaultZkPort: 2181
#          replicationFactor: 1
---
spring:
  profiles: jwtest
---
spring:
  profiles: jwprod

+ 8 - 0
manage-gateway/src/main/resources/banner.txt

@ -0,0 +1,8 @@
 __  __                                         _____       _
 |  \/  |                                       / ____|     | |
 | \  / | __ _ _ __   __ _  __ _  ___          | |  __  __ _| |_ _____      ____ _ _   _
 | |\/| |/ _` | '_ \ / _` |/ _` |/ _ \         | | |_ |/ _` | __/ _ \ \ /\ / / _` | | | |
 | |  | | (_| | | | | (_| | (_| |  __/         | |__| | (_| | ||  __/\ V  V / (_| | |_| |
 |_|  |_|\__,_|_| |_|\__,_|\__, |\___|          \_____|\__,_|\__\___| \_/\_/ \__,_|\__, |
                            __/ |                                                   __/ |
                           |___/                                                   |___/

+ 46 - 0
manage-gateway/src/main/resources/bootstrap.yml

@ -0,0 +1,46 @@
##优先读取 boostarap配置 然后在读取application。yml的配置
spring:
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      failFast: false ##启动快速失败 即链接不到配置服务就启动失败
      username: jw
      password: jkzl
      discovery:
        enabled: true ##使用发现服务
        service-id: svr-configurations ##配置服务的名字
---
spring:
  profiles: jwdev
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/
---
spring:
  profiles: jwtest
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/
---
spring:
  profiles: jwprod
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/

+ 1 - 0
readme.MD

@ -16,6 +16,7 @@
     common-lib-parent-pom    common公共工程的maven父pom
     jw-lib-parent-pom   jw业务公共工程的maven父pom 
     web-gateway 对外的接口网关
     manage-gateway 基卫后台管理系统的接口网关
     .gitignore   项目提交忽略配置文件
     
项目运行

+ 11 - 0
svr-configuration/src/main/resources/application.yml

@ -2,6 +2,17 @@ server:
  port: 1221
eureka:
  client:
    healthcheck:
      enabled: true #启动监控检查
  instance:
    #eurika使用IP不使用host
    prefer-ip-address: true
    #定制化在eurika中显示的名称
    ##instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}}
    instance-id: 127.0.0.1:${server.port}
---
spring:

+ 2 - 1
svr-configuration/src/main/resources/bootstrap.yml

@ -32,7 +32,8 @@ spring:
      server:
        git:
          uri: http://192.168.1.220:10080/chenweida/jw.config.git
          #uri: http://192.168.116.100:10080/chenweida/mini.jw.config.git
#          uri: http://192.168.116.100:10080/chenweida/mini.jw.config.git
#          uri: http://192.168.1.220:10080/chenyongxing/jw.config.git
        default-label: master

+ 77 - 2
svr-lib-parent-pom/pom.xml

@ -7,7 +7,6 @@
    <artifactId>svr-lib-parent-pom</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <developers>
        <developer>
            <id>cwd</id>
@ -19,7 +18,19 @@
            </roles>
        </developer>
    </developers>
    <!--deploy 的时候发布到这个服务器-->
    <distributionManagement>
        <repository>
            <id>releases</id>
            <name>Releases</name>
            <url>http://172.19.103.43:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshots</name>
            <url>http://172.19.103.43:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <modules>
        <module>../svr-configuration</module> <!--配置服务-->
@ -30,10 +41,12 @@
        <!--业务微服务-->
        <module>../svr/svr-base</module><!--基础微服务-->
        <module>../svr/svr-quota</module><!--统计微服务-->
        <module>../svr/svr-wlyy</module><!--i健康微服务-->
        <!--网关-->
        <module>../web-gateway</module><!--web网关-->
        <module>../manage-gateway</module><!--后台管理系统网关-->
    </modules>
    <properties>
@ -54,6 +67,13 @@
        <version.swagger-ui>2.4.0</version.swagger-ui>
        <version.quartz>2.3.0</version.quartz>
        <version.logback>1.2.3</version.logback>
        <version.spring-elasticsearch>2.1.3.RELEASE</version.spring-elasticsearch>
        <version.jest>2.4.0</version.jest>
        <version.json>20160212</version.json>
        <version.net-json>2.4</version.net-json>
        <version.springside>4.2.3-GA</version.springside>
        <version.common.lang3>3.1</version.common.lang3>
        <version.elasticsearch>2.4.4</version.elasticsearch>
    </properties>
    <!--dependencyManagement作用子配置不写版本默认继承父配置-->
    <dependencyManagement>
@ -75,6 +95,11 @@
                <artifactId>common-rest-model</artifactId>
                <version>${version.myCommon}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.jw</groupId>
                <artifactId>svr-base</artifactId>
                <version>${version.myCommon}</version>
            </dependency>
            <dependency>
                <groupId>com.yihu.jw</groupId>
                <artifactId>common-util</artifactId>
@ -254,6 +279,12 @@
                <artifactId>spring-boot-starter-aop</artifactId>
                <version>${version.springBoot}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
                <version>${version.springBoot}</version>
            </dependency>
            <!--springBoot end-->
            <!--spring start-->
@ -269,6 +300,11 @@
                <version>${version.spring}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${version.spring}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
@ -299,6 +335,11 @@
                <artifactId>spring-data-commons</artifactId>
                <version>${version.spring-data-common}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-elasticsearch</artifactId>
                <version>${version.spring-elasticsearch}</version>
            </dependency>
            <!--spring end-->
            <!--数据库驱动 start-->
@ -400,7 +441,41 @@
                <version>${version.logback}</version>
            </dependency>
            <!--log end-->
            <!-- json start-->
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>${version.json}</version>
            </dependency>
            <dependency>
                <groupId>net.sf.json-lib</groupId>
                <artifactId>json-lib</artifactId>
                <version>${version.net-json}</version>
            </dependency>
            <!--json end -->
            <!-- es 客户端 start-->
            <dependency>
                <groupId>io.searchbox</groupId>
                <artifactId>jest</artifactId>
                <version>${version.jest}</version>
            </dependency>
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>${version.elasticsearch}</version>
            </dependency>
            <!-- es 客户端 end-->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${version.common.lang3}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>

+ 2 - 1
svr/readme.MD

@ -1,4 +1,5 @@
svr 相关的db设计
    svn:https://192.168.1.103:888/svn/outwindow/基础开发部/doc/i健康2.0/db
    svr-base 基础扩展服务,部分基础服务用ehr的
    svr-quota 统计相关服务
    svr-quota 统计相关服务
    svr-wlyy i健康公共业务后台

+ 8 - 4
svr/svr-base/pom.xml

@ -16,7 +16,7 @@
    <dependencies>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-swagger</artifactId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
@ -24,15 +24,15 @@
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-mysql</artifactId>
            <artifactId>common-log</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-log</artifactId>
            <artifactId>common-mysql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
@ -108,5 +108,9 @@
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
    </dependencies>
</project>

+ 14 - 0
svr/svr-base/readme.MD

@ -0,0 +1,14 @@
基础微服务
    每个模块有自己独立的文件夹,这样做的好处是以后如果哪个模块需要独立成微服务,代码直接剪切到新的微服务即可。
    每个模块下面有独立的controller,service,model和dao
    base:
        saas  saas配置
        module 模块配置管理
        function 功能配置管理
    wx:
        wechat   微信配置相关
        wxAccessToken  微信token管理
        wxGraphicMessage    微信图文管理
        wxMenu  微信菜单管理
        wxTemplate  微信模版
    

+ 0 - 7
svr/svr-base/src/main/java/com/yihu/jw/SvrBaseApplication.java

@ -2,14 +2,7 @@ package com.yihu.jw;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;
/**
 * Created by chenweida on 2017/5/10.

+ 27 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/controller/FunctionController.java

@ -125,4 +125,31 @@ public class FunctionController extends EnvelopRestController {
        List<MFunction> mFunctions = convertToModels(list, new ArrayList<>(list.size()), MFunction.class, fields);
        return Envelop.getSuccessList(BaseContants.Function.message_success_find_functions,mFunctions);
    }
    @PutMapping(value = BaseContants.Function.api_assignFunction, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "给对应的模块分配功能")
    public Envelop assignModule(
            @ApiParam(name = "module_code", value = "module_code", defaultValue = "")
            @RequestParam String moduleCode,
            @ApiParam(name = "functionCodes", value = "功能的code,可以传多个,逗号分割", defaultValue = "")
            @RequestParam String functionCodes) {
        try {
            functionService.assignFunction(moduleCode,functionCodes);
            return Envelop.getSuccess(BaseContants.Function.message_success_assign_function);
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseContants.Function.api_getModuleFunctions, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询saas的模块")
    public Envelop getModuleFunctions(
            @ApiParam(name = "saas_code", value = "saas_code", defaultValue = "")
            @RequestParam String saasCode) {
        try {
            return Envelop.getSuccess(BaseContants.Function.message_success_find_functions_module,functionService.getModuleFunctions(saasCode));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

+ 29 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/controller/ModuleController.java

@ -1,6 +1,7 @@
package com.yihu.jw.base.controller;
import com.yihu.jw.base.model.Module;
import com.yihu.jw.base.model.SaasModule;
import com.yihu.jw.base.service.ModuleService;
import com.yihu.jw.base.service.ModuleService;
import com.yihu.jw.restmodel.base.BaseContants;
@ -126,4 +127,32 @@ public class ModuleController extends EnvelopRestController {
        List<MModule> mModules = convertToModels(list, new ArrayList<>(list.size()), MModule.class, fields);
        return Envelop.getSuccessList(BaseContants.Module.message_success_find_Modules,mModules);
    }
    @PutMapping(value = BaseContants.Module.api_assignModule, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "分配模块", notes = "给对应的saas分配模块")
    public Envelop assignModule(
            @ApiParam(name = "saas_code", value = "saas_code", defaultValue = "")
            @RequestParam String saasCode,
            @ApiParam(name = "moduleCodes", value = "模块的code,可以传多个,逗号分割", defaultValue = "")
            @RequestParam String moduleCodes) {
        try {
            moduleService.assignModule(saasCode,moduleCodes);
            return Envelop.getSuccess(BaseContants.Module.message_success_assign_module);
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseContants.Module.api_getSaasModules, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "查询saas的模块", notes = "查询saas已经分配的模块")
    public Envelop getSaasModules(
            @ApiParam(name = "saas_code", value = "saas_code", defaultValue = "")
            @RequestParam String saasCode) {
        try {
            return Envelop.getSuccess(BaseContants.Module.message_success_assign_module,moduleService.getSaasModules(saasCode));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

+ 103 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/controller/sms/SmsController.java

@ -0,0 +1,103 @@
package com.yihu.jw.base.controller.sms;
import com.yihu.jw.base.model.sms.BaseSms;
import com.yihu.jw.base.service.sms.SmsService;
import com.yihu.jw.restmodel.base.sms.BaseSmsContants;
import com.yihu.jw.restmodel.base.sms.MSms;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
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;
/**
 * Created by chenweida on 2017/5/19.
 */
@RestController
@RequestMapping(BaseSmsContants.Sms.api_common)
@Api(value = "短信模块", description = "短信模块接口管理")
public class SmsController extends EnvelopRestController {
    @Autowired
    private SmsService smsService;
    @PostMapping(value = BaseSmsContants.Sms.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建短信", notes = "创建单个短信")
    public Envelop createSms(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            BaseSms sms = toEntity(jsonData, BaseSms.class);
            return Envelop.getSuccess(BaseSmsContants.Sms.message_success_create, smsService.createSms(sms));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = BaseSmsContants.Sms.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改短信", notes = "修改短信")
    public Envelop updateSms(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            BaseSms sms = toEntity(jsonData, BaseSms.class);
            return Envelop.getSuccess(BaseSmsContants.Sms.message_success_update, smsService.updateSms(sms));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseSmsContants.Sms.api_getSmss, method = RequestMethod.GET)
    @ApiOperation(value = "获取短信列表(分页)")
    public Envelop getSmss(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
            @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<BaseSms> list = smsService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=smsService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MSms> mSmss = convertToModels(list, new ArrayList<>(list.size()), MSms.class, fields);
        return Envelop.getSuccessListWithPage(BaseSmsContants.Sms.message_success_find_smss,mSmss, page, size,count);
    }
    @GetMapping(value = BaseSmsContants.Sms.api_getSmssNoPage)
    @ApiOperation(value = "获取短信列表,不分页")
    public Envelop getAppsNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,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<BaseSms> list = smsService.search(fields,filters,sorts);
        //封装返回格式
        List<MSms> mSmss = convertToModels(list, new ArrayList<>(list.size()), MSms.class, fields);
        return Envelop.getSuccessList(BaseSmsContants.Sms.message_success_find_smss,mSmss);
    }
}

+ 128 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/controller/sms/SmsGatewayController.java

@ -0,0 +1,128 @@
package com.yihu.jw.base.controller.sms;
import com.yihu.jw.base.model.sms.BaseSmsGateway;
import com.yihu.jw.base.service.sms.SmsGatewayService;
import com.yihu.jw.restmodel.base.sms.BaseSmsContants;
import com.yihu.jw.restmodel.base.sms.MSmsGateway;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.restmodel.exception.ApiException;
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;
/**
 * Created by chenweida on 2017/5/19.
 */
@RestController
@RequestMapping(BaseSmsContants.SmsGateway.api_common)
@Api(value = "功能模块", description = "功能模块接口管理")
public class SmsGatewayController extends EnvelopRestController {
    @Autowired
    private SmsGatewayService smsGatewayService;
    @PostMapping(value = BaseSmsContants.SmsGateway.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建功能", notes = "创建单个功能")
    public Envelop createSmsGateway(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            BaseSmsGateway smsGateway = toEntity(jsonData, BaseSmsGateway.class);
            return Envelop.getSuccess(BaseSmsContants.SmsGateway.message_success_create, smsGatewayService.createSmsGateway(smsGateway));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = BaseSmsContants.SmsGateway.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改功能", notes = "修改功能")
    public Envelop updateSmsGateway(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            BaseSmsGateway smsGateway = toEntity(jsonData, BaseSmsGateway.class);
            return Envelop.getSuccess(BaseSmsContants.SmsGateway.message_success_update, smsGatewayService.updateSmsGateway(smsGateway));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = BaseSmsContants.SmsGateway.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "删除功能", notes = "删除功能")
    public Envelop deleteSmsGateway(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            smsGatewayService.deleteSmsGateway(code);
            return Envelop.getSuccess(BaseSmsContants.SmsGateway.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = BaseSmsContants.SmsGateway.api_getByCode, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据code查找功能", notes = "根据code查找功能")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(BaseSmsContants.SmsGateway.message_success_find, smsGatewayService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = BaseSmsContants.SmsGateway.api_getSmsGateways, method = RequestMethod.GET)
    @ApiOperation(value = "获取功能列表(分页)")
    public Envelop getSmsGateways(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,remark")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            //code like 1,name大于aa ,code 等于1 , defaultValue = "code?1;name>aa;code=1"
            @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<BaseSmsGateway> list = smsGatewayService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=smsGatewayService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MSmsGateway> mSmsGateways = convertToModels(list, new ArrayList<>(list.size()), MSmsGateway.class, fields);
        return Envelop.getSuccessListWithPage(BaseSmsContants.SmsGateway.message_success_find_SmsGateways,mSmsGateways, page, size,count);
    }
    @GetMapping(value = BaseSmsContants.SmsGateway.api_getSmsGatewaysNoPage)
    @ApiOperation(value = "获取功能列表,不分页")
    public Envelop getAppsNoPage(
            @ApiParam(name = "fields", value = "返回的字段,为空返回全部字段", defaultValue = "code,name,saasId,parentCode,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<BaseSmsGateway> list = smsGatewayService.search(fields,filters,sorts);
        //封装返回格式
        List<MSmsGateway> mSmsGateways = convertToModels(list, new ArrayList<>(list.size()), MSmsGateway.class, fields);
        return Envelop.getSuccessList(BaseSmsContants.SmsGateway.message_success_find_SmsGateways,mSmsGateways);
    }
}

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/dao/FunctionDao.java

@ -10,12 +10,12 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface FunctionDao extends PagingAndSortingRepository<Function, Long>, JpaSpecificationExecutor<Function> {
    @Query("from Function f where f.name=?1 and f.status=0")
    @Query("from Function f where f.name=?1 and f.status=1")
    Function findByName(String name);
    @Query("from Function f where f.name=?1 and f.status=0 and f.code != ?2")
    @Query("from Function f where f.name=?1 and f.status=1 and f.code != ?2")
    Function findByNameExcludeCode(String name, String code);
    @Query("from Function f where f.code=?1 and f.status=0")
    @Query("from Function f where f.code=?1 and f.status=1")
    Function findByCode(String code);
}

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/dao/ModuleDao.java

@ -9,12 +9,12 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by chenweida on 2017/5/19.
 */
public interface ModuleDao extends PagingAndSortingRepository<Module, Long>, JpaSpecificationExecutor<Module> {
    @Query("from Module f where f.name=?1 and f.status=0")
    @Query("from Module f where f.name=?1 and f.status=1")
    Module findByName(String name);
    @Query("from Module f where f.name=?1 and f.status=0 and f.code != ?2")
    @Query("from Module f where f.name=?1 and f.status=1 and f.code != ?2")
    Module findByNameExcludeCode(String name, String code);
    @Query("from Module f where f.code=?1 and f.status=0")
    @Query("from Module f where f.code=?1 and f.status=1")
    Module findByCode(String code);
}

+ 17 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/ModuleFunctionDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.base.dao;
import com.yihu.jw.base.model.ModuleFunction;
import com.yihu.jw.base.model.SaasModule;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/22.
 */
public interface ModuleFunctionDao extends PagingAndSortingRepository<ModuleFunction, Long>, JpaSpecificationExecutor<ModuleFunction> {
    @Modifying
    @Query("delete from ModuleFunction es where es.moduleId = ?1")
    int deleteByModuleCode(String moduleCode);
}

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/dao/SaasDao.java

@ -9,12 +9,12 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by chenweida on 2017/5/19.
 */
public interface SaasDao extends PagingAndSortingRepository<Saas, Long>, JpaSpecificationExecutor<Saas> {
    @Query("from Saas f where f.name=?1 and f.status=0")
    @Query("from Saas f where f.name=?1 and f.status=1")
    Saas findByName(String name);
    @Query("from Saas f where f.name=?1 and f.status=0 and f.code != ?2")
    @Query("from Saas f where f.name=?1 and f.status=1 and f.code != ?2")
    Saas findByNameExcludeCode(String name, String code);
    @Query("from Saas f where f.code=?1 and f.status=0")
    @Query("from Saas f where f.code=?1 and f.status=1")
    Saas findByCode(String code);
}

+ 17 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/SaasModuleDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.base.dao;
import com.yihu.jw.base.model.Saas;
import com.yihu.jw.base.model.SaasModule;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/22.
 */
public interface SaasModuleDao extends PagingAndSortingRepository<SaasModule, Long>, JpaSpecificationExecutor<SaasModule> {
    @Modifying
    @Query("delete from SaasModule es where es.saasId = ?1")
    int deleteBySaasCode(String saasCode);
}

+ 22 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/sms/SmsDao.java

@ -0,0 +1,22 @@
package com.yihu.jw.base.dao.sms;
import com.yihu.jw.base.model.Function;
import com.yihu.jw.base.model.sms.BaseSms;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/22.
 */
public interface SmsDao extends PagingAndSortingRepository<BaseSms, Long>, JpaSpecificationExecutor<BaseSms> {
    @Query("from Function f where f.name=?1 and f.status=1")
    BaseSms findByName(String name);
    @Query("from Function f where f.name=?1 and f.status=1 and f.code != ?2")
    BaseSms findByNameExcludeCode(String name, String code);
    @Query("from Function f where f.code=?1 and f.status=1")
    BaseSms findByCode(String code);
}

+ 21 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/sms/SmsGatewayDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.base.dao.sms;
import com.yihu.jw.base.model.sms.BaseSms;
import com.yihu.jw.base.model.sms.BaseSmsGateway;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/5/22.
 */
public interface SmsGatewayDao extends PagingAndSortingRepository<BaseSmsGateway, Long>, JpaSpecificationExecutor<BaseSmsGateway> {
    @Query("from BaseSmsGateway f where f.name=?1 and f.status=1")
    BaseSmsGateway findByName(String name);
    @Query("from BaseSmsGateway f where f.name=?1 and f.status=1 and f.code != ?2")
    BaseSmsGateway findByNameExcludeCode(String name, String code);
    @Query("from BaseSmsGateway f where f.code=?1 and f.status=1")
    BaseSmsGateway findByCode(String code);
}

+ 3 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/model/Function.java

@ -19,7 +19,7 @@ public class Function extends IdEntity implements java.io.Serializable {
	private String name; //功能名称
	private String saasId; // saasid
	private String parentCode; //父功能code
	private Integer status; //状态 -1 已删除 0可用
	private Integer status; //状态 -1 删除 0 禁用 可用
	private String createUser;
	private String createUserName;
	private Date createTime;
@ -129,6 +129,7 @@ public class Function extends IdEntity implements java.io.Serializable {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
@ -156,6 +157,7 @@ public class Function extends IdEntity implements java.io.Serializable {
		this.modifyUserName = modifyUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "modify_time", nullable = false, length = 0)
	public Date getModifyTime() {
		return this.modifyTime;

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/model/Module.java

@ -18,7 +18,7 @@ public class Module extends IdEntity implements java.io.Serializable {
	private String name; //模块名称
	private String saasId; //关联 Saas code
	private String parentCode;//父id
	private Integer status;
	private Integer status; //-1 删除 0 禁用 可用
	private String createUser;
	private String createUserName;
	private Date createTime;

+ 148 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/model/sms/BaseSms.java

@ -0,0 +1,148 @@
package com.yihu.jw.base.model.sms;// default package
import com.yihu.jw.base.model.base.IdEntity;
import java.sql.Timestamp;
import java.util.Date;
import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
/**
 * BaseSms entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "base_sms")
public class BaseSms extends IdEntity implements java.io.Serializable {
	// Fields
	private String saasId;	//saasid 关联base_saas code
	private String mobile;	//电话号码
	private String ip;	//发送短信的ip地址
	private Integer type;	//发送短信的类别
	private String captcha;	//验证码 1微信端注册,2微信端找回密码,3医生端找回密码,4患者登录,5医生登录
	private String content;	// 短信内容
	private Date deadline;	//过期时间
	private Integer status;	//短信状态 状态,0未发送,1已发送
	private Date czrq; //操作时间
	// Constructors
	/** default constructor */
	public BaseSms() {
	}
	/** minimal constructor */
	public BaseSms(String mobile, String ip, Integer type, String captcha,
			String content, Timestamp deadline, Integer status, Timestamp czrq) {
		this.mobile = mobile;
		this.ip = ip;
		this.type = type;
		this.captcha = captcha;
		this.content = content;
		this.deadline = deadline;
		this.status = status;
		this.czrq = czrq;
	}
	/** full constructor */
	public BaseSms(String saasId, String mobile, String ip, Integer type,
			String captcha, String content, Timestamp deadline, Integer status,
			Timestamp czrq) {
		this.saasId = saasId;
		this.mobile = mobile;
		this.ip = ip;
		this.type = type;
		this.captcha = captcha;
		this.content = content;
		this.deadline = deadline;
		this.status = status;
		this.czrq = czrq;
	}
	@Column(name = "saas_id", length = 64)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "mobile", nullable = false, length = 20)
	public String getMobile() {
		return this.mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	@Column(name = "ip", nullable = false, length = 20)
	public String getIp() {
		return this.ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	@Column(name = "type", nullable = false)
	public Integer getType() {
		return this.type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	@Column(name = "captcha", nullable = false, length = 10)
	public String getCaptcha() {
		return this.captcha;
	}
	public void setCaptcha(String captcha) {
		this.captcha = captcha;
	}
	@Column(name = "content", nullable = false, length = 500)
	public String getContent() {
		return this.content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "deadline", nullable = false, length = 0)
	public Date getDeadline() {
		return this.deadline;
	}
	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}
	@Column(name = "status", nullable = false)
	public Integer getStatus() {
		return this.status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "czrq", nullable = false, length = 0)
	public Date getCzrq() {
		return this.czrq;
	}
	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}
}

+ 134 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/model/sms/BaseSmsGateway.java

@ -0,0 +1,134 @@
package com.yihu.jw.base.model.sms;// default package
import com.yihu.jw.base.model.base.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
 * BaseSmsGateway entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "base_sms_gateway")
public class BaseSmsGateway  extends IdEntity implements java.io.Serializable {
	// Fields
	private String code; //业务code
	private String name;//名称
	private String saasId; //关联 base_saas code
	private String orgCode; //机构code
	private String ip; // 短信接口的ip地址
	private String username;  //短信接口的账号
	private String password;	//短信接口的密码
	private String url;	//短信接口的url
	private Integer status;// -1 删除 0 禁用 可用
	// Constructors
	/** default constructor */
	public BaseSmsGateway() {
	}
	/** minimal constructor */
	public BaseSmsGateway(Long id) {
		this.id = id;
	}
	/** full constructor */
	public BaseSmsGateway(Long id, String code, String saasId,
			String orgCode, String ip, String username, String password,
			String url) {
		this.id = id;
		this.code = code;
		this.saasId = saasId;
		this.orgCode = orgCode;
		this.ip = ip;
		this.username = username;
		this.password = password;
		this.url = url;
	}
	@Column(name = "code", length = 64)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "saas_id", length = 64)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "org_code", length = 64)
	public String getOrgCode() {
		return this.orgCode;
	}
	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	@Column(name = "ip", length = 20)
	public String getIp() {
		return this.ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	@Column(name = "username", length = 20)
	public String getUsername() {
		return this.username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	@Column(name = "password", length = 50)
	public String getPassword() {
		return this.password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@Column(name = "url", length = 200)
	public String getUrl() {
		return this.url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
}

+ 32 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/FunctionService.java

@ -1,16 +1,23 @@
package com.yihu.jw.base.service;
import com.yihu.jw.base.dao.FunctionDao;
import com.yihu.jw.base.dao.ModuleFunctionDao;
import com.yihu.jw.base.model.Function;
import com.yihu.jw.base.model.ModuleFunction;
import com.yihu.jw.base.model.SaasModule;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.base.MFunction;
import com.yihu.jw.restmodel.base.MModule;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
@ -20,6 +27,10 @@ import java.util.List;
public class FunctionService extends BaseJpaService<Function, FunctionDao> {
    @Autowired
    private FunctionDao functionDao;
    @Autowired
    private ModuleFunctionDao moduleFunctionDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public Function createFunction(Function function) throws ApiException {
@ -70,4 +81,25 @@ public class FunctionService extends BaseJpaService<Function, FunctionDao> {
        }
        function.setStatus(-1);
    }
    @Transactional
    public void assignFunction(String moduleCode, String functionCodes) {
        //先删除原来已经分配好的功能
        moduleFunctionDao.deleteByModuleCode(moduleCode);
        //分配新的功能
        String [] functionCodeArr=functionCodes.split(",");
        List<ModuleFunction> saasModuleList=new ArrayList<>();
        for(String functionCode:functionCodeArr){
            ModuleFunction saasModule=new ModuleFunction();
            saasModule.setModuleId(moduleCode);
            saasModule.setFunctionId(functionCode);
            saasModuleList.add(saasModule);
        }
        moduleFunctionDao.save(saasModuleList);
    }
    public List<MFunction> getModuleFunctions(String saasCode) {
        String sql=" select m.code,m.parent_code,m.name from base_function f,base_module_function mf where f.code=mf.function_id and f.status=1 and mf.module_id=?";
        return jdbcTemplate.queryForList(sql,MFunction.class,saasCode);
    }
}

+ 33 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/ModuleService.java

@ -2,17 +2,24 @@ package com.yihu.jw.base.service;
import com.yihu.jw.base.dao.ModuleDao;
import com.yihu.jw.base.dao.ModuleDao;
import com.yihu.jw.base.dao.SaasModuleDao;
import com.yihu.jw.base.model.Module;
import com.yihu.jw.base.model.Module;
import com.yihu.jw.base.model.SaasModule;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.base.MModule;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */
@ -20,6 +27,11 @@ import org.springframework.util.StringUtils;
public class ModuleService extends BaseJpaService<Module, ModuleDao> {
    @Autowired
    private ModuleDao moduleDao;
    @Autowired
    private SaasModuleDao saasModuleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Transactional
    public Module createModule(Module module) throws ApiException {
@ -73,4 +85,25 @@ public class ModuleService extends BaseJpaService<Module, ModuleDao> {
        }
        module.setStatus(-1);
    }
    @Transactional
    public void assignModule(String saasCode, String moduleCodes) {
        //先删除原来已经分配好的模块
        saasModuleDao.deleteBySaasCode(saasCode);
        //分配新的模块
        String [] moduleCodeArr=moduleCodes.split(",");
        List<SaasModule> saasModuleList=new ArrayList<>();
        for(String moduleCode:moduleCodeArr){
            SaasModule saasModule=new SaasModule();
            saasModule.setModuleId(moduleCode);
            saasModule.setSaasId(saasCode);
            saasModuleList.add(saasModule);
        }
        saasModuleDao.save(saasModuleList);
    }
    public List<MModule> getSaasModules(String saasCode) {
        String sql=" select m.code,m.parent_code,m.name from base_module m,base_saas_module sm where m.code=sm.module_id and m.status=1 and sm.saas_id=?";
       return jdbcTemplate.queryForList(sql,MModule.class,saasCode);
    }
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/SaasService.java

@ -68,4 +68,8 @@ public class SaasService extends BaseJpaService<Saas, SaasDao> {
        }
        saas.setStatus(-1);
    }
    public Saas findByName(String cityName) {
        return saasDao.findByName(cityName);
    }
}

+ 72 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsGatewayService.java

@ -0,0 +1,72 @@
package com.yihu.jw.base.service.sms;
import com.yihu.jw.base.dao.sms.SmsGatewayDao;
import com.yihu.jw.base.model.sms.BaseSmsGateway;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.base.sms.BaseSmsContants;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
/**
 * Created by chenweida on 2017/5/22.
 */
@Service
public class SmsGatewayService extends BaseJpaService<BaseSmsGateway, SmsGatewayDao> {
    @Autowired
    private SmsGatewayDao smsGatewayDao;
    @Transactional
    public BaseSmsGateway createSmsGateway(BaseSmsGateway smsGateway) throws ApiException {
        if (StringUtils.isEmpty(smsGateway.getCode())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        BaseSmsGateway smsGatewayTmp = smsGatewayDao.findByName(smsGateway.getName());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
    @Transactional
    public BaseSmsGateway updateSmsGateway(BaseSmsGateway smsGateway) {
        if (StringUtils.isEmpty(smsGateway.getCode())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getName())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(smsGateway.getId())) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        BaseSmsGateway smsGatewayTmp = smsGatewayDao.findByNameExcludeCode(smsGateway.getName(), smsGateway.getCode());
        if (smsGatewayTmp != null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_name_exist, CommonContants.common_error_params_code);
        }
        return smsGatewayDao.save(smsGateway);
    }
    public BaseSmsGateway findByCode(String code) {
        BaseSmsGateway smsGateway = smsGatewayDao.findByCode(code);
        if (smsGateway == null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return smsGateway;
    }
    @Transactional
    public void deleteSmsGateway(String code) {
        BaseSmsGateway smsGateway = smsGatewayDao.findByCode(code);
        if (smsGateway == null) {
            throw new ApiException(BaseSmsContants.SmsGateway.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        smsGateway.setStatus(-1);
    }
}

+ 29 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/sms/SmsService.java

@ -0,0 +1,29 @@
package com.yihu.jw.base.service.sms;
import com.yihu.jw.base.dao.sms.SmsDao;
import com.yihu.jw.base.model.sms.BaseSms;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.restmodel.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * Created by chenweida on 2017/5/22.
 */
@Service
public class SmsService  extends BaseJpaService<BaseSms, SmsDao>{
    @Autowired
    private SmsDao smsDao;
    @Transactional
    public BaseSms createSms(BaseSms sms) throws ApiException {
        return smsDao.save(sms);
    }
    @Transactional
    public BaseSms updateSms(BaseSms sms) {
        return smsDao.save(sms);
    }
}

+ 0 - 10
svr/svr-base/src/main/java/com/yihu/jw/user/service/PatientService.java

@ -1,10 +0,0 @@
package com.yihu.jw.user.service;
import org.springframework.stereotype.Service;
/**
 * Created by chenweida on 2017/5/11.
 */
@Service
public class PatientService {
}

+ 115 - 0
svr/svr-base/src/main/java/com/yihu/jw/util/HttpUtil.java

@ -0,0 +1,115 @@
package com.yihu.jw.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
/*
 * MD5 算法
 */
public class HttpUtil {
	private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
	/**
	 * 向指定URL发送GET方法的请求
	 *
	 * @param url
	 *            发送请求的URL
	 * @param param
	 *            请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
	 * @return URL 所代表远程资源的响应结果
	 */
	public static String sendGet(String url, String param) {
		String result = "";
		BufferedReader in = null;
		try {
			String urlNameString = url + "?" + param;
			URL realUrl = new URL(urlNameString);
			// 打开和URL之间的连接
			URLConnection connection = realUrl.openConnection();
			// 设置通用的请求属性
			connection.setRequestProperty("accept", "*/*");
			connection.setRequestProperty("connection", "Keep-Alive");
			connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
			// 建立实际的连接
			connection.connect();
			// 定义 BufferedReader输入流来读取URL的响应
			in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			String line;
			while ((line = in.readLine()) != null) {
				result += line;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (in != null) {
					in.close();
				}
			} catch (Exception e2) {
				e2.printStackTrace();
			}
		}
		return result;
	}
	/**
	 * 向指定 URL 发送POST方法的请求
	 *
	 * @param url
	 *            发送请求的 URL带上参数
	 * @param param
	 *            POST参数。
	 * @return 所代表远程资源的响应结果
	 */
	public static String sendPost(String url, String param) {
		StringBuffer buffer = new StringBuffer();
		PrintWriter out = null;
		BufferedReader in = null;
		HttpURLConnection conn = null;
		try {
			URL realUrl = new URL(url);
			// 打开和URL之间的连接
			conn = (HttpURLConnection) realUrl.openConnection();
			conn.setRequestMethod("POST");
			conn.setConnectTimeout(5000);
			conn.setDoOutput(true);
			conn.setDoInput(true);
			conn.setUseCaches(false);
			conn.setRequestProperty("Content-Type", "application/text");
			conn.setRequestProperty("accept", "*/*");
			conn.setRequestProperty("connection", "Keep-Alive");
			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
			OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
			osw.write(param.toString());
			osw.flush();
			// 读取返回内容
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
			String temp;
			while ((temp = br.readLine()) != null) {
				buffer.append(temp);
				buffer.append("\n");
			}
		} catch (Exception e) {
			logger.error("push message error:", e);
		} finally {
			try {
				if (out != null) {
					out.close();
				}
				if (in != null) {
					in.close();
				}
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}
		return buffer.toString();
	}
}

+ 109 - 0
svr/svr-base/src/main/java/com/yihu/jw/util/MessageUtil.java

@ -0,0 +1,109 @@
package com.yihu.jw.util;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/5/23 0023.
 */
public class MessageUtil {
    /**
     * 返回消息类型:文本
     */
    public static final String RESP_MESSAGE_TYPE_TEXT = "text";
    /**
     * 返回消息类型:音乐
     */
    public static final String RESP_MESSAGE_TYPE_MUSIC = "music";
    /**
     * 返回消息类型:图文
     */
    public static final String RESP_MESSAGE_TYPE_NEWS = "news";
    /**
     * 请求消息类型:文本
     */
    public static final String REQ_MESSAGE_TYPE_TEXT = "text";
    /**
     * 请求消息类型:图片
     */
    public static final String REQ_MESSAGE_TYPE_IMAGE = "image";
    /**
     * 请求消息类型:链接
     */
    public static final String REQ_MESSAGE_TYPE_LINK = "link";
    /**
     * 请求消息类型:地理位置
     */
    public static final String REQ_MESSAGE_TYPE_LOCATION = "location";
    /**
     * 请求消息类型:音频
     */
    public static final String REQ_MESSAGE_TYPE_VOICE = "voice";
    /**
     * 请求消息类型:推送
     */
    public static final String REQ_MESSAGE_TYPE_EVENT = "event";
    /**
     * 事件类型:subscribe(订阅)
     */
    public static final String EVENT_TYPE_SUBSCRIBE = "subscribe";
    /**
     * 事件类型:unsubscribe(取消订阅)
     */
    public static final String EVENT_TYPE_UNSUBSCRIBE = "unsubscribe";
    /**
     * 事件类型:CLICK(自定义菜单点击事件)
     */
    public static final String EVENT_TYPE_CLICK = "CLICK";
    /**
     * 解析微信发来的请求(XML)
     *
     * @param request
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public static Map<String, String> parseXml(HttpServletRequest request) throws Exception {
        // 将解析结果存储在HashMap中
        Map<String, String> map = new HashMap<String, String>();
        // 从request中取得输入流
        InputStream inputStream = request.getInputStream();
        // 读取输入流
        SAXReader reader = new SAXReader();
        Document document = reader.read(inputStream);
        // 得到xml根元素
        Element root = document.getRootElement();
        // 得到根元素的所有子节点
        List<Element> elementList = root.elements();
        // 遍历所有子节点
        for (Element e : elementList)
            map.put(e.getName(), e.getText());
        // 释放资源
        inputStream.close();
        inputStream = null;
        return map;
    }
}

+ 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;
    }
}

+ 120 - 5
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WechatController.java

@ -1,14 +1,129 @@
package com.yihu.jw.wx.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.wx.MWxWechat;
import com.yihu.jw.restmodel.wx.WxContants;
import com.yihu.jw.wx.model.WxWechat;
import com.yihu.jw.wx.service.WechatService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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;
/**
 * Created by chenweida on 2017/5/11.
 */
@RestController
@RequestMapping("/wechat")
@Api(description = "微信相关操作")
public class WechatController {
@RequestMapping(WxContants.Wechat.api_common)
@Api(value = "微信相关操作", description = "微信相关操作")
public class WechatController extends EnvelopRestController {
    @Autowired
    private WechatService wechatService;
    @PostMapping(value = WxContants.Wechat.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信配置", notes = "创建微信配置")
    public Envelop createWechat(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxWechat wechat = toEntity(jsonData, WxWechat.class);
            return Envelop.getSuccess(WxContants.Wechat.message_success_create, wechatService.createWechat(wechat));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WxContants.Wechat.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信配置", notes = "修改微信配置")
    public Envelop updateWechat(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxWechat Wechat = toEntity(jsonData, WxWechat.class);
            return Envelop.getSuccess(WxContants.Wechat.message_success_update, wechatService.updateWxchat(Wechat));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WxContants.Wechat.api_delete)
    @ApiOperation(value = "删除微信配置", notes = "删除微信配置")
    public Envelop deleteWechat(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wechatService.deleteWechat(code);
            return Envelop.getSuccess(WxContants.Wechat.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WxContants.Wechat.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(WxContants.Wechat.message_success_find, wechatService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WxContants.Wechat.api_getWechats, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信配置列表(分页)")
    public Envelop getWechats(
            @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<WxWechat> list = wechatService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wechatService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MWxWechat> mWxWechats = convertToModels(list, new ArrayList<>(list.size()), MWxWechat.class, fields);
        return Envelop.getSuccessListWithPage(WxContants.Wechat.message_success_find_functions,mWxWechats, page, size,count);
    }
    @GetMapping(value = WxContants.Wechat.api_getWechatNoPage)
    @ApiOperation(value = "获取微信列表配置,不分页")
    public Envelop getWechatNoPage(
            @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<WxWechat> list = wechatService.search(fields,filters,sorts);
        //封装返回格式
        List<MWxWechat> mWxWechats = convertToModels(list, new ArrayList<>(list.size()), MWxWechat.class, fields);
        return Envelop.getSuccessList(WxContants.Wechat.message_success_find_functions,mWxWechats);
    }
}

+ 47 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxAccessTokenController.java

@ -0,0 +1,47 @@
package com.yihu.jw.wx.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.wx.WxContants;
import com.yihu.jw.wx.model.WxAccessToken;
import com.yihu.jw.wx.service.WxAccessTokenService;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by cyx on 2017/5/11.
 */
@RestController
@RequestMapping(WxContants.WxAccessToken.api_common)
@Api(value = "微信token模块", description = "微信token模块接口管理")
public class WxAccessTokenController extends EnvelopRestController {
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    /**
     * 根据wechatCode获取WxAccessToken
     * @param wechatCode
     * @return MWxAccessToken
     * @throws Exception
     */
    @GetMapping(value = WxContants.WxAccessToken.api_get)
    @ApiOperation(value = "根据wechatCode获取最新的WxAccessToken")
    public Envelop getWxAccessToken(
            @ApiParam(name = "wechatCode", value = "wechatCode")
            @RequestParam(value = "wechatCode") String wechatCode) {
        try {
            WxAccessToken wxAccessToken = wxAccessTokenService.getWxAccessTokenByCode(wechatCode);
            return Envelop.getSuccess(WxContants.WxAccessToken.message_success_get, wxAccessToken);
        }catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

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

@ -0,0 +1,155 @@
package com.yihu.jw.wx.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.wx.MWxGraphicMessage;
import com.yihu.jw.restmodel.wx.WxContants;
import com.yihu.jw.wx.model.WxGraphicMessage;
import com.yihu.jw.wx.service.WxGraphicMessageService;
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;
/**
 *   2017/5/11.
 */
@RestController
@RequestMapping(WxContants.WxGraphicMessage.api_common)
@Api(value = "微信图文相关操作", description = "微信图文相关操作")
public class WxGraphicMessageController extends EnvelopRestController {
    @Autowired
    private WxGraphicMessageService wxGraphicMessageService;
    @PostMapping(value = WxContants.WxGraphicMessage.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信图文消息", notes = "创建微信图文消息")
    public Envelop createWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxGraphicMessage WxGraphicMessage = toEntity(jsonData, WxGraphicMessage.class);
            return Envelop.getSuccess(WxContants.WxGraphicMessage.message_success_create, wxGraphicMessageService.createWxGraphicMessage(WxGraphicMessage));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WxContants.WxGraphicMessage.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信图文消息", notes = "修改微信图文消息")
    public Envelop updateWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxGraphicMessage WxGraphicMessage = toEntity(jsonData, WxGraphicMessage.class);
            return Envelop.getSuccess(WxContants.WxGraphicMessage.message_success_update, wxGraphicMessageService.updateWxGraphicMessage(WxGraphicMessage));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WxContants.WxGraphicMessage.api_delete)
    @ApiOperation(value = "删除微信图文消息", notes = "删除微信图文消息")
    public Envelop deleteWxGraphicMessage(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wxGraphicMessageService.deleteWxGraphicMessage(code);
            return Envelop.getSuccess(WxContants.WxGraphicMessage.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WxContants.WxGraphicMessage.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(WxContants.WxGraphicMessage.message_success_find, wxGraphicMessageService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WxContants.WxGraphicMessage.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 {
        //得到list数据
        List<WxGraphicMessage> list = wxGraphicMessageService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wxGraphicMessageService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MWxGraphicMessage> mWxGraphicMessages = convertToModels(list, new ArrayList<>(list.size()), MWxGraphicMessage.class, fields);
        return Envelop.getSuccessListWithPage(WxContants.WxGraphicMessage.message_success_find_functions,mWxGraphicMessages, page, size,count);
    }
    @GetMapping(value = WxContants.WxGraphicMessage.api_getWxGraphicMessageNoPage)
    @ApiOperation(value = "获取图文消息列表,不分页")
    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 {
        //得到list数据
        List<WxGraphicMessage> list = wxGraphicMessageService.search(fields,filters,sorts);
        //封装返回格式
        List<MWxGraphicMessage> mWxGraphicMessages = convertToModels(list, new ArrayList<>(list.size()), MWxGraphicMessage.class, fields);
        return Envelop.getSuccessList(WxContants.WxGraphicMessage.message_success_find_functions,mWxGraphicMessages);
    }
    //@GetMapping(value = WlyyContants.WxGraphicMessage.api_sendGraphicMessages)
    //@ApiOperation(value = "发送图文消息")
    //public Envelop sendGraphicMessages(
    //        @ApiParam(name = "codes", value = "根据code发送微信图文消息,多个code用,分割")
    //        @RequestParam(value = "codes", required = true) String codes,HttpServletRequest request) throws Exception {
    //    String messages = wxGraphicMessageService.sendGraphicMessages(codes, request);
    //    return Envelop.getSuccess("成功",messages);
    //}
    @GetMapping(value = WxContants.WxGraphicMessage.api_sendGraphicMessages)
    @ApiOperation(value = "发送图文消息")
    @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 {
        String messages = wxGraphicMessageService.sendGraphicMessages(codes, fromUserName,toUserName);
        return messages;
    }
}

+ 154 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxMenuController.java

@ -0,0 +1,154 @@
package com.yihu.jw.wx.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.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;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
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;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@RestController
@RequestMapping(WxContants.WxMenu.api_common)
@Api(value = "微信菜单相关操作", description = "微信菜单相关操作")
public class WxMenuController extends EnvelopRestController {
    @Autowired
    private WxMenuService wxMenuService;
    @PostMapping(value = WxContants.WxMenu.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "添加微信菜单", notes = "添加微信菜单")
    public Envelop createWxMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxMenu wxMenu = toEntity(jsonData, WxMenu.class);
            return Envelop.getSuccess(WxContants.WxMenu.message_success_create, wxMenuService.createWxMenu(wxMenu));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WxContants.WxMenu.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信菜单", notes = "修改微信菜单")
    public Envelop updateWxMenu(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxMenu wxMenu = toEntity(jsonData, WxMenu.class);
            return Envelop.getSuccess(WxContants.WxMenu.message_success_update, wxMenuService.updateWxMenu(wxMenu));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WxContants.WxMenu.api_delete)
    @ApiOperation(value = "删除微信菜单", notes = "删除微信菜单")
    public Envelop deleteWxMenu(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wxMenuService.deleteWxMenu(code);
            return Envelop.getSuccess(WxContants.WxMenu.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WxContants.WxMenu.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(WxContants.WxMenu.message_success_find, wxMenuService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WxContants.WxMenu.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 {
        //得到list数据
        List<WxWechat> list = wxMenuService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wxMenuService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MWxMenu> mWxMenus = convertToModels(list, new ArrayList<>(list.size()), MWxMenu.class, fields);
        return Envelop.getSuccessListWithPage(WxContants.WxMenu.message_success_find_functions,mWxMenus, page, size,count);
    }
    @GetMapping(value = WxContants.WxMenu.api_getWxMenuNoPage)
    @ApiOperation(value = "获取微信菜单列表,不分页")
    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 {
        //得到list数据
        List<WxMenu> list = wxMenuService.search(fields,filters,sorts);
        //封装返回格式
        List<MWxMenu> mWxMenus = convertToModels(list, new ArrayList<>(list.size()), MWxMenu.class, fields);
        return Envelop.getSuccessList(WxContants.WxMenu.message_success_find_functions,mWxMenus);
    }
    /**
     * 创建微信公众号菜单
     *
     * @return
     */
    @ApiOperation(value = "创建微信公众号菜单", notes = "创建微信公众号菜单")
    @RequestMapping(value = WxContants.WxMenu.api_createMenu ,method = RequestMethod.GET)
    public Envelop createWechatMenu(
            @ApiParam(name = "wechatCode", value = "", defaultValue = "")
            @RequestParam(value = "wechatCode", required = true)String wechatCode){
        try{
            JSONObject result = wxMenuService.createWechatMenu(wechatCode);
            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 );
        }
    }
}

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

@ -0,0 +1,166 @@
package com.yihu.jw.wx.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.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;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
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;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@RestController
@RequestMapping(WxContants.WxTemplate.api_common)
@Api(value = "微信模版相关操作", description = "微信模版相关操作")
public class WxTemplateController extends EnvelopRestController {
    @Autowired
    private WxTemplateService wxTemplateService;
    @PostMapping(value = WxContants.WxTemplate.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信模版", notes = "创建微信模版")
    public Envelop createWxTemplate(
            @ApiParam(name = "json_data", value = "微信模版json字符串")
            @RequestBody String jsonData) {
        try {
            WxTemplate WxTemplate = toEntity(jsonData, WxTemplate.class);
            return Envelop.getSuccess(WxContants.WxTemplate.message_success_create, wxTemplateService.createWxTemplate(WxTemplate));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @PutMapping(value = WxContants.WxTemplate.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信模版", notes = "修改微信模版")
    public Envelop updateWxTemplate(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        try {
            WxTemplate WxTemplate = toEntity(jsonData, WxTemplate.class);
            return Envelop.getSuccess(WxContants.WxTemplate.message_success_update, wxTemplateService.updateWxTemplate(WxTemplate));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @DeleteMapping(value = WxContants.WxTemplate.api_delete)
    @ApiOperation(value = "删除微信模版", notes = "删除微信模版")
    public Envelop deleteWxTemplate(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wxTemplateService.deleteWxTemplate(code);
            return Envelop.getSuccess(WxContants.WxTemplate.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @GetMapping(value = WxContants.WxTemplate.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(WxContants.WxTemplate.message_success_find, wxTemplateService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
    @RequestMapping(value = WxContants.WxTemplate.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 {
        //得到list数据
        List<WxTemplate> list = wxTemplateService.search(fields, filters, sorts, page, size);
        //获取总数
        long count=wxTemplateService.getCount(filters);
        //封装头信息
        pagedResponse(request, response, count, page, size);
        //封装返回格式
        List<MWxTemplate> mWxWechats = convertToModels(list, new ArrayList<>(list.size()), MWxTemplate.class, fields);
        return Envelop.getSuccessListWithPage(WxContants.WxTemplate.message_success_find_functions,mWxWechats, page, size,count);
    }
    @GetMapping(value = WxContants.WxTemplate.api_getWxTemplatesNoPage)
    @ApiOperation(value = "获取微信模版列表(不分页)")
    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 {
        //得到list数据
        List<WxTemplate> list = wxTemplateService.search(fields,filters,sorts);
        //封装返回格式
        List<MWxTemplate> mMWxTemplates = convertToModels(list, new ArrayList<>(list.size()), MWxTemplate.class, fields);
        return Envelop.getSuccessList(WxContants.WxTemplate.message_success_find_functions,mMWxTemplates);
    }
    @GetMapping(value = WxContants.WxTemplate.api_sendTemplateMessage)
    @ApiOperation(value = "发送微信模板消息")
    @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
    ){
        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);
        }
    }
}

+ 26 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WechatDao.java

@ -0,0 +1,26 @@
package com.yihu.jw.wx.dao;
import com.yihu.jw.wx.model.WxWechat;
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/5/20 0020.
 */
public interface WechatDao extends PagingAndSortingRepository<WxWechat, Long>, JpaSpecificationExecutor<WxWechat> {
    @Query("from WxWechat w where w.appId = ?1 and w.status!=-1")
    WxWechat findByAppId(String appId);
    @Query("from WxWechat w where w.appId = ?1 and w.code!= ?2 and w.status!=-1")
    WxWechat findByAppIdExcludeCode(String appId, String code);
    @Query("from WxWechat w where w.code =?1 and w.status!=-1")
    WxWechat findByCode(String code);
    @Query("from WxWechat w where w.id = ?1 and w.status!=-1")
    WxWechat findById(Long id);
}

+ 19 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxAccessTokenDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.wx.dao;
import com.yihu.jw.base.model.Function;
import com.yihu.jw.wx.model.WxAccessToken;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by Administrator on 2017/5/18 0018.
 */
public interface WxAccessTokenDao extends PagingAndSortingRepository<WxAccessToken, Long>, JpaSpecificationExecutor<WxAccessToken> {
    @Query("from WxAccessToken w where w.wechatCode =?1 order by w.addTimestamp desc")
    List<WxAccessToken> getWxAccessTokenByCode(String wechatCode);
}

+ 25 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxGraphicMessageDao.java

@ -0,0 +1,25 @@
package com.yihu.jw.wx.dao;
import com.yihu.jw.wx.model.WxGraphicMessage;
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/5/20 0020.
 */
public interface WxGraphicMessageDao extends PagingAndSortingRepository<WxGraphicMessage, Long>, JpaSpecificationExecutor<WxGraphicMessage> {
    @Query("from WxWechat w where w.appId = ?1 and w.status!=-1")
    WxGraphicMessage findByAppId(String appId);
    @Query("from WxWechat w where w.appId = ?1 and w.code!= ?2 and w.status!=-1")
    WxGraphicMessage findByAppIdExcludeCode(String appId, String code);
    @Query("from WxGraphicMessage w where w.code =?1 and w.status!=-1")
    WxGraphicMessage findByCode(String code);
    @Query("from WxGraphicMessage w where w.id =?1 and w.status!=-1")
    WxGraphicMessage findById(Long id);
}

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

@ -0,0 +1,46 @@
package com.yihu.jw.wx.dao;
import com.yihu.jw.wx.model.WxMenu;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
public interface WxMenuDao  extends PagingAndSortingRepository<WxMenu, Long>, JpaSpecificationExecutor<WxMenu> {
    @Query("from WxMenu m where m.code = ?1 and m.status = 1")
    WxMenu findByCode(String code);
    @Query("from WxMenu m where m.id = ?1 and m.status = 1")
    WxMenu findById(Long id);
    @Query("from WxMenu m where m.wechatCode =?1 and m.status = 1 order  by m.supMenucode ,m.sort")
    List<WxMenu> findByWechatCode(String wechatCode);
    @Query("from WxMenu m where m.wechatCode = ?1 and  m.supMenucode= ?2 and m.status =1 order by m.sort")
    List<WxMenu> findChildMenus(String wechatCode, String sup_menucode);
    /**
     * 根据wechatCode判断父菜单的sort是否重复
     * @param wechatCode
     * @param sort
     */
    @Query("from WxMenu m where m.wechatCode = ?1 and m.status =1 and m.sort =?2 and m.supMenucode is null and m.code != ?3")
    WxMenu findByWechatCodeExcludeSortFromParent(String wechatCode, Integer sort,String code);
    /**
     * 根据wechatCode,supMenucode判断子菜单的sort是否重复
     * @param wechatCode
     * @param sort
     */
    @Query("from WxMenu m where m.wechatCode = ?1 and m.status =1 and m.sort =?2 and m.supMenucode =?3 and m.code != ?4")
    WxMenu findByWechatCodeExcludeSortFromChild(String wechatCode, Integer sort,String supMenucode,String code);
    @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);
}

+ 19 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxTemplateDao.java

@ -0,0 +1,19 @@
package com.yihu.jw.wx.dao;
import com.yihu.jw.wx.model.WxTemplate;
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/5/20 0020.
 */
public interface WxTemplateDao extends PagingAndSortingRepository<WxTemplate, Long>, JpaSpecificationExecutor<WxTemplate> {
    @Query("from WxTemplate w where w.code = ?1 and w.status =1")
    WxTemplate findByCode(String code);
    @Query("from WxTemplate w where w.id = ?1 and w.status =1")
    WxTemplate findById(Long id);
}

+ 30 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/model/Miniprogram.java

@ -0,0 +1,30 @@
package com.yihu.jw.wx.model;
import java.io.Serializable;
/**
 * Created by Administrator on 2017/5/24 0024.
 */
public class Miniprogram implements Serializable{
    private static final long serialVersionUID = -7963058957081033262L;
    private String appid;
    private String pagepath;
    public String getAppid() {
        return appid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    public String getPagepath() {
        return pagepath;
    }
    public void setPagepath(String pagepath) {
        this.pagepath = pagepath;
    }
}

+ 58 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WechatTemplate.java

@ -0,0 +1,58 @@
package com.yihu.jw.wx.model;
import java.io.Serializable;
import java.util.Map;
/**
 * 微信消息模板推送内容
 * @author George
 */
public class WechatTemplate implements Serializable {
	private static final long serialVersionUID = 3877107913397496785L;
    private String touser;//用户openId
    private String template_id;//模板消息id
    private String url;//URL置空,则在发送后,点击模板消息会进入一个空白页面(ios),或无法点击(android)
    private Miniprogram miniprogram;
    private Map<String,WechatTemplateData> data;//详细内容
    public Miniprogram getMiniprogram() {
        return miniprogram;
    }
    public void setMiniprogram(Miniprogram miniprogram) {
        this.miniprogram = miniprogram;
    }
    
    public String getTemplate_id() {
        return template_id;
    }
    public void setTemplate_id(String template_id) {
        this.template_id = template_id;
    }
    public String getTouser() {
        return touser;
    }
    public void setTouser(String touser) {
        this.touser = touser;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public Map<String, WechatTemplateData> getData() {
        return data;
    }
    public void setData(Map<String, WechatTemplateData> data) {
        this.data = data;
    }
    
}

+ 31 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WechatTemplateData.java

@ -0,0 +1,31 @@
package com.yihu.jw.wx.model;
import java.io.Serializable;
/**
 * 微信消息模板
 * @author George
 */
public class WechatTemplateData implements Serializable {
	private static final long serialVersionUID = -7399054549159698617L;
	private String value;
    private String color;
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getColor() {
        return color;
    }
    public void setColor(String color) {
        this.color = color;
    }
}

+ 18 - 22
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxAccessToken.java

@ -1,33 +1,31 @@
package com.yihu.jw.wx.model;// default package
import java.util.Date;
import com.yihu.jw.base.model.base.IdEntity;
import javax.persistence.*;
import java.util.Date;
/**
 * 微信 accesstoken表
 */
@Entity
@Table(name = "wx_access_token")
public class WxAccessToken implements java.io.Serializable {
public class WxAccessToken extends IdEntity implements java.io.Serializable {
	// Fields
	private Integer id;//业务id
	private String code;//业务code
	private String wechatCode;//关联的微信code 关联表 Wx_Wechat
	private String accessToken;//调用微信返回的accesstoken
	private long addTimestamp;//创建时间
	private Integer expiresIn;//凭证有效时间(秒)
	private long expiresIn;//凭证有效时间(秒)
	private Date czrq;//操作时间
	// Constructors
	/** default constructor */
	public WxAccessToken() {
	}
	/** minimal constructor */
	public WxAccessToken(Integer id, String accessToken, long addTimestamp,
			Integer expiresIn, Date czrq) {
	public WxAccessToken(Long id, String accessToken, long addTimestamp,
			long expiresIn, Date czrq) {
		this.id = id;
		this.accessToken = accessToken;
		this.addTimestamp = addTimestamp;
@ -35,10 +33,11 @@ public class WxAccessToken implements java.io.Serializable {
		this.czrq = czrq;
	}
	/** full constructor */
	public WxAccessToken(Integer id, String wechatCode, String accessToken,
			long addTimestamp, Integer expiresIn, Date czrq) {
	// Constructors
	public WxAccessToken(Long id, String code, String wechatCode, String accessToken, long addTimestamp, Integer expiresIn, Date czrq) {
		this.id = id;
		this.code = code;
		this.wechatCode = wechatCode;
		this.accessToken = accessToken;
		this.addTimestamp = addTimestamp;
@ -46,15 +45,12 @@ public class WxAccessToken implements java.io.Serializable {
		this.czrq = czrq;
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	public String getCode() {
		return code;
	}
	public void setId(Integer id) {
		this.id = id;
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "wechat_code", length = 64)
@ -85,11 +81,11 @@ public class WxAccessToken implements java.io.Serializable {
	}
	@Column(name = "expires_in", nullable = false)
	public Integer getExpiresIn() {
	public Long getExpiresIn() {
		return this.expiresIn;
	}
	public void setExpiresIn(Integer expiresIn) {
	public void setExpiresIn(Long expiresIn) {
		this.expiresIn = expiresIn;
	}

+ 167 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxGraphicMessage.java

@ -0,0 +1,167 @@
package com.yihu.jw.wx.model;
import com.yihu.jw.base.model.base.IdEntity;
import javax.persistence.*;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/21 0021.
 */
@Entity
@Table(name = "wx_graphic_message")
public class WxGraphicMessage extends IdEntity implements java.io.Serializable {
    private String code;//业务code
    private String title;//标题
    private String description;//描述
    private String url;//图文消息url值
    private String picUrl;//图片地址
    private String createUser;//创建人
    private String createUserName;//创建人名
    private Date createTime;//创建时间
    private String updateUser;//修改人
    private String updateUserName;//修改人名称
    private Date updateTime;//修改时间
    private String remark;//备注
    private Integer status;  //状态 -1删除 0 冻结 1可用
    public WxGraphicMessage() {
    }
    public WxGraphicMessage(String code, String title, String description, String url, String picUrl, String createUser, String createUserName, Date createTime, String updateUser, String updateUserName, Date updateTime, String remark, Integer status) {
        this.code = code;
        this.title = title;
        this.description = description;
        this.url = url;
        this.picUrl = picUrl;
        this.createUser = createUser;
        this.createUserName = createUserName;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateUserName = updateUserName;
        this.updateTime = updateTime;
        this.remark = remark;
        this.status = status;
    }
    @Column(name = "code", length = 64)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "title", length = 200)
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    @Column(name = "description", length = 2000)
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    @Column(name = "url", length = 2000)
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @Column(name = "pic_url", length = 2000)
    public String getPicUrl() {
        return picUrl;
    }
    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }
    @Column(name = "create_user", length = 200)
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name", length = 200)
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time", length = 0)
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "update_user", length = 200)
    public String getUpdateUser() {
        return updateUser;
    }
    @Column(name = "remark", length = 1000)
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    @Column(name = "update_user_name", length = 200)
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time", length = 0)
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Column(name = "remark", length = 1000)
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 203 - 159
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxMenu.java

@ -1,170 +1,214 @@
package com.yihu.jw.wx.model;// default package
import java.util.Date;
import com.yihu.jw.base.model.base.IdEntity;
import javax.persistence.*;
import java.util.Date;
/**
 * 微信 菜单表
 */
@Entity
@Table(name = "wx_menu")
public class WxMenu implements java.io.Serializable {
	// Fields
	private Integer id;//菜单id
	private String wechatCode;//关联的微信code 关联表 Wx_Wechat
	private String supMenucode;//父菜单id 如果是一级菜单 此字段为空
	private String type;//菜单类型 1 view 2click
	private String name;//菜单名称
	private Integer sort;//菜单排序 父菜单排序 不包含子菜单那
	private String url;//url
	private String updateUser;//更新人
	private Date updateTime;//更新时间
	private Date createTime;//创建时间
	private String createUser;//创建人
	private String remark;//备注
	// Constructors
	/** default constructor */
	public WxMenu() {
	}
	/** minimal constructor */
	public WxMenu(Integer id) {
		this.id = id;
	}
	/** full constructor */
	public WxMenu(Integer id, String wechatCode, String supMenucode,
			String type, String name, Integer sort, String url,
			String updateUser, Date updateTime, Date createTime,
			String createUser, String remark) {
		this.id = id;
		this.wechatCode = wechatCode;
		this.supMenucode = supMenucode;
		this.type = type;
		this.name = name;
		this.sort = sort;
		this.url = url;
		this.updateUser = updateUser;
		this.updateTime = updateTime;
		this.createTime = createTime;
		this.createUser = createUser;
		this.remark = remark;
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "wechat_code", length = 200)
	public String getWechatCode() {
		return this.wechatCode;
	}
	public void setWechatCode(String wechatCode) {
		this.wechatCode = wechatCode;
	}
	@Column(name = "sup_menucode", length = 200)
	public String getSupMenucode() {
		return this.supMenucode;
	}
	public void setSupMenucode(String supMenucode) {
		this.supMenucode = supMenucode;
	}
	@Column(name = "type", length = 20)
	public String getType() {
		return this.type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "sort")
	public Integer getSort() {
		return this.sort;
	}
	public void setSort(Integer sort) {
		this.sort = sort;
	}
	@Column(name = "url", length = 1000)
	public String getUrl() {
		return this.url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	@Column(name = "update_user", length = 50)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "create_user", length = 50)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
public class WxMenu extends IdEntity implements java.io.Serializable {
    private String code;//业务code
    private String wechatCode;//关联的微信code 关联表 Wx_Wechat
    private String supMenucode;//父菜单id 如果是一级菜单 此字段为空
    private String type;//菜单类型
    private String name;//菜单名称
    private String menuKey;//click等点击类型必须
    private Integer sort;//菜单排序 父菜单排序 不包含子菜单那
    private String url;//url
    private String mediaId;//点用新增永久素材接口返回的合法media_id
    private String appid;//小程序的appid
    private String pagepath;//小程序的页面程序
    private String updateUser;//更新人
    private Date updateTime;//更新时间
    private Date createTime;//创建时间
    private String createUser;//创建人
    private String remark;//备注
    private Integer status; //状态 -1删除 0 冻结 1可用
    /**
     * 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.menuKey = menuKey;
        this.sort = sort;
        this.url = url;
        this.mediaId = mediaId;
        this.appid = appid;
        this.pagepath = pagepath;
        this.updateUser = updateUser;
        this.updateTime = updateTime;
        this.createTime = createTime;
        this.createUser = createUser;
        this.remark = remark;
        this.status = status;
    }
    @Column(name="menu_key")
    public String getMenuKey() {
        return menuKey;
    }
    public void setMenuKey(String menuKey) {
        this.menuKey = menuKey;
    }
    public String getMediaId() {
        return mediaId;
    }
    @Column(name = "media_id", length = 200)
    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }
    public String getAppid() {
        return appid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    public String getPagepath() {
        return pagepath;
    }
    public void setPagepath(String pagepath) {
        this.pagepath = pagepath;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public Integer getStatus() {
        return status;
    }
    // Constructors
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "wechat_code", length = 200)
    public String getWechatCode() {
        return this.wechatCode;
    }
    public void setWechatCode(String wechatCode) {
        this.wechatCode = wechatCode;
    }
    @Column(name = "sup_menucode", length = 200)
    public String getSupMenucode() {
        return this.supMenucode;
    }
    public void setSupMenucode(String supMenucode) {
        this.supMenucode = supMenucode;
    }
    @Column(name = "type", length = 20)
    public String getType() {
        return this.type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "name", length = 200)
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "sort")
    public Integer getSort() {
        return this.sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    @Column(name = "url", length = 1000)
    public String getUrl() {
        return this.url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    @Column(name = "update_user", length = 50)
    public String getUpdateUser() {
        return this.updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time", length = 0)
    public Date getUpdateTime() {
        return this.updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time", length = 0)
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "create_user", length = 50)
    public String getCreateUser() {
        return this.createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "remark", length = 1000)
    public String getRemark() {
        return this.remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 185 - 146
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxTemplate.java

@ -1,157 +1,196 @@
package com.yihu.jw.wx.model;// default package
import java.util.Date;
import com.yihu.jw.base.model.base.IdEntity;
import javax.persistence.*;
import java.util.Date;
/**
 * WxTemplate entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "wx_template")
public class WxTemplate implements java.io.Serializable {
	// Fields
	private Integer id;//模板id
	private String code;//模板code
	private String name;//模板名称
	private String wechatCode;//关联的微信code 关联表 Wx_Wechat
	private String templateCode;//微信的模板code
	private String value;//模板值
	private String createUser;//创建人
	private String createUserName;//创建人名
	private Date createTime;//创建时间
	private String updateUser;//修改人
	private String updateUserName;//修改人名称
	private Date updateTime;//修改时间
	private String remark;
	// Constructors
	/** default constructor */
	public WxTemplate() {
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 64)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "wechat_code", length = 64)
	public String getWechatCode() {
		return this.wechatCode;
	}
	public void setWechatCode(String wechatCode) {
		this.wechatCode = wechatCode;
	}
	@Column(name = "template_code", length = 100)
	public String getTemplateCode() {
		return this.templateCode;
	}
	public void setTemplateCode(String templateCode) {
		this.templateCode = templateCode;
	}
	@Column(name = "value", length = 2000)
	public String getValue() {
		return this.value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	@Column(name = "create_user", length = 200)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 200)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "update_user", length = 200)
	public String geUpdateUser() {
		return this.updateUser;
	}
	public void seUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 200)
	public String geUpdateUserName() {
		return this.updateUserName;
	}
	public void seUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date geUpdateTime() {
		return this.updateTime;
	}
	public void seUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
public class WxTemplate extends IdEntity implements java.io.Serializable {
    // Fields
    private String code;//模板code
    private String title;//模板标题
    private String wechatCode;//关联的微信code 关联表 Wx_Wechat
    private String templateId;//微信模板id
    private String content;//模板内容
    private String createUser;//创建人
    private String createUserName;//创建人名
    private Date createTime;//创建时间
    private String updateUser;//修改人
    private String updateUserName;//修改人名称
    private Date updateTime;//修改时间
    private String remark;
    private Integer status;  //状态 -1删除 0 冻结 1可用
    public WxTemplate(String code, String title, String wechatCode, String templateId, String content, String createUser, String createUserName, Date createTime, String updateUser, String updateUserName, Date updateTime, String remark, Integer status) {
        this.code = code;
        this.title = title;
        this.wechatCode = wechatCode;
        this.templateId = templateId;
        this.content = content;
        this.createUser = createUser;
        this.createUserName = createUserName;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateUserName = updateUserName;
        this.updateTime = updateTime;
        this.remark = remark;
        this.status = status;
    }
    /**
     * default constructor
     */
    public WxTemplate() {
    }
    @Column(name = "title")
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    @Column(name="wechat_code")
    public String getWechatCode() {
        return wechatCode;
    }
    public void setWechatCode(String wechatCode) {
        this.wechatCode = wechatCode;
    }
    @Column(name="template_id")
    public String getTemplateId() {
        return templateId;
    }
    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }
    @Column(name="content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getUpdateUser() {
        return updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    public String getUpdateUserName() {
        return updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getStatus() {
        return status;
    }
    // Constructors
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "code", length = 64)
    public String getCode() {
        return this.code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "create_user", length = 200)
    public String getCreateUser() {
        return this.createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name", length = 200)
    public String getCreateUserName() {
        return this.createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time", nullable = false, length = 0)
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "update_user", length = 200)
    public String geUpdateUser() {
        return this.updateUser;
    }
    public void seUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    @Column(name = "update_user_name", length = 200)
    public String geUpdateUserName() {
        return this.updateUserName;
    }
    public void seUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time", nullable = false, length = 0)
    public Date geUpdateTime() {
        return this.updateTime;
    }
    public void seUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Column(name = "remark", length = 1000)
    public String getRemark() {
        return this.remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 212 - 216
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxWechat.java

@ -1,227 +1,223 @@
package com.yihu.jw.wx.model;// default package
import java.util.Date;
import com.yihu.jw.base.model.base.IdEntity;
import javax.persistence.*;
import java.util.Date;
/**
 * WxWechat entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "wx_wechat")
public class WxWechat implements java.io.Serializable {
	// Fields
	private Integer id;//'主键
	private String code;//业务code
	private String saasId;//'saas配置id'
	private String weichatId;//微信的id
	private String name;//名称
	private String status;//'类型 -1 已删除 0待审核 1审核通过 2 审核不通过'
	private String type;//'1:服务号 2 订阅号
	private String appId;//'微信app_id'
	private String appSecret;//'微信app_secret'
	private String baseUrl;//'微信base_url'
	private String createUser;//'创建人'
	private String createUserName;//'创建人名'
	private Date createTime;//'创建时间'
	private String updateUser;//'修改人
	private String updateUserName;//'修改人名'
	private Date updateTime;//'修改时间'
	private String remark;//'备注'
	// Constructors
	/** default constructor */
	public WxWechat() {
	}
	/** minimal constructor */
	public WxWechat(Integer id, Date createTime, Date updateTime) {
		this.id = id;
		this.createTime = createTime;
		this.updateTime = updateTime;
	}
	/** full constructor */
	public WxWechat(Integer id, String code, String saasId, String weichatId,
			String name, String status, String type, String appId,
			String appSecret, String baseUrl, String createUser,
			String createUserName, Date createTime, String updateUser,
			String updateUserName, Date updateTime, String remark) {
		this.id = id;
		this.code = code;
		this.saasId = saasId;
		this.weichatId = weichatId;
		this.name = name;
		this.status = status;
		this.type = type;
		this.appId = appId;
		this.appSecret = appSecret;
		this.baseUrl = baseUrl;
		this.createUser = createUser;
		this.createUserName = createUserName;
		this.createTime = createTime;
		this.updateUser = updateUser;
		this.updateUserName = updateUserName;
		this.updateTime = updateTime;
		this.remark = remark;
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 64)
	public String getCode() {
		return this.code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@Column(name = "saas_id", length = 50)
	public String getSaasId() {
		return this.saasId;
	}
	public void setSaasId(String saasId) {
		this.saasId = saasId;
	}
	@Column(name = "weichat_id", length = 50)
	public String getWeichatId() {
		return this.weichatId;
	}
	public void setWeichatId(String weichatId) {
		this.weichatId = weichatId;
	}
	@Column(name = "name", length = 200)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Column(name = "status", precision = 2, scale = 0)
	public String getStatus() {
		return this.status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "type", length = 2)
	public String getType() {
		return this.type;
	}
	public void setType(String type) {
		this.type = type;
	}
	@Column(name = "app_id", length = 200)
	public String getAppId() {
		return this.appId;
	}
	public void setAppId(String appId) {
		this.appId = appId;
	}
	@Column(name = "app_secret", length = 200)
	public String getAppSecret() {
		return this.appSecret;
	}
	public void setAppSecret(String appSecret) {
		this.appSecret = appSecret;
	}
	@Column(name = "base_url", length = 200)
	public String getBaseUrl() {
		return this.baseUrl;
	}
	public void setBaseUrl(String baseUrl) {
		this.baseUrl = baseUrl;
	}
	@Column(name = "create_user", length = 200)
	public String getCreateUser() {
		return this.createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	@Column(name = "create_user_name", length = 200)
	public String getCreateUserName() {
		return this.createUserName;
	}
	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	@Column(name = "update_user", length = 200)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 200)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
public class WxWechat extends IdEntity implements java.io.Serializable {
    // Fields
    private String code;//业务code
    private String saasId;//'saas配置id'
    private String name;//名称
    private String token;//token
    private String encodingAesKey;//加密密钥
    private Integer encType;//加密方式  0:明文模式   1:兼容模式   2:安全模式
    private String status;//'类型 -1 已删除 0待审核 1审核通过 2 审核不通过'
    private String type;//'1:服务号 2 订阅号
    private String appId;//'微信app_id'
    private String appSecret;//'微信app_secret'
    private String baseUrl;//'微信base_url'
    private String createUser;//'创建人'
    private String createUserName;//'创建人名'
    private Date createTime;//'创建时间'
    private String updateUser;//'修改人
    private String updateUserName;//'修改人名'
    private Date updateTime;//'修改时间'
    private String remark;//'备注'
    public WxWechat(String code, String saasId, String name, String token, String encodingAesKey, Integer encType, String status, String type, String appId, String appSecret, String baseUrl, String createUser, String createUserName, Date createTime, String updateUser, String updateUserName, Date updateTime, String remark) {
        this.code = code;
        this.saasId = saasId;
        this.name = name;
        this.token = token;
        this.encodingAesKey = encodingAesKey;
        this.encType = encType;
        this.status = status;
        this.type = type;
        this.appId = appId;
        this.appSecret = appSecret;
        this.baseUrl = baseUrl;
        this.createUser = createUser;
        this.createUserName = createUserName;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateUserName = updateUserName;
        this.updateTime = updateTime;
        this.remark = remark;
    }
    /**
     * default constructor
     */
    public WxWechat() {
    }
    @Column(name = "enc_type")
    public Integer getEncType() {
        return encType;
    }
    public void setEncType(Integer encType) {
        this.encType = encType;
    }
    @Column(name = "token", length = 64)
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    @Column(name="encoding_aes_key")
    public String getEncodingAesKey() {
        return encodingAesKey;
    }
    public void setEncodingAesKey(String encodingAesKey) {
        this.encodingAesKey = encodingAesKey;
    }
    @Column(name = "code", length = 64)
    public String getCode() {
        return this.code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "saas_id", length = 50)
    public String getSaasId() {
        return this.saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    @Column(name = "name", length = 200)
    public String getName() {
        return this.name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "status", precision = 2, scale = 0)
    public String getStatus() {
        return this.status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "type", length = 2)
    public String getType() {
        return this.type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "app_id", length = 200)
    public String getAppId() {
        return this.appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    @Column(name = "app_secret", length = 200)
    public String getAppSecret() {
        return this.appSecret;
    }
    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }
    @Column(name = "base_url", length = 200)
    public String getBaseUrl() {
        return this.baseUrl;
    }
    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }
    @Column(name = "create_user", length = 200)
    public String getCreateUser() {
        return this.createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name", length = 200)
    public String getCreateUserName() {
        return this.createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time", nullable = false, length = 0)
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "remark", length = 1000)
    public String getRemark() {
        return this.remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "update_user", length = 200)
    public String getUpdateUser() {
        return this.updateUser;
    }
    public void setUpdateUser(String updateUser) {
        this.updateUser = updateUser;
    }
    @Column(name = "update_user_name", length = 200)
    public String getUpdateUserName() {
        return this.updateUserName;
    }
    public void setUpdateUserName(String updateUserName) {
        this.updateUserName = updateUserName;
    }
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_time", nullable = false, length = 0)
    public Date getUpdateTime() {
        return this.updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

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

@ -0,0 +1,119 @@
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.wx.dao.WechatDao;
import com.yihu.jw.wx.model.WxWechat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
@Service
public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
    @Autowired
    private WechatDao wechatDao;
    @Transient
    public WxWechat createWechat(WxWechat wechat) {
        if (StringUtils.isEmpty(wechat.getCode())) {
            throw new ApiException(WxContants.Wechat.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getSaasId())) {
            throw new ApiException(WxContants.Wechat.message_fail_saasId_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getStatus())) {
            throw new ApiException(WxContants.Wechat.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getType())) {
            throw new ApiException(WxContants.Wechat.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.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);
        }
        WxWechat wechatTem = wechatDao.findByAppId(wechat.getAppId());
        if (wechatTem != null) {
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wechat.setCreateTime(date);
        wechat.setUpdateTime(date);
        return wechatDao.save(wechat);
    }
    @Transient
    public WxWechat updateWxchat(WxWechat wechat) {
        if (StringUtils.isEmpty(wechat.getCode())) {
            throw new ApiException(WxContants.Wechat.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getSaasId())) {
            throw new ApiException(WxContants.Wechat.message_fail_saasId_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getStatus())) {
            throw new ApiException(WxContants.Wechat.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getType())) {
            throw new ApiException(WxContants.Wechat.message_fail_type_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.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);
        }
        Long id = wechat.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        WxWechat wechat1 = findById(id);
        if(wechat1 == null){
            throw new ApiException(WxContants.Wechat.message_fail_wxWechat_is_no_exist, CommonContants.common_error_params_code);
        }
        //设置修改时间创建时间
        wechat.setCreateTime(wechat1.getCreateTime());
        wechat.setUpdateTime(new Date());
        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);
        }
        return wechatDao.save(wechat);
    }
    public WxWechat findByCode(String code) {
        WxWechat wxWechat = wechatDao.findByCode(code);
        return wxWechat;
    }
    public WxWechat findById(Long id){
        return wechatDao.findById(id);
    }
    @Transient
    public void deleteWechat(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);
        }
        wxWechat.setStatus("-1");
        wechatDao.save(wxWechat);
    }
}

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

@ -0,0 +1,90 @@
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;
import com.yihu.jw.wx.model.WxAccessToken;
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 java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by Administrator on 2017/5/18 0018.
 */
@Service
public class WxAccessTokenService extends BaseJpaService<WxAccessToken, WxAccessTokenDao> {
    @Autowired
    private WxAccessTokenDao wxAccessTokenDao;
    @Autowired
    private WechatDao wechatDao;
    /**
     * 根据wechatCode查找最新一条
     * @param wechatCode
     * @return
     */
    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) {
                    if ((System.currentTimeMillis() - accessToken.getAddTimestamp()) < (accessToken.getExpiresIn() * 1000)) {
                        return accessToken;
                    } else {
                        wxAccessTokenDao.delete(accessToken);
                        break;
                    }
                }
            }
            String token_url = "https://api.weixin.qq.com/cgi-bin/token";
            String appId="";
            String appSecret="";
            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);
            if (json.has("access_token")) {
                String token = json.get("access_token").toString();
                String expires_in = json.get("expires_in").toString();
                WxAccessToken newaccessToken = new WxAccessToken();
                newaccessToken.setAccessToken(token);
                newaccessToken.setExpiresIn(Long.parseLong(expires_in));
                newaccessToken.setAddTimestamp(System.currentTimeMillis());
                newaccessToken.setCzrq(new Date());
                newaccessToken.setCode(UUID.randomUUID().toString().replace("-",""));
                newaccessToken.setWechatCode(wechatCode);
                wxAccessTokenDao.save(newaccessToken);
                return newaccessToken;
            } else {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

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

@ -0,0 +1,189 @@
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.MessageUtil;
import com.yihu.jw.wx.dao.WxGraphicMessageDao;
import com.yihu.jw.wx.model.WxGraphicMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
@Service
public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, WxGraphicMessageDao> {
    @Autowired
    private WxGraphicMessageDao wxGraphicMessageDao;
    @Transient
    public WxGraphicMessage createWxGraphicMessage(WxGraphicMessage wxGraphicMessage) {
        if (StringUtils.isEmpty(wxGraphicMessage.getCode())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        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);
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wxGraphicMessage.setCreateTime(date);
        wxGraphicMessage.setUpdateTime(date);
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    @Transient
    public WxGraphicMessage updateWxGraphicMessage(WxGraphicMessage wxGraphicMessage) {
        if (StringUtils.isEmpty(wxGraphicMessage.getCode())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        Long id = wxGraphicMessage.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        //根据id查找
        WxGraphicMessage wxGraphicMessage1 = findById(id);
        if(wxGraphicMessage1==null){
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_wxGraphicMessage_is_no_exist, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wxGraphicMessage.setCreateTime(wxGraphicMessage1.getCreateTime());
        wxGraphicMessage.setUpdateTime(date);
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    public WxGraphicMessage findByCode(String code) {
        WxGraphicMessage WxGraphicMessage = wxGraphicMessageDao.findByCode(code);
        return WxGraphicMessage;
    }
    public WxGraphicMessage findById(Long id) {
      return wxGraphicMessageDao.findById(id);
    }
    @Transient
    public void deleteWxGraphicMessage(String code) {
        WxGraphicMessage WxGraphicMessage = findByCode(code);
        WxGraphicMessage.setStatus(-1);
        wxGraphicMessageDao.save(WxGraphicMessage);
    }
    private String replyNewsMessage(String toUser,String fromUser,List<Map<String,String>> articles) throws Exception {
        if(articles == null || articles.size() < 1){
            throw new Exception("图文信息不能为空!");
        }
        StringBuilder result = new StringBuilder();
        result.append("<xml>");
        result.append("<ToUserName>" + toUser + "</ToUserName>");
        result.append("<FromUserName>" + fromUser + "</FromUserName>");
        result.append("<CreateTime>" + new Date().getTime() + "</CreateTime>");
        result.append("<MsgType>news</MsgType>");
        result.append("<ArticleCount>" + articles.size() + "</ArticleCount>");
        result.append("<Articles>");
        for(Map<String,String>  article : articles){
            result.append("<item>");
            result.append("<Title>" +  article.get("Title") +"</Title>");
            result.append("<Description>" + article.get("Description") + "</Description>");
            result.append("<PicUrl>" + article.get("PicUrl") + "</PicUrl>");
            result.append("<Url>" + article.get("Url") + "</Url>");
            result.append("</item>");
        }
        result.append("</Articles>");
        result.append("</xml>");
        return result.toString();
    }
    /**
     * 发送图文消息
     * @param codes
     * @param request
     * @return
     */
    public String sendGraphicMessages(String codes, HttpServletRequest request) {
        try {
            // xml请求解析
            Map<String, String> requestMap = MessageUtil.parseXml(request);
            //用户openid
            String fromUserName = requestMap.get("FromUserName");
            //微信公众号
            String toUserName = requestMap.get("ToUserName");
            // 图文信息
            List<Map<String,String>> articles =  new ArrayList<>();
            if(codes!=null){
                String[] codeArray = codes.split(",");
                for(String code: codeArray){
                    WxGraphicMessage graphicMessage = findByCode(code);
                    Map<String,String> article = new HashMap<>();
                    article.put("Url",graphicMessage.getUrl());
                    article.put("Title", graphicMessage.getTitle());
                    article.put("Description",graphicMessage.getDescription());
                    article.put("PicUrl",graphicMessage.getPicUrl());
                    articles.add(article);
                }
            }
            // 构建回复消息XML
            return replyNewsMessage(fromUserName, toUserName, articles);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
        }
    }
    /**
     * 发送图文消息
     * @param codes
     * @param fromUserName   用户的openId
     * @param toUserName
     * @return
     */
    public String sendGraphicMessages(String codes, String fromUserName,String toUserName) {
        try {
        // 图文信息
            List<Map<String,String>> articles =  new ArrayList<>();
            if(codes!=null){
                String[] codeArray = codes.split(",");
                for(String code: codeArray){
                    WxGraphicMessage graphicMessage = findByCode(code);
                    Map<String,String> article = new HashMap<>();
                    article.put("Url",graphicMessage.getUrl());
                    article.put("Title", graphicMessage.getTitle());
                    article.put("Description",graphicMessage.getDescription());
                    article.put("PicUrl",graphicMessage.getPicUrl());
                    articles.add(article);
                }
            }
            // 构建回复消息XML
            return replyNewsMessage(fromUserName, toUserName, articles);
        } catch (Exception e) {
            e.printStackTrace();
            return e.getMessage();
        }
    }
}

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

@ -0,0 +1,325 @@
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.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;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    @Autowired
    private WxMenuDao wxMenuDao;
    @Autowired
    private WechatService wechatService;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    /**
     * 将菜单保存至数据库(微信未创建)
     * @param wxMenu
     * @return
     */
    public WxMenu createWxMenu(WxMenu wxMenu) {
        if(canSaveOrUpata(wxMenu)){
            wxMenu.setCreateTime(new Date());
            return wxMenuDao.save(wxMenu);
        }
        return null;
    }
    @Transient
    public WxMenu updateWxMenu(WxMenu wxMenu) {
        if(canSaveOrUpata(wxMenu)){
            Long id = wxMenu.getId();
            if (StringUtils.isEmpty(id)) {
                throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
            }
            WxMenu wxMenu1 = findById(id);
            if(wxMenu1==null){
                throw new ApiException(WxContants.WxMenu.message_fail_WxMenu_is_no_exist, CommonContants.common_error_params_code);
            }
            wxMenu.setCreateTime(wxMenu1.getCreateTime());
            return wxMenuDao.save(wxMenu);
        }
        return null;
    }
    @Transient
    public void deleteWxMenu(String code) {
        WxMenu wxMenu = wxMenuDao.findByCode(code);
        if (wxMenu == null) {
            throw new ApiException(WxContants.WxMenu.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        String supMenucode = wxMenu.getSupMenucode();
        if(StringUtils.isEmpty(supMenucode)) {//如果是空,则为父菜单
            List<WxMenu> childMenus = findChildMenus(wxMenu.getWechatCode(), wxMenu.getCode());
            if(childMenus!=null){
                for(WxMenu wxmenu:childMenus){
                    wxmenu.setStatus(-1);
                    wxMenuDao.save(wxmenu);
                }
            }
        }
        wxMenu.setStatus(-1);
        wxMenuDao.save(wxMenu);
    }
    public WxMenu findByCode(String code) {
        return wxMenuDao.findByCode(code);
    }
    public WxMenu findById(Long id) {
        return wxMenuDao.findById(id);
    }
    /**
     * 根据wechatCode查找所有菜单
     * @param wechatCode
     * @return
     */
    public List<WxMenu> findByWechatCode(String wechatCode){
        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();
        // 请求微信接口创建菜单
        String url = " https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + token;
        String jsonStr = HttpUtil.sendPost(url, menuJsonString);
        JSONObject result = new JSONObject(jsonStr);
        return result;
    }
    private String getMenuToString(List<WxMenu> menus,String wechatCode){
        String menuJsonStr = "";
        List<WxMenu> parentMenus = new ArrayList<WxMenu>();//存储父菜单
        if(menus!=null){
            menuJsonStr = "{\"button\":[{";
            for(WxMenu wxMenu:menus){
                if(StringUtils.isEmpty(wxMenu.getSupMenucode())){//说明是父菜单
                    parentMenus.add(wxMenu);
                }
            }
        }
        int j = 0;
        for(WxMenu menu:parentMenus){//遍历父菜单
            if(j==0){
                j++;
            }else{
                menuJsonStr += ",{";
            }
            menuJsonStr = getString(menuJsonStr, menu);
            //查找是否有子菜单
            List<WxMenu> childMenus = findChildMenus(wechatCode, menu.getCode());
            if(childMenus!=null){
                int i =0;
                menuJsonStr += ",\"sub_button\":[{";
                for(WxMenu childMenu:childMenus){
                    if(i==0){
                        i++;
                    }else{
                        menuJsonStr += ",{";
                    }
                    menuJsonStr = getString(menuJsonStr, childMenu);
                    menuJsonStr += "}";
                }
                menuJsonStr += "]}";
            }
        }
        menuJsonStr += "]}";
        return menuJsonStr;
    }
    private String getString(String menuJsonStr, WxMenu menu) {
        menuJsonStr += "\"name\":\""+ menu.getName()+"\"";
        if(!StringUtils.isEmpty(menu.getType())){
            menuJsonStr += ",\"type\":\"" + menu.getType()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getMenuKey())){
            menuJsonStr += ",\"key\":\"" + menu.getMenuKey()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getUrl())){
            menuJsonStr += ",\"url\":\"" + menu.getUrl()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getMediaId())){
            menuJsonStr += ",\"media_id\":\"" + menu.getMediaId()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getAppid())){
            menuJsonStr += ",\"appid\":\"" + menu.getAppid()+"\"";
        }
        if(!StringUtils.isEmpty(menu.getPagepath())){
            menuJsonStr += ",\"pagepath\":\"" + menu.getPagepath()+"\"";
        }
        return menuJsonStr;
    }
    /**
     * 查找子菜单
     * @param wechatCode
     * @param sup_menucode
     * @return
     */
    public List<WxMenu> findChildMenus(String wechatCode,String sup_menucode ){
        return wxMenuDao.findChildMenus(wechatCode,sup_menucode);
    }
    private boolean canSaveOrUpata(WxMenu wxMenu){
        if (StringUtils.isEmpty(wxMenu.getCode())) {
            throw new ApiException(WxContants.WxMenu.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        String wechatCode = wxMenu.getWechatCode();
        if (StringUtils.isEmpty(wechatCode)) {
            throw new ApiException(WxContants.WxMenu.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        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.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);
        }
        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_key_is_null, 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);
            }
        }
        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())){//如果是空,则为父菜单
            //判断sort是否重复
            wxMenuTemp = wxMenuDao.findByWechatCodeExcludeSortFromParent(wxMenu.getWechatCode(), wxMenu.getSort(),wxMenu.getCode());
        }else{//子菜单
            wxMenuTemp = wxMenuDao.findByWechatCodeExcludeSortFromChild(wxMenu.getWechatCode(), wxMenu.getSort(), wxMenu.getSupMenucode(), wxMenu.getCode());
        }
        if(null!=wxMenuTemp){
            throw new ApiException(WxContants.WxMenu.message_fail_sort_is_repeat, CommonContants.common_error_params_code);
        }
        wxMenu.setUpdateTime(new Date());
        return true;
    }
}

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

@ -0,0 +1,164 @@
package com.yihu.jw.wx.service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
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.WxTemplateDao;
import com.yihu.jw.wx.model.*;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao> {
    @Autowired
    private WxTemplateDao wxTemplateDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WechatService wechatService;
    public WxTemplate createWxTemplate(WxTemplate wxTemplate) {
        if (StringUtils.isEmpty(wxTemplate.getCode())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        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);
        }
        String content = wxTemplate.getContent().replace(" ","");
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
        }
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wxTemplate.setCreateTime(date);
        wxTemplate.setUpdateTime(date);
        return wxTemplateDao.save(wxTemplate);
    }
    public WxTemplate updateWxTemplate(WxTemplate wxTemplate) {
        if (StringUtils.isEmpty(wxTemplate.getCode())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxTemplate.getWechatCode())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxTemplate.getTemplateId())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_templateid_is_null, CommonContants.common_error_params_code);
        }
        String content = wxTemplate.getContent().replace(" ","");
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
        }
        Long id = wxTemplate.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        WxTemplate wxTemplate1 = findById(id);
        if(wxTemplate1==null){
            throw new ApiException(WxContants.WxTemplate.message_fail_template_is_no_exist, CommonContants.common_error_params_code);
        }
        wxTemplate.setCreateTime(wxTemplate1.getCreateTime());
        wxTemplate.setUpdateTime(new Date());
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
        return wxTemplateDao.save(wxTemplate);
    }
    public void deleteWxTemplate(String code) {
        WxTemplate wxTemplate = wxTemplateDao.findByCode(code);
        if (wxTemplate == null) {
            throw new ApiException(WxContants.WxTemplate.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        wxTemplate.setStatus(-1);
        wxTemplateDao.save(wxTemplate);
    }
    public WxTemplate findByCode(String code) {
        WxTemplate wxTemplate = wxTemplateDao.findByCode(code);
        return wxTemplate;
    }
    public WxTemplate findById(Long id) {
        WxTemplate wxTemplate = wxTemplateDao.findById(id);
        return wxTemplate;
    }
    public JSONObject sendTemplateMessage(String openid, String templateCode, String url, String data,Miniprogram miniprogram) {
        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("\\{\\{");
            //将result,withdrawMoney,withdrawTime,cardInfo,arrivedTime等字符串放入contentList中
            List<String> contentList = new ArrayList<>();
            for(int i=1;i<contentArray.length;i++){
                contentList.add(contentArray[i].substring(0,contentArray[i].indexOf(".")));
            }
            ObjectMapper mapper = new ObjectMapper();
            ////将data转为对象
            Map<String, WechatTemplateData> dataMap = mapper.readValue(data, new TypeReference<LinkedHashMap<String, WechatTemplateData>>() {});
            Map<String, WechatTemplateData> newDataMap = new LinkedHashMap<String, WechatTemplateData>();
            int j = 0;
            for (Map.Entry<String, WechatTemplateData> entry : dataMap.entrySet()) {//(keyword1,WechatTemplateData)
                String key = entry.getKey();//keyword1   转为result
                newDataMap.put(contentList.get(j),entry.getValue());
                j++;
            }
            //将数据封装在WechatTemplate对象中
            WechatTemplate wechatTemplate = new WechatTemplate();
            wechatTemplate.setTouser(openid);
            wechatTemplate.setUrl(url);
            wechatTemplate.setTemplate_id(wxTemplate.getTemplateId());
            if(miniprogram!=null){
                wechatTemplate.setMiniprogram(miniprogram);
            }
            wechatTemplate.setData(newDataMap);
            String params = mapper.writeValueAsString(wechatTemplate);
            WxAccessToken wxAccessTokenByCode = wxAccessTokenService.getWxAccessTokenByCode(wechatCode);
            String token = wxAccessTokenByCode.getAccessToken();
            String token_url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + token;
            String result = HttpUtil.sendPost(token_url, params);
            JSONObject jsonResult = new JSONObject(result);
            return jsonResult;
        } catch (Exception e) {
            e.printStackTrace();
            JSONObject jsonResult = new JSONObject(e);
            return jsonResult;
        }
    }
}

BIN
svr/svr-quota/doc/统计架构.png


+ 55 - 0
svr/svr-quota/pom.xml

@ -56,5 +56,60 @@
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.nlpcn</groupId>
            <artifactId>elasticsearch-sql</artifactId>
            <version>2.4.1.0</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.15</version>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz-jobs</artifactId>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>io.searchbox</groupId>
            <artifactId>jest</artifactId>
        </dependency>
    </dependencies>
</project>

+ 14 - 0
svr/svr-quota/readme.MD

@ -0,0 +1,14 @@
包结构:
    config:配置
    controller:控制器
    dao.jpa:dao层
    etl:etl相关
    job:执行的job
    model.jpa:数据库的映射
    service:服务层
    util:工具类
    vo:modelvo
    
    
相关资料
    powerdesign:https://192.168.1.103:888/svn/outwindow/基础开发部/doc/i健康2.0

+ 4 - 2
svr/svr-quota/src/main/java/com/yihu/jw/SvrQuotaApplication.java

@ -1,17 +1,19 @@
package com.yihu.jw;
package com.yihu.jw.quota;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
/**
 * Created by chenweida on 2017/5/16.
 */
@SpringBootApplication
@EnableDiscoveryClient//服务注册到发现服务
@EnableJpaRepositories(basePackages="com.yihu.jw.quota.dao.jpa")
public class SvrQuotaApplication {
    public static void main(String[] args) {
        SpringApplication.run(SvrQuotaApplication.class, args);
    }
}
}

+ 50 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/config/AsyncConfig.java

@ -0,0 +1,50 @@
package com.yihu.jw.quota.config;
import org.apache.tomcat.util.threads.ThreadPoolExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
/**
 * Created by Administrator on 2016.10.18.
 * 启用多綫程
 */
@Configuration
@EnableAsync
public class AsyncConfig {
    /** 如果池中的实际线程数小于corePoolSize,无论是否其中有空闲的线程,都会给新的任务产生新的线程 */
    private int corePoolSize = 5;
    /** 如果池中的线程数=maximumPoolSize,则有空闲线程使用空闲线程,否则新任务放入queueCapacity. */
    private int maxPoolSize = 20;
    /** 缓冲队列. */
    private int queueCapacity = 10;
    @Bean
    public Executor dbExtractExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
    @Bean
    public Executor dbStorageExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
        // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        executor.initialize();
        return executor;
    }
}

+ 25 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/JobFactory.java

@ -0,0 +1,25 @@
package com.yihu.jw.quota.config.quota;//package com.yihu.jw.config.quartz;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
/**
 * Created by Administrator on 2016.10.12.
 * 為了讓quartz種可以使用Spring的注入
 */
@Component("jobFactory")
public class JobFactory extends AdaptableJobFactory {
    @Autowired
    private AutowireCapableBeanFactory capableBeanFactory;
    @Override
    protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
        // 调用父类的方法
        Object jobInstance = super.createJobInstance(bundle);
       // 进行注入
        capableBeanFactory.autowireBean(jobInstance);
        return jobInstance;
    }
}

+ 52 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/config/quota/SchedulerConfig.java

@ -0,0 +1,52 @@
package com.yihu.jw.quota.config.quota;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.Properties;
/**
 * Created by chenweida on 2016/2/3.
 */
@Configuration
public class SchedulerConfig {
    @Autowired
    private ApplicationContext applicationContext;
    @Autowired
    private JobFactory jobFactory;
    @Autowired
    private DataSource dataSource;
    @Bean
    SchedulerFactoryBean schedulerFactoryBean() throws IOException {
        SchedulerFactoryBean bean = new SchedulerFactoryBean();
        bean.setJobFactory(jobFactory);
        bean.setApplicationContext(this.applicationContext);
        bean.setOverwriteExistingJobs(true);
        bean.setStartupDelay(20);// 延时启动
        bean.setSchedulerName("schedulerFactoryBeanCWD");
        bean.setAutoStartup(true);
        bean.setDataSource(dataSource);
        bean.setQuartzProperties(quartzProperties());
        return bean;
    }
    /**
     * quartz配置文件
     * @return
     * @throws IOException
     */
    @Bean
    public Properties quartzProperties() throws IOException {
        PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
        propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
        propertiesFactoryBean.afterPropertiesSet();
        return propertiesFactoryBean.getObject();
    }
}

+ 436 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/BaseController.java

@ -0,0 +1,436 @@
package com.yihu.jw.quota.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BaseController {
	private static Logger logger = LoggerFactory.getLogger(BaseController.class);
	@Autowired
	protected HttpServletRequest request;
	/**
	 * 獲取髮送請求用戶的uid
	 * @return
	 */
	public String getUID() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("uid");
			
		} catch (Exception e) {
			return null;
		}
	}
	public String getOpenid() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("openid");
			
		} catch (Exception e) {
			return null;
		}
	}
	
	/**
	 * 获取用户ID
	 * @return
	 */
	public long getId() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getLong("id");
		} catch (Exception e) {
			return 0;
		}
	}
	public String getIMEI() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("imei");
		} catch (Exception e) {
			return null;
		}
	}
	
	public String getToken() {
		try {
			String userAgent = request.getHeader("userAgent");
			if(StringUtils.isEmpty(userAgent)){
				userAgent = request.getHeader("User-Agent");
			}
			JSONObject json = new JSONObject(userAgent);
			return json.getString("token");
		} catch (Exception e) {
			return null;
		}
	}
	public void error(Exception e) {
		logger.error(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	public void warn(Exception e) {
		logger.warn(getClass().getName() + ":", e.getMessage());
		e.printStackTrace();
	}
	/**
	 * 返回接口处理结果
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String error(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 接口处理成功
	 * @param msg
	 * @return
	 */
	public String success(String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", 200);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	public String write(int code, String msg) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return null;
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, List<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, list);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONObject value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param total 总数
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, int total, String key, JSONArray value) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			json.put("total", total);
			json.put(key, value);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Object value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> list) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			// 是否为第一页
			map.put("isFirst", list.isFirst());
			// 是否为最后一页
			map.put("isLast", list.isLast());
			// 总条数
			map.put("total", list.getTotalElements());
			// 总页数
			map.put("totalPages", list.getTotalPages());
			map.put(key, list.getContent());
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 *
	 *
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", page.isFirst());
			// 是否为最后一页
			json.put("isLast", page.isLast());
			// 总条数
			json.put("total", page.getTotalElements());
			// 总页数
			json.put("totalPages", page.getTotalPages());
			json.put(key, array);
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @param value 结果数据
	 * @return
	 */
	public String write(int code, String msg, String key, Map<?, ?> value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	* 返回接口处理结果
	*
	* @param code 结果码,成功为200
	* @param msg 结果提示信息
	* @param value 结果数据
	* @return
	*/
	public String write(int code, String msg, String key, String value) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, value);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果
	 * 
	 * 
	 * @param code 结果码,成功为200
	 * @param msg 结果提示信息
	 * @return
	 */
	public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
		try {
			JSONObject json = new JSONObject();
			json.put("status", code);
			json.put("msg", msg);
			// 是否为第一页
			json.put("isFirst", isFirst);
			// 是否为最后一页
			json.put("isLast", isLast);
			// 总条数
			json.put("total", total);
			// 总页数
			json.put("totalPages", totalPages);
			json.put(key, values);
			return json.toString();
		} catch (Exception e) {
			logger.error("BaseController:", e.getMessage());
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	public String trimEnd(String param, String trimChars) {
		if (param.endsWith(trimChars)) {
			param = param.substring(0, param.length() - trimChars.length());
		}
		return param;
	}
	/**
	 * 无效用户消息返回
	 * @param e
	 * @param defaultCode
	 * @param defaultMsg
	 * @return
	 */
	public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
		try {
			// if (e instanceof UndeclaredThrowableException) {
			// UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
			// InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
			// if (iue != null) {
			// return error(iue.getCode(), iue.getMsg());
			// }
			// }
			return error(defaultCode, defaultMsg);
		} catch (Exception e2) {
			return null;
		}
	}
}

+ 45 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/controller/JobController.java

@ -0,0 +1,45 @@
package com.yihu.jw.quota.controller;
import com.yihu.jw.quota.service.job.JobService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * 任务启动
 *
 * @author chenweida
 */
@RestController
@RequestMapping(value = "/job", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "后台-任务控制")
public class JobController extends BaseController {
    @Autowired
    private JobService jobService;
    /**
     * 启动任务
     *
     * @param id id
     * @return
     */
    @ApiOperation(value = "根据ID立即单个任务")
    @RequestMapping(value = "startNowById", method = RequestMethod.GET)
    public String startNowById(
            @ApiParam(name = "id", value = "任务ID", required = true)@RequestParam(value = "id", required = true) String id) {
        try {
            jobService.startNowById(id);
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

+ 14 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.quota.dao.jpa;
import com.yihu.jw.quota.model.jpa.TjQuota;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDao extends PagingAndSortingRepository<TjQuota, Long>, JpaSpecificationExecutor<TjQuota> {
    @Query("from TjQuota j where j.code=?1 and j.status=1 ")
    TjQuota findByCode(String id);
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/TjQuotaLogDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa;
import com.yihu.jw.quota.model.jpa.TjQuota;
import com.yihu.jw.quota.model.jpa.TjQuotaLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/2.
 */
public interface TjQuotaLogDao extends PagingAndSortingRepository<TjQuotaLog, Long>, JpaSpecificationExecutor< TjQuotaLog> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.dict;
import com.yihu.jw.quota.model.jpa.dict.SystemDict;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionMain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface SystemDictDao extends PagingAndSortingRepository<SystemDict, Long>, JpaSpecificationExecutor<SystemDict> {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dict/SystemDictListDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.dict;
import com.yihu.jw.quota.model.jpa.dict.SystemDictList;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface SystemDictListDao extends PagingAndSortingRepository<SystemDictList, Long>, JpaSpecificationExecutor<SystemDictList> {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionMainDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionMain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjDimensionMainDao extends PagingAndSortingRepository<TjDimensionMain, Long>, JpaSpecificationExecutor<TjDimensionMain> {
}

+ 12 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjDimensionSlaveDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.dimension.TjDimensionSlave;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjDimensionSlaveDao extends PagingAndSortingRepository<TjDimensionSlave, Long>, JpaSpecificationExecutor<TjDimensionSlave
        > {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionMainDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionMain;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDimensionMainDao extends PagingAndSortingRepository<TjQuotaDimensionMain, Long>, JpaSpecificationExecutor<TjQuotaDimensionMain> {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/dimension/TjQuotaDimensionSlaveDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.dimension;
import com.yihu.jw.quota.model.jpa.dimension.TjQuotaDimensionSlave;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjQuotaDimensionSlaveDao extends PagingAndSortingRepository<TjQuotaDimensionSlave, Long>, JpaSpecificationExecutor<TjQuotaDimensionSlave> {
}

+ 11 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjDataSaveDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.quota.dao.jpa.save;
import com.yihu.jw.quota.model.jpa.save.TjDataSave;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/6/1.
 */
public interface TjDataSaveDao extends PagingAndSortingRepository<TjDataSave, Long>, JpaSpecificationExecutor<TjDataSave> {
}

+ 0 - 0
svr/svr-quota/src/main/java/com/yihu/jw/quota/dao/jpa/save/TjQuotaDataSaveDao.java


Some files were not shown because too many files changed in this diff