Bläddra i källkod

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

chenweida 8 år sedan
förälder
incheckning
5eaa754f22
20 ändrade filer med 758 tillägg och 270 borttagningar
  1. 20 0
      common/common-mysql/src/main/java/com/yihu/jw/mysql/query/BaseJpaService.java
  2. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WechatController.java
  3. 2 3
      svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java
  4. 40 0
      svr/svr-manage/src/main/java/com/yihu/jw/manage/controller/base/SaasController.java
  5. 34 33
      svr/svr-manage/src/main/java/com/yihu/jw/manage/controller/wechat/GraphicMessageController.java
  6. 5 23
      svr/svr-manage/src/main/java/com/yihu/jw/manage/controller/wechat/WechatConfigController.java
  7. 28 0
      svr/svr-manage/src/main/java/com/yihu/jw/manage/service/base/SaasService.java
  8. 62 24
      svr/svr-manage/src/main/java/com/yihu/jw/manage/service/wechat/GraphicMessageService.java
  9. 5 6
      svr/svr-manage/src/main/java/com/yihu/jw/manage/service/wechat/WechatConfigService.java
  10. 1 0
      svr/svr-manage/src/main/resources/application.yml
  11. 95 36
      svr/svr-manage/src/main/resources/webapp/html/wechat/graphicMessage/html/graphicMessageList.html
  12. 287 30
      svr/svr-manage/src/main/resources/webapp/html/wechat/graphicMessage/js/graphicMessageList.js
  13. 5 18
      svr/svr-manage/src/main/resources/webapp/html/wechat/wechatConfig/js/wechatConfigList.js
  14. 18 15
      web-gateway/src/main/java/com/yihu/jw/commnon/base/wx/WechatContants.java
  15. 20 10
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatController.java
  16. 39 13
      web-gateway/src/main/java/com/yihu/jw/controller/base/wx/WechatGraphicMessageController.java
  17. 10 8
      web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/GraphicMessageFegin.java
  18. 7 6
      web-gateway/src/main/java/com/yihu/jw/fegin/base/wx/WechatFegin.java
  19. 38 13
      web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/GraphicMessageFeginFallbackFactory.java
  20. 41 31
      web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/WechatFeginFallbackFactory.java

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

@ -81,6 +81,11 @@ public class BaseJpaService<T, R> {
    }
    public List search(String fields, String filters, String sorts, Integer page, Integer size) throws ParseException {
        if(filters!=null){
            filters = "status<>-1;"+filters;
        }else{
            filters="status<>-1;";
        }
        URLQueryParser queryParser = createQueryParser(fields, filters, sorts);
        CriteriaQuery query = queryParser.makeCriteriaQuery();
@ -94,6 +99,11 @@ public class BaseJpaService<T, R> {
                .getResultList();
    }
    public List search(String fields, String filters, String sorts) throws ParseException {
        if(filters!=null){
            filters = "status<>-1;"+filters;
        }else{
            filters="status<>-1;";
        }
        URLQueryParser queryParser = createQueryParser(fields, filters, sorts);
        CriteriaQuery query = queryParser.makeCriteriaQuery();
@ -103,6 +113,11 @@ public class BaseJpaService<T, R> {
    }
    public List search(String filters) throws ParseException {
        if(filters!=null){
            filters = "status<>-1;"+filters;
        }else{
            filters="status<>-1;";
        }
        URLQueryParser queryParser = createQueryParser("", filters, "");
        CriteriaQuery query = queryParser.makeCriteriaQuery();
@ -112,6 +127,11 @@ public class BaseJpaService<T, R> {
    }
    public List search(String filters,String sorts) throws ParseException {
        if(filters!=null){
            filters = "status<>-1;"+filters;
        }else{
            filters="status<>-1;";
        }
        URLQueryParser queryParser = createQueryParser("", filters, sorts);
        CriteriaQuery query = queryParser.makeCriteriaQuery();

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

@ -25,7 +25,7 @@ import java.util.List;
@RestController
@RequestMapping(WxContants.Wechat.api_common)
@Api(value = "微信相关操作", description = "微信相关操作")
public class WechatController extends EnvelopRestController {
public class WechatConfigController extends EnvelopRestController {
    @Autowired
    private WechatService wechatService;

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

@ -26,9 +26,8 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
    @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);
        }
        String code = UUID.randomUUID().toString().replaceAll("-", "");
        wxGraphicMessage.setCode(code);
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }

+ 40 - 0
svr/svr-manage/src/main/java/com/yihu/jw/manage/controller/base/SaasController.java

@ -0,0 +1,40 @@
package com.yihu.jw.manage.controller.base;
import com.yihu.jw.manage.service.base.SaasService;
import com.yihu.jw.restmodel.common.Envelop;
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 Administrator on 2017/6/13 0013.
 */
@RestController
@RequestMapping("/base")
@Api(description = "saas相关")
public class SaasController {
    @Autowired
    private SaasService saasService;
    @GetMapping("/saases")
    @ApiOperation(value = "分页获取微信配置列表")
    public Envelop list(
            @ApiParam(name = "name", value = "name", required = false) @RequestParam(required = false, name = "name") String name,
            @ApiParam(name = "sorts", value = "排序", required = false) @RequestParam(required = false, name = "sorts") String sorts,
            @ApiParam(name = "start", value = "当前页", required = false) @RequestParam(required = false, name = "start", defaultValue = "1") Integer start,
            @ApiParam(name = "length", value = "每页显示条数", required = false) @RequestParam(required = false, name = "length", defaultValue = "10") Integer length
    ) {
        try {
            Envelop envelop = saasService.list(name, sorts,length, start);
            return envelop;
        } catch (Exception e) {
            return Envelop.getError("获取信息失败:" + e.getMessage(), -1);
        }
    }
}

+ 34 - 33
svr/svr-manage/src/main/java/com/yihu/jw/manage/controller/wechat/GraphicMessageController.java

@ -1,67 +1,68 @@
package com.yihu.jw.manage.controller.wechat;
import com.yihu.jw.manage.model.system.ManageUser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yihu.jw.manage.model.wechat.GraphicMessage;
import com.yihu.jw.manage.service.wechat.GraphicMessageService;
import com.yihu.jw.restmodel.common.Envelop;
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.data.domain.Page;
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;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
 * Created by Administrator on 2017/6/13 0013.
 */
@RestController
@RequestMapping("/graphicMessage")
@RequestMapping("/wechat")
@Api(description = "微信图文消息管理")
public class GraphicMessageController {
    @Autowired
    private GraphicMessageService graphicMessageService;
    @GetMapping("/list")
    @ApiOperation(value = "图文消息列表")
    @GetMapping("graphicMessage/list")
    @ApiOperation(value = "分页获取微信图文列表")
    public Envelop list(
            @ApiParam(name = "title", value = "标题", required = false) @RequestParam(required = false, name = "title") String title,
            @ApiParam(name = "description", value = "描述", required = false) @RequestParam(required = false, name = "description") String description,
            @ApiParam(name = "page", value = "当前页", required = false) @RequestParam(required = false, name = "page", defaultValue = "1") Integer page,
            @ApiParam(name = "pageSize", value = "每页显示条数", required = false) @RequestParam(required = false, name = "pageSize", defaultValue = "10") Integer pageSize
            @ApiParam(name = "sorts", value = "排序", required = false) @RequestParam(required = false, name = "sorts") String sorts,
            @ApiParam(name = "start", value = "当前页", required = false) @RequestParam(required = false, name = "start", defaultValue = "1") Integer start,
            @ApiParam(name = "length", value = "每页显示条数", required = false) @RequestParam(required = false, name = "length", defaultValue = "10") Integer length
    ) {
        try {
            Page<ManageUser> users = graphicMessageService.list(title, description , pageSize, page);
            return Envelop.getSuccessListWithPage(
                    "获取信息成功",
                    users.getContent(),//数据内容
                    page, //当前页
                    pageSize,//每个显示条数
                    users.getTotalElements()//总数
            );
            Envelop envelop = graphicMessageService.list(title, sorts,length, start);
            return envelop;
        } catch (Exception e) {
            return Envelop.getError("获取信息成功:" + e.getMessage(), -1);
            return Envelop.getError("获取信息失败:" + e.getMessage(), -1);
        }
    }
    @GetMapping("/getByCode")
    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    @DeleteMapping(value = "/graphicMessage/{codes}")
    @ApiOperation(value = "通过codes删除,多个code用,分割", notes = "通过codes删除")
    public Envelop deleteByCodes(
            @ApiParam(name = "codes", value = "codes")
            @PathVariable String codes
    ) {
        return graphicMessageService.findByCode(code);
        Envelop envelop = graphicMessageService.deleteByCode(codes);
        return envelop;
    }
    @GetMapping("/getByCodea")
    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
    public Envelop findByCodea(
    @GetMapping(value = "/graphicMessage/{code}")
    @ApiOperation(value = "根据code查找图文消息", notes = "根据code查找图文消息")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
            @PathVariable String code
    ) {
        return graphicMessageService.findByCodea(code);
        Envelop envelop = graphicMessageService.findByCode(code);
        return envelop;
    }
    @PostMapping(value = "/graphicMessage")
    @ApiOperation(value = "保存或者修改微信图文消息", notes = "保存或者修改微信图文消息")
    public Envelop saveOrUpdate(@ModelAttribute @Valid GraphicMessage graphicMessage) throws JsonProcessingException {
        return graphicMessageService.saveOrUpdate(graphicMessage);
    }
}

+ 5 - 23
svr/svr-manage/src/main/java/com/yihu/jw/manage/controller/wechat/WechatConfigController.java

@ -16,14 +16,14 @@ import javax.validation.Valid;
 * Created by Administrator on 2017/6/13 0013.
 */
@RestController
@RequestMapping("/wechatConfig")
@RequestMapping("/wechat")
@Api(description = "微信配置管理")
public class WechatConfigController {
    @Autowired
    private WechatConfigService wechatConfigService;
    @GetMapping("/list")
    @GetMapping("wechatConfig/list")
    @ApiOperation(value = "分页获取微信配置列表")
    public Envelop list(
            @ApiParam(name = "name", value = "微信名", required = false) @RequestParam(required = false, name = "name") String name,
@ -40,7 +40,7 @@ public class WechatConfigController {
    }
    @DeleteMapping(value = "/wechat/{codes}")
    @DeleteMapping(value = "/wechatConfig/{codes}")
    @ApiOperation(value = "通过codes删除,多个code用,分割", notes = "通过codes删除")
    public Envelop deleteByCodes(
            @ApiParam(name = "codes", value = "codes")
@ -50,7 +50,7 @@ public class WechatConfigController {
        return envelop;
    }
    @GetMapping(value = "/wechat/{code}")
    @GetMapping(value = "/wechatConfig/{code}")
    @ApiOperation(value = "根据code查找微信配置", notes = "根据code查找微信配置")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
@ -60,27 +60,9 @@ public class WechatConfigController {
        return envelop;
    }
    @PostMapping(value = "/wechat")
    @PostMapping(value = "/wechatConfig")
    @ApiOperation(value = "保存微信配置", notes = "保存微信配置")
    public Envelop save(@ModelAttribute @Valid WechatConfig wechatConfig) throws JsonProcessingException {
        return wechatConfigService.saveOrUpdate(wechatConfig);
    }
    /*@GetMapping("/getByCode")
    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        return wechatConfigService.findByCode(code);
    }
    @GetMapping("/getByCodea")
    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
    public Envelop findByCodea(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        return wechatConfigService.findByCodea(code);
    }*/
}

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

@ -0,0 +1,28 @@
package com.yihu.jw.manage.service.base;
import com.yihu.jw.restmodel.common.Envelop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
/**
 * Created by Administrator on 2017/6/13 0013.
 */
@Service
public class SaasService {
    @Value("${spring.gateway}")
    private String url;
    @Autowired
    private RestTemplate template;
   public Envelop list(String name, String sorts ,Integer size, Integer page) {
       Envelop forObject = template.getForObject(url + "/saas/getSaass",
               Envelop.class);
       return forObject;
    }
}

+ 62 - 24
svr/svr-manage/src/main/java/com/yihu/jw/manage/service/wechat/GraphicMessageService.java

@ -1,49 +1,87 @@
package com.yihu.jw.manage.service.wechat;
import com.yihu.jw.manage.model.system.ManageUser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yihu.jw.manage.model.wechat.GraphicMessage;
import com.yihu.jw.manage.util.RestTemplateUtil;
import com.yihu.jw.restmodel.common.Envelop;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by Administrator on 2017/6/13 0013.
 */
@Service
public class GraphicMessageService {
    @Value("${spring.gateway}")
    private String url;
    @Autowired
    private RestTemplate template;
   public Page<ManageUser> list(String title, String description, Integer size, Integer page) {
       Object forObject = null;
       String fields = "id,code,title,description,url";
       String filters="";//&filters={filters}
       //forObject = template.getForObject(url + "/graphicMessage/getWxGraphicMessages?fields={fields}&filters={filters}&sorts={sorts}&size={size}&page={page}",
       //        Object.class,fields,null,null,size,page);
       forObject = template.getForObject(url + "/graphicMessage/getWxGraphicMessages?fields="+fields+"&size="+size+"&page="+page,//&filters="+null+"&sorts="+null+
                       Object.class);
       System.out.print(forObject.toString());
       System.out.print("-----------------------------");
       return null;
    public Envelop list(String title, String sorts ,Integer size, Integer page) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> filters = new HashMap<>();
        map.put("size",size);
        map.put("page",page);
        map.put("sorts",sorts);
        map.put("filters","");
        if(StringUtils.isNotBlank(title)){
            filters.put("title",title);
            map.put("filters",filters);
        }
        Envelop forObject = template.getForObject(url + "/wechat/graphicMessage/list?size={size}&page={page}&sorts={sorts}&filters={filters}",
                Envelop.class,map);
        return forObject;
    }
    public Envelop deleteByCode(String codes) {
        //delete 没有返回值....
        //template.delete(url + "/graphicMessage/delete?codes={codes}", codes);
        MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
        map.add("codes", codes);
        String urlRequest = url + "/wechat/graphicMessage/"+codes;
        RestTemplateUtil restTemplateUtil = new RestTemplateUtil(urlRequest,map);
        Envelop envelop = restTemplateUtil.exchange(urlRequest, HttpMethod.DELETE, Envelop.class);
        return envelop;
    }
    public Envelop findByCode(String code) {
        //Object forObject = template.getForObject(url + "/graphicMessage/getByCode?code=1", Object.class);
        Object forObject = template.getForObject(url + "/graphicMessage/getByCodea?code={code}", Object.class,code);
        System.out.print(forObject.toString());
        System.out.print("-----------------------------");
        return null;
        Envelop envelop = template.getForObject(url + "/wechat/graphicMessage/"+code, Envelop.class);
        return envelop;
    }
    public Envelop findByCodea(String code) {
        //Object forObject = template.getForObject(url + "/graphicMessage/getByCode?code=1", Object.class);
        Object forObject = template.getForObject(url + "/graphicMessage/getByCodea/{code}", Object.class,code);
        System.out.print(forObject.toString());
        System.out.print("-----------------------------");
        return null;
    public Envelop saveOrUpdate(GraphicMessage graphicMessage) throws JsonProcessingException {
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        JSONObject jsonObj = JSONObject.fromObject(graphicMessage);
        HttpEntity<String> formEntity = new HttpEntity<String>(jsonObj.toString(), headers);
        Envelop envelop =null;
        if(graphicMessage.getId()==null){//说明是保存
            ResponseEntity<Envelop> responseEntity = template.postForEntity(url + "/wechat/graphicMessage", formEntity, Envelop.class);
            envelop = responseEntity.getBody();
            return envelop;
        }
        MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
        map.add("jsonData",jsonObj.toString());
        String urlRequest = url + "/wechat/graphicMessage";
        RestTemplateUtil restTemplateUtil = new RestTemplateUtil(urlRequest,map);
        envelop = restTemplateUtil.exchange(urlRequest, HttpMethod.PUT, Envelop.class);
        return envelop;
    }
}

+ 5 - 6
svr/svr-manage/src/main/java/com/yihu/jw/manage/service/wechat/WechatConfigService.java

@ -37,12 +37,11 @@ public class WechatConfigService {
       map.put("sorts",sorts);
       map.put("filters","");
       if(StringUtils.isNotBlank(name)){
           name = name.replaceAll(" ","");
           filters.put("name",name);
           map.put("filters",filters);
       }
       Envelop forObject = template.getForObject(url + "/wechatConfig/getWechats?size={size}&page={page}&sorts={sorts}&filters={filters}",
       Envelop forObject = template.getForObject(url + "/wechat/wechatConfig/list?size={size}&page={page}&sorts={sorts}&filters={filters}",
               Envelop.class,map);
       return forObject;
@ -53,14 +52,14 @@ public class WechatConfigService {
        //template.delete(url + "/wechatConfig/delete?codes={codes}", codes);
        MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
        map.add("codes", codes);
        String urlRequest = url + "/wechatConfig/delete?codes="+codes;
        String urlRequest = url + "/wechat/wechatConfig/"+codes;
        RestTemplateUtil restTemplateUtil = new RestTemplateUtil(urlRequest,map);
        Envelop envelop = restTemplateUtil.exchange(urlRequest, HttpMethod.DELETE, Envelop.class);
        return envelop;
    }
    public Envelop findByCode(String code) {
        Envelop envelop = template.getForObject(url + "/wechatConfig/getByCode?code={code}", Envelop.class,code);
        Envelop envelop = template.getForObject(url + "/wechat/wechatConfig/"+code, Envelop.class);
        return envelop;
    }
@ -73,13 +72,13 @@ public class WechatConfigService {
        HttpEntity<String> formEntity = new HttpEntity<String>(jsonObj.toString(), headers);
        Envelop envelop =null;
        if(wechatConfig.getId()==null){//说明是保存
            ResponseEntity<Envelop> responseEntity = template.postForEntity(url + "/wechatConfig/create", formEntity, Envelop.class);
            ResponseEntity<Envelop> responseEntity = template.postForEntity(url + "/wechat/wechatConfig", formEntity, Envelop.class);
            envelop = responseEntity.getBody();
            return envelop;
        }
        MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
        map.add("jsonData",jsonObj.toString());
        String urlRequest = url + "/wechatConfig/update";
        String urlRequest = url + "/wechat/wechatConfig";
        RestTemplateUtil restTemplateUtil = new RestTemplateUtil(urlRequest,map);
        envelop = restTemplateUtil.exchange(urlRequest, HttpMethod.PUT, Envelop.class);

+ 1 - 0
svr/svr-manage/src/main/resources/application.yml

@ -32,6 +32,7 @@ spring:
---
spring:
  profiles: dev
  gateway: http://localhost:8088/v1
  datasource:
    url: jdbc:mysql://172.19.103.77/jw2?useUnicode:true&characterEncoding=utf-8&autoReconnect=true

+ 95 - 36
svr/svr-manage/src/main/resources/webapp/html/wechat/graphicMessage/html/graphicMessageList.html

@ -2,7 +2,7 @@
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图文消息管理页面</title>
    <title>微信图文消息管理页面</title>
    <link href="/common/css/bootstrap/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="/common/css/bootstrap/font-awesome.min.css?v=4.3.0" rel="stylesheet">
@ -10,10 +10,37 @@
    <link href="/common/css/bootstrap/animate.min.css" rel="stylesheet">
    <link href="/common/css/bootstrap/style.min.css?v=3.0.0" rel="stylesheet">
    <link href="/common/css/bootstrap/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <!-- Data Tables -->
    <link href="/common/css/bootstrap/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
    <style>
        .m-form-group:after { display: table; content: " "; clear: both; }
        .m-form-group{
            margin-top: 18px;;
        }
        select{
            width:250px !important;
        }
    </style>
</head>
<body class="gray-bg">
<div class="panel panel-default">
    <div class="panel-body">
        <div class="col-md-12">
            <div class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-2 control-label">标题:</label>
                    <div class="col-sm-3">
                        <input type="text" class="form-control" id="title" name="title" style="width: 250px">
                    </div>
                    <div class="col-sm-2">
                        <button type="button" class="btn btn-success search" style="float: right;">查 询</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
@ -22,49 +49,21 @@
                    <h5>
                        <small>图文消息列表</small>
                    </h5>
                    <!--<div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="table_data_tables.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="table_data_tables.html#">选项1</a>
                            </li>
                            <li><a href="table_data_tables.html#">选项2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>-->
                </div>
                <input type="button" onclick="haha()"/>
                <div class="ibox-content">
                    <table id="graphicMessageList" class="table table-striped table-bordered table-hover dataTables-example">
                    <table id="list" class="table table-striped table-bordered table-hover dataTables-example">
                        <thead>
                        <tr>
                            <th><input type="checkbox" name="checkAll" /></th>
                            <th>标题</th>
                            <th>描述</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <th>啊啊啊</th>
                            <th>不不不</th>
                            <th>充充充</th>
                        </tr>
                        </tbody>
                        <tfoot>
                        <tr>
                            <th>标题</th>
                            <th>描述</th>
                            <th>创建时间</th>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
@ -72,19 +71,79 @@
    </div>
</div>
<div class="modal fade" id="myModal-add-info" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:1200px;height: 800px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"
                        data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    新 增
                </h4>
            </div>
            <form class="form-horizontal" role="form" action="" method="post"  id="category_add" >
                <input  id="id" type="hidden" name="id" :value="graphicMessage.id" />
                <input  type="hidden" name="code" :value="graphicMessage.code" />
                <input  type="hidden" name="createUser" :value="graphicMessage.createUser" />
                <input  type="hidden" name="createUserName" :value="graphicMessage.createUserName" />
                <!--<input  type="hidden" name="createTime" :value="graphicMessage.createTime" />-->
                <div class="m-form-group">
                    <label class="col-sm-3 control-label no-padding-right" >标题: </label>
                    <div class="col-sm-2">
                        <input type="text"  class="form-control"  name="title" style="width: 250px"   :value="graphicMessage.title"/>
                    </div>
                    <label class="col-sm-2 control-label no-padding-right" >url:</label>
                    <div class="col-sm-5">
                        <input type="url"  class="form-control"  name="url" style="width: 250px" required="true" :value="graphicMessage.url"/>
                    </div>
                </div>
                <div class="m-form-group">
                    <label class="col-sm-3 control-label no-padding-right" >图片地址:</label>
                    <div class="col-sm-2">
                        <input type="url"  class="form-control"  name="picUrl" style="width: 250px"   :value="graphicMessage.picUrl"/>
                    </div>
                    <label class="col-sm-2 control-label no-padding-right" >备注:</label>
                    <div class="col-sm-5">
                        <input type="text"  class="form-control"  name="remark" style="width: 250px" required="true" :value="graphicMessage.remark"/>
                    </div>
                </div>
                <div style="margin:0 auto; text-align: center;margin-top: 15px">
                    <label class="col-sm-3 control-label no-padding-right" >描述:</label>
                    <textarea style="width:54%;height:150px;margin-left: -211px;" :value="graphicMessage.description" name="description"></textarea>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>
                    <button type="button" class="btn btn-primary" id="btnsubmit">
                        提交
                    </button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div>
</div>
<!-- 全局js -->
<script type="text/javascript" src="/common/js/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/common/js/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="/common/js/util/util.js"></script>
<!--<script type="text/javascript" src="/common/js/vue/vue.js"></script>--><!--2.0-->
<script type="text/javascript" src="/common/js/vue.js"></script><!--1.0-->
<script type="text/javascript" src="/common/js/layer/layer.min.js"></script>
<script type="text/javascript" src="/common/js/plugins/jeditable/jquery.jeditable.js"></script>
<script type="text/javascript" src="/common/js/plugins/moment/moment.js"></script>
<!-- Data Tables -->
<script type="text/javascript" src="/common/js/plugins/dataTables/jquery.dataTables.js"></script>
<script type="text/javascript" src="/common/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<!-- 自定义js -->
<script type="text/javascript" src="/common/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript" src="/wechat/graphicMessage/js/graphicMessageList.js"></script>
</body>

+ 287 - 30
svr/svr-manage/src/main/resources/webapp/html/wechat/graphicMessage/js/graphicMessageList.js

@ -1,38 +1,295 @@
$(document).ready(function () {
    //初始化用户列表
    $("#graphicMessageList").dataTable({
        serverSide: true, //开启服务器模式
        paging: true,//是否显示分页栏,默认是true
        searching: false, //禁用搜索和排序 默认false
        ordering: false,//禁止排序 默认false
        ajax: {
            url: '/graphicMessage/list',
            type: 'GET',
            dataSrc: "detailModelList"
        },
        columns: [
            {data: 'detailModelList.name'},
            {data: 'detailModelList.code'},
            {data: 'detailModelList.mobile'}
        ],
        "columnDefs": [  //隐藏第几列  下标从0开始
            {
                "targets": [0, 2],
                "visible": false,
                "searchable": false
var table;
var usercode = window.localStorage.getItem("userCode");
$(function () {
    table = $("#list").DataTable({
            "aLengthMenu": [1, 2, 30, 40],
            "searching": false,//禁用搜索
            "lengthChange": true,
            "paging": true,//开启表格分页
            "bProcessing": true,
            "bServerSide": true,
            "bAutoWidth": false,
            "sort": "position",
            "deferRender": true,//延迟渲染
            "bStateSave": false, //在第三页刷新页面,会自动到第一页
            "iDisplayLength": 10,//每页显示条数
            "iDisplayStart": 1, //当前页
            "dom": '<l<\'#topPlugin\'>f>rt<ip><"clear">',
            "ordering": false,//全局禁用排序
            "ajax": {
                url: '/wechat/graphicMessage/list',
                data: function (d) {
                    d.title = $("#title").val();
                    d.userCode = usercode;
                },
                type: 'GET',
                dataSrc: "detailModelList"
            },
            "aoColumns": [
                {
                    "mData": "code",
                    "orderable": false, // 禁用排序
                    "sDefaultContent": "",
                    "sWidth": "2%"
                },
                {
                    "mData": 'title',
                    "sWidth": "10%",
                    "orderable": false // 禁用排序
                },
                {
                    "mData": 'description',
                    "sWidth": "10%",
                    "orderable": false // 禁用排序
                },
                {
                    "mData": 'createTime',
                    "sWidth": "10%",
                    "orderable": false, // 禁用排序
                    "render": function (data, type, full, meta) {
                        //时间格式化
                        return moment(data).format("YYYY-MM-DD HH:mm:ss");
                    }
                },
                {
                    "mData": "code",
                    "orderable": false, // 禁用排序
                    "sDefaultContent": '',
                    "sWidth": "10%",
                    "render": function (data, type, full, meta) {
                        return data = '<button id="findOne" class="btn btn-primary  btn-sm" data-id=' + data + ' onclick="show(\''+data+'\')">查 看</button>';/*<button id="deleteOne" class="btn btn-danger btn-sm" style="margin-left: 7px;" data-id=' + data + '>删 除</button>*/
                    }
                }
            ],
            "columnDefs": [{
                "orderable": false, // 禁用排序
                "targets": [0], // 指定的列
                "data": "code",
                "render": function (data, type, full, meta) {
                    return '<input type="checkbox" value="' + data + '" name="code"/>';
                }
            }],
            "oLanguage": { // 国际化配置
                "sProcessing": "正在获取数据,请稍后...",
                "sLengthMenu": "显示 _MENU_ 条",
                "sZeroRecords": "没有找到数据",
                "sInfo": "从 _START_ 到  _END_ 条记录 总记录数为 _TOTAL_ 条",
                "sInfoEmpty": "记录数为0",
                "sInfoFiltered": "(全部记录数 _MAX_ 条)",
                "sInfoPostFix": "",
                "sSearch": "搜索",
                "sUrl": "",
                "oPaginate": {
                    "sFirst": "第一页",
                    "sPrevious": "上一页",
                    "sNext": "下一页",
                    "sLast": "最后一页"
                }
            },
            initComplete: initComplete,
            drawCallback: function (settings) {
                $('input[name=checkAll]')[0].checked = false;//取消全选状态
            }
        ],
        "order": [[1, 'asc']]  //索引行
        }
    );
    /**
     * 表格加载渲染完毕后执行的方法
     * @param data
     */
    function initComplete(data){
        //删除用户按钮的HTMLDOM
        var topPlugin='<button   class="btn btn-danger btn-sm" id="deleteAll">批量删除</button> <button   class="btn btn-primary btn-sm addBtn" >新 增</button>       <button  class="btn btn-warning btn-sm" id="reset">重置搜索条件</button>' ;
        $("#topPlugin").append(topPlugin);//在表格上方topPlugin DIV中追加HTML
    }
    /**
     * 多选选中和取消选中,同时选中第一个单元格单选框,并联动全选单选框
     */
    $('#wechatList tbody').on('click', 'tr', function(event) {
        var checkAllWechat=$('input[name=checkAllWechat]')[0];//关联全选单选框
        $($(this).children()[0]).children().each(function(){
            if(this.type=="checkbox" && (!$(event.target).is(":checkbox") && $(":checkbox",this).trigger("click"))){
                if(!this.checked){
                    this.checked = true;
                    addValue(this);
                    var selected=table.rows('.selected').data().length;//被选中的行数
                    //全选单选框的状态处理
                    var recordsDisplay=table.page.info().recordsDisplay;//搜索条件过滤后的总行数
                    var iDisplayStart=table.page.info().start;// 起始行数
                    if(selected === table.page.len()||selected === recordsDisplay||selected === (recordsDisplay - iDisplayStart)){
                        checkAllWechat.checked = true;
                    }
                }else{
                    this.checked = false;
                    cancelValue(this);
                    checkAllWechat.checked = false;
                }
            }
        });
        $(this).toggleClass('selected');//放在最后处理,以便给checkbox做检测
    });
});
function haha(){
    $.ajax({
        url:"/graphicMessage/getByCode?code=1",
        success:function(data){
            debugger
    /**
     * 全选按钮被点击事件
     */
    $('input[name=checkAllWechat]').click(function(){
        if(this.checked){
            $('#wechatList tbody tr').each(function(){
                if(!$(this).hasClass('selected')){
                    $(this).click();
                }
            });
        }else{
            $('#wechatList tbody tr').click();
        }
    });
    /**
     * 单选框被选中时将它的value放入隐藏域
     */
    function addValue(para) {
        var wechatCodes = $("input[name=wechatCodes]");
        if(wechatCodes.val() === ""){
            wechatCodes.val($(para).val());
        }else{
            wechatCodes.val(wechatCodes.val()+","+$(para).val());
        }
    }
    /**
     * 单选框取消选中时将它的value移除隐藏域
     */
    function cancelValue(para){
        //取消选中checkbox要做的操作
        var wechatCodes = $("input[name=checkAllWechat]");
        var array = wechatCodes.val().split(",");
        wechatCodes.val("");
        for (var i = 0; i < array.length; i++) {
            if (array[i] === $(para).val()) {
                continue;
            }
            if (wechatCodes.val() === "") {
                wechatCodes.val(array[i]);
            } else {
                wechatCodes.val(wechatCodes.val() + "," + array[i]);
            }
        }
    }
    $(document).delegate('.addBtn','click',function() {
        contentVM.wechatConfig='';
        $('#myModal-add-info').modal('show');
        setTimeout(function(){
            console.log($(':input','#myModal-add-info')
                .not(':button, :submit, :reset, :hidden').length)
            console.log("---------------------")
            $(':input','#myModal-add-info')
                .not(':button, :submit, :reset, :hidden')
                .val('')
                .removeAttr('checked');
        },200);
    });
    //批量删除
    $(document).delegate('#deleteAll','click',function() {
        var theArray=[];
        $("input[name=code]:checked").each(function() {
            theArray.push($(this).val());
        });
        if(theArray.length<1){
            alert("请至少选择一个");
        }else{
            var codes = theArray.join(",");
            del(codes);
        }
    });
    $(document).delegate('.upOrderStatus','click',function() {
        var id=$(this).data("id");
        //alert(id);
        $("#titleId").html(id);
        $('#editOrderStatus').modal("show");
    });
    //清空查询条件
    $(document).delegate('#reset','click',function() {
        $("#title").val("");
    });
    //重新查询
    $(document).delegate('.search', 'click', function () {
        table.ajax.reload();
    });
});
var contentVM = new Vue({
    el: '#category_add',
    data: {
        graphicMessage: '',//记录详情信息
        saasList:''//记录saas列表
    },
    replace:false
});
do_get("/base/saases",{},function(data){
    contentVM.saasList = data.detailModelList;
    console.log( data.detailModelList);
},function(data){
})
//查看配置
function show(code){
    $("#myModal-add-info").removeData("modal");
    var data={};
    do_get("/wechat/graphicMessage/"+code,data,function(data){
        contentVM.graphicMessage = data.obj;
        $('#myModal-add-info').modal('show');
        $("#myModalLabel").html("查看");
    },function(data){
    });
}
function del(codes){
    var url = "/wechat/graphicMessage/"+codes+"?userCode="+usercode;
    do_delete(url,{},function(data){
        if(data.successFlg==true){
            alert("删除成功");
            table.ajax.reload();
        }else{
            alert("删除失败")
        }
    })
}
$("#btnsubmit").click(function(){
    var url = "";
    var id = $("#id").val();
    var data = $("#category_add").serialize();
    url = "/wechat/graphicMessage"
    do_post(url,data,function(data){
        if(data.successFlg){
            if(id==''){
                alert("保存成功");
            }else{
                alert("修改成功");
            }
            $('#myModal-add-info').modal('hide');
            table.ajax.reload();
            return;
        }
        alert(data.errorMsg);
    })
})

+ 5 - 18
svr/svr-manage/src/main/resources/webapp/html/wechat/wechatConfig/js/wechatConfigList.js

@ -17,7 +17,7 @@ $(function () {
            "dom": '<l<\'#topPlugin\'>f>rt<ip><"clear">',
            "ordering": false,//全局禁用排序
            "ajax": {
                url: '/wechatConfig/list',
                url: '/wechat/wechatConfig/list',
                data: function (d) {
                    d.name = $("#name").val();
                    d.userCode = usercode;
@ -218,14 +218,6 @@ $(function () {
    }
//   function exp1(){
//	   $("#exp").attr("src",contextPath+"/department/export.do?t=" + new Date().getTime());
//   }
    $(document).delegate('#expCsv','click',function() {
        $("#exp").attr("src",contextPath+"/department/export.do?t=" + new Date().getTime());
    });
    $(document).delegate('.addBtn','click',function() {
        contentVM.wechatConfig='';
        $('#myModal-add-info').modal('show');
@ -275,12 +267,8 @@ $(function () {
    $(document).delegate('.search', 'click', function () {
        table.ajax.reload();
    });
});
var contentVM = new Vue({
    el: '#category_add',
    data: {
@ -290,7 +278,6 @@ var contentVM = new Vue({
    replace:false
});
do_get("/base/saases",{},function(data){
    contentVM.saasList = data.detailModelList;
    console.log( data.detailModelList);
@ -302,7 +289,7 @@ do_get("/base/saases",{},function(data){
function show(code){
    $("#myModal-add-info").removeData("modal");
    var data={};
    do_get("/wechatConfig/wechat/"+code,data,function(data){
    do_get("/wechat/wechatConfig/"+code,data,function(data){
        contentVM.wechatConfig = data.obj;
        $('#myModal-add-info').modal('show');
        $("#myModalLabel").html("查看");
@ -312,7 +299,7 @@ function show(code){
}
function del(codes){
    var url = "/wechatConfig/wechat/"+codes+"?userCode="+usercode;
    var url = "/wechat/wechatConfig/"+codes+"?userCode="+usercode;
    do_delete(url,{},function(data){
        if(data.successFlg==true){
            alert("删除成功");
@ -328,7 +315,7 @@ $("#btnsubmit").click(function(){
    var id = $("#id").val();
    var data = $("#category_add").serialize();
    if(id==''){//说明是保存
        url = "/wechatConfig/wechat"
        url = "/wechat/wechatConfig"
        do_post(url,data,function(data){
            if(data.successFlg){
                alert("保存成功");
@ -340,7 +327,7 @@ $("#btnsubmit").click(function(){
        })
    }else{//说明是修改
        url="/wechatConfig/wechat?userCode="+usercode;
        url="/wechat/wechatConfig?userCode="+usercode;
        do_put(url,data,function(data){
            console.log(data);
            if(data.successFlg){

+ 18 - 15
web-gateway/src/main/java/com/yihu/jw/commnon/base/wx/WechatContants.java

@ -4,6 +4,9 @@ package com.yihu.jw.commnon.base.wx;
 * Created by Administrator on 2017/5/20 0020.
 */
public class WechatContants {
    public static final String api_common="wechat";
    //微信token模块常量
    public static class AccessToken{
        public static final String api_common="accessToken";
@ -23,6 +26,7 @@ public class WechatContants {
        public static final String api_createMenu="createMenu";
    }
    //微信模板消息
    public static class Template {
        public static final String api_common="template";
@ -34,26 +38,25 @@ public class WechatContants {
        public static final String api_getWxTemplatesNoPage="getWxTemplatesNoPage";
        public static final String api_sendTemplateMessage="sendTemplateMessage";
    }
    //微信配置表
    public static class Config {
        public static final String api_common="wechatConfig";
        public static final String api_create="create";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWechatNoPage="getWechatNoPage";
        public static final String api_getWechats="getWechats";
        public static final String api_getByCode="getByCode";
        public static final String api_create="wechatConfig";
        public static final String api_update="wechatConfig";
        public static final String api_delete="wechatConfig/{codes}";
        public static final String api_getWechatNoPage="wechatConfig/listNoPage";
        public static final String api_getWechats="wechatConfig/list";
        public static final String api_getByCode="wechatConfig/{code}";
    }
    //微信图文消息
    public static class GraphicMessage {
        public static final String api_common="graphicMessage";
        public static final String api_create="create";
        public static final String api_update="update";
        public static final String api_delete="delete";
        public static final String api_getWxGraphicMessageNoPage="getWxGraphicMessageNoPage";
        public static final String api_create="graphicMessage";
        public static final String api_update="graphicMessage";
        public static final String api_delete="graphicMessage/{codes}";
        public static final String api_getWxGraphicMessageNoPage="graphicMessage/listNoPage";
        public static final String api_getWxGraphicMessages="graphicMessage/list";
        public static final String api_getByCode="graphicMessage/{code}";
        public static final String api_sendGraphicMessages="sendGraphicMessages";
        public static final String api_getWxGraphicMessages="getWxGraphicMessages";
        public static final String api_getByCode="getByCode";
    }
}

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

@ -5,6 +5,8 @@ import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.commnon.base.wx.WechatContants;
import com.yihu.jw.fegin.base.wx.WechatFegin;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.exception.business.JiWeiException;
import com.yihu.jw.version.ApiVersion;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -19,31 +21,33 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(WechatContants.Config.api_common)
@RequestMapping("{version}/"+WechatContants.api_common)
@Api(description = "微信配置")
public class WechatController{
public class WechatConfigController {
    private Logger logger= LoggerFactory.getLogger(WechatController.class);
    private Logger logger= LoggerFactory.getLogger(WechatConfigController.class);
    @Autowired
    private WechatFegin wechatFegin;
    @Autowired
    private Tracer tracer;
    @ApiVersion(1)
    @ApiOperation(value = "创建微信配置")
    @PostMapping(value = WechatContants.Config.api_create,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop createWechat(
            @ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData) {
        tracer.getCurrentSpan().logEvent("开始调用微服务创建微信配置");
        System.out.println(jsonData);//{"id":null,"code":"","saasId":"1","name":"aaaawefr","token":"","encodingAesKey":"","encType":null,"status":0,"type":"1","appId":"","appSecret":"","baseUrl":"","createUser":"","createUserName":"","createTime":null,"updateUser":null,"updateUserName":null,"updateTime":null,"remark":""}
            @ApiParam(name = "json_data", value = "", defaultValue = "") @RequestBody String jsonData) throws JiWeiException {
        tracer.getCurrentSpan().logEvent("创建微信配置:jsonData="+jsonData);
        //{"id":null,"code":"","saasId":"1","name":"aaaawefr","token":"","encodingAesKey":"","encType":null,"status":0,"type":"1","appId":"","appSecret":"","baseUrl":"","createUser":"","createUserName":"","createTime":null,"updateUser":null,"updateUserName":null,"updateTime":null,"remark":""}
        Envelop wechat =wechatFegin.createWechat(jsonData);
        tracer.getCurrentSpan().logEvent("创建微信配置微服务结束");
        return wechat;
    }
    @ApiVersion(1)
    @ApiOperation(value = "更新微信配置")
    @PutMapping(value = WechatContants.Config.api_update,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @HystrixCommand(commandProperties = {
@ -51,15 +55,17 @@ public class WechatController{
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop updateWechat(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
            @RequestBody String jsonData) throws JiWeiException {
        JSONObject json = new JSONObject(jsonData);
        String data = json.get("jsonData").toString();
        data = data.substring(2,data.length() - 2);
        data = data.replaceAll("\\\\\"","\"");
        tracer.getCurrentSpan().logEvent("更新微信配置:jsonData="+data);
        Envelop wechat =wechatFegin.updateWechat(data);
        return wechat;
    }
    @ApiVersion(1)
    @DeleteMapping(value = WechatContants.Config.api_delete)
    @ApiOperation(value = "删除微信配置", notes = "删除微信配置")
    @HystrixCommand(commandProperties = {
@ -67,11 +73,12 @@ public class WechatController{
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop deleteWechat(
            @ApiParam(name = "codes", value = "codes")
            @RequestParam(value = "codes", required = true) String codes) {
            @PathVariable(value = "codes", required = true) String codes) throws JiWeiException {
        Envelop wechat =wechatFegin.deleteWechat(codes);
        return wechat;
    }
    @ApiVersion(1)
    @GetMapping(value = WechatContants.Config.api_getByCode)
    @ApiOperation(value = "根据code查找微信配置", notes = "根据code查找微信配置")
    @HystrixCommand(commandProperties = {
@ -79,11 +86,12 @@ public class WechatController{
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
            @PathVariable(value = "code", required = true) String code
    ) throws JiWeiException {
       return wechatFegin.findByCode(code);
    }
    @ApiVersion(1)
    @RequestMapping(value = WechatContants.Config.api_getWechats, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信配置列表(分页)")
    @HystrixCommand(commandProperties = {
@ -112,6 +120,7 @@ public class WechatController{
        return envelop;
    }
    @ApiVersion(1)
    @GetMapping(value = WechatContants.Config.api_getWechatNoPage)
    @ApiOperation(value = "获取微信列表配置,不分页")
    @HystrixCommand(commandProperties = {
@ -126,4 +135,5 @@ public class WechatController{
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        return wechatFegin.getWechatNoPage(fields,filters,sorts);
    }
}

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

@ -5,9 +5,13 @@ import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.jw.commnon.base.wx.WechatContants;
import com.yihu.jw.fegin.base.wx.GraphicMessageFegin;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.exception.business.JiWeiException;
import com.yihu.jw.version.ApiVersion;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,7 +26,7 @@ import javax.servlet.http.HttpServletResponse;
 * Created by Administrator on 2017/5/31 0031.
 */
@RestController
@RequestMapping(WechatContants.GraphicMessage.api_common)
@RequestMapping("{version}/"+WechatContants.api_common)
@Api(description = "微信图文相关")
public class WechatGraphicMessageController {
    private Logger logger= LoggerFactory.getLogger(WechatGraphicMessageController.class);
@ -33,6 +37,7 @@ public class WechatGraphicMessageController {
    @Autowired
    private Tracer tracer;
    @ApiVersion(1)
    @PostMapping(value = WechatContants.GraphicMessage.api_create, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "创建微信图文消息", notes = "创建微信图文消息")
    @HystrixCommand(commandProperties = {
@ -40,11 +45,14 @@ public class WechatGraphicMessageController {
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop createWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return graphicMessageFegin.createWxGraphicMessage(jsonData);
            @RequestBody String jsonData) throws JiWeiException {
        tracer.getCurrentSpan().logEvent("创建微信配置:jsonData="+jsonData);
        Envelop graphicMessage =graphicMessageFegin.createWxGraphicMessage(jsonData);
        return graphicMessage;
    }
    @ApiVersion(1)
    @PutMapping(value = WechatContants.GraphicMessage.api_update, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "修改微信图文消息", notes = "修改微信图文消息")
    @HystrixCommand(commandProperties = {
@ -52,22 +60,28 @@ public class WechatGraphicMessageController {
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop updateWxGraphicMessage(
            @ApiParam(name = "json_data", value = "", defaultValue = "")
            @RequestBody String jsonData) {
        return graphicMessageFegin.updateWxGraphicMessage(jsonData);
            @RequestBody String jsonData) throws JiWeiException {
        JSONObject json = new JSONObject(jsonData);
        String data = json.get("jsonData").toString();
        data = data.substring(2,data.length() - 2);
        data = data.replaceAll("\\\\\"","\"");
        tracer.getCurrentSpan().logEvent("更新图文消息:jsonData="+data);
        return graphicMessageFegin.updateWxGraphicMessage(data);
    }
    @ApiVersion(1)
    @DeleteMapping(value = WechatContants.GraphicMessage.api_delete)
    @ApiOperation(value = "删除微信图文消息", notes = "删除微信图文消息")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop deleteWxGraphicMessage(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        return graphicMessageFegin.deleteWxGraphicMessage(code);
            @ApiParam(name = "codes", value = "codes")
            @PathVariable(value = "codes", required = true) String codes) throws JiWeiException {
        return graphicMessageFegin.deleteWxGraphicMessage(codes);
    }
    @ApiVersion(1)
    @GetMapping(value = WechatContants.GraphicMessage.api_getByCode)
    @ApiOperation(value = "根据code查找微信图文消息", notes = "根据code查找微信图文消息")
    @HystrixCommand(commandProperties = {
@ -75,11 +89,12 @@ public class WechatGraphicMessageController {
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
            @PathVariable(value = "code", required = true) String code
    ) throws JiWeiException {
        return graphicMessageFegin.findByCode(code);
    }
    @ApiVersion(1)
    @RequestMapping(value = WechatContants.GraphicMessage.api_getWxGraphicMessages, method = RequestMethod.GET)
    @ApiOperation(value = "获取微信图文消息列表(分页)")
    public Envelop getWxGraphicMessages(
@ -95,10 +110,20 @@ public class WechatGraphicMessageController {
            @RequestParam(value = "page", required = false) int page,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        return graphicMessageFegin.getWxGraphicMessages(fields,filters,sorts,size,page);
    }
        String filterStr = "";
        if(StringUtils.isNotBlank(filters)){
            filters = filters.replaceAll("=", ":");
            JSONObject jsonResult = new JSONObject(filters);
            if(jsonResult.has("title")){
                filterStr+="title?"+jsonResult.get("title")+";";
            }
        }
        tracer.getCurrentSpan().logEvent("过滤:"+filterStr);
        return graphicMessageFegin.getWxGraphicMessages(fields,filterStr,sorts,size,page);
    }
    @ApiVersion(1)
    @GetMapping(value = WechatContants.GraphicMessage.api_getWxGraphicMessageNoPage)
    @ApiOperation(value = "获取图文消息列表,不分页")
    @HystrixCommand(commandProperties = {
@ -114,6 +139,7 @@ public class WechatGraphicMessageController {
        return graphicMessageFegin.getWxGraphicMessageNoPage(fields,filters,sorts);
    }
    @ApiVersion(1)
    @GetMapping(value = WechatContants.GraphicMessage.api_sendGraphicMessages)
    @ApiOperation(value = "发送图文消息")
    @HystrixCommand(commandProperties = {

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

@ -3,8 +3,10 @@ package com.yihu.jw.fegin.base.wx;
import com.yihu.jw.fegin.fallbackfactory.base.wx.GraphicMessageFeginFallbackFactory;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.exception.business.JiWeiException;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -20,17 +22,17 @@ import org.springframework.web.bind.annotation.RequestParam;
@RequestMapping(value = WxContants.WxGraphicMessage.api_common)
public interface GraphicMessageFegin {
    @RequestMapping(value = WxContants.WxGraphicMessage.api_create, method = RequestMethod.POST)
    Envelop createWxGraphicMessage( @RequestBody String jsonData);
    @RequestMapping(value = WxContants.WxGraphicMessage.api_create, method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop createWxGraphicMessage( @RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value = WxContants.WxGraphicMessage.api_update,method = RequestMethod.PUT)
    Envelop updateWxGraphicMessage( @RequestBody String jsonData);
    @RequestMapping(value = WxContants.WxGraphicMessage.api_update,method = RequestMethod.PUT,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop updateWxGraphicMessage( @RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value = WxContants.WxGraphicMessage.api_delete,method = RequestMethod.DELETE)
    Envelop deleteWxGraphicMessage(String code);
    Envelop deleteWxGraphicMessage(@RequestParam(value = "code") String codes) throws JiWeiException;
    @RequestMapping(value = WxContants.WxGraphicMessage.api_getByCode,method = RequestMethod.GET)
    Envelop findByCode(String code);
    Envelop findByCode(@RequestParam(value = "code") String code) throws JiWeiException;
    @RequestMapping(value = WxContants.WxGraphicMessage.api_getWxGraphicMessages,method = RequestMethod.GET)
    Envelop getWxGraphicMessages(
@ -38,13 +40,13 @@ public interface GraphicMessageFegin {
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts,
            @RequestParam(value = "size", required = false) int size,
            @RequestParam(value = "page", required = false) int page);
            @RequestParam(value = "page", required = false) int page) throws JiWeiException;
    @RequestMapping(value = WxContants.WxGraphicMessage.api_getWxGraphicMessageNoPage,method = RequestMethod.GET)
    Envelop getWxGraphicMessageNoPage(
            @RequestParam(value = "fields", required = false) String fields,
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "sorts", required = false) String sorts);
            @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException;
    @RequestMapping(value = WxContants.WxGraphicMessage.api_sendGraphicMessages,method = RequestMethod.GET)
    String sendGraphicMessages(

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

@ -3,6 +3,7 @@ package com.yihu.jw.fegin.base.wx;
import com.yihu.jw.fegin.fallbackfactory.base.wx.WechatFeginFallbackFactory;
import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.exception.business.JiWeiException;
import com.yihu.jw.restmodel.wx.WxContants;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
@ -20,20 +21,20 @@ import org.springframework.web.bind.annotation.RequestParam;
public interface WechatFegin {
    @RequestMapping(value = WxContants.Wechat.api_create, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop createWechat( @RequestBody String jsonData);
    Envelop createWechat( @RequestBody String jsonData) throws JiWeiException;
    @RequestMapping(value = WxContants.Wechat.api_update, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    Envelop updateWechat(String jsonData);
    Envelop updateWechat(String jsonData) throws JiWeiException;
    @RequestMapping(value = WxContants.Wechat.api_delete,method = RequestMethod.DELETE)
    Envelop deleteWechat(@RequestParam(value = "codes") String codes);
    Envelop deleteWechat(@RequestParam(value = "codes") String codes) throws JiWeiException;
    @RequestMapping(value = WxContants.Wechat.api_getByCode,method = RequestMethod.GET)
    Envelop findByCode(@RequestParam(value = "code") String code);
    Envelop findByCode(@RequestParam(value = "code") String code) throws JiWeiException;
    @RequestMapping(value = WxContants.Wechat.api_getWechats ,method = RequestMethod.GET)
    Envelop getWechats(@RequestParam(value = "fields" ,required = false)String fields, @RequestParam(value = "filters",required = false) String filters, @RequestParam(value = "sorts" ,required = false)String sorts, @RequestParam(value = "size" ,required = false) int size,@RequestParam(value = "page" ,required = false)int page);
    Envelop getWechats(@RequestParam(value = "fields" ,required = false)String fields, @RequestParam(value = "filters",required = false) String filters, @RequestParam(value = "sorts" ,required = false)String sorts, @RequestParam(value = "size" ,required = false) int size,@RequestParam(value = "page" ,required = false)int page) throws JiWeiException;
    @RequestMapping(value = WxContants.Wechat.api_getWechatNoPage,method = RequestMethod.GET )
    Envelop getWechatNoPage(@RequestParam(value = "fields")String fields,@RequestParam(value = "filters") String filters,@RequestParam(value = "sorts") String sorts);
    Envelop getWechatNoPage(@RequestParam(value = "fields")String fields,@RequestParam(value = "filters") String filters,@RequestParam(value = "sorts") String sorts) throws JiWeiException;
}

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

@ -2,7 +2,10 @@ package com.yihu.jw.fegin.fallbackfactory.base.wx;
import com.yihu.jw.fegin.base.wx.GraphicMessageFegin;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.exception.business.JiWeiException;
import feign.hystrix.FallbackFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
@ -12,37 +15,59 @@ import org.springframework.web.bind.annotation.RequestParam;
@Component
public class GraphicMessageFeginFallbackFactory implements FallbackFactory<GraphicMessageFegin> {
    @Autowired
    private Tracer tracer;
    @Override
    public GraphicMessageFegin create(Throwable throwable) {
    public GraphicMessageFegin create(Throwable e) {
        return new GraphicMessageFegin() {
            @Override
            public Envelop createWxGraphicMessage(@RequestParam(value = "jsonData") String jsonData) {
                return null;
            public Envelop createWxGraphicMessage(@RequestParam(value = "jsonData") String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("创建微信图文消息失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop updateWxGraphicMessage(@RequestParam(value = "jsonData") String jsonData) {
                return null;
            public Envelop updateWxGraphicMessage(@RequestParam(value = "jsonData") String jsonData) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("更新微信图文消息失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("jsonData:"+jsonData);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop deleteWxGraphicMessage(String code) {
                return null;
            public Envelop deleteWxGraphicMessage(String codes) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("删除微信配置失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("codes:"+codes);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop findByCode(String code) {
                return null;
            public Envelop findByCode(String code) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("根据code查找微信图文消息失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("code:"+code);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getWxGraphicMessages(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts, @RequestParam(value = "size", required = false) int size, @RequestParam(value = "page", required = false) int page) {
                return null;
            public Envelop getWxGraphicMessages(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts, @RequestParam(value = "size", required = false) int size, @RequestParam(value = "page", required = false) int page) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("分页查找微信图文消息失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filters);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                tracer.getCurrentSpan().logEvent("size:" + size);
                tracer.getCurrentSpan().logEvent("page:" + page);
                throw new JiWeiException(e);
            }
            @Override
            public Envelop getWxGraphicMessageNoPage(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts) {
                return null;
            public Envelop getWxGraphicMessageNoPage(@RequestParam(value = "fields", required = false) String fields, @RequestParam(value = "filters", required = false) String filters, @RequestParam(value = "sorts", required = false) String sorts) throws JiWeiException {
                tracer.getCurrentSpan().logEvent("查找微信图文消息列表失败:原因:"+e.getMessage());
                tracer.getCurrentSpan().logEvent("fields:" + fields);
                tracer.getCurrentSpan().logEvent("filters:" + filters);
                tracer.getCurrentSpan().logEvent("sorts:" + sorts);
                throw new JiWeiException(e);
            }
            @Override

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 41 - 31
web-gateway/src/main/java/com/yihu/jw/fegin/fallbackfactory/base/wx/WechatFeginFallbackFactory.java