Browse Source

微信基础信息维护

trick9191 6 years ago
parent
commit
4acca3289e

+ 11 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/WxWechatDO.java

@ -23,7 +23,7 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    private String token;//token
    private String encodingAesKey;//加密密钥
    private Integer encType;//加密方式  0:明文模式   1:兼容模式   2:安全模式
    private Integer status;//'类型 -1 已删除 0待审核 1审核通过 2 审核不通过'
    private Integer status;//'类型 -1 已删除 0未认证 1已认证 2 审核中 3.审核未通过'
    private String type;//'1:服务号 2 订阅号
    private String appId;//'微信app_id'
    private String appSecret;//'微信app_secret'
@ -31,6 +31,7 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    private String baseUrl;//'微信base_url'
    private String userName;//公总号登录账户
    private String password;//用户密码
    private String publicType;//1.自运营,2.外接
    private String remark;//'备注'
@ -178,4 +179,13 @@ public class WxWechatDO extends UuidIdentityEntityWithOperator implements java.i
    public void setPassword(String password) {
        this.password = password;
    }
    @Column(name = "public_type", length = 200)
    public String getPublicType() {
        return publicType;
    }
    public void setPublicType(String publicType) {
        this.publicType = publicType;
    }
}

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -135,6 +135,8 @@ public class BaseRequestMapping {
     */
    public static class WeChat extends Basic {
        public static final String PREFIX  = "/wechat";
        public static final String api_success ="success";
        public static final String getWechatInfos ="/getWechatInfos";
    }
    /**

+ 29 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxSaasVO.java

@ -0,0 +1,29 @@
package com.yihu.jw.restmodel.base.wx;
import io.swagger.annotations.ApiModelProperty;
/**
 * Created by Trick on 2018/9/26.
 */
public class WxSaasVO {
    @ApiModelProperty(value = "saasid")
    private String saasid;
    @ApiModelProperty(value = "saas名称")
    private String saasName;
    public String getSaasid() {
        return saasid;
    }
    public void setSaasid(String saasid) {
        this.saasid = saasid;
    }
    public String getSaasName() {
        return saasName;
    }
    public void setSaasName(String saasName) {
        this.saasName = saasName;
    }
}

+ 26 - 144
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/wx/WxWechatVO.java

@ -1,5 +1,7 @@
package com.yihu.jw.restmodel.base.wx;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -10,26 +12,18 @@ import java.util.Map;
 */
public class WxWechatVO {
    private String id;
    private String saasId;//'saas配置id'
    private String name;//名称
    private String token;//token
    private String encodingAesKey;//加密密钥
    private Integer encType;//加密方式  0:明文模式   1:兼容模式   2:安全模式
    private Integer status;//'类型 -1 已删除 0待审核 1审核通过 2 审核不通过'
    private String type;//'1:服务号 2 订阅号
    private String appId;//'微信app_id'
    private String appSecret;//'微信app_secret'
    private String baseUrl;//'微信base_url'
    private String createUser;//'创建人'
    private String createUserName;//'创建人名'
    private Date createTime;//'创建时间'
    private String updateUser;//'修改人
    private String updateUserName;//'修改人名'
    private Date updateTime;//'修改时间'
    private String remark;//'备注'
    private List<Map<String,Object>> children = new ArrayList<>();
    private String state;
    @ApiModelProperty(value = "id")
    private String id ;
    @ApiModelProperty(value = "名称")
    private String name;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "状态")
    private Integer status;
    @ApiModelProperty(value = "对接类型")
    private Integer publicType;
    @ApiModelProperty(value = "租户")
    private List<WxSaasVO> saas;
    public String getId() {
        return id;
@ -39,14 +33,6 @@ public class WxWechatVO {
        this.id = id;
    }
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getName() {
        return name;
    }
@ -55,28 +41,12 @@ public class WxWechatVO {
        this.name = name;
    }
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    public String getEncodingAesKey() {
        return encodingAesKey;
    }
    public void setEncodingAesKey(String encodingAesKey) {
        this.encodingAesKey = encodingAesKey;
    }
    public Integer getEncType() {
        return encType;
    public String getRemark() {
        return remark;
    }
    public void setEncType(Integer encType) {
        this.encType = encType;
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getStatus() {
@ -87,107 +57,19 @@ public class WxWechatVO {
        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;
    }
    public List<Map<String, Object>> getChildren() {
        return children;
    public Integer getPublicType() {
        return publicType;
    }
    public void setChildren(List<Map<String, Object>> children) {
        this.children = children;
    public void setPublicType(Integer publicType) {
        this.publicType = publicType;
    }
    public String getState() {
        return state;
    public List<WxSaasVO> getSaas() {
        return saas;
    }
    public void setState(String state) {
        this.state = state;
    public void setSaas(List<WxSaasVO> saas) {
        this.saas = saas;
    }
}

+ 44 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/wx/WechatController.java

@ -0,0 +1,44 @@
package com.yihu.jw.base.endpoint.wx;
import com.yihu.jw.base.service.wx.WechatService;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2018/9/26.
 */
@RestController
@RequestMapping(BaseRequestMapping.WeChat.PREFIX)
@Api(value = "微信基础信息管理", description = "微信基础信息管理", tags = {"微信基础 - 微信基础信息管理"})
public class WechatController extends EnvelopRestEndpoint {
    @Autowired
    private WechatService wechatService;
    @GetMapping(value = BaseRequestMapping.WeChat.getWechatInfos)
    @ApiOperation(value = "获取微信基本信息列表", notes = "获取微信基本信息列表")
    public MixEnvelop getWxWechatList(@ApiParam(name = "name", value = "微信名称")
                                      @RequestParam(value = "name", required = false) String name,
                                      @ApiParam(name = "saasName", value = "租户名称")
                                      @RequestParam(value = "saasName", required = false) String saasName,
                                      @ApiParam(name = "status", value = "状态")
                                      @RequestParam(value = "status", required = false) Integer status,
                                      @ApiParam(name = "publicType", value = "微信类型")
                                      @RequestParam(value = "publicType", required = false) Integer publicType,
                                      @ApiParam(name = "page", value = "页码")
                                      @RequestParam(value = "page", required = true) Integer page,
                                      @ApiParam(name = "size", value = "每页大小")
                                      @RequestParam(value = "size", required = true) Integer size) {
        return wechatService.getWxWechatList(name, saasName, status, publicType, page, size);
    }
}

+ 97 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -1,13 +1,109 @@
package com.yihu.jw.base.service.wx;
import com.yihu.jw.restmodel.base.saas.SaasVO;
import com.yihu.jw.restmodel.base.wx.WxSaasVO;
import com.yihu.jw.restmodel.base.wx.WxWechatVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * Created by Administrator on 2017/5/20 0020.
 * Created by trick on 2017/5/20 0020.
 */
@Service
@Transactional
public class WechatService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public MixEnvelop getWxWechatList(String name,String saasName,Integer status,Integer publicType,Integer page,Integer size){
        String sql = "SELECT " +
                " w.id, " +
                " w.name, " +
                " w.`status`, " +
                " w.type, " +
                " w.public_type AS publicType," +
                " w.remark " +
                " FROM " +
                " wx_wechat w ";
        if (StringUtils.isNotBlank(saasName)) {
            sql += " JOIN wx_wechat_saas s ON w.id = s.wechat_id" +
                    " JOIN base_saas bs ON s.saas_id = bs.id ";
        }
        sql += " WHERE 1=1 ";
        if (StringUtils.isNotBlank(name)) {
            sql += " AND w.`name` LIKE '%" + name + "%' ";
        }
        if (publicType!=null) {
            sql += " AND w.public_type = " + publicType + " " ;
        }
        if (status!=null) {
            sql += " AND w.`status` = " + status + "";
        }
        if (StringUtils.isNotBlank(saasName)) {
            sql += " AND bs.`name` like '%" + saasName + "%'";
        }
        sql += "LIMIT " + (page - 1) * size + "," + size + "";
        List<WxWechatVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxWechatVO.class));
        if(list!=null&&list.size()>0){
            for(WxWechatVO wx :list){
                wx.setSaas(getWxSaasVOs(wx.getId()));
            }
        }
        String countSql = "SELECT count(1) AS total"+
                " FROM " +
                " wx_wechat w ";;
        if (StringUtils.isNotBlank(saasName)) {
            countSql += " JOIN wx_wechat_saas s ON w.id = s.wechat_id" +
                    " JOIN base_saas bs ON s.saas_id = bs.id ";
        }
        countSql += " WHERE 1=1 ";
        if (StringUtils.isNotBlank(name)) {
            sql += " AND w.`name` LIKE '%" + name + "%' ";
        }
        if (publicType!=null) {
            sql += " AND w.public_type = " + publicType + " " ;
        }
        if (status!=null) {
            sql += " AND w.`status` = " + status + "";
        }
        if (StringUtils.isNotBlank(saasName)) {
            countSql += " AND bs.`name` like '%" + saasName + "%'";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(countSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success, list, page, size, count);
    }
    public List<WxSaasVO> getWxSaasVOs(String id){
        String sql ="SELECT " +
                " bs.`name` AS saasName, " +
                " bs.id AS saasid" +
                " FROM " +
                " wx_wechat_saas s " +
                " JOIN base_saas bs ON s.saas_id = s.saas_id " +
                " WHERE " +
                " s.wechat_id = '"+id+"'";
        List<WxSaasVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxSaasVO.class));
        return list;
    }
}