Browse Source
# Conflicts: # epmet-commons/pom.xml # epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerServiceImpl.java # epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicService.java # epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java # epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.javadev_shibei_match
57 changed files with 1149 additions and 26 deletions
@ -0,0 +1,18 @@ |
|||
package com.epmet.constant; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/19 上午10:26 |
|||
*/ |
|||
public interface SsoConstant { |
|||
|
|||
/** |
|||
* 酒城e通appId |
|||
*/ |
|||
String WINE_CITY_E_OPEN_APP_ID = ""; |
|||
|
|||
String USER_INFO_IS_NULL = "【jcetApiService.getUserInfoByTicket(formDTO.getTicket()】结果为空......"; |
|||
|
|||
String INSERT_UPDATE_USER_FAILURE = "新增或更新user_weChat失败......"; |
|||
|
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.dto.form.SsoLoginFormDTO; |
|||
import com.epmet.dto.result.SsoLoginResultDTO; |
|||
import com.epmet.service.SsoService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/18 下午4:33 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("sso/resi") |
|||
public class SsoController { |
|||
|
|||
@Autowired |
|||
private SsoService ssoService; |
|||
|
|||
/** |
|||
* @Description 0、入口:得到token |
|||
* @Param formDTO |
|||
* @author zxc |
|||
* @date 2021/1/18 下午4:59 |
|||
*/ |
|||
@PostMapping("login") |
|||
public Result<SsoLoginResultDTO> ssoLogin(@RequestBody SsoLoginFormDTO formDTO){ |
|||
ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class); |
|||
return new Result<SsoLoginResultDTO>().ok(ssoService.ssoLogin(formDTO)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/18 下午4:43 |
|||
*/ |
|||
@Data |
|||
public class SsoLoginFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -6543952487970013031L; |
|||
|
|||
public interface SsoLoginForm{} |
|||
|
|||
/** |
|||
* sso票据,有效期为300秒 |
|||
*/ |
|||
@NotBlank(message = "sso票据不能为空",groups = SsoLoginForm.class) |
|||
private String ticket; |
|||
|
|||
/** |
|||
* 三方平台应用AppId |
|||
*/ |
|||
@NotBlank(message = "三方平台应用AppId不能为空",groups = SsoLoginForm.class) |
|||
private String appId; |
|||
|
|||
/** |
|||
* app类型 resi;居民段,work:工作端 |
|||
*/ |
|||
@NotBlank(message = "app不能为空",groups = SsoLoginForm.class) |
|||
private String app; |
|||
|
|||
@NotBlank(message = "client不能为空",groups = SsoLoginForm.class) |
|||
private String client; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/18 下午4:45 |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class SsoLoginResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 3491079788196180035L; |
|||
|
|||
private String token = ""; |
|||
} |
@ -0,0 +1,39 @@ |
|||
package com.epmet.redis; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.epmet.commons.tools.redis.RedisKeys; |
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/18 下午5:09 |
|||
*/ |
|||
@Component |
|||
public class SsoRedis { |
|||
|
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
/** |
|||
* @Description token放入缓存 |
|||
* @Param user |
|||
* @Param expire |
|||
* @author zxc |
|||
* @date 2021/1/18 下午5:10 |
|||
*/ |
|||
public void set(TokenDto user, long expire) { |
|||
if (user == null) { |
|||
return; |
|||
} |
|||
String key = RedisKeys.getCpUserKey(user.getApp(), "wxmp", user.getUserId()); |
|||
//bean to map
|
|||
Map<String, Object> map = BeanUtil.beanToMap(user, false, true); |
|||
redisUtils.hMSet(key, map, expire); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.dto.form.SsoLoginFormDTO; |
|||
import com.epmet.dto.result.SsoLoginResultDTO; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/18 下午4:34 |
|||
*/ |
|||
public interface SsoService { |
|||
|
|||
/** |
|||
* @Description 0、入口:得到token |
|||
* @Param formDTO |
|||
* @author zxc |
|||
* @date 2021/1/18 下午4:59 |
|||
*/ |
|||
SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO); |
|||
|
|||
} |
@ -0,0 +1,157 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; |
|||
import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.security.dto.TokenDto; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.utils.DateUtils; |
|||
import com.epmet.commons.tools.utils.HttpClientManager; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.constant.SsoConstant; |
|||
import com.epmet.dto.PaCustomerDTO; |
|||
import com.epmet.dto.UserDTO; |
|||
import com.epmet.dto.form.SsoLoginFormDTO; |
|||
import com.epmet.dto.form.UserInfoFormDTO; |
|||
import com.epmet.dto.result.SsoLoginResultDTO; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.jwt.JwtTokenProperties; |
|||
import com.epmet.jwt.JwtTokenUtils; |
|||
import com.epmet.redis.SsoRedis; |
|||
import com.epmet.service.SsoService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/18 下午4:35 |
|||
*/ |
|||
@Service |
|||
@Slf4j |
|||
public class SsoServiceImpl implements SsoService { |
|||
|
|||
@Autowired |
|||
private SsoRedis ssoRedis; |
|||
|
|||
@Autowired |
|||
private JwtTokenUtils jwtTokenUtils; |
|||
|
|||
@Autowired |
|||
private JwtTokenProperties jwtTokenProperties; |
|||
|
|||
@Autowired |
|||
private JcetApiService jcetApiService; |
|||
|
|||
@Autowired |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
|
|||
/** |
|||
* @Description 0、入口:得到token |
|||
* @Param formDTO |
|||
* @author zxc |
|||
* @date 2021/1/18 下午4:59 |
|||
*/ |
|||
@Override |
|||
public SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO) { |
|||
String userId = ""; |
|||
if (formDTO.getAppId().equals(SsoConstant.WINE_CITY_E_OPEN_APP_ID)) { |
|||
UserInfoResultDTO userInfo = null; |
|||
try { |
|||
userInfo = jcetApiService.getUserInfoByTicket(formDTO.getTicket()); |
|||
} catch (UnsupportedEncodingException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
if (null == userInfo){ |
|||
throw new RenException(SsoConstant.USER_INFO_IS_NULL); |
|||
} |
|||
UserInfoFormDTO userInfoFormDTO = ConvertUtils.sourceToTarget(userInfo, UserInfoFormDTO.class); |
|||
userInfoFormDTO.setApp(formDTO.getApp()); |
|||
Result<UserDTO> userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO); |
|||
if (!userDTOResult.success()){ |
|||
throw new RenException(SsoConstant.INSERT_UPDATE_USER_FAILURE); |
|||
} |
|||
userId = userDTOResult.getData().getId(); |
|||
} |
|||
//生成业务token
|
|||
String token = this.generateToken(formDTO.getApp(),formDTO.getClient(), userId); |
|||
//存放Redis
|
|||
this.disposeTokenDto(formDTO, userId, token, getCustomerId(formDTO.getAppId())); |
|||
return new SsoLoginResultDTO(token); |
|||
} |
|||
|
|||
/** |
|||
* @Description token放缓存 |
|||
* @Param formDTO |
|||
* @Param userId |
|||
* @Param token |
|||
* @Param customerId |
|||
* @author zxc |
|||
* @date 2021/1/18 下午5:32 |
|||
*/ |
|||
public void disposeTokenDto(SsoLoginFormDTO formDTO, String userId, String token, String customerId){ |
|||
int expire = jwtTokenProperties.getExpire(); |
|||
TokenDto tokenDto = new TokenDto(); |
|||
tokenDto.setCustomerId(customerId); |
|||
tokenDto.setApp(formDTO.getApp()); |
|||
tokenDto.setClient(formDTO.getClient()); |
|||
tokenDto.setUserId(userId); |
|||
tokenDto.setToken(token); |
|||
tokenDto.setUpdateTime(System.currentTimeMillis()); |
|||
tokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); |
|||
ssoRedis.set(tokenDto, expire); |
|||
log.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); |
|||
} |
|||
|
|||
/** |
|||
* @Description 居民端登陆生成业务token的key |
|||
* @Param app |
|||
* @Param client |
|||
* @Param userId |
|||
* @author zxc |
|||
* @date 2021/1/18 下午5:14 |
|||
*/ |
|||
private String generateToken(String app,String client, String userId) { |
|||
Map<String, Object> map = new HashMap<>(16); |
|||
map.put("app", app); |
|||
map.put("client", client); |
|||
map.put("userId", userId); |
|||
String token = jwtTokenUtils.createToken(map); |
|||
log.info("app:" + app + ";client:" + client + ";userId:" + userId + ";生成token[" + token + "]"); |
|||
return token; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取customerId |
|||
* @Param appId |
|||
* @author zxc |
|||
* @date 2021/1/19 下午1:47 |
|||
*/ |
|||
public String getCustomerId(String appId){ |
|||
JSONObject jsonObject = new JSONObject(); |
|||
String customerMsgUrl = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/"; |
|||
String data = HttpClientManager.getInstance().sendPostByJSON(customerMsgUrl + appId, JSON.toJSONString(jsonObject)).getData(); |
|||
log.info("调用third服务,根据appId查询客户信息:httpclient->url:" + customerMsgUrl + ",结果->" + data); |
|||
JSONObject toResult = JSON.parseObject(data); |
|||
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); |
|||
if (null != toResult.get("code")) { |
|||
mapToResult.setCode(((Integer) toResult.get("code")).intValue()); |
|||
} |
|||
if (!mapToResult.success()) { |
|||
log.error(String.format("根据appId查询客户信息失败,对应appId->" + appId)); |
|||
throw new RenException(mapToResult.getMsg()); |
|||
} |
|||
Object publicCustomerResultDTO = mapToResult.getData(); |
|||
JSONObject json = JSON.parseObject(publicCustomerResultDTO.toString()); |
|||
Map<String, Object> map = (Map) json.get("customer"); |
|||
PaCustomerDTO customer = ConvertUtils.mapToEntity(map, PaCustomerDTO.class); |
|||
log.info("小程序登陆third服务获取客户用户信息PaCustomerDTO->" + customer); |
|||
return customer.getId(); |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<artifactId>epmet-commons</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>epmet-commons-thirdplat</artifactId> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-tools</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
</project> |
@ -0,0 +1,36 @@ |
|||
package com.epmet.commons.thirdplat; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTicketFormDTO; |
|||
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTokenFormDTO; |
|||
import com.epmet.commons.thirdplat.encrypt.SignUtils; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
public class DemoApp { |
|||
|
|||
private static String appid = "soXDEoM1"; |
|||
private static String appsecret = "V7ea0KnlYt7eSyzc"; |
|||
|
|||
public static void main(String[] args) throws UnsupportedEncodingException { |
|||
|
|||
//SsoToken ssoToken = new SsoToken();
|
|||
//ssoToken.setSsoToken("wxz");
|
|||
|
|||
SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO(); |
|||
ssoTicket.setSsoTicket("wxz"); |
|||
|
|||
int bodyLength = JSON.toJSONString(ssoTicket).getBytes("utf-8").length; |
|||
|
|||
Map<String, Object> headers = new HashMap(); |
|||
long timestamp = System.currentTimeMillis(); |
|||
headers.put("openTimestamp", String.valueOf(timestamp)); |
|||
headers.put("openAppId", appid); |
|||
String encryptContent = appid + timestamp + bodyLength; |
|||
headers.put("openSign", SignUtils.generate(encryptContent, appsecret)); |
|||
System.out.println(headers); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.epmet.commons.thirdplat.apiservice; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.thirdplat.dto.result.jcet.JcetResult; |
|||
import com.epmet.commons.thirdplat.properties.ThirdplatProps; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
|
|||
public class AbstractApiService { |
|||
|
|||
protected ThirdplatProps thirdplatProps; |
|||
|
|||
/** |
|||
* @Description 解析请求结果 |
|||
* @return |
|||
* @author wxz |
|||
* @date 2021.01.19 09:53 |
|||
*/ |
|||
protected <R> R parseResult(Result<String> thResult, Class<R> resultType) { |
|||
if (!thResult.success()) { |
|||
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
|||
EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getMsg().concat(":").concat(thResult.getInternalMsg())); |
|||
} |
|||
|
|||
JcetResult jcetResult = JSON.parseObject(thResult.getData(), JcetResult.class); |
|||
if (!jcetResult.isSuccess()) { |
|||
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
|||
jcetResult.getMsg().concat(",错误码:") + jcetResult.getCode()); |
|||
} |
|||
|
|||
return JSON.parseObject(jcetResult.getMsg(), resultType); |
|||
} |
|||
} |
@ -0,0 +1,95 @@ |
|||
package com.epmet.commons.thirdplat.apiservice.jcet; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.thirdplat.apiservice.AbstractApiService; |
|||
import com.epmet.commons.thirdplat.constants.JcetConstants; |
|||
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTicketFormDTO; |
|||
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTokenFormDTO; |
|||
import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO; |
|||
import com.epmet.commons.thirdplat.encrypt.SignUtils; |
|||
import com.epmet.commons.thirdplat.properties.JcetThirdplatProps; |
|||
import com.epmet.commons.thirdplat.properties.ThirdplatProps; |
|||
import com.epmet.commons.tools.utils.HttpClientManager; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Component |
|||
public class JcetApiService extends AbstractApiService { |
|||
|
|||
private JcetThirdplatProps jcetThirdplatProps; |
|||
|
|||
public JcetApiService(ThirdplatProps props) { |
|||
this.thirdplatProps = props; |
|||
jcetThirdplatProps = props.getJcet(); |
|||
} |
|||
|
|||
/** |
|||
* @return |
|||
* @Description 通过第三方平台ticket获取用户信息 |
|||
* @author wxz |
|||
* @date 2021.01.19 10:26 |
|||
*/ |
|||
public UserInfoResultDTO getUserInfoByTicket(String ticket) throws UnsupportedEncodingException { |
|||
SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO(); |
|||
ssoTicket.setSsoTicket(ticket); |
|||
|
|||
String domain = jcetThirdplatProps.getDomain(); |
|||
Result<String> result = HttpClientManager.getInstance().sendPost( |
|||
domain.concat(JcetConstants.URL_GET_USER_BY_TICKET), |
|||
domain.startsWith("https://"), |
|||
JSON.toJSONString(ssoTicket), |
|||
getHeaders(ssoTicket)); |
|||
|
|||
UserInfoResultDTO resultDTO = parseResult(result, UserInfoResultDTO.class); |
|||
return resultDTO; |
|||
} |
|||
|
|||
/** |
|||
* @return |
|||
* @Description 通过token获取用户信息 |
|||
* @author wxz |
|||
* @date 2021.01.19 10:28 |
|||
*/ |
|||
public UserInfoResultDTO getUserInfoByToken(String token) throws UnsupportedEncodingException { |
|||
SsoTokenFormDTO ssoToken = new SsoTokenFormDTO(); |
|||
ssoToken.setSsoToken(token); |
|||
|
|||
HashMap<String, Object> paramMap = new HashMap<>(); |
|||
paramMap.put(JcetConstants.PLAT_TOKEN_NAME, token); |
|||
|
|||
String domain = jcetThirdplatProps.getDomain(); |
|||
|
|||
Result<String> result = HttpClientManager.getInstance().sendGet( |
|||
domain.concat(JcetConstants.URL_GET_USER_BY_TOKEN), |
|||
domain.startsWith("https://"), |
|||
paramMap, |
|||
getHeaders(ssoToken)); |
|||
|
|||
UserInfoResultDTO resultDTO = parseResult(result, UserInfoResultDTO.class); |
|||
return resultDTO; |
|||
} |
|||
|
|||
/** |
|||
* 获取请求所需要的头信息 |
|||
* |
|||
* @param contentObject |
|||
* @return |
|||
* @throws UnsupportedEncodingException |
|||
*/ |
|||
private Map<String, String> getHeaders(Object contentObject) throws UnsupportedEncodingException { |
|||
int bodyLength = JSON.toJSONString(contentObject).getBytes("utf-8").length; |
|||
|
|||
Map<String, String> headers = new HashMap(); |
|||
long timestamp = System.currentTimeMillis(); |
|||
headers.put("openTimestamp", String.valueOf(timestamp)); |
|||
headers.put("openAppId", jcetThirdplatProps.getAppkey()); |
|||
String encryptContent = jcetThirdplatProps.getAppkey() + timestamp + bodyLength; |
|||
headers.put("openSign", SignUtils.generate(encryptContent, jcetThirdplatProps.getAppsecret())); |
|||
return headers; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.epmet.commons.thirdplat.config; |
|||
|
|||
import com.epmet.commons.thirdplat.properties.ThirdplatProps; |
|||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* 第三方平台的相关配置 |
|||
*/ |
|||
@Configuration |
|||
@EnableConfigurationProperties(ThirdplatProps.class) |
|||
public class ThirdplatConfig { |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.epmet.commons.thirdplat.constants; |
|||
|
|||
public interface JcetConstants { |
|||
|
|||
String URL_GET_USER_BY_TICKET = "/openapi-cgw/openapi-login/sso/getUserInfoByTicket"; |
|||
String URL_GET_USER_BY_TOKEN = "/openapi-cgw/openapi-login/sso/getUserInfoByToken"; |
|||
|
|||
String PLAT_TICKET_NAME = "ssoTicket"; |
|||
String PLAT_TOKEN_NAME = "ssoToken"; |
|||
|
|||
String PLAT_HEADER_OPEN_TIMESTAMP = "openTimestamp"; |
|||
String PLAT_HEADER_OPEN_APP_ID = "openAppId"; |
|||
String PLAT_HEADER_OPEN_SIGN = "openSign"; |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.epmet.commons.thirdplat.dto.form.jcet; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class SsoTicketFormDTO { |
|||
private String ssoTicket; |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.epmet.commons.thirdplat.dto.form.jcet; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class SsoTokenFormDTO { |
|||
private String ssoToken; |
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.commons.thirdplat.dto.result.jcet; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class JcetResult { |
|||
|
|||
private boolean success; |
|||
private String msg; |
|||
private Object data; |
|||
private int code; |
|||
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.commons.thirdplat.dto.result.jcet; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class UserInfoResultDTO { |
|||
|
|||
private String name; |
|||
private String mobile; |
|||
private String uid; |
|||
private String account; |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
package com.epmet.commons.thirdplat.encrypt; |
|||
|
|||
|
|||
import com.epmet.commons.tools.exception.RenException; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.nio.charset.Charset; |
|||
import java.security.MessageDigest; |
|||
import java.security.NoSuchAlgorithmException; |
|||
|
|||
public class EncryptUtils { |
|||
private final static char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; |
|||
/** |
|||
* 32位 MD5加密 |
|||
* |
|||
* @param s |
|||
* @return |
|||
*/ |
|||
public static String md5Hex(String s) throws UnsupportedEncodingException { |
|||
byte[] result = digest("MD5", s.getBytes(Charset.defaultCharset())); |
|||
return hex(result); |
|||
} |
|||
/** |
|||
* 32 位 sha256加密 |
|||
* |
|||
* @param s |
|||
* @return |
|||
*/ |
|||
public static String sha256(String s) { |
|||
byte[] result = digest("SHA-256", s.getBytes(Charset.defaultCharset())); |
|||
return hex(result); |
|||
} |
|||
private static byte[] digest(String algorithm, byte[] data) { |
|||
try { |
|||
MessageDigest digest = MessageDigest.getInstance(algorithm); |
|||
digest.update(data, 0, data.length); |
|||
return digest.digest(); |
|||
} catch (NoSuchAlgorithmException e) { |
|||
throw new RenException(algorithm + " error", e); |
|||
} |
|||
} |
|||
private static String hex(byte[] data) { |
|||
char[] result = new char[data.length * 2]; |
|||
int c = 0; |
|||
for (byte b : data) { |
|||
result[c++] = HEX_DIGITS[(b >> 4) & 0xf]; |
|||
result[c++] = HEX_DIGITS[b & 0xf]; |
|||
} |
|||
return new String(result); |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.epmet.commons.thirdplat.encrypt; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
|
|||
public class SignUtils { |
|||
public static String generate(String content, String secret) throws UnsupportedEncodingException { |
|||
String sign = EncryptUtils.sha256(content); |
|||
sign = EncryptUtils.md5Hex(sign + secret); |
|||
return sign; |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
System.out.println(777); |
|||
} |
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.epmet.commons.thirdplat.properties; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* 酒城e通三方平台配置 |
|||
*/ |
|||
@Data |
|||
public class JcetThirdplatProps { |
|||
private String domain; |
|||
private String appkey; |
|||
private String appsecret; |
|||
} |
@ -0,0 +1,12 @@ |
|||
package com.epmet.commons.thirdplat.properties; |
|||
|
|||
import lombok.Data; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
|
|||
@Data |
|||
@ConfigurationProperties(prefix = "thirdplat") |
|||
public class ThirdplatProps { |
|||
|
|||
private JcetThirdplatProps jcet; |
|||
|
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.epmet.constant; |
|||
|
|||
/** |
|||
* @author zhaoqifeng |
|||
* @dscription |
|||
* @date 2021/1/19 9:43 |
|||
*/ |
|||
public interface ThirdConstant { |
|||
/** |
|||
* 小程序 |
|||
*/ |
|||
String MINI = "mini"; |
|||
/** |
|||
* 第三方app |
|||
*/ |
|||
String APP = "app"; |
|||
} |
@ -0,0 +1,3 @@ |
|||
ALTER TABLE `pa_customer` |
|||
ADD COLUMN `TYPE` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'mini' |
|||
COMMENT '客户类型 mini 微信小程序客户 app 第三方app客户' AFTER `IS_INITIALIZE`; |
@ -0,0 +1,40 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/1/19 上午10:31 |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class UserInfoFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 3394557656494741201L; |
|||
|
|||
public interface UserInfoForm{} |
|||
|
|||
/** |
|||
* 工作端:WORK、居民端:resi、运营端:oper |
|||
*/ |
|||
@NotBlank(message = "app类型不能为空",groups = {UserInfoForm.class}) |
|||
private String app; |
|||
|
|||
/** |
|||
* UID 用户唯一标识 即wx_open_id |
|||
*/ |
|||
@NotBlank(message = "UID不能为空",groups = {UserInfoForm.class}) |
|||
private String uid; |
|||
|
|||
private String name; |
|||
private String mobile; |
|||
private String account; |
|||
|
|||
private String userId; |
|||
} |
Loading…
Reference in new issue