Explorar o código

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

chenyongxing %!s(int64=8) %!d(string=hai) anos
pai
achega
c950a8b382
Modificáronse 34 ficheiros con 1994 adicións e 131 borrados
  1. 8 4
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/BaseContants.java
  2. 0 2
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/common/Envelop.java
  3. 135 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxGraphicMessage.java
  4. 136 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxMenu.java
  5. 136 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxTemplate.java
  6. 164 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/MWxWechat.java
  7. 119 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/WxContants.java
  8. 7 1
      common/common-swagger/src/main/java/com/yihu/jw/config/SwaggerConfig.java
  9. 11 0
      svr-configuration/src/main/resources/application.yml
  10. 2 1
      svr-configuration/src/main/resources/bootstrap.yml
  11. 6 0
      svr/svr-base/readme.MD
  12. 0 7
      svr/svr-base/src/main/java/com/yihu/jw/SvrBaseApplication.java
  13. 0 2
      svr/svr-base/src/main/java/com/yihu/jw/base/service/FunctionService.java
  14. 120 5
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WechatController.java
  15. 60 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxAccessTokenController.java
  16. 129 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxGraphicMessageController.java
  17. 131 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxMenuController.java
  18. 128 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxTemplateController.java
  19. 22 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WechatDao.java
  20. 19 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxAccessTokenDao.java
  21. 25 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxGraphicMessageDao.java
  22. 15 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxMenuDao.java
  23. 15 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxTemplateDao.java
  24. 17 17
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxAccessToken.java
  25. 166 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxGraphicMessage.java
  26. 37 38
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxMenu.java
  27. 52 13
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxTemplate.java
  28. 16 40
      svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxWechat.java
  29. 80 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WechatService.java
  30. 48 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxAccessTokenService.java
  31. 64 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java
  32. 61 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java
  33. 64 0
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxTemplateService.java
  34. 1 1
      web-gateway/src/main/resources/bootstrap.yml

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

@ -5,7 +5,9 @@ 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";
@ -16,19 +18,20 @@ public class BaseContants {
        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_wechatCode_is_null="wechatCode is null";
        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_getFunctionsNoPage="getFunctionsNoPage";
    }
    //模块常量
@ -83,4 +86,5 @@ public class BaseContants {
        public static final String api_getSaassNoPage="getSaassNoPage";
    }
}

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

+ 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 wechatCode;//关联的微信code 关联表 Wx_Wechat
    private String name;//名称
    private String value;//图文消息url值
    private String keyword;//关键字
    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可用
    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 getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getKeyword() {
        return keyword;
    }
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
    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;
    }
}

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

@ -0,0 +1,136 @@
package com.yihu.jw.restmodel.wx;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class MWxMenu {
    private Long id;
    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;
    }
    private String code;//业务code
    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;//备注
    private Integer status; //状态 -1 已删除 0可用
}

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

@ -0,0 +1,136 @@
package com.yihu.jw.restmodel.wx;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class MWxTemplate {
    private Long id;
    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 getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getWechatCode() {
        return wechatCode;
    }
    public void setWechatCode(String wechatCode) {
        this.wechatCode = wechatCode;
    }
    public String getTemplateCode() {
        return templateCode;
    }
    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    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;
    }
    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;
    private Integer status; //状态 -1 已删除 0可用
}

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

@ -0,0 +1,164 @@
package com.yihu.jw.restmodel.wx;
import java.util.Date;
/**
 * Created by Administrator on 2017/5/20 0020.
 */
public class MWxWechat {
    private Long id;
    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 getWeichatId() {
        return weichatId;
    }
    public void setWeichatId(String weichatId) {
        this.weichatId = weichatId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String 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;
    }
    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;//'备注'
}

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

@ -0,0 +1,119 @@
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_create="wxAccessToken create success";
        public static final String message_success_get="wxAccessToken get success";
        public static final String api_common="wxAccessToken";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String message_fail_wechatCode_is_null="wechatCode is null";
        public static final String message_fail_expiresIn_is_null="expiresIn is null";
    }
    //微信按钮模块常量
    public static class WxMenu{
        public static final String api_common="wxMenu";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String api_delete="delete";
        public static final String api_getByCode="getByCode";
        public static final String api_update="update";
        public static final String api_getWxMenus="getWxMenus";
        public static final String api_getWxMenuNoPage="getWxMenuNoPage";
        public static final String message_fail_wechatCode_is_null="wechatCode is null";
        public static final String message_fail_wxMenuName_is_null="wxMenuName is null";
        public static final String message_fail_wechatcode_is_null="wechatCode is null";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="weChatMenuName is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="id is null";
        public static final String message_success_update="wxMenu update success";
        public static final String message_success_delete="wxMenu delete success";
        public static final String message_success_find="wxMenu success find";
        public static final String message_success_create="wxMenu create success";
        public static final String message_success_get="wxMenu get success";
        public static final String message_success_find_functions="wxMenu find success";
    }
    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 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_name_exist="wxTemplate name exist";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="wxTemplate is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_wechatCode_is_null="wechatCode is null";
    }
    public static class Wechat {
        public static final String api_common="wechat";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWechatNoPage="getWechatNoPage";
        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_name_exist="wechat name exist";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="wechat is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_appId_is_null="appId is null";
        public static final String message_fail_appSecret_is_null="appSecret is null";
        public static final String message_fail_appId_exist="wechat appId exist";
    }
    public static class WxGraphicMessage {
        public static final String api_common="wxGraphicMessage";
        public static final String api_create="create";
        public static final String api_get="get";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWxGraphicMessageNoPage="getWxGraphicMessageNoPage";
        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_id_is_null="id is null";
        public static final String message_fail_code_no_exist="code no exist";
        public static final String message_fail_code_exist="code exist";
        public static final String message_fail_appSecret_is_null="appSecret is null";
        public static final String message_fail_appId_exist="wxGraphicMessage appId exist";
        public static final String message_fail_value_is_null="value is null";
    }
}

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

@ -1,6 +1,7 @@
package com.yihu.jw.config;
import com.yihu.jw.restmodel.base.BaseContants;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@ -30,7 +31,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());

+ 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

@ -31,8 +31,9 @@ spring:
      failFast: true ##启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: http://192.168.1.220:10080/chenweida/jw.config.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.1.220:10080/chenyongxing/jw.config.git
        default-label: master

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

@ -5,4 +5,10 @@
        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.

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

@ -11,8 +11,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * Created by chenweida on 2017/5/19.
 */

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

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

@ -0,0 +1,60 @@
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.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by chenweida 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());
        }
    }
    @PostMapping(value = WxContants.WxAccessToken.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建WxAccessToken")
    public Envelop createWxAccessToken(
            @ApiParam(name = "wxAccessToken", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String wxAccessTokenJson) throws Exception {
        try {
            WxAccessToken wxAccessToken = toEntity(wxAccessTokenJson, WxAccessToken.class);
            wxAccessToken = wxAccessTokenService.createWxAccessToken(wxAccessToken);
            return Envelop.getSuccess(WxContants.WxAccessToken.message_success_create, wxAccessToken);
        }catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

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

@ -0,0 +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.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;
/**
 * Created by chenweida on 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.updateWxchat(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,name,wechatCode,value,keyword,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @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,name,wechatCode,value,keyword,remark,status")
            @RequestParam(value = "fields", required = false) String fields,
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档", defaultValue = "+name,+createTime")
            @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);
    }
}

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

@ -0,0 +1,131 @@
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.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.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);
    }
}

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

@ -0,0 +1,128 @@
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.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.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 = "", defaultValue = "")
            @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,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<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,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<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);
    }
}

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

@ -0,0 +1,22 @@
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);
}

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

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

@ -0,0 +1,15 @@
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;
/**
 * 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")
    WxMenu findByCode(String code);
}

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

@ -0,0 +1,15 @@
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 =0")
    WxTemplate findByCode(String code);
}

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

@ -1,18 +1,29 @@
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
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	private String wechatCode;//关联的微信code 关联表 Wx_Wechat
	private String accessToken;//调用微信返回的accesstoken
	private long addTimestamp;//创建时间
@ -26,7 +37,7 @@ public class WxAccessToken implements java.io.Serializable {
	}
	/** minimal constructor */
	public WxAccessToken(Integer id, String accessToken, long addTimestamp,
	public WxAccessToken(Long id, String accessToken, long addTimestamp,
			Integer expiresIn, Date czrq) {
		this.id = id;
		this.accessToken = accessToken;
@ -35,10 +46,9 @@ 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) {
	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,16 +56,6 @@ 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 void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "wechat_code", length = 64)
	public String getWechatCode() {

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

@ -0,0 +1,166 @@
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 wechatCode;//关联的微信code 关联表 Wx_Wechat
    private String name;//名称
    private String value;//图文消息url值
    private String keyword;//关键字
    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可用
    public WxGraphicMessage(String code, String wechatCode, String name, String value, String keyword, String createUser, String createUserName, Date createTime, String updateUser, String updateUserName, Date updateTime, String remark, Integer status) {
        this.code = code;
        this.wechatCode = wechatCode;
        this.name = name;
        this.value = value;
        this.keyword = keyword;
        this.createUser = createUser;
        this.createUserName = createUserName;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateUserName = updateUserName;
        this.updateTime = updateTime;
        this.remark = remark;
        this.status = status;
    }
    public WxGraphicMessage() {
    }
    @Column(name = "code", length = 64)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "wechat_code", length = 200)
    public String getWechatCode() {
        return wechatCode;
    }
    public void setWechatCode(String wechatCode) {
        this.wechatCode = wechatCode;
    }
    @Column(name = "name", length = 200)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "value", length = 2000)
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    @Column(name = "keyword", length = 100)
    public String getKeyword() {
        return keyword;
    }
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
    @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;
    }
}

+ 37 - 38
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxMenu.java

@ -1,18 +1,43 @@
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 {
public class WxMenu extends IdEntity implements java.io.Serializable {
	public WxMenu(Long id, String code, String wechatCode, String supMenucode, String type, String name, Integer sort, String url, String updateUser, Date updateTime, Date createTime, String createUser, String remark, Integer status) {
		this.id = id;
		this.code = code;
		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;
		this.status = status;
	}
	// Fields
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	private Integer id;//菜单id
	private String code;//业务code
	private String wechatCode;//关联的微信code 关联表 Wx_Wechat
	private String supMenucode;//父菜单id 如果是一级菜单 此字段为空
	private String type;//菜单类型 1 view 2click
@ -24,47 +49,21 @@ public class WxMenu implements java.io.Serializable {
	private Date createTime;//创建时间
	private String createUser;//创建人
	private String remark;//备注
	private Integer status; //状态 -1 已删除 0可用
	// Constructors
	/** default constructor */
	public WxMenu() {
	}
	/** minimal constructor */
	public WxMenu(Integer id) {
		this.id = id;
	public Integer getStatus() {
		return status;
	}
	/** 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;
	public void setStatus(Integer status) {
		this.status = status;
	}
	// Constructors
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	/** default constructor */
	public WxMenu() {
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "wechat_code", length = 200)
	public String getWechatCode() {

+ 52 - 13
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxTemplate.java

@ -1,18 +1,19 @@
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 {
public class WxTemplate extends IdEntity implements java.io.Serializable{
	// Fields
	private Integer id;//模板id
	private String code;//模板code
	private String name;//模板名称
	private String wechatCode;//关联的微信code 关联表 Wx_Wechat
@ -25,25 +26,63 @@ public class WxTemplate implements java.io.Serializable {
	private String updateUserName;//修改人名称
	private Date updateTime;//修改时间
	private String remark;
	private Integer status; //状态 -1 已删除 0可用
	// Constructors
	public WxTemplate(Long id, String code, String name, String wechatCode, String templateCode, String value, String createUser, String createUserName, Date createTime, String updateUser, String updateUserName, Date updateTime, String remark, Integer status) {
		this.id = id;
		this.code = code;
		this.name = name;
		this.wechatCode = wechatCode;
		this.templateCode = templateCode;
		this.value = value;
		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() {
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	public String getUpdateUserName() {
		return updateUserName;
	}
	public void setId(Integer id) {
		this.id = id;
	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;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	// Constructors
	/** default constructor */
	public WxTemplate() {
	}
	@Column(name = "code", length = 64)
	public String getCode() {
		return this.code;

+ 16 - 40
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxWechat.java

@ -1,17 +1,18 @@
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 {
public class WxWechat extends IdEntity implements java.io.Serializable{
	// Fields
	private Integer id;//'主键
	private String code;//业务code
	private String saasId;//'saas配置id'
	private String weichatId;//微信的id
@ -29,26 +30,7 @@ public class WxWechat implements java.io.Serializable {
	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;
	public WxWechat(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.code = code;
		this.saasId = saasId;
		this.weichatId = weichatId;
@ -67,16 +49,10 @@ public class WxWechat implements java.io.Serializable {
		this.remark = remark;
	}
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	/** default constructor */
	public WxWechat() {
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "code", length = 64)
	public String getCode() {
@ -187,6 +163,15 @@ public class WxWechat implements java.io.Serializable {
		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;
@ -215,13 +200,4 @@ public class WxWechat implements java.io.Serializable {
		this.updateTime = updateTime;
	}
	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
}

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

@ -0,0 +1,80 @@
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;
/**
 * 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.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);
        }
        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.getAppId())) {
            throw new ApiException(WxContants.Wechat.message_fail_appId_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wechat.getCode())) {
            throw new ApiException(WxContants.Wechat.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        WxWechat wechatTem = wechatDao.findByAppIdExcludeCode(wechat.getAppId(),wechat.getCode());
        if(wechatTem!=null){
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
        }
        return wechatDao.save(wechat);
    }
    public WxWechat findByCode(String code) {
        WxWechat wxWechat = wechatDao.findByCode(code);
        if (wxWechat == null) {
            throw new ApiException(WxContants.Wechat.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return wxWechat;
    }
    @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);
    }
}

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

@ -0,0 +1,48 @@
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.WxAccessTokenDao;
import com.yihu.jw.wx.model.WxAccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
/**
 * Created by Administrator on 2017/5/18 0018.
 */
@Service
public class WxAccessTokenService extends BaseJpaService<WxAccessToken, WxAccessTokenDao> {
    @Autowired
    private WxAccessTokenDao wxAccessTokenDao;
    /**
     * 根据wechatCode查找最新一条
     * @param wechatCode
     * @return
     */
    public WxAccessToken getWxAccessTokenByCode(String wechatCode) {
        List<WxAccessToken> wxAccessTokens =  wxAccessTokenDao.getWxAccessTokenByCode(wechatCode);
        if(wxAccessTokens!=null&&wxAccessTokens.size()>0){
            return wxAccessTokens.get(0);
        }
        return null;
    }
    @Transactional
    public WxAccessToken createWxAccessToken(WxAccessToken wxAccessToken) {
        if (StringUtils.isEmpty(wxAccessToken.getWechatCode())) {
            throw new ApiException(WxContants.WxAccessToken.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxAccessToken.getExpiresIn())) {
            throw new ApiException(WxContants.WxAccessToken.message_fail_expiresIn_is_null, CommonContants.common_error_params_code);
        }
        return wxAccessTokenDao.save(wxAccessToken);
    }
}

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

@ -0,0 +1,64 @@
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.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;
/**
 * 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.getValue())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_value_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);
        }
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    @Transient
    public WxGraphicMessage updateWxchat(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.getValue())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_value_is_null, CommonContants.common_error_params_code);
        }
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    public WxGraphicMessage findByCode(String code) {
        WxGraphicMessage WxGraphicMessage = wxGraphicMessageDao.findByCode(code);
        if (WxGraphicMessage == null) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return WxGraphicMessage;
    }
    @Transient
    public void deleteWxGraphicMessage(String code) {
        WxGraphicMessage WxGraphicMessage = findByCode(code);
        WxGraphicMessage.setStatus(-1);
        wxGraphicMessageDao.save(WxGraphicMessage);
    }
}

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

@ -0,0 +1,61 @@
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.WxMenuDao;
import com.yihu.jw.wx.model.WxMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    @Autowired
    private WxMenuDao wxMenuDao;
    public WxMenu createWxMenu(WxMenu wxMenu) {
        if (StringUtils.isEmpty(wxMenu.getWechatCode())) {
            throw new ApiException(WxContants.WxMenu.message_fail_wechatCode_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getName())) {
            throw new ApiException(WxContants.WxMenu.message_fail_wxMenuName_is_null, CommonContants.common_error_params_code);
        }
        return wxMenuDao.save(wxMenu);
    }
    @Transient
    public WxMenu updateWxMenu(WxMenu wxMenu) {
        if (StringUtils.isEmpty(wxMenu.getWechatCode())) {
            throw new ApiException(WxContants.WxMenu.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getName())) {
            throw new ApiException(WxContants.WxMenu.message_fail_name_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wxMenu.getId())) {
            throw new ApiException(WxContants.WxMenu.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        return wxMenuDao.save(wxMenu);
    }
    @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);
        }
        wxMenu.setStatus(-1);
        wxMenuDao.save(wxMenu);
    }
    public WxMenu findByCode(String code) {
        return wxMenuDao.findByCode(code);
    }
}

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

@ -0,0 +1,64 @@
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.WxTemplateDao;
import com.yihu.jw.wx.model.WxTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
/**
 * Created by Administrator on 2017/5/19 0019.
 */
@Service
public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao> {
    @Autowired
    private WxTemplateDao wxTemplateDao;
    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);
        }
        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.getId())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_id_is_null, 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);
        if (wxTemplate == null) {
            throw new ApiException(WxContants.WxTemplate.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return wxTemplate;
    }
}

+ 1 - 1
web-gateway/src/main/resources/bootstrap.yml

@ -3,7 +3,7 @@ spring:
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      failFast: true ##启动快速失败 即链接不到配置服务就启动失败
      failFast: false ##启动快速失败 即链接不到配置服务就启动失败
      username: jw
      password: jkzl
      discovery: