Browse Source

企业微信授权

master
zhizhi wu 5 years ago
parent
commit
707a06ffb0
  1. 6
      health/pom.xml
  2. 118
      health/src/main/java/com/ccsens/health/api/WeixinController.java
  3. 24
      health/src/main/java/com/ccsens/health/api/WxTest.java
  4. 8
      health/src/main/java/com/ccsens/health/bean/po/Employee.java
  5. 30
      health/src/main/java/com/ccsens/health/bean/po/EmployeeExample.java
  6. 337
      health/src/main/java/com/ccsens/health/bean/po/HealthAuth.java
  7. 205
      health/src/main/java/com/ccsens/health/bean/po/HealthAuthAgent.java
  8. 1331
      health/src/main/java/com/ccsens/health/bean/po/HealthAuthAgentExample.java
  9. 2141
      health/src/main/java/com/ccsens/health/bean/po/HealthAuthExample.java
  10. 30
      health/src/main/java/com/ccsens/health/persist/mapper/HealthAuthAgentMapper.java
  11. 30
      health/src/main/java/com/ccsens/health/persist/mapper/HealthAuthMapper.java
  12. 60
      health/src/main/java/com/ccsens/health/service/ConstantService.java
  13. 18
      health/src/main/java/com/ccsens/health/service/IConstantService.java
  14. 30
      health/src/main/java/com/ccsens/health/service/IWeiXinService.java
  15. 204
      health/src/main/java/com/ccsens/health/service/WeiXinService.java
  16. 2
      health/src/main/resources/logback-spring.xml
  17. 14
      health/src/main/resources/mapper_raw/EmployeeMapper.xml
  18. 401
      health/src/main/resources/mapper_raw/HealthAuthAgentMapper.xml
  19. 593
      health/src/main/resources/mapper_raw/HealthAuthMapper.xml
  20. 5
      pom.xml
  21. 123
      util/src/main/java/com/ccsens/util/RestTemplateUtil.java
  22. 72
      util/src/main/java/com/ccsens/util/enterprisewx/WeiXinConstant.java
  23. 2
      util/src/main/java/com/ccsens/util/enterprisewx/XMLParse.java
  24. 35
      util/src/main/java/com/ccsens/util/enterprisewx/dto/MessageDto.java

6
health/pom.xml

@ -28,11 +28,7 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
</dependencies>
<build>

118
health/src/main/java/com/ccsens/health/api/WeixinController.java

@ -1,15 +1,26 @@
package com.ccsens.health.api;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.health.service.IConstantService;
import com.ccsens.health.service.IWeiXinService;
import com.ccsens.util.HttpsUtil;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.RestTemplateUtil;
import com.ccsens.util.enterprisewx.AesException;
import com.ccsens.util.enterprisewx.WXBizMsgCrypt;
import com.ccsens.util.enterprisewx.WeiXinConstant;
import com.ccsens.util.enterprisewx.dto.MessageDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
/**
@ -18,58 +29,87 @@ import java.util.Map;
@Slf4j
@RestController
public class WeixinController {
@Autowired
private IWeiXinService weiXinService;
@Autowired
private IConstantService constantService;
/**
* 业务设置URL
*/
public void settings(){
public void settings(MessageDto dto) throws Exception{
log.info("业务设置接收参数:{}", dto);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID);
String verifyURL = wxcpt.VerifyURL(dto.getMsg_signature(), dto.getTimestamp(), dto.getNonce(), dto.getEchostr());
log.info("业务设置解析结果:{}", verifyURL);
String jsonStr = JacksonUtil.xmlToJson(verifyURL);
}
/**
* 数据回调URL
*/
public void userChangeNotice(){
@PostMapping("userChangeNotice")
public String userChangeNotice(MessageDto dto) throws Exception{
log.info("数据回调请求参数:{}", dto);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID);
String verifyURL = wxcpt.VerifyURL(dto.getMsg_signature(), dto.getTimestamp(), dto.getNonce(), dto.getEchostr());
log.info("数据回调解析结果:{}", verifyURL);
return verifyURL;
}
/**
* 指令回调URL
*/
public void authorizationChangeNotice(){
@PostMapping("authorizationChangeNotice")
public String authorizationChangeNotice(MessageDto dto) throws Exception{
log.info("请求参数:{}", dto);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID);
String verifyURL = wxcpt.VerifyURL(dto.getMsg_signature(), dto.getTimestamp(), dto.getNonce(), dto.getEchostr());
log.info("解析结果:{}", verifyURL);
String jsonStr = JacksonUtil.xmlToJson(verifyURL);
JSONObject json = JSONObject.parseObject(jsonStr);
switch (json.getString("InfoType")){
case "suite_ticket" :
MessageDto.Ticket ticket = JSONObject.parseObject(jsonStr, MessageDto.Ticket.class);
constantService.saveConstant(WeiXinConstant.getSuiteTicket(ticket.getSuiteId()), ticket.getSuiteTicket());
break;
case "create_auth" :
MessageDto.Grant grant = JSONObject.parseObject(jsonStr, MessageDto.Grant.class);
constantService.saveConstant(WeiXinConstant.getTempAuthCodeKey(grant.getSuiteId()), grant.getAuthCode());
getPermanentCode(grant.getAuthCode());
break;
case "change_auth" :
//TODO 变更授权通知
break;
case "cancel_auth" :
//TODO 取消授权通知
break;
//TODO 成员变更和部门变更通知
}
return "success";
}
/**
* 获取临时授权码
* msg_signature=3a7b08bb8e6dbce3c9671d6fdb69d15066227608
* &timestamp=1403610513
* &nonce=380320359
* 获取永久授权码
* @param authCode
*/
@RequestMapping("reciveSysMsg")
public String reciveSysMsg(MessageDto dto){
String token = "4CxIpRDBWHMiePP3x6muNe4hRj";
String corpID = "ww86f65c2e95cd8b4c";
String encodingAESKey = "NInifq246LLoF5wyCq4fRJNJOvKI7XIkgdUqOpWoP3G";
String providerSecret = "fr8OXt4iMqIxe3QMUVkHCK_j9oj0qllZciOgw5CdGldDksv5yMoxFduPbZGmIlfj";
String verifyURL = null;
try {
log.info("请求参数:{}", dto);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(token, encodingAESKey, corpID);
verifyURL = wxcpt.VerifyURL(dto.getMsg_signature(), dto.getTimestamp(), dto.getNonce(), dto.getEchostr());
log.info("解析路径:{}", verifyURL);
} catch (Exception e) {
e.printStackTrace();
log.error("解密异常", e);
}
return verifyURL;
@Async
public void getPermanentCode(String authCode){
weiXinService.savePermanentCode(authCode);
// TODO 读取部门信息和成员信息
}
public void getAuthCode(MessageDto dto){
/**
* 系统验证
*/
@GetMapping("reciveSysMsg")
public String reciveSysMsg(MessageDto dto) throws Exception{
log.info("请求参数:{}", dto);
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeiXinConstant.token, WeiXinConstant.encodingAESKey, WeiXinConstant.corpID);
String verifyURL = wxcpt.VerifyURL(dto.getMsg_signature(), dto.getTimestamp(), dto.getNonce(), dto.getEchostr());
log.info("解析结果:{}", verifyURL);
return verifyURL;
}
}

24
health/src/main/java/com/ccsens/health/api/WxTest.java

@ -1,8 +1,10 @@
package com.ccsens.health.api;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ccsens.util.JacksonUtil;
import com.ccsens.util.enterprisewx.AesException;
import com.ccsens.util.enterprisewx.WXBizMsgCrypt;
import com.ccsens.util.enterprisewx.XMLParse;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@ -21,15 +23,17 @@ public class WxTest {
WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);
encryptMsg(wxcpt);
// String sVerifyEchoStr = "iDALk2Ey5gNLx9QzQvATu314lxZWNQVuarffoLlVkX0rVbPHn8Erjtaq6BPNZ/L435Rs5Ezo0DSYJWio5EXM9giZ7daAACkEjz4q0UUuZMOKqlisRBrOUXXTolN7hAh6J8D4wbtktDFHnqxo3wdI7d4KK9gR7gGpZYIlcJbcTT1liQFDOZs74+eor1bCr8dnausBAnTJ/warNWkNc1ats6s93iLx6MqrhZujXlsCCMhSC7GN4hIcqczpPObwiYJqMLAJx1c1I0gZuz10dbKNuo4ox5ZcCHxQQH0QJl2It3KfUTOFyL3d4/TavlKc3Be9m+zBqQnzvmtsYl/7aH+mjbLL7Qqi1akZXnZfu1F7FwtR9vlLQZkBCMHyY+VnvZKHlaKUrFZRQBp60vCDy3ZNOuII+gPhwAws+0PnBozoUO4zhzgdTpPHBdEUcEDGzsRceZkxU6woJshzuvXWYbowTg==";
// String sVerifyMsgSig = "b9c452eb36c076b4dbce9f4aaaee79daa90f126a";
// String sVerifyTimeStamp = "1583330437232";
// String sVerifyNonce = "1";
// String sEchoStr = wxcpt.VerifyURL(sVerifyMsgSig, sVerifyTimeStamp,
// sVerifyNonce, sVerifyEchoStr);
// System.out.println("verifyurl echostr: " + sEchoStr);
// encryptMsg(wxcpt);
String sVerifyEchoStr = "iDALk2Ey5gNLx9QzQvATu314lxZWNQVuarffoLlVkX0rVbPHn8Erjtaq6BPNZ/L435Rs5Ezo0DSYJWio5EXM9giZ7daAACkEjz4q0UUuZMOKqlisRBrOUXXTolN7hAh6J8D4wbtktDFHnqxo3wdI7d4KK9gR7gGpZYIlcJbcTT1liQFDOZs74+eor1bCr8dnausBAnTJ/warNWkNc1ats6s93iLx6MqrhZujXlsCCMhSC7GN4hIcqczpPObwiYJqMLAJx1c1I0gZuz10dbKNuo4ox5ZcCHxQQH0QJl2It3KfUTOFyL3d4/TavlKc3Be9m+zBqQnzvmtsYl/7aH+mjbLL7Qqi1akZXnZfu1F7FwtR9vlLQZkBCMHyY+VnvZKHlaKUrFZRQBp60vCDy3ZNOuII+gPhwAws+0PnBozoUO4zhzgdTpPHBdEUcEDGzsRceZkxU6woJshzuvXWYbowTg==";
String sVerifyMsgSig = "b9c452eb36c076b4dbce9f4aaaee79daa90f126a";
String sVerifyTimeStamp = "1583330437232";
String sVerifyNonce = "1";
String sEchoStr = wxcpt.VerifyURL(sVerifyMsgSig, sVerifyTimeStamp,
sVerifyNonce, sVerifyEchoStr);
System.out.println("verifyurl echostr: " + sEchoStr);
String s = JacksonUtil.xmlToJson(sEchoStr);
System.out.println("s:"+s);
}

8
health/src/main/java/com/ccsens/health/bean/po/Employee.java

@ -20,7 +20,7 @@ public class Employee implements Serializable {
private String englishName;
private String tallUserId;
private Long tallUserId;
private Date createdAt;
@ -94,12 +94,12 @@ public class Employee implements Serializable {
this.englishName = englishName == null ? null : englishName.trim();
}
public String getTallUserId() {
public Long getTallUserId() {
return tallUserId;
}
public void setTallUserId(String tallUserId) {
this.tallUserId = tallUserId == null ? null : tallUserId.trim();
public void setTallUserId(Long tallUserId) {
this.tallUserId = tallUserId;
}
public Date getCreatedAt() {

30
health/src/main/java/com/ccsens/health/bean/po/EmployeeExample.java

@ -635,62 +635,52 @@ public class EmployeeExample {
return (Criteria) this;
}
public Criteria andTallUserIdEqualTo(String value) {
public Criteria andTallUserIdEqualTo(Long value) {
addCriterion("tall_user_id =", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdNotEqualTo(String value) {
public Criteria andTallUserIdNotEqualTo(Long value) {
addCriterion("tall_user_id <>", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdGreaterThan(String value) {
public Criteria andTallUserIdGreaterThan(Long value) {
addCriterion("tall_user_id >", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdGreaterThanOrEqualTo(String value) {
public Criteria andTallUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("tall_user_id >=", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdLessThan(String value) {
public Criteria andTallUserIdLessThan(Long value) {
addCriterion("tall_user_id <", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdLessThanOrEqualTo(String value) {
public Criteria andTallUserIdLessThanOrEqualTo(Long value) {
addCriterion("tall_user_id <=", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdLike(String value) {
addCriterion("tall_user_id like", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdNotLike(String value) {
addCriterion("tall_user_id not like", value, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdIn(List<String> values) {
public Criteria andTallUserIdIn(List<Long> values) {
addCriterion("tall_user_id in", values, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdNotIn(List<String> values) {
public Criteria andTallUserIdNotIn(List<Long> values) {
addCriterion("tall_user_id not in", values, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdBetween(String value1, String value2) {
public Criteria andTallUserIdBetween(Long value1, Long value2) {
addCriterion("tall_user_id between", value1, value2, "tallUserId");
return (Criteria) this;
}
public Criteria andTallUserIdNotBetween(String value1, String value2) {
public Criteria andTallUserIdNotBetween(Long value1, Long value2) {
addCriterion("tall_user_id not between", value1, value2, "tallUserId");
return (Criteria) this;
}

337
health/src/main/java/com/ccsens/health/bean/po/HealthAuth.java

@ -0,0 +1,337 @@
package com.ccsens.health.bean.po;
import java.io.Serializable;
import java.util.Date;
public class HealthAuth implements Serializable {
private Long id;
private String accessToken;
private Integer expiresIn;
private String permanentCode;
private String corpid;
private String corpName;
private String corpType;
private String corpSquareLogoUrl;
private Integer corpUserMax;
private Long corpAgentMax;
private String corpFullName;
private Byte subjectType;
private Long verifiedEndTime;
private String corpWxqrcode;
private String corpScale;
private String corpIndustry;
private String corpSubIndustry;
private String location;
private String authUserid;
private String authName;
private String authAvatar;
private String dealerCorpInfoCorpid;
private String dealerCorpInfoCorpName;
private String registerCode;
private String templateId;
private String state;
private Date createdAt;
private Date updatedAt;
private Byte recStatus;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken == null ? null : accessToken.trim();
}
public Integer getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Integer expiresIn) {
this.expiresIn = expiresIn;
}
public String getPermanentCode() {
return permanentCode;
}
public void setPermanentCode(String permanentCode) {
this.permanentCode = permanentCode == null ? null : permanentCode.trim();
}
public String getCorpid() {
return corpid;
}
public void setCorpid(String corpid) {
this.corpid = corpid == null ? null : corpid.trim();
}
public String getCorpName() {
return corpName;
}
public void setCorpName(String corpName) {
this.corpName = corpName == null ? null : corpName.trim();
}
public String getCorpType() {
return corpType;
}
public void setCorpType(String corpType) {
this.corpType = corpType == null ? null : corpType.trim();
}
public String getCorpSquareLogoUrl() {
return corpSquareLogoUrl;
}
public void setCorpSquareLogoUrl(String corpSquareLogoUrl) {
this.corpSquareLogoUrl = corpSquareLogoUrl == null ? null : corpSquareLogoUrl.trim();
}
public Integer getCorpUserMax() {
return corpUserMax;
}
public void setCorpUserMax(Integer corpUserMax) {
this.corpUserMax = corpUserMax;
}
public Long getCorpAgentMax() {
return corpAgentMax;
}
public void setCorpAgentMax(Long corpAgentMax) {
this.corpAgentMax = corpAgentMax;
}
public String getCorpFullName() {
return corpFullName;
}
public void setCorpFullName(String corpFullName) {
this.corpFullName = corpFullName == null ? null : corpFullName.trim();
}
public Byte getSubjectType() {
return subjectType;
}
public void setSubjectType(Byte subjectType) {
this.subjectType = subjectType;
}
public Long getVerifiedEndTime() {
return verifiedEndTime;
}
public void setVerifiedEndTime(Long verifiedEndTime) {
this.verifiedEndTime = verifiedEndTime;
}
public String getCorpWxqrcode() {
return corpWxqrcode;
}
public void setCorpWxqrcode(String corpWxqrcode) {
this.corpWxqrcode = corpWxqrcode == null ? null : corpWxqrcode.trim();
}
public String getCorpScale() {
return corpScale;
}
public void setCorpScale(String corpScale) {
this.corpScale = corpScale == null ? null : corpScale.trim();
}
public String getCorpIndustry() {
return corpIndustry;
}
public void setCorpIndustry(String corpIndustry) {
this.corpIndustry = corpIndustry == null ? null : corpIndustry.trim();
}
public String getCorpSubIndustry() {
return corpSubIndustry;
}
public void setCorpSubIndustry(String corpSubIndustry) {
this.corpSubIndustry = corpSubIndustry == null ? null : corpSubIndustry.trim();
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location == null ? null : location.trim();
}
public String getAuthUserid() {
return authUserid;
}
public void setAuthUserid(String authUserid) {
this.authUserid = authUserid == null ? null : authUserid.trim();
}
public String getAuthName() {
return authName;
}
public void setAuthName(String authName) {
this.authName = authName == null ? null : authName.trim();
}
public String getAuthAvatar() {
return authAvatar;
}
public void setAuthAvatar(String authAvatar) {
this.authAvatar = authAvatar == null ? null : authAvatar.trim();
}
public String getDealerCorpInfoCorpid() {
return dealerCorpInfoCorpid;
}
public void setDealerCorpInfoCorpid(String dealerCorpInfoCorpid) {
this.dealerCorpInfoCorpid = dealerCorpInfoCorpid == null ? null : dealerCorpInfoCorpid.trim();
}
public String getDealerCorpInfoCorpName() {
return dealerCorpInfoCorpName;
}
public void setDealerCorpInfoCorpName(String dealerCorpInfoCorpName) {
this.dealerCorpInfoCorpName = dealerCorpInfoCorpName == null ? null : dealerCorpInfoCorpName.trim();
}
public String getRegisterCode() {
return registerCode;
}
public void setRegisterCode(String registerCode) {
this.registerCode = registerCode == null ? null : registerCode.trim();
}
public String getTemplateId() {
return templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId == null ? null : templateId.trim();
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state == null ? null : state.trim();
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public Byte getRecStatus() {
return recStatus;
}
public void setRecStatus(Byte recStatus) {
this.recStatus = recStatus;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", accessToken=").append(accessToken);
sb.append(", expiresIn=").append(expiresIn);
sb.append(", permanentCode=").append(permanentCode);
sb.append(", corpid=").append(corpid);
sb.append(", corpName=").append(corpName);
sb.append(", corpType=").append(corpType);
sb.append(", corpSquareLogoUrl=").append(corpSquareLogoUrl);
sb.append(", corpUserMax=").append(corpUserMax);
sb.append(", corpAgentMax=").append(corpAgentMax);
sb.append(", corpFullName=").append(corpFullName);
sb.append(", subjectType=").append(subjectType);
sb.append(", verifiedEndTime=").append(verifiedEndTime);
sb.append(", corpWxqrcode=").append(corpWxqrcode);
sb.append(", corpScale=").append(corpScale);
sb.append(", corpIndustry=").append(corpIndustry);
sb.append(", corpSubIndustry=").append(corpSubIndustry);
sb.append(", location=").append(location);
sb.append(", authUserid=").append(authUserid);
sb.append(", authName=").append(authName);
sb.append(", authAvatar=").append(authAvatar);
sb.append(", dealerCorpInfoCorpid=").append(dealerCorpInfoCorpid);
sb.append(", dealerCorpInfoCorpName=").append(dealerCorpInfoCorpName);
sb.append(", registerCode=").append(registerCode);
sb.append(", templateId=").append(templateId);
sb.append(", state=").append(state);
sb.append(", createdAt=").append(createdAt);
sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus);
sb.append("]");
return sb.toString();
}
}

205
health/src/main/java/com/ccsens/health/bean/po/HealthAuthAgent.java

@ -0,0 +1,205 @@
package com.ccsens.health.bean.po;
import java.io.Serializable;
import java.util.Date;
public class HealthAuthAgent implements Serializable {
private Long id;
private Long authId;
private Long agentid;
private String name;
private String squareLogoUrl;
private String roundLogoUrl;
private String privilege;
private String allowParty;
private String allowTag;
private String allowUser;
private String extraParty;
private String extraUser;
private String extraTag;
private String level;
private Date createdAt;
private Date updatedAt;
private Byte recStatus;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getAuthId() {
return authId;
}
public void setAuthId(Long authId) {
this.authId = authId;
}
public Long getAgentid() {
return agentid;
}
public void setAgentid(Long agentid) {
this.agentid = agentid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getSquareLogoUrl() {
return squareLogoUrl;
}
public void setSquareLogoUrl(String squareLogoUrl) {
this.squareLogoUrl = squareLogoUrl == null ? null : squareLogoUrl.trim();
}
public String getRoundLogoUrl() {
return roundLogoUrl;
}
public void setRoundLogoUrl(String roundLogoUrl) {
this.roundLogoUrl = roundLogoUrl == null ? null : roundLogoUrl.trim();
}
public String getPrivilege() {
return privilege;
}
public void setPrivilege(String privilege) {
this.privilege = privilege == null ? null : privilege.trim();
}
public String getAllowParty() {
return allowParty;
}
public void setAllowParty(String allowParty) {
this.allowParty = allowParty == null ? null : allowParty.trim();
}
public String getAllowTag() {
return allowTag;
}
public void setAllowTag(String allowTag) {
this.allowTag = allowTag == null ? null : allowTag.trim();
}
public String getAllowUser() {
return allowUser;
}
public void setAllowUser(String allowUser) {
this.allowUser = allowUser == null ? null : allowUser.trim();
}
public String getExtraParty() {
return extraParty;
}
public void setExtraParty(String extraParty) {
this.extraParty = extraParty == null ? null : extraParty.trim();
}
public String getExtraUser() {
return extraUser;
}
public void setExtraUser(String extraUser) {
this.extraUser = extraUser == null ? null : extraUser.trim();
}
public String getExtraTag() {
return extraTag;
}
public void setExtraTag(String extraTag) {
this.extraTag = extraTag == null ? null : extraTag.trim();
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level == null ? null : level.trim();
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public Byte getRecStatus() {
return recStatus;
}
public void setRecStatus(Byte recStatus) {
this.recStatus = recStatus;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", authId=").append(authId);
sb.append(", agentid=").append(agentid);
sb.append(", name=").append(name);
sb.append(", squareLogoUrl=").append(squareLogoUrl);
sb.append(", roundLogoUrl=").append(roundLogoUrl);
sb.append(", privilege=").append(privilege);
sb.append(", allowParty=").append(allowParty);
sb.append(", allowTag=").append(allowTag);
sb.append(", allowUser=").append(allowUser);
sb.append(", extraParty=").append(extraParty);
sb.append(", extraUser=").append(extraUser);
sb.append(", extraTag=").append(extraTag);
sb.append(", level=").append(level);
sb.append(", createdAt=").append(createdAt);
sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus);
sb.append("]");
return sb.toString();
}
}

1331
health/src/main/java/com/ccsens/health/bean/po/HealthAuthAgentExample.java

File diff suppressed because it is too large

2141
health/src/main/java/com/ccsens/health/bean/po/HealthAuthExample.java

File diff suppressed because it is too large

30
health/src/main/java/com/ccsens/health/persist/mapper/HealthAuthAgentMapper.java

@ -0,0 +1,30 @@
package com.ccsens.health.persist.mapper;
import com.ccsens.health.bean.po.HealthAuthAgent;
import com.ccsens.health.bean.po.HealthAuthAgentExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface HealthAuthAgentMapper {
long countByExample(HealthAuthAgentExample example);
int deleteByExample(HealthAuthAgentExample example);
int deleteByPrimaryKey(Long id);
int insert(HealthAuthAgent record);
int insertSelective(HealthAuthAgent record);
List<HealthAuthAgent> selectByExample(HealthAuthAgentExample example);
HealthAuthAgent selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") HealthAuthAgent record, @Param("example") HealthAuthAgentExample example);
int updateByExample(@Param("record") HealthAuthAgent record, @Param("example") HealthAuthAgentExample example);
int updateByPrimaryKeySelective(HealthAuthAgent record);
int updateByPrimaryKey(HealthAuthAgent record);
}

30
health/src/main/java/com/ccsens/health/persist/mapper/HealthAuthMapper.java

@ -0,0 +1,30 @@
package com.ccsens.health.persist.mapper;
import com.ccsens.health.bean.po.HealthAuth;
import com.ccsens.health.bean.po.HealthAuthExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface HealthAuthMapper {
long countByExample(HealthAuthExample example);
int deleteByExample(HealthAuthExample example);
int deleteByPrimaryKey(Long id);
int insert(HealthAuth record);
int insertSelective(HealthAuth record);
List<HealthAuth> selectByExample(HealthAuthExample example);
HealthAuth selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") HealthAuth record, @Param("example") HealthAuthExample example);
int updateByExample(@Param("record") HealthAuth record, @Param("example") HealthAuthExample example);
int updateByPrimaryKeySelective(HealthAuth record);
int updateByPrimaryKey(HealthAuth record);
}

60
health/src/main/java/com/ccsens/health/service/ConstantService.java

@ -0,0 +1,60 @@
package com.ccsens.health.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.StrUtil;
import com.ccsens.health.bean.po.Constant;
import com.ccsens.health.bean.po.ConstantExample;
import com.ccsens.health.persist.mapper.ConstantMapper;
import com.ccsens.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
public class ConstantService implements IConstantService {
@Autowired
private Snowflake snowflake;
@Autowired
private ConstantMapper constantMapper;
@Autowired
private RedisUtil redisUtil;
private final String KEY_START = "constant_";
@Override
public void saveConstant(String key, String value) {
ConstantExample example = new ConstantExample();
example.createCriteria().andTKeyEqualTo(key);
List<Constant> constants = constantMapper.selectByExample(example);
Constant constant = null;
if (CollectionUtil.isEmpty(constants)) {
constant = new Constant();
constant.setId(snowflake.nextId());
constant.settKey(key);
constant.settValue(value);
constantMapper.insertSelective(constant);
} else {
constant = constants.get(0);
constant.settValue(value);
constantMapper.updateByPrimaryKeySelective(constant);
}
redisUtil.set(KEY_START + key, value);
}
@Override
public String getByKey(String key) {
String value = (String)redisUtil.get(KEY_START + key);
if (StrUtil.isNotBlank(value)) {
return value;
}
ConstantExample example = new ConstantExample();
example.createCriteria().andTKeyEqualTo(key);
List<Constant> constants = constantMapper.selectByExample(example);
if (CollectionUtil.isEmpty(constants)) {
return null;
}
value = constants.get(0).gettValue();
redisUtil.set(KEY_START+key, value);
return value;
}
}

18
health/src/main/java/com/ccsens/health/service/IConstantService.java

@ -0,0 +1,18 @@
package com.ccsens.health.service;
public interface IConstantService {
/**
* 保存常量
* @param key
* @param value
*/
void saveConstant(String key, String value);
/**
* 获取常量
* @param key
* @return
*/
String getByKey(String key);
}

30
health/src/main/java/com/ccsens/health/service/IWeiXinService.java

@ -0,0 +1,30 @@
package com.ccsens.health.service;
/**
* 企业微信相关业务
*/
public interface IWeiXinService {
/**
* 保存永久授权
* @param authCode 微信返回永久授权字符串
*/
void savePermanentCode(String authCode);
/**
* 获取第三方应用凭证
* @param suiteId
* @param suiteTicket
*/
void getSuiteToken(String suiteId, String suiteTicket);
/**
* 获取第三方授权
* @param suiteId
* @param corpId
* @param permanent_code
* @return
*/
String getAccessToken(String suiteId, String corpId, String permanent_code);
}

204
health/src/main/java/com/ccsens/health/service/WeiXinService.java

@ -0,0 +1,204 @@
package com.ccsens.health.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.health.bean.po.HealthAuth;
import com.ccsens.health.bean.po.HealthAuthAgent;
import com.ccsens.health.persist.mapper.HealthAuthAgentMapper;
import com.ccsens.health.persist.mapper.HealthAuthMapper;
import com.ccsens.util.RedisUtil;
import com.ccsens.util.RestTemplateUtil;
import com.ccsens.util.enterprisewx.WeiXinConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class WeiXinService implements IWeiXinService {
@Autowired
private Snowflake snowflake;
@Resource
private HealthAuthMapper healthAuthMapper;
@Resource
private HealthAuthAgentMapper healthAuthAgentMapper;
@Autowired
private RedisUtil redisUtil;
@Override
public String getAccessToken(String suiteId, String corpId, String permanent_code ) {
String key = WeiXinConstant.getAccessToken(suiteId, corpId);
String value = (String) redisUtil.get(key);
if (StrUtil.isNotBlank(value)) {
return value;
}
Map<String, String> param = new HashMap<>();
param.put("auth_corpid",corpId);
param.put("permanent_code", permanent_code);
String resultStr = RestTemplateUtil.postBody(WeiXinConstant.GET_CORP_TOKEN, param);
log.info("获取企业凭证结果:{}", resultStr);
JSONObject result = JSONObject.parseObject(resultStr);
if (WeiXinConstant.pageResult(result)) {
//TODO 异常处理
return null;
}
String accessToken = result.getString("access_token");
redisUtil.set(key, accessToken, result.getInteger("expires_in"));
return accessToken;
}
@Override
public void getSuiteToken(String suiteId, String suiteTicket) {
log.info("获取suiteToken, suiteId:{}, suiteTicket:{}", suiteId, suiteTicket);
String key = WeiXinConstant.getSuiteAccessToken(suiteId);
String suiteAccessToken = (String)redisUtil.get(key);
if (StrUtil.isNotBlank(suiteAccessToken)) {
long expire = redisUtil.getExpire(key);
log.info("suiteTicket有效时长:{}",expire);
//有效期大于20分钟
int expireTime = 1200;
if (expire > expireTime) {
log.info("有效时长大于1200,无需更新");
return;
}
}
Map<String, String> param = new HashMap<>();
param.put("suite_id", suiteId);
param.put("suite_secret", WeiXinConstant.suiteSecret);
param.put("suite_ticket", suiteTicket);
String resultStr = RestTemplateUtil.postBody(WeiXinConstant.GET_SUITE_TOKEN, param);
log.info("获取suite_ticket返回:{}", resultStr);
JSONObject result = JSONObject.parseObject(resultStr);
if (!WeiXinConstant.pageResult(result)) {
log.info("获取suite_ticket异常");
// TODO
return;
}
redisUtil.set(key, result.getString("suite_access_token"), result.getInteger("expires_in"));
}
@Override
public void savePermanentCode(String authCode) {
//授权成功通知
Map<String, String> params = new HashMap<>();
params.put("auth_code", authCode);
String result = RestTemplateUtil.postBody(WeiXinConstant.GET_PERMANENT_CODE, params);
log.info("获取永久授权返回:{}", result);
JSONObject json = JSONObject.parseObject(result);
if (json.getInteger(WeiXinConstant.ERR_CODE).intValue() != 0) {
log.error("获取永久授权码异常:{}", result);
//TODO 异常如何处理
return;
}
HealthAuth auth = initAuth(json);
HealthAuthAgent agent = initAuthAgent(json);
log.info("agent:{}", agent);
healthAuthMapper.insertSelective(auth);
if (agent != null) {
healthAuthAgentMapper.insertSelective(agent);
}
}
/**
* 初始化永久授权信息
* @param json
* @return HealthAuth
*/
private HealthAuth initAuth(JSONObject json) {
HealthAuth auth = new HealthAuth();
auth.setId(snowflake.nextId());
auth.setAccessToken(json.getString("access_token"));
auth.setExpiresIn(json.getInteger("expires_in"));
auth.setPermanentCode(json.getString("permanent_code"));
JSONObject dealerCorpInfo = json.getJSONObject("dealer_corp_info");
if (dealerCorpInfo != null) {
auth.setDealerCorpInfoCorpid(dealerCorpInfo.getString("corpid"));
auth.setDealerCorpInfoCorpName(dealerCorpInfo.getString("corp_name"));
}
JSONObject authCorpInfo = json.getJSONObject("auth_corp_info");
if (authCorpInfo != null) {
auth.setCorpid(authCorpInfo.getString("corpid"));
auth.setCorpName(authCorpInfo.getString("corp_name"));
auth.setCorpType(authCorpInfo.getString("corp_type"));
auth.setCorpSquareLogoUrl(authCorpInfo.getString("corp_square_logo_url"));
auth.setCorpUserMax(authCorpInfo.getInteger("corp_user_max"));
auth.setCorpAgentMax(authCorpInfo.getLong("corp_agent_max"));
auth.setCorpFullName(authCorpInfo.getString("corp_full_name"));
auth.setVerifiedEndTime(authCorpInfo.getLong("verified_end_time"));
auth.setSubjectType(authCorpInfo.getByte("subject_type"));
auth.setCorpWxqrcode(authCorpInfo.getString("corp_wxqrcode"));
auth.setCorpScale(authCorpInfo.getString("corp_scale"));
auth.setCorpIndustry(authCorpInfo.getString("corp_industry"));
auth.setCorpSubIndustry(authCorpInfo.getString("corp_sub_industry"));
auth.setLocation(authCorpInfo.getString("location"));
}
JSONObject authUserInfo = json.getJSONObject("auth_user_info");
if (authUserInfo != null) {
auth.setAuthUserid(authUserInfo.getString("userid"));
auth.setAuthName(authUserInfo.getString("name"));
auth.setAuthAvatar(authUserInfo.getString("avatar"));
}
JSONObject registerCodeInfo = json.getJSONObject("register_code_info");
if (registerCodeInfo != null) {
auth.setRegisterCode(registerCodeInfo.getString("register_code"));
auth.setTemplateId(registerCodeInfo.getString("template_id"));
auth.setState(registerCodeInfo.getString("state"));
}
log.info("auth:{}", auth);
return auth;
}
/**
* 初始化授权应用信息
* @param json
* @return HealthAuthAgent
*/
private HealthAuthAgent initAuthAgent(JSONObject json) {
JSONObject authInfo = json.getJSONObject("auth_info");
if (authInfo == null) {
return null;
}
JSONArray agentArray = authInfo.getJSONArray("agent");
if (agentArray == null || agentArray.isEmpty()) {
return null;
}
JSONObject agentJson = (JSONObject) agentArray.get(0);
HealthAuthAgent agent = new HealthAuthAgent();
agent.setId(snowflake.nextId());
agent.setAgentid(agentJson.getLong("agentid"));
agent.setName(agentJson.getString("name"));
agent.setRoundLogoUrl(agentJson.getString("round_logo_url"));
agent.setSquareLogoUrl(agentJson.getString("square_logo_url"));
JSONObject privilege = agentJson.getJSONObject("privilege");
if (privilege != null) {
agent.setLevel(privilege.getString("level"));
agent.setAllowParty(privilege.getString("allow_party"));
agent.setAllowUser(privilege.getString("allow_user"));
agent.setAllowTag(privilege.getString("allow_tag"));
agent.setExtraParty(privilege.getString("extra_party"));
agent.setExtraUser(privilege.getString("extra_user"));
agent.setExtraTag(privilege.getString("extra_tag"));
}
return agent;
}
}

2
health/src/main/resources/logback-spring.xml

@ -9,7 +9,7 @@
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="/home/cloud/game/log/" />
<property name="log.path" value="/home/cloud/health/log/" />
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->

14
health/src/main/resources/mapper_raw/EmployeeMapper.xml

@ -10,7 +10,7 @@
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="hide_mobile" jdbcType="TINYINT" property="hideMobile" />
<result column="english_name" jdbcType="VARCHAR" property="englishName" />
<result column="tall_user_id" jdbcType="VARCHAR" property="tallUserId" />
<result column="tall_user_id" jdbcType="BIGINT" property="tallUserId" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
@ -115,7 +115,7 @@
)
values (#{id,jdbcType=BIGINT}, #{userid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{gender,jdbcType=TINYINT}, #{status,jdbcType=TINYINT}, #{address,jdbcType=VARCHAR},
#{hideMobile,jdbcType=TINYINT}, #{englishName,jdbcType=VARCHAR}, #{tallUserId,jdbcType=VARCHAR},
#{hideMobile,jdbcType=TINYINT}, #{englishName,jdbcType=VARCHAR}, #{tallUserId,jdbcType=BIGINT},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
)
</insert>
@ -185,7 +185,7 @@
#{englishName,jdbcType=VARCHAR},
</if>
<if test="tallUserId != null">
#{tallUserId,jdbcType=VARCHAR},
#{tallUserId,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
@ -232,7 +232,7 @@
english_name = #{record.englishName,jdbcType=VARCHAR},
</if>
<if test="record.tallUserId != null">
tall_user_id = #{record.tallUserId,jdbcType=VARCHAR},
tall_user_id = #{record.tallUserId,jdbcType=BIGINT},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
@ -258,7 +258,7 @@
address = #{record.address,jdbcType=VARCHAR},
hide_mobile = #{record.hideMobile,jdbcType=TINYINT},
english_name = #{record.englishName,jdbcType=VARCHAR},
tall_user_id = #{record.tallUserId,jdbcType=VARCHAR},
tall_user_id = #{record.tallUserId,jdbcType=BIGINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT}
@ -291,7 +291,7 @@
english_name = #{englishName,jdbcType=VARCHAR},
</if>
<if test="tallUserId != null">
tall_user_id = #{tallUserId,jdbcType=VARCHAR},
tall_user_id = #{tallUserId,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
@ -314,7 +314,7 @@
address = #{address,jdbcType=VARCHAR},
hide_mobile = #{hideMobile,jdbcType=TINYINT},
english_name = #{englishName,jdbcType=VARCHAR},
tall_user_id = #{tallUserId,jdbcType=VARCHAR},
tall_user_id = #{tallUserId,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT}

401
health/src/main/resources/mapper_raw/HealthAuthAgentMapper.xml

@ -0,0 +1,401 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.health.persist.mapper.HealthAuthAgentMapper">
<resultMap id="BaseResultMap" type="com.ccsens.health.bean.po.HealthAuthAgent">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="auth_id" jdbcType="BIGINT" property="authId" />
<result column="agentid" jdbcType="BIGINT" property="agentid" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="square_logo_url" jdbcType="VARCHAR" property="squareLogoUrl" />
<result column="round_logo_url" jdbcType="VARCHAR" property="roundLogoUrl" />
<result column="privilege" jdbcType="VARCHAR" property="privilege" />
<result column="allow_party" jdbcType="VARCHAR" property="allowParty" />
<result column="allow_tag" jdbcType="VARCHAR" property="allowTag" />
<result column="allow_user" jdbcType="VARCHAR" property="allowUser" />
<result column="extra_party" jdbcType="VARCHAR" property="extraParty" />
<result column="extra_user" jdbcType="VARCHAR" property="extraUser" />
<result column="extra_tag" jdbcType="VARCHAR" property="extraTag" />
<result column="level" jdbcType="VARCHAR" property="level" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, auth_id, agentid, name, square_logo_url, round_logo_url, privilege, allow_party,
allow_tag, allow_user, extra_party, extra_user, extra_tag, level, created_at, updated_at,
rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.health.bean.po.HealthAuthAgentExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_health_auth_agent
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_health_auth_agent
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from t_health_auth_agent
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.ccsens.health.bean.po.HealthAuthAgentExample">
delete from t_health_auth_agent
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.health.bean.po.HealthAuthAgent">
insert into t_health_auth_agent (id, auth_id, agentid,
name, square_logo_url, round_logo_url,
privilege, allow_party, allow_tag,
allow_user, extra_party, extra_user,
extra_tag, level, created_at,
updated_at, rec_status)
values (#{id,jdbcType=BIGINT}, #{authId,jdbcType=BIGINT}, #{agentid,jdbcType=BIGINT},
#{name,jdbcType=VARCHAR}, #{squareLogoUrl,jdbcType=VARCHAR}, #{roundLogoUrl,jdbcType=VARCHAR},
#{privilege,jdbcType=VARCHAR}, #{allowParty,jdbcType=VARCHAR}, #{allowTag,jdbcType=VARCHAR},
#{allowUser,jdbcType=VARCHAR}, #{extraParty,jdbcType=VARCHAR}, #{extraUser,jdbcType=VARCHAR},
#{extraTag,jdbcType=VARCHAR}, #{level,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.ccsens.health.bean.po.HealthAuthAgent">
insert into t_health_auth_agent
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="authId != null">
auth_id,
</if>
<if test="agentid != null">
agentid,
</if>
<if test="name != null">
name,
</if>
<if test="squareLogoUrl != null">
square_logo_url,
</if>
<if test="roundLogoUrl != null">
round_logo_url,
</if>
<if test="privilege != null">
privilege,
</if>
<if test="allowParty != null">
allow_party,
</if>
<if test="allowTag != null">
allow_tag,
</if>
<if test="allowUser != null">
allow_user,
</if>
<if test="extraParty != null">
extra_party,
</if>
<if test="extraUser != null">
extra_user,
</if>
<if test="extraTag != null">
extra_tag,
</if>
<if test="level != null">
level,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="recStatus != null">
rec_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="authId != null">
#{authId,jdbcType=BIGINT},
</if>
<if test="agentid != null">
#{agentid,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="squareLogoUrl != null">
#{squareLogoUrl,jdbcType=VARCHAR},
</if>
<if test="roundLogoUrl != null">
#{roundLogoUrl,jdbcType=VARCHAR},
</if>
<if test="privilege != null">
#{privilege,jdbcType=VARCHAR},
</if>
<if test="allowParty != null">
#{allowParty,jdbcType=VARCHAR},
</if>
<if test="allowTag != null">
#{allowTag,jdbcType=VARCHAR},
</if>
<if test="allowUser != null">
#{allowUser,jdbcType=VARCHAR},
</if>
<if test="extraParty != null">
#{extraParty,jdbcType=VARCHAR},
</if>
<if test="extraUser != null">
#{extraUser,jdbcType=VARCHAR},
</if>
<if test="extraTag != null">
#{extraTag,jdbcType=VARCHAR},
</if>
<if test="level != null">
#{level,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
#{recStatus,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.ccsens.health.bean.po.HealthAuthAgentExample" resultType="java.lang.Long">
select count(*) from t_health_auth_agent
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_health_auth_agent
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.authId != null">
auth_id = #{record.authId,jdbcType=BIGINT},
</if>
<if test="record.agentid != null">
agentid = #{record.agentid,jdbcType=BIGINT},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.squareLogoUrl != null">
square_logo_url = #{record.squareLogoUrl,jdbcType=VARCHAR},
</if>
<if test="record.roundLogoUrl != null">
round_logo_url = #{record.roundLogoUrl,jdbcType=VARCHAR},
</if>
<if test="record.privilege != null">
privilege = #{record.privilege,jdbcType=VARCHAR},
</if>
<if test="record.allowParty != null">
allow_party = #{record.allowParty,jdbcType=VARCHAR},
</if>
<if test="record.allowTag != null">
allow_tag = #{record.allowTag,jdbcType=VARCHAR},
</if>
<if test="record.allowUser != null">
allow_user = #{record.allowUser,jdbcType=VARCHAR},
</if>
<if test="record.extraParty != null">
extra_party = #{record.extraParty,jdbcType=VARCHAR},
</if>
<if test="record.extraUser != null">
extra_user = #{record.extraUser,jdbcType=VARCHAR},
</if>
<if test="record.extraTag != null">
extra_tag = #{record.extraTag,jdbcType=VARCHAR},
</if>
<if test="record.level != null">
level = #{record.level,jdbcType=VARCHAR},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if>
<if test="record.updatedAt != null">
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="record.recStatus != null">
rec_status = #{record.recStatus,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_health_auth_agent
set id = #{record.id,jdbcType=BIGINT},
auth_id = #{record.authId,jdbcType=BIGINT},
agentid = #{record.agentid,jdbcType=BIGINT},
name = #{record.name,jdbcType=VARCHAR},
square_logo_url = #{record.squareLogoUrl,jdbcType=VARCHAR},
round_logo_url = #{record.roundLogoUrl,jdbcType=VARCHAR},
privilege = #{record.privilege,jdbcType=VARCHAR},
allow_party = #{record.allowParty,jdbcType=VARCHAR},
allow_tag = #{record.allowTag,jdbcType=VARCHAR},
allow_user = #{record.allowUser,jdbcType=VARCHAR},
extra_party = #{record.extraParty,jdbcType=VARCHAR},
extra_user = #{record.extraUser,jdbcType=VARCHAR},
extra_tag = #{record.extraTag,jdbcType=VARCHAR},
level = #{record.level,jdbcType=VARCHAR},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.health.bean.po.HealthAuthAgent">
update t_health_auth_agent
<set>
<if test="authId != null">
auth_id = #{authId,jdbcType=BIGINT},
</if>
<if test="agentid != null">
agentid = #{agentid,jdbcType=BIGINT},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="squareLogoUrl != null">
square_logo_url = #{squareLogoUrl,jdbcType=VARCHAR},
</if>
<if test="roundLogoUrl != null">
round_logo_url = #{roundLogoUrl,jdbcType=VARCHAR},
</if>
<if test="privilege != null">
privilege = #{privilege,jdbcType=VARCHAR},
</if>
<if test="allowParty != null">
allow_party = #{allowParty,jdbcType=VARCHAR},
</if>
<if test="allowTag != null">
allow_tag = #{allowTag,jdbcType=VARCHAR},
</if>
<if test="allowUser != null">
allow_user = #{allowUser,jdbcType=VARCHAR},
</if>
<if test="extraParty != null">
extra_party = #{extraParty,jdbcType=VARCHAR},
</if>
<if test="extraUser != null">
extra_user = #{extraUser,jdbcType=VARCHAR},
</if>
<if test="extraTag != null">
extra_tag = #{extraTag,jdbcType=VARCHAR},
</if>
<if test="level != null">
level = #{level,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
rec_status = #{recStatus,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.health.bean.po.HealthAuthAgent">
update t_health_auth_agent
set auth_id = #{authId,jdbcType=BIGINT},
agentid = #{agentid,jdbcType=BIGINT},
name = #{name,jdbcType=VARCHAR},
square_logo_url = #{squareLogoUrl,jdbcType=VARCHAR},
round_logo_url = #{roundLogoUrl,jdbcType=VARCHAR},
privilege = #{privilege,jdbcType=VARCHAR},
allow_party = #{allowParty,jdbcType=VARCHAR},
allow_tag = #{allowTag,jdbcType=VARCHAR},
allow_user = #{allowUser,jdbcType=VARCHAR},
extra_party = #{extraParty,jdbcType=VARCHAR},
extra_user = #{extraUser,jdbcType=VARCHAR},
extra_tag = #{extraTag,jdbcType=VARCHAR},
level = #{level,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

593
health/src/main/resources/mapper_raw/HealthAuthMapper.xml

@ -0,0 +1,593 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.health.persist.mapper.HealthAuthMapper">
<resultMap id="BaseResultMap" type="com.ccsens.health.bean.po.HealthAuth">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="access_token" jdbcType="VARCHAR" property="accessToken" />
<result column="expires_in" jdbcType="INTEGER" property="expiresIn" />
<result column="permanent_code" jdbcType="VARCHAR" property="permanentCode" />
<result column="corpid" jdbcType="VARCHAR" property="corpid" />
<result column="corp_name" jdbcType="VARCHAR" property="corpName" />
<result column="corp_type" jdbcType="VARCHAR" property="corpType" />
<result column="corp_square_logo_url" jdbcType="VARCHAR" property="corpSquareLogoUrl" />
<result column="corp_user_max" jdbcType="INTEGER" property="corpUserMax" />
<result column="corp_agent_max" jdbcType="BIGINT" property="corpAgentMax" />
<result column="corp_full_name" jdbcType="VARCHAR" property="corpFullName" />
<result column="subject_type" jdbcType="TINYINT" property="subjectType" />
<result column="verified_end_time" jdbcType="BIGINT" property="verifiedEndTime" />
<result column="corp_wxqrcode" jdbcType="VARCHAR" property="corpWxqrcode" />
<result column="corp_scale" jdbcType="VARCHAR" property="corpScale" />
<result column="corp_industry" jdbcType="VARCHAR" property="corpIndustry" />
<result column="corp_sub_industry" jdbcType="VARCHAR" property="corpSubIndustry" />
<result column="location" jdbcType="VARCHAR" property="location" />
<result column="auth_userid" jdbcType="VARCHAR" property="authUserid" />
<result column="auth_name" jdbcType="VARCHAR" property="authName" />
<result column="auth_avatar" jdbcType="VARCHAR" property="authAvatar" />
<result column="dealer_corp_info_corpid" jdbcType="VARCHAR" property="dealerCorpInfoCorpid" />
<result column="dealer_corp_info_corp_name" jdbcType="VARCHAR" property="dealerCorpInfoCorpName" />
<result column="register_code" jdbcType="VARCHAR" property="registerCode" />
<result column="template_id" jdbcType="VARCHAR" property="templateId" />
<result column="state" jdbcType="VARCHAR" property="state" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, access_token, expires_in, permanent_code, corpid, corp_name, corp_type, corp_square_logo_url,
corp_user_max, corp_agent_max, corp_full_name, subject_type, verified_end_time, corp_wxqrcode,
corp_scale, corp_industry, corp_sub_industry, location, auth_userid, auth_name, auth_avatar,
dealer_corp_info_corpid, dealer_corp_info_corp_name, register_code, template_id,
state, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.health.bean.po.HealthAuthExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_health_auth
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_health_auth
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from t_health_auth
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.ccsens.health.bean.po.HealthAuthExample">
delete from t_health_auth
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.health.bean.po.HealthAuth">
insert into t_health_auth (id, access_token, expires_in,
permanent_code, corpid, corp_name,
corp_type, corp_square_logo_url, corp_user_max,
corp_agent_max, corp_full_name, subject_type,
verified_end_time, corp_wxqrcode, corp_scale,
corp_industry, corp_sub_industry, location,
auth_userid, auth_name, auth_avatar,
dealer_corp_info_corpid, dealer_corp_info_corp_name,
register_code, template_id, state,
created_at, updated_at, rec_status
)
values (#{id,jdbcType=BIGINT}, #{accessToken,jdbcType=VARCHAR}, #{expiresIn,jdbcType=INTEGER},
#{permanentCode,jdbcType=VARCHAR}, #{corpid,jdbcType=VARCHAR}, #{corpName,jdbcType=VARCHAR},
#{corpType,jdbcType=VARCHAR}, #{corpSquareLogoUrl,jdbcType=VARCHAR}, #{corpUserMax,jdbcType=INTEGER},
#{corpAgentMax,jdbcType=BIGINT}, #{corpFullName,jdbcType=VARCHAR}, #{subjectType,jdbcType=TINYINT},
#{verifiedEndTime,jdbcType=BIGINT}, #{corpWxqrcode,jdbcType=VARCHAR}, #{corpScale,jdbcType=VARCHAR},
#{corpIndustry,jdbcType=VARCHAR}, #{corpSubIndustry,jdbcType=VARCHAR}, #{location,jdbcType=VARCHAR},
#{authUserid,jdbcType=VARCHAR}, #{authName,jdbcType=VARCHAR}, #{authAvatar,jdbcType=VARCHAR},
#{dealerCorpInfoCorpid,jdbcType=VARCHAR}, #{dealerCorpInfoCorpName,jdbcType=VARCHAR},
#{registerCode,jdbcType=VARCHAR}, #{templateId,jdbcType=VARCHAR}, #{state,jdbcType=VARCHAR},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.ccsens.health.bean.po.HealthAuth">
insert into t_health_auth
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="accessToken != null">
access_token,
</if>
<if test="expiresIn != null">
expires_in,
</if>
<if test="permanentCode != null">
permanent_code,
</if>
<if test="corpid != null">
corpid,
</if>
<if test="corpName != null">
corp_name,
</if>
<if test="corpType != null">
corp_type,
</if>
<if test="corpSquareLogoUrl != null">
corp_square_logo_url,
</if>
<if test="corpUserMax != null">
corp_user_max,
</if>
<if test="corpAgentMax != null">
corp_agent_max,
</if>
<if test="corpFullName != null">
corp_full_name,
</if>
<if test="subjectType != null">
subject_type,
</if>
<if test="verifiedEndTime != null">
verified_end_time,
</if>
<if test="corpWxqrcode != null">
corp_wxqrcode,
</if>
<if test="corpScale != null">
corp_scale,
</if>
<if test="corpIndustry != null">
corp_industry,
</if>
<if test="corpSubIndustry != null">
corp_sub_industry,
</if>
<if test="location != null">
location,
</if>
<if test="authUserid != null">
auth_userid,
</if>
<if test="authName != null">
auth_name,
</if>
<if test="authAvatar != null">
auth_avatar,
</if>
<if test="dealerCorpInfoCorpid != null">
dealer_corp_info_corpid,
</if>
<if test="dealerCorpInfoCorpName != null">
dealer_corp_info_corp_name,
</if>
<if test="registerCode != null">
register_code,
</if>
<if test="templateId != null">
template_id,
</if>
<if test="state != null">
state,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="recStatus != null">
rec_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="accessToken != null">
#{accessToken,jdbcType=VARCHAR},
</if>
<if test="expiresIn != null">
#{expiresIn,jdbcType=INTEGER},
</if>
<if test="permanentCode != null">
#{permanentCode,jdbcType=VARCHAR},
</if>
<if test="corpid != null">
#{corpid,jdbcType=VARCHAR},
</if>
<if test="corpName != null">
#{corpName,jdbcType=VARCHAR},
</if>
<if test="corpType != null">
#{corpType,jdbcType=VARCHAR},
</if>
<if test="corpSquareLogoUrl != null">
#{corpSquareLogoUrl,jdbcType=VARCHAR},
</if>
<if test="corpUserMax != null">
#{corpUserMax,jdbcType=INTEGER},
</if>
<if test="corpAgentMax != null">
#{corpAgentMax,jdbcType=BIGINT},
</if>
<if test="corpFullName != null">
#{corpFullName,jdbcType=VARCHAR},
</if>
<if test="subjectType != null">
#{subjectType,jdbcType=TINYINT},
</if>
<if test="verifiedEndTime != null">
#{verifiedEndTime,jdbcType=BIGINT},
</if>
<if test="corpWxqrcode != null">
#{corpWxqrcode,jdbcType=VARCHAR},
</if>
<if test="corpScale != null">
#{corpScale,jdbcType=VARCHAR},
</if>
<if test="corpIndustry != null">
#{corpIndustry,jdbcType=VARCHAR},
</if>
<if test="corpSubIndustry != null">
#{corpSubIndustry,jdbcType=VARCHAR},
</if>
<if test="location != null">
#{location,jdbcType=VARCHAR},
</if>
<if test="authUserid != null">
#{authUserid,jdbcType=VARCHAR},
</if>
<if test="authName != null">
#{authName,jdbcType=VARCHAR},
</if>
<if test="authAvatar != null">
#{authAvatar,jdbcType=VARCHAR},
</if>
<if test="dealerCorpInfoCorpid != null">
#{dealerCorpInfoCorpid,jdbcType=VARCHAR},
</if>
<if test="dealerCorpInfoCorpName != null">
#{dealerCorpInfoCorpName,jdbcType=VARCHAR},
</if>
<if test="registerCode != null">
#{registerCode,jdbcType=VARCHAR},
</if>
<if test="templateId != null">
#{templateId,jdbcType=VARCHAR},
</if>
<if test="state != null">
#{state,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
#{recStatus,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.ccsens.health.bean.po.HealthAuthExample" resultType="java.lang.Long">
select count(*) from t_health_auth
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_health_auth
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.accessToken != null">
access_token = #{record.accessToken,jdbcType=VARCHAR},
</if>
<if test="record.expiresIn != null">
expires_in = #{record.expiresIn,jdbcType=INTEGER},
</if>
<if test="record.permanentCode != null">
permanent_code = #{record.permanentCode,jdbcType=VARCHAR},
</if>
<if test="record.corpid != null">
corpid = #{record.corpid,jdbcType=VARCHAR},
</if>
<if test="record.corpName != null">
corp_name = #{record.corpName,jdbcType=VARCHAR},
</if>
<if test="record.corpType != null">
corp_type = #{record.corpType,jdbcType=VARCHAR},
</if>
<if test="record.corpSquareLogoUrl != null">
corp_square_logo_url = #{record.corpSquareLogoUrl,jdbcType=VARCHAR},
</if>
<if test="record.corpUserMax != null">
corp_user_max = #{record.corpUserMax,jdbcType=INTEGER},
</if>
<if test="record.corpAgentMax != null">
corp_agent_max = #{record.corpAgentMax,jdbcType=BIGINT},
</if>
<if test="record.corpFullName != null">
corp_full_name = #{record.corpFullName,jdbcType=VARCHAR},
</if>
<if test="record.subjectType != null">
subject_type = #{record.subjectType,jdbcType=TINYINT},
</if>
<if test="record.verifiedEndTime != null">
verified_end_time = #{record.verifiedEndTime,jdbcType=BIGINT},
</if>
<if test="record.corpWxqrcode != null">
corp_wxqrcode = #{record.corpWxqrcode,jdbcType=VARCHAR},
</if>
<if test="record.corpScale != null">
corp_scale = #{record.corpScale,jdbcType=VARCHAR},
</if>
<if test="record.corpIndustry != null">
corp_industry = #{record.corpIndustry,jdbcType=VARCHAR},
</if>
<if test="record.corpSubIndustry != null">
corp_sub_industry = #{record.corpSubIndustry,jdbcType=VARCHAR},
</if>
<if test="record.location != null">
location = #{record.location,jdbcType=VARCHAR},
</if>
<if test="record.authUserid != null">
auth_userid = #{record.authUserid,jdbcType=VARCHAR},
</if>
<if test="record.authName != null">
auth_name = #{record.authName,jdbcType=VARCHAR},
</if>
<if test="record.authAvatar != null">
auth_avatar = #{record.authAvatar,jdbcType=VARCHAR},
</if>
<if test="record.dealerCorpInfoCorpid != null">
dealer_corp_info_corpid = #{record.dealerCorpInfoCorpid,jdbcType=VARCHAR},
</if>
<if test="record.dealerCorpInfoCorpName != null">
dealer_corp_info_corp_name = #{record.dealerCorpInfoCorpName,jdbcType=VARCHAR},
</if>
<if test="record.registerCode != null">
register_code = #{record.registerCode,jdbcType=VARCHAR},
</if>
<if test="record.templateId != null">
template_id = #{record.templateId,jdbcType=VARCHAR},
</if>
<if test="record.state != null">
state = #{record.state,jdbcType=VARCHAR},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if>
<if test="record.updatedAt != null">
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="record.recStatus != null">
rec_status = #{record.recStatus,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_health_auth
set id = #{record.id,jdbcType=BIGINT},
access_token = #{record.accessToken,jdbcType=VARCHAR},
expires_in = #{record.expiresIn,jdbcType=INTEGER},
permanent_code = #{record.permanentCode,jdbcType=VARCHAR},
corpid = #{record.corpid,jdbcType=VARCHAR},
corp_name = #{record.corpName,jdbcType=VARCHAR},
corp_type = #{record.corpType,jdbcType=VARCHAR},
corp_square_logo_url = #{record.corpSquareLogoUrl,jdbcType=VARCHAR},
corp_user_max = #{record.corpUserMax,jdbcType=INTEGER},
corp_agent_max = #{record.corpAgentMax,jdbcType=BIGINT},
corp_full_name = #{record.corpFullName,jdbcType=VARCHAR},
subject_type = #{record.subjectType,jdbcType=TINYINT},
verified_end_time = #{record.verifiedEndTime,jdbcType=BIGINT},
corp_wxqrcode = #{record.corpWxqrcode,jdbcType=VARCHAR},
corp_scale = #{record.corpScale,jdbcType=VARCHAR},
corp_industry = #{record.corpIndustry,jdbcType=VARCHAR},
corp_sub_industry = #{record.corpSubIndustry,jdbcType=VARCHAR},
location = #{record.location,jdbcType=VARCHAR},
auth_userid = #{record.authUserid,jdbcType=VARCHAR},
auth_name = #{record.authName,jdbcType=VARCHAR},
auth_avatar = #{record.authAvatar,jdbcType=VARCHAR},
dealer_corp_info_corpid = #{record.dealerCorpInfoCorpid,jdbcType=VARCHAR},
dealer_corp_info_corp_name = #{record.dealerCorpInfoCorpName,jdbcType=VARCHAR},
register_code = #{record.registerCode,jdbcType=VARCHAR},
template_id = #{record.templateId,jdbcType=VARCHAR},
state = #{record.state,jdbcType=VARCHAR},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.health.bean.po.HealthAuth">
update t_health_auth
<set>
<if test="accessToken != null">
access_token = #{accessToken,jdbcType=VARCHAR},
</if>
<if test="expiresIn != null">
expires_in = #{expiresIn,jdbcType=INTEGER},
</if>
<if test="permanentCode != null">
permanent_code = #{permanentCode,jdbcType=VARCHAR},
</if>
<if test="corpid != null">
corpid = #{corpid,jdbcType=VARCHAR},
</if>
<if test="corpName != null">
corp_name = #{corpName,jdbcType=VARCHAR},
</if>
<if test="corpType != null">
corp_type = #{corpType,jdbcType=VARCHAR},
</if>
<if test="corpSquareLogoUrl != null">
corp_square_logo_url = #{corpSquareLogoUrl,jdbcType=VARCHAR},
</if>
<if test="corpUserMax != null">
corp_user_max = #{corpUserMax,jdbcType=INTEGER},
</if>
<if test="corpAgentMax != null">
corp_agent_max = #{corpAgentMax,jdbcType=BIGINT},
</if>
<if test="corpFullName != null">
corp_full_name = #{corpFullName,jdbcType=VARCHAR},
</if>
<if test="subjectType != null">
subject_type = #{subjectType,jdbcType=TINYINT},
</if>
<if test="verifiedEndTime != null">
verified_end_time = #{verifiedEndTime,jdbcType=BIGINT},
</if>
<if test="corpWxqrcode != null">
corp_wxqrcode = #{corpWxqrcode,jdbcType=VARCHAR},
</if>
<if test="corpScale != null">
corp_scale = #{corpScale,jdbcType=VARCHAR},
</if>
<if test="corpIndustry != null">
corp_industry = #{corpIndustry,jdbcType=VARCHAR},
</if>
<if test="corpSubIndustry != null">
corp_sub_industry = #{corpSubIndustry,jdbcType=VARCHAR},
</if>
<if test="location != null">
location = #{location,jdbcType=VARCHAR},
</if>
<if test="authUserid != null">
auth_userid = #{authUserid,jdbcType=VARCHAR},
</if>
<if test="authName != null">
auth_name = #{authName,jdbcType=VARCHAR},
</if>
<if test="authAvatar != null">
auth_avatar = #{authAvatar,jdbcType=VARCHAR},
</if>
<if test="dealerCorpInfoCorpid != null">
dealer_corp_info_corpid = #{dealerCorpInfoCorpid,jdbcType=VARCHAR},
</if>
<if test="dealerCorpInfoCorpName != null">
dealer_corp_info_corp_name = #{dealerCorpInfoCorpName,jdbcType=VARCHAR},
</if>
<if test="registerCode != null">
register_code = #{registerCode,jdbcType=VARCHAR},
</if>
<if test="templateId != null">
template_id = #{templateId,jdbcType=VARCHAR},
</if>
<if test="state != null">
state = #{state,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
rec_status = #{recStatus,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.health.bean.po.HealthAuth">
update t_health_auth
set access_token = #{accessToken,jdbcType=VARCHAR},
expires_in = #{expiresIn,jdbcType=INTEGER},
permanent_code = #{permanentCode,jdbcType=VARCHAR},
corpid = #{corpid,jdbcType=VARCHAR},
corp_name = #{corpName,jdbcType=VARCHAR},
corp_type = #{corpType,jdbcType=VARCHAR},
corp_square_logo_url = #{corpSquareLogoUrl,jdbcType=VARCHAR},
corp_user_max = #{corpUserMax,jdbcType=INTEGER},
corp_agent_max = #{corpAgentMax,jdbcType=BIGINT},
corp_full_name = #{corpFullName,jdbcType=VARCHAR},
subject_type = #{subjectType,jdbcType=TINYINT},
verified_end_time = #{verifiedEndTime,jdbcType=BIGINT},
corp_wxqrcode = #{corpWxqrcode,jdbcType=VARCHAR},
corp_scale = #{corpScale,jdbcType=VARCHAR},
corp_industry = #{corpIndustry,jdbcType=VARCHAR},
corp_sub_industry = #{corpSubIndustry,jdbcType=VARCHAR},
location = #{location,jdbcType=VARCHAR},
auth_userid = #{authUserid,jdbcType=VARCHAR},
auth_name = #{authName,jdbcType=VARCHAR},
auth_avatar = #{authAvatar,jdbcType=VARCHAR},
dealer_corp_info_corpid = #{dealerCorpInfoCorpid,jdbcType=VARCHAR},
dealer_corp_info_corp_name = #{dealerCorpInfoCorpName,jdbcType=VARCHAR},
register_code = #{registerCode,jdbcType=VARCHAR},
template_id = #{templateId,jdbcType=VARCHAR},
state = #{state,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

5
pom.xml

@ -223,6 +223,11 @@
<artifactId>qcloudsms</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
</dependencies>
<!-- 引入spring cloud的依赖,不能少,主要用来管理Spring Cloud生态各组件的版本 -->

123
util/src/main/java/com/ccsens/util/RestTemplateUtil.java

@ -0,0 +1,123 @@
package com.ccsens.util;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.util.Map;
@Slf4j
@Component
public class RestTemplateUtil {
@Autowired
private RestTemplate restTemplate;
private static RestTemplateUtil util;
@PostConstruct
public void init(){
util = this;
util.restTemplate = this.restTemplate;
}
public static Object getForEntity(String url, Map<String, Object> params, Class<?> returnClass) {
if (params != null && !params.isEmpty()) {
if (!url.contains("?")) {
url += "?";
}
for (String key : params.keySet()) {
if (url.endsWith("?")) {
url += key + "="+params.get(key)+"";
} else {
url += "&" + key + "="+params.get(key)+"";
}
}
}
log.info("url:{}, params:{}", url, params);
ResponseEntity<String> entity = util.restTemplate.getForEntity(url, String.class);
log.info("entity:{}",entity);
return JSONObject.parseObject(entity.getBody(), returnClass);
}
public static String postBody(String url, Object params) {
log.info("路径:{}, 参数:{}", url, params);
HttpHeaders httpHeaders = new HttpHeaders();
MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8");
httpHeaders.setContentType(type);
// MultiValueMap<String, Object> map=new LinkedMultiValueMap<>();
JSONObject json = JSON.parseObject(JSON.toJSONString(params));
HttpEntity<Map<String, Object>> objectHttpEntity = new HttpEntity<>(json,httpHeaders);
ResponseEntity<String> response = util.restTemplate.postForEntity(url, objectHttpEntity, String.class);
log.info("返回:{}", response);
return response.getBody();
}
public static String postUrlEncode(String url, Object params) {
log.info("请求路径:{},请求参数:{}", url, params);
JSONObject json = JSON.parseObject(JSON.toJSONString(params));
MultiValueMap<String, Object> paramMap = transMultiValueMap(json);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
HttpEntity<MultiValueMap> formEntity = new HttpEntity<>(paramMap, headers);
ResponseEntity<String> result = util.restTemplate.postForEntity(url, formEntity, String.class);
log.info("接口返回结果:{}", result);
return result.getBody();
}
/**
* 发送multipart/form-data
* @author whj
* @date 2019/8/20
* @param url
* @param params
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject postImg(String url, JSONObject params) {
log.info("请求路径:{},请求参数:{}", url, params);
HttpHeaders headers = new HttpHeaders();
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, Object> paramMap = transMultiValueMap(params);
HttpEntity<MultiValueMap> formEntity = new HttpEntity<>(paramMap, headers);
JSONObject result = util.restTemplate.postForObject(url, formEntity, JSONObject.class);
log.info("接口返回结果:{}", result);
return result;
}
/**
* 将参数封装成MultiValueMap对象
* @author whj
* @date 2019/8/20
* @param params
* @return org.springframework.util.MultiValueMap<java.lang.String,java.lang.Object>
*/
private static MultiValueMap<String, Object> transMultiValueMap(JSONObject params) {
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>();
for (String key: params.keySet()) {
paramMap.add(key, params.get(key));
}
return paramMap;
}
public static boolean pageResult(String result) {
if (StrUtil.isBlank(result) || result.contains("<html")) {
return false;
}
return true;
}
}

72
util/src/main/java/com/ccsens/util/enterprisewx/WeiXinConstant.java

@ -1,9 +1,77 @@
package com.ccsens.util.enterprisewx;
import com.alibaba.fastjson.JSONObject;
/**
* @author wu
*/
public class WeiXinConstant {
public static final String token = "4CxIpRDBWHMiePP3x6muNe4hRj";
public static final String corpID = "ww86f65c2e95cd8b4c";
public static final String encodingAESKey = "NInifq246LLoF5wyCq4fRJNJOvKI7XIkgdUqOpWoP3G";
public static final String providerSecret = "fr8OXt4iMqIxe3QMUVkHCK_j9oj0qllZciOgw5CdGldDksv5yMoxFduPbZGmIlfj";
public static final String suiteSecret = "suite_secret";
public static final String ERR_CODE = "errcode";
public static final String ERR_MSG = "errmsg";
/**
* 获取永久授权
*/
public static final String GET_PERMANENT_CODE = "https://qyapi.weixin.qq.com/cgi-bin/service/get_permanent_code";
public static final String GET_SUITE_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/service/get_suite_token";
public static final String GET_CORP_TOKEN = "https://qyapi.weixin.qq.com/cgi-bin/service/get_corp_token";
/**
* 获取第三方凭证
* @param suiteId
* @return
*/
public static String getAccessToken(String suiteId, String corpID) {
return "access_token_" + suiteId + "_" + corpID;
}
/**
* 获取临时授权码key
* @param suiteId
* @return
*/
public static String getTempAuthCodeKey(String suiteId) {
return "temp_auth_code_" + suiteId;
}
public static String getSuiteAccessToken(String suiteId){
return "suite_access_token_" + suiteId;
}
/**
* 获取SuiteTicket的key
* @param suiteId
* @return
*/
public static String getSuiteTicket(String suiteId) {
return "suite_ticket_" + suiteId;
}
/**
* 获取suiteToken的key
* @param suiteId
* @return
*/
public static String getSuiteToken(String suiteId) {
return "suite_token_" + suiteId;
}
private String corpId = "ww86f65c2e95cd8b4c";
private String provider_secret = "fr8OXt4iMqIxe3QMUVkHCK_j9oj0qllZciOgw5CdGldDksv5yMoxFduPbZGmIlfj";
/**
* 判断返回是否正确
* @param result
* @return
*/
public static boolean pageResult(JSONObject result) {
return result.getIntValue(ERR_CODE) == 0;
}
}

2
util/src/main/java/com/ccsens/util/enterprisewx/XMLParse.java

@ -23,7 +23,7 @@ import org.xml.sax.InputSource;
*
* 提供提取消息格式中的密文及生成回复消息格式的接口.
*/
public class XMLParse {
class XMLParse {
/**
* 提取出xml数据包中的加密消息

35
util/src/main/java/com/ccsens/util/enterprisewx/dto/MessageDto.java

@ -1,5 +1,7 @@
package com.ccsens.util.enterprisewx.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.UnsupportedEncodingException;
@ -9,16 +11,39 @@ import java.net.URLDecoder;
* @author wu
*/
@Data
@ApiModel("企业微信接收参数")
public class MessageDto {
private String msg_signature;
private String timestamp;
private String nonce;
private String echostr;
public void urlEncode() throws UnsupportedEncodingException {
msg_signature = URLDecoder.decode(msg_signature, "UTF-8");
nonce = URLDecoder.decode(nonce, "UTF-8");
timestamp = URLDecoder.decode(timestamp, "UTF-8");
echostr = URLDecoder.decode(echostr, "UTF-8");
@Data
@ApiModel("suite_ticket通知")
public static class Ticket{
@ApiModelProperty("第三方应用的SuiteId")
private String SuiteId;
@ApiModelProperty("通知类型")
private String InfoType;
@ApiModelProperty("时间戳")
private String TimeStamp;
@ApiModelProperty("ticket")
private String SuiteTicket;
}
@Data
@ApiModel("授权通知")
public static class Grant{
@ApiModelProperty("第三方应用的SuiteId")
private String SuiteId;
@ApiModelProperty("临时授权码")
private String AuthCode;
@ApiModelProperty("通知类型")
private String InfoType;
@ApiModelProperty("时间戳")
private String TimeStamp;
}
}

Loading…
Cancel
Save