Browse Source
Conflicts: epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/GovIssueOpenFeignClient.java epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/feign/fallback/GovIssueOpenFeignClientFallBack.java epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.javadev_shibei_match
1564 changed files with 76028 additions and 2414 deletions
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.constant; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/1/19 上午10:26 |
||||
|
*/ |
||||
|
public interface SsoConstant { |
||||
|
|
||||
|
/** |
||||
|
* 酒城e通appId |
||||
|
*/ |
||||
|
String WINE_CITY_E_OPEN_APP_ID = "64929543"; |
||||
|
|
||||
|
String USER_INFO_IS_NULL = "【jcetApiService.getUserInfoByTicket(formDTO.getTicket()】结果为空......"; |
||||
|
|
||||
|
String INSERT_UPDATE_USER_FAILURE = "新增或更新user_weChat失败......"; |
||||
|
|
||||
|
String USER_ID_IS_NULL = "userId为空,生成token失败......"; |
||||
|
String CUSTOMER_ID_IS_NULL = "customerId为空,缓存放置token失败......"; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,92 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; |
||||
|
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.dto.form.SsoEnteOrgFormDTO; |
||||
|
import com.epmet.dto.form.SsoLoginFormDTO; |
||||
|
import com.epmet.dto.form.SsoWorkLoginFormDTO; |
||||
|
import com.epmet.dto.form.SsoLoginOperFormDTO; |
||||
|
import com.epmet.dto.result.SsoLoginResultDTO; |
||||
|
import com.epmet.dto.result.UserTokenResultDTO; |
||||
|
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") |
||||
|
public class SsoController { |
||||
|
|
||||
|
@Autowired |
||||
|
private SsoService ssoService; |
||||
|
|
||||
|
@Autowired |
||||
|
private JcetApiService jcetApiService; |
||||
|
|
||||
|
/** |
||||
|
* @Description 0、泸州app登陆入口:得到token |
||||
|
* @Param formDTO |
||||
|
* @author zxc |
||||
|
* @date 2021/1/18 下午4:59 |
||||
|
*/ |
||||
|
@PostMapping("resi/login") |
||||
|
public Result<SsoLoginResultDTO> ssoResiLogin(@RequestBody SsoLoginFormDTO formDTO){ |
||||
|
ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class); |
||||
|
return new Result<SsoLoginResultDTO>().ok(ssoService.ssoResiLogin(formDTO)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Description 0、第三方系统跳转至 运营平台登陆接口 |
||||
|
* @Param formDTO |
||||
|
* @author zxc |
||||
|
* @date 2021/1/18 下午4:59 |
||||
|
*/ |
||||
|
@PostMapping("oper/third/login") |
||||
|
public Result<UserTokenResultDTO> thirdLoginOper(@RequestBody SsoLoginOperFormDTO formDTO) { |
||||
|
ValidatorUtils.validateEntity(formDTO, SsoLoginOperFormDTO.ThirdPlatformLoginForm.class); |
||||
|
return new Result<UserTokenResultDTO>().ok(ssoService.thirdLoginOperWork(formDTO)); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("test") |
||||
|
public Result<ThirdPlatUserInfo> testssoLogin() { |
||||
|
ThirdPlatUserInfo userInfoByTicket = null; |
||||
|
try { |
||||
|
userInfoByTicket = jcetApiService.getCUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui"); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return new Result<ThirdPlatUserInfo>().ok(userInfoByTicket); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @Author sun |
||||
|
* @Description 1、ticket自动登录获取内部token |
||||
|
**/ |
||||
|
@PostMapping("work/login") |
||||
|
public Result<UserTokenResultDTO> ssoWorkLogin(@RequestBody SsoWorkLoginFormDTO formDTO){ |
||||
|
ValidatorUtils.validateEntity(formDTO, SsoWorkLoginFormDTO.SsoLoginForm.class); |
||||
|
return new Result<UserTokenResultDTO>().ok(ssoService.ssoWorkLogin(formDTO)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @Author sun |
||||
|
* @Description 4、自动进入组织-返回token |
||||
|
**/ |
||||
|
@PostMapping(value = "work/enterorg") |
||||
|
public Result<UserTokenResultDTO> enterOrg(@RequestBody SsoEnteOrgFormDTO formDTO) { |
||||
|
ValidatorUtils.validateEntity(formDTO, SsoEnteOrgFormDTO.AddUserShowGroup.class, SsoEnteOrgFormDTO.AddUserInternalGroup.class); |
||||
|
UserTokenResultDTO userTokenResultDTO = ssoService.enterOrg(formDTO); |
||||
|
return new Result<UserTokenResultDTO>().ok(userTokenResultDTO); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description 4、自动进入组织-返回token |
||||
|
* @Author sun |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SsoEnteOrgFormDTO implements Serializable { |
||||
|
public interface AddUserInternalGroup {} |
||||
|
public interface AddUserShowGroup extends CustomerClientShowGroup {} |
||||
|
/** |
||||
|
* sso票据,有效期为300秒 |
||||
|
*/ |
||||
|
@NotBlank(message = "ssotoken不能为空",groups = SsoWorkLoginFormDTO.SsoLoginForm.class) |
||||
|
private String token; |
||||
|
|
||||
|
/** |
||||
|
* 手机号 |
||||
|
*/ |
||||
|
@NotBlank(message = "手机号不能为空",groups = {AddUserShowGroup.class}) |
||||
|
private String mobile; |
||||
|
|
||||
|
/** |
||||
|
* 选择的组织所属的id |
||||
|
*/ |
||||
|
@NotBlank(message = "客户id不能为空",groups = {AddUserInternalGroup.class}) |
||||
|
private String customerId; |
||||
|
|
||||
|
/** |
||||
|
* 选择的要进入的组织(根组织id) |
||||
|
*/ |
||||
|
@NotBlank(message = "组织id不能为空",groups = {AddUserInternalGroup.class}) |
||||
|
private String rootAgencyId; |
||||
|
|
||||
|
/** |
||||
|
* resi;居民段,gov:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "app不能为空",groups = SsoLoginFormDTO.SsoLoginForm.class) |
||||
|
private String app; |
||||
|
|
||||
|
/** |
||||
|
* app;居民段,app:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "client不能为空",groups = SsoLoginFormDTO.SsoLoginForm.class) |
||||
|
private String client; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,42 @@ |
|||||
|
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;居民段,gov:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "app不能为空", groups = SsoLoginForm.class) |
||||
|
private String app; |
||||
|
|
||||
|
/** |
||||
|
* app;居民段,app:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "client不能为空", groups = SsoLoginForm.class) |
||||
|
private String client; |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/1/18 下午4:43 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SsoLoginOperFormDTO extends LoginCommonFormDTO { |
||||
|
|
||||
|
private static final long serialVersionUID = -4215746830030486659L; |
||||
|
|
||||
|
public interface ThirdPlatformLoginForm { |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 上游系统token |
||||
|
*/ |
||||
|
@NotBlank(message = "token不能为空", groups = {ThirdPlatformLoginForm.class}) |
||||
|
private String thirdToken; |
||||
|
|
||||
|
/** |
||||
|
* 上游系统标识 |
||||
|
* |
||||
|
* @see com.epmet.enums.ThirdPlatformEnum |
||||
|
*/ |
||||
|
@NotBlank(message = "平台标识不能为空", groups = {ThirdPlatformLoginForm.class}) |
||||
|
private String platform; |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
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 SsoWorkLoginFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -6543952487970013031L; |
||||
|
|
||||
|
public interface SsoLoginForm{} |
||||
|
|
||||
|
/** |
||||
|
* sso票据,有效期为300秒 |
||||
|
*/ |
||||
|
@NotBlank(message = "ssotoken不能为空",groups = SsoLoginForm.class) |
||||
|
private String token; |
||||
|
|
||||
|
/** |
||||
|
* 三方平台应用AppId |
||||
|
*/ |
||||
|
@NotBlank(message = "三方平台应用AppId不能为空",groups = SsoLoginForm.class) |
||||
|
private String appId; |
||||
|
|
||||
|
/** |
||||
|
* app类型 resi;居民段,gov:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "app不能为空",groups = SsoLoginForm.class) |
||||
|
private String app; |
||||
|
|
||||
|
/** |
||||
|
* app;居民段,app:工作端 |
||||
|
*/ |
||||
|
@NotBlank(message = "client不能为空",groups = SsoLoginForm.class) |
||||
|
private String client; |
||||
|
} |
||||
@ -0,0 +1,57 @@ |
|||||
|
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 ThirdPlatFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -6543952487970013031L; |
||||
|
|
||||
|
public interface SsoLoginForm { |
||||
|
} |
||||
|
|
||||
|
public interface ThirdPlatformLoginForm { |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* sso票据,有效期为300秒 |
||||
|
*/ |
||||
|
@NotBlank(message = "sso票据不能为空", groups = {SsoLoginForm.class, ThirdPlatformLoginForm.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; |
||||
|
|
||||
|
/** |
||||
|
* 上游系统token |
||||
|
*/ |
||||
|
@NotBlank(message = "token不能为空", groups = {ThirdPlatformLoginForm.class}) |
||||
|
private String thirdToken; |
||||
|
|
||||
|
/** |
||||
|
* 上游系统token |
||||
|
* |
||||
|
* @see com.epmet.enums.ThirdPlatformEnum |
||||
|
*/ |
||||
|
@NotBlank(message = "token不能为空", groups = {ThirdPlatformLoginForm.class}) |
||||
|
private String platform; |
||||
|
} |
||||
@ -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,50 @@ |
|||||
|
package com.epmet.enums; |
||||
|
|
||||
|
/** |
||||
|
* 系统环境变量枚举类 |
||||
|
* dev|test|prod |
||||
|
* |
||||
|
* @author jianjun liu |
||||
|
* @date 2020-07-03 11:14 |
||||
|
**/ |
||||
|
public enum ThirdPlatformEnum { |
||||
|
/** |
||||
|
* 平阴联动指挥平台 |
||||
|
*/ |
||||
|
PINGYIN_LIANDONG("pyld", "平阴联动指挥平台", "pyldApiService"), |
||||
|
; |
||||
|
|
||||
|
private String code; |
||||
|
private String name; |
||||
|
private String apiService; |
||||
|
|
||||
|
|
||||
|
ThirdPlatformEnum(String code, String name, String apiService) { |
||||
|
this.code = code; |
||||
|
this.name = name; |
||||
|
this.apiService = apiService; |
||||
|
} |
||||
|
|
||||
|
public static ThirdPlatformEnum getEnum(String code) { |
||||
|
ThirdPlatformEnum[] values = ThirdPlatformEnum.values(); |
||||
|
for (ThirdPlatformEnum value : values) { |
||||
|
if (value.getCode().equals(code)) { |
||||
|
return value; |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public String getCode() { |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public String getApiService() { |
||||
|
return apiService; |
||||
|
} |
||||
|
} |
||||
@ -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(), user.getClient(), user.getUserId()); |
||||
|
//bean to map
|
||||
|
Map<String, Object> map = BeanUtil.beanToMap(user, false, true); |
||||
|
redisUtils.hMSet(key, map, expire); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.dto.form.SsoEnteOrgFormDTO; |
||||
|
import com.epmet.dto.form.SsoLoginFormDTO; |
||||
|
import com.epmet.dto.form.SsoLoginOperFormDTO; |
||||
|
import com.epmet.dto.form.SsoWorkLoginFormDTO; |
||||
|
import com.epmet.dto.result.SsoLoginResultDTO; |
||||
|
import com.epmet.dto.result.UserTokenResultDTO; |
||||
|
|
||||
|
/** |
||||
|
* @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 ssoResiLogin(SsoLoginFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @Author sun |
||||
|
* @Description 1、ticket自动登录获取内部token |
||||
|
**/ |
||||
|
UserTokenResultDTO ssoWorkLogin(SsoWorkLoginFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @Author sun |
||||
|
* @Description 4、自动进入组织-返回token |
||||
|
**/ |
||||
|
UserTokenResultDTO enterOrg(SsoEnteOrgFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* desc: sso登陆运营端 |
||||
|
* |
||||
|
* @param formDTO |
||||
|
* @return com.epmet.dto.result.UserTokenResultDTO |
||||
|
* @author LiuJanJun |
||||
|
* @date 2021/2/24 1:28 下午 |
||||
|
*/ |
||||
|
UserTokenResultDTO thirdLoginOperWork(SsoLoginOperFormDTO formDTO); |
||||
|
} |
||||
@ -0,0 +1,552 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.epmet.common.token.constant.LoginConstant; |
||||
|
import com.epmet.commons.thirdplat.apiservice.AbstractApiService; |
||||
|
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; |
||||
|
import com.epmet.commons.thirdplat.constants.PyldConstants; |
||||
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
||||
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
||||
|
import com.epmet.commons.tools.exception.RenException; |
||||
|
import com.epmet.commons.tools.security.dto.GovTokenDto; |
||||
|
import com.epmet.commons.tools.security.dto.TokenDto; |
||||
|
import com.epmet.commons.tools.utils.*; |
||||
|
import com.epmet.dto.*; |
||||
|
import com.epmet.dto.form.*; |
||||
|
import com.epmet.dto.result.*; |
||||
|
import com.epmet.enums.ThirdPlatformEnum; |
||||
|
import com.epmet.feign.EpmetUserFeignClient; |
||||
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
||||
|
import com.epmet.feign.GovOrgOpenFeignClient; |
||||
|
import com.epmet.feign.OperCrmOpenFeignClient; |
||||
|
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.apache.commons.codec.digest.DigestUtils; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Set; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2021/1/18 下午4:35 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class SsoServiceImpl implements SsoService { |
||||
|
|
||||
|
Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
|
||||
|
@Autowired |
||||
|
private SsoRedis ssoRedis; |
||||
|
|
||||
|
@Autowired |
||||
|
private JwtTokenUtils jwtTokenUtils; |
||||
|
|
||||
|
@Autowired |
||||
|
private JwtTokenProperties jwtTokenProperties; |
||||
|
|
||||
|
@Autowired |
||||
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private CpUserDetailRedis cpUserDetailRedis; |
||||
|
|
||||
|
@Autowired |
||||
|
private EpmetUserFeignClient epmetUserFeignClient; |
||||
|
|
||||
|
@Value("${epmet.third.urlPrefix}") |
||||
|
private String epmetThirdUrlPrefix; |
||||
|
|
||||
|
/** |
||||
|
* @Description 0、入口:得到token |
||||
|
* @Param formDTO |
||||
|
* @author zxc |
||||
|
* @date 2021/1/18 下午4:59 |
||||
|
*/ |
||||
|
@Override |
||||
|
public SsoLoginResultDTO ssoResiLogin(SsoLoginFormDTO formDTO) { |
||||
|
String customerId = getCustomerId(formDTO.getAppId()); |
||||
|
//String customerId = "3a4f923665a7a07701bcb311aac9a156";
|
||||
|
String userId = ""; |
||||
|
|
||||
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); |
||||
|
if (!apiServiceResult.success()) { |
||||
|
throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); |
||||
|
} |
||||
|
|
||||
|
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) { |
||||
|
throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); |
||||
|
} |
||||
|
|
||||
|
ThirdPlatUserInfo userInfo; |
||||
|
try { |
||||
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
||||
|
userInfo = apiService.getCUserInfoByTicket(formDTO.getTicket()); |
||||
|
} catch (Exception e) { |
||||
|
throw new RenException(e.getMessage()); |
||||
|
} |
||||
|
|
||||
|
if (null == userInfo){ |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
||||
|
"【SSO登录】调用第三方平台查询用户信息失败,用户信息为空"); |
||||
|
} |
||||
|
UserInfoFormDTO userInfoFormDTO = new UserInfoFormDTO(); |
||||
|
userInfoFormDTO.setApp(formDTO.getApp()); |
||||
|
userInfoFormDTO.setUid(userInfo.getOpenId()); |
||||
|
userInfoFormDTO.setName(userInfo.getName()); |
||||
|
userInfoFormDTO.setMobile(userInfo.getMobile()); |
||||
|
|
||||
|
Result<UserDTO> userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO); |
||||
|
if (!userDTOResult.success()){ |
||||
|
throw new RenException("【SSO登录】新增或更新user_weChat失败"); |
||||
|
} |
||||
|
userId = userDTOResult.getData().getId(); |
||||
|
|
||||
|
if (StringUtils.isBlank(userId)){ |
||||
|
throw new RenException("【SSO登录】userId为空,生成token失败"); |
||||
|
} |
||||
|
//生成业务token
|
||||
|
String token = this.generateToken(formDTO.getApp(), formDTO.getClient(), userId); |
||||
|
//存放Redis
|
||||
|
|
||||
|
if (StringUtils.isBlank(customerId)) { |
||||
|
throw new RenException("【SSO登录】customerId为空,缓存放置token失败"); |
||||
|
} |
||||
|
this.disposeTokenDto(formDTO.getApp(), formDTO.getClient(), userId, token, customerId); |
||||
|
return new SsoLoginResultDTO(token); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public UserTokenResultDTO thirdLoginOperWork(SsoLoginOperFormDTO formDTO) { |
||||
|
ThirdPlatUserInfo thirdUser; |
||||
|
try { |
||||
|
ThirdPlatformEnum platformEnum = ThirdPlatformEnum.getEnum(formDTO.getPlatform()); |
||||
|
String apiService = platformEnum.getApiService(); |
||||
|
AbstractApiService apiServiceImpl = (AbstractApiService) SpringContextUtils.getBean(apiService); |
||||
|
thirdUser = apiServiceImpl.getGUserInfoBySSOToken(formDTO.getThirdToken()); |
||||
|
} catch (RenException e) { |
||||
|
throw new RenException(e.getCode(), e.getMessage()); |
||||
|
} catch (Exception e) { |
||||
|
throw new RenException(e.getMessage()); |
||||
|
} |
||||
|
if (thirdUser == null) { |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), PyldConstants.REPONSE_USER_NOT_LOGIN); |
||||
|
} |
||||
|
//获取用户信息
|
||||
|
GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO(); |
||||
|
form.setCustomerId(thirdUser.getCustomerId()); |
||||
|
form.setMobile(thirdUser.getMobile()); |
||||
|
Result<GovWebOperLoginResultDTO> result = epmetUserFeignClient.getStaffIdAndPwd(form); |
||||
|
//todo userId 写死测试 3f7f852ce22c511aa67ecb695395295d start
|
||||
|
/* GovWebOperLoginResultDTO demo = new GovWebOperLoginResultDTO(); |
||||
|
demo.setUserId("3f7f852ce22c511aa67ecb695395295d"); |
||||
|
result = new Result<>(); |
||||
|
result.ok(demo);*/ |
||||
|
//test end
|
||||
|
|
||||
|
if (!result.success() || null == result.getData() || null == result.getData().getUserId()) { |
||||
|
logger.error("根据手机号查询PC工作端登陆人员信息失败,返回10003账号不存在"); |
||||
|
throw new RenException(EpmetErrorCode.ERR10003.getCode()); |
||||
|
} |
||||
|
|
||||
|
//4、生成token返回,且将TokenDto存到redis
|
||||
|
//生成业务token
|
||||
|
GovWebOperLoginResultDTO epmetUser = result.getData(); |
||||
|
|
||||
|
|
||||
|
String token = this.generateToken(formDTO.getApp(), formDTO.getClient(), epmetUser.getUserId()); |
||||
|
//存放Redis
|
||||
|
|
||||
|
this.disposeTokenDto(formDTO.getApp(), formDTO.getClient(), epmetUser.getUserId(), token, thirdUser.getCustomerId()); |
||||
|
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); |
||||
|
userTokenResultDTO.setToken(token); |
||||
|
userTokenResultDTO.setCustomerId(thirdUser.getCustomerId()); |
||||
|
return userTokenResultDTO; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Description token放缓存 |
||||
|
* @Param formDTO |
||||
|
* @Param userId |
||||
|
* @Param token |
||||
|
* @Param customerId |
||||
|
* @author zxc |
||||
|
* @date 2021/1/18 下午5:32 |
||||
|
*/ |
||||
|
public void disposeTokenDto(String app, String client, String userId, String token, String customerId) { |
||||
|
int expire = jwtTokenProperties.getExpire(); |
||||
|
TokenDto tokenDto = new TokenDto(); |
||||
|
tokenDto.setCustomerId(customerId); |
||||
|
tokenDto.setApp(app); |
||||
|
tokenDto.setClient(client); |
||||
|
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 = epmetThirdUrlPrefix + "/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(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @Author sun |
||||
|
* @Description 1、ticket自动登录获取内部token |
||||
|
**/ |
||||
|
@Override |
||||
|
public UserTokenResultDTO ssoWorkLogin(SsoWorkLoginFormDTO formDTO) { |
||||
|
|
||||
|
//1.根据appId查询客户id
|
||||
|
String customerId = getCustomerId(formDTO.getAppId()); |
||||
|
//String customerId = "3a4f923665a7a07701bcb311aac9a156";
|
||||
|
|
||||
|
//2.客户Id换取第三方apiService,根据ticket换取华为Id
|
||||
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); |
||||
|
if (!apiServiceResult.success()) { |
||||
|
throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); |
||||
|
} |
||||
|
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) { |
||||
|
throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); |
||||
|
} |
||||
|
ThirdPlatUserInfo userInfo; |
||||
|
try { |
||||
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
||||
|
userInfo = apiService.getGUserInfoBySSOToken(formDTO.getToken()); |
||||
|
} catch (Exception e) { |
||||
|
throw new RenException(e.getMessage()); |
||||
|
} |
||||
|
if (null == userInfo){ |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
||||
|
"【SSO登录】调用第三方平台查询用户信息失败,用户信息为空"); |
||||
|
} |
||||
|
|
||||
|
//3.根据华为openId查询用户是否存在历史登陆信息
|
||||
|
Result<StaffLatestAgencyResultDTO> latestStaffWechat = epmetUserOpenFeignClient.getLatestStaffWechatLoginRecord(userInfo.getOpenId()); |
||||
|
if (!latestStaffWechat.success() || null == latestStaffWechat.getData()) { |
||||
|
logger.error(String.format("没有获取到用户最近一次登录账户信息,code[%s],msg[%s]", EpmetErrorCode.PLEASE_LOGIN.getCode(), EpmetErrorCode.PLEASE_LOGIN.getMsg())); |
||||
|
throw new RenException(EpmetErrorCode.PLEASE_LOGIN.getCode()); |
||||
|
} |
||||
|
StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = latestStaffWechat.getData(); |
||||
|
|
||||
|
//4.记录staff_wechat
|
||||
|
this.savestaffwechat(staffLatestAgencyResultDTO.getStaffId(), userInfo.getOpenId()); |
||||
|
|
||||
|
//5.记录登录日志
|
||||
|
this.saveStaffLoginRecord(staffLatestAgencyResultDTO); |
||||
|
|
||||
|
//6.获取用户token
|
||||
|
String token = this.generateGovWxmpToken(staffLatestAgencyResultDTO.getStaffId(), formDTO.getApp(), formDTO.getClient()); |
||||
|
|
||||
|
//7.保存到redis
|
||||
|
this.saveLatestGovTokenDto(staffLatestAgencyResultDTO, userInfo, token); |
||||
|
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); |
||||
|
userTokenResultDTO.setToken(token); |
||||
|
|
||||
|
return userTokenResultDTO; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param userId openid |
||||
|
* @Author sun |
||||
|
* @Description 保存微信和当前登录用户关系 |
||||
|
**/ |
||||
|
private Result savestaffwechat(String userId, String openid) { |
||||
|
StaffWechatFormDTO staffWechatFormDTO = new StaffWechatFormDTO(); |
||||
|
staffWechatFormDTO.setUserId(userId); |
||||
|
staffWechatFormDTO.setWxOpenId(openid); |
||||
|
return epmetUserOpenFeignClient.saveStaffWechat(staffWechatFormDTO); |
||||
|
} |
||||
|
/** |
||||
|
* @param latestStaffWechatLoginDTO |
||||
|
* @Author sun |
||||
|
* @Description 保存登录日志 |
||||
|
**/ |
||||
|
private Result saveStaffLoginRecord(StaffLatestAgencyResultDTO latestStaffWechatLoginDTO) { |
||||
|
StaffLoginAgencyRecordFormDTO staffLoginAgencyRecordFormDTO = new StaffLoginAgencyRecordFormDTO(); |
||||
|
staffLoginAgencyRecordFormDTO.setCustomerId(latestStaffWechatLoginDTO.getCustomerId()); |
||||
|
staffLoginAgencyRecordFormDTO.setStaffId(latestStaffWechatLoginDTO.getStaffId()); |
||||
|
staffLoginAgencyRecordFormDTO.setWxOpenId(latestStaffWechatLoginDTO.getWxOpenId()); |
||||
|
staffLoginAgencyRecordFormDTO.setMobile(latestStaffWechatLoginDTO.getMobile()); |
||||
|
staffLoginAgencyRecordFormDTO.setAgencyId(latestStaffWechatLoginDTO.getAgencyId()); |
||||
|
Result staffLoginRecordResult = epmetUserOpenFeignClient.saveStaffLoginRecord(staffLoginAgencyRecordFormDTO); |
||||
|
return staffLoginRecordResult; |
||||
|
} |
||||
|
/** |
||||
|
* @Description 生成政府端小程序业务token Key |
||||
|
* @Author sun |
||||
|
**/ |
||||
|
private String generateGovWxmpToken(String staffId, String app, String client) { |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("app", app); |
||||
|
map.put("client", client); |
||||
|
map.put("userId", staffId); |
||||
|
String token = jwtTokenUtils.createToken(map); |
||||
|
logger.info("app:" + app + ";client:" + client + ";userId:" + staffId + ";生成token[" + token + "]"); |
||||
|
return token; |
||||
|
} |
||||
|
/** |
||||
|
* @Description 保存tokenDto到redis |
||||
|
* @Author sun |
||||
|
**/ |
||||
|
private void saveLatestGovTokenDto(StaffLatestAgencyResultDTO staffLatestAgency, ThirdPlatUserInfo userInfo, String token) { |
||||
|
int expire = jwtTokenProperties.getExpire(); |
||||
|
GovTokenDto govTokenDto = new GovTokenDto(); |
||||
|
govTokenDto.setApp(LoginConstant.APP_GOV); |
||||
|
govTokenDto.setClient(LoginConstant.CLIENT_APP); |
||||
|
govTokenDto.setUserId(staffLatestAgency.getStaffId()); |
||||
|
govTokenDto.setOpenId(userInfo.getOpenId()); |
||||
|
govTokenDto.setSessionKey(""); |
||||
|
govTokenDto.setUnionId(""); |
||||
|
govTokenDto.setToken(token); |
||||
|
govTokenDto.setUpdateTime(System.currentTimeMillis()); |
||||
|
govTokenDto.setExpireTime(jwtTokenUtils.getExpiration(token).getTime()); |
||||
|
govTokenDto.setRootAgencyId(staffLatestAgency.getAgencyId()); |
||||
|
govTokenDto.setCustomerId(staffLatestAgency.getCustomerId()); |
||||
|
|
||||
|
//设置部门,网格,角色列表
|
||||
|
govTokenDto.setDeptIdList(getDeptartmentIdList(staffLatestAgency.getStaffId())); |
||||
|
govTokenDto.setGridIdList(getGridIdList(staffLatestAgency.getStaffId())); |
||||
|
CustomerAgencyDTO agency = getAgencyByStaffId(staffLatestAgency.getStaffId()); |
||||
|
if (agency != null) { |
||||
|
govTokenDto.setAgencyId(agency.getId()); |
||||
|
govTokenDto.setRoleList(queryGovStaffRoles(staffLatestAgency.getStaffId(), agency.getId())); |
||||
|
} |
||||
|
govTokenDto.setOrgIdPath(getOrgIdPath(staffLatestAgency.getStaffId())); |
||||
|
|
||||
|
cpUserDetailRedis.set(govTokenDto, expire); |
||||
|
logger.info("截止时间:" + DateUtils.format(jwtTokenUtils.getExpiration(token), "yyyy-MM-dd HH:mm:ss")); |
||||
|
} |
||||
|
public Set<String> getDeptartmentIdList(String staffId) { |
||||
|
try { |
||||
|
Result<List<DepartmentListResultDTO>> deptListResult = govOrgOpenFeignClient.getDepartmentListByStaffId(staffId); |
||||
|
if (deptListResult.success()) { |
||||
|
if (!CollectionUtils.isEmpty(deptListResult.getData())) { |
||||
|
Set<String> deptIdLists = deptListResult.getData().stream().map(dept -> dept.getDepartmentId()).collect(Collectors.toSet()); |
||||
|
return deptIdLists; |
||||
|
} |
||||
|
} else { |
||||
|
logger.error("登录:查询部门列表,远程调用返回错误:{}", deptListResult.getMsg()); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); |
||||
|
logger.error("登录:查询部门列表异常:{}", errorStackTrace); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
/** |
||||
|
* 根据工作人员ID查询网格ID列表 |
||||
|
* @param staffId |
||||
|
*/ |
||||
|
public Set<String> getGridIdList(String staffId) { |
||||
|
Result<List<GridByStaffResultDTO>> result = govOrgOpenFeignClient.listGridsbystaffid(staffId); |
||||
|
if (!result.success()) { |
||||
|
logger.error("登录:查询网格列表,远程调用返回错误:{}", result.getMsg()); |
||||
|
return null; |
||||
|
} else { |
||||
|
List<GridByStaffResultDTO> grids = result.getData(); |
||||
|
return grids.stream().map(grid -> grid.getGridId()).collect(Collectors.toSet()); |
||||
|
} |
||||
|
} |
||||
|
/** |
||||
|
* 根据staffId查询所属的组织机构 |
||||
|
* |
||||
|
* @param staffId |
||||
|
*/ |
||||
|
public CustomerAgencyDTO getAgencyByStaffId(String staffId) { |
||||
|
Result<CustomerAgencyDTO> result = govOrgOpenFeignClient.getAgencyByStaff(staffId); |
||||
|
if (!result.success()) { |
||||
|
logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); |
||||
|
return null; |
||||
|
} |
||||
|
return result.getData(); |
||||
|
} |
||||
|
/** |
||||
|
* 查询人员在某机关单位下的角色列表 |
||||
|
* @param staffId orgId |
||||
|
*/ |
||||
|
public List<GovTokenDto.Role> queryGovStaffRoles(String staffId, String orgId) { |
||||
|
StaffRoleFormDTO formDTO = new StaffRoleFormDTO(); |
||||
|
formDTO.setStaffId(staffId); |
||||
|
formDTO.setOrgId(orgId); |
||||
|
Result<List<GovStaffRoleDTO>> gridResult = epmetUserOpenFeignClient.getRolesOfStaff(formDTO); |
||||
|
if (!CollectionUtils.isEmpty(gridResult.getData())) { |
||||
|
//return gridResult.getData().stream().map(role -> role.getId()).collect(Collectors.toSet());
|
||||
|
return ConvertUtils.sourceToTarget(gridResult.getData(), GovTokenDto.Role.class); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
/** |
||||
|
* 查询工作人员的OrgIdPath |
||||
|
* @param staffId |
||||
|
*/ |
||||
|
public String getOrgIdPath(String staffId) { |
||||
|
Result<CustomerAgencyDTO> result = govOrgOpenFeignClient.getAgencyByStaff(staffId); |
||||
|
if (!result.success()) { |
||||
|
logger.error("登录:查询登录人所属的机关OrgIdPath失败:{}", result.getMsg()); |
||||
|
return null; |
||||
|
} |
||||
|
CustomerAgencyDTO agency = result.getData(); |
||||
|
if (agency != null) { |
||||
|
if ("0".equals(agency.getPid())) { |
||||
|
// 顶级
|
||||
|
return agency.getId(); |
||||
|
} else { |
||||
|
return agency.getPids().concat(":").concat(agency.getId()); |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param formDTO |
||||
|
* @Author sun |
||||
|
* @Description 4、自动进入组织-返回token |
||||
|
**/ |
||||
|
@Override |
||||
|
public UserTokenResultDTO enterOrg(SsoEnteOrgFormDTO formDTO) { |
||||
|
//1、需要校验要登录的客户,是否被禁用
|
||||
|
CustomerStaffFormDTO customerStaffFormDTO = new CustomerStaffFormDTO(); |
||||
|
customerStaffFormDTO.setCustomerId(formDTO.getCustomerId()); |
||||
|
customerStaffFormDTO.setMobile(formDTO.getMobile()); |
||||
|
Result<CustomerStaffDTO> customerStaffDTOResult = epmetUserOpenFeignClient.getCustomerStaffInfo(customerStaffFormDTO); |
||||
|
if (!customerStaffDTOResult.success() || null == customerStaffDTOResult.getData()) { |
||||
|
logger.error(String.format("获取工作人员信息失败,手机号[%s],客户id:[%s],code[%s],msg[%s]", formDTO.getMobile(), formDTO.getCustomerId(), customerStaffDTOResult.getCode(), customerStaffDTOResult.getMsg())); |
||||
|
throw new RenException(customerStaffDTOResult.getCode()); |
||||
|
} |
||||
|
CustomerStaffDTO customerStaff = customerStaffDTOResult.getData(); |
||||
|
|
||||
|
//2.客户Id换取第三方apiService,根据ticket换取华为Id
|
||||
|
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(formDTO.getCustomerId())); |
||||
|
if (!apiServiceResult.success()) { |
||||
|
throw new RenException("【SSO enterOrg】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); |
||||
|
} |
||||
|
if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) { |
||||
|
throw new RenException("【SSO enterOrg】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); |
||||
|
} |
||||
|
ThirdPlatUserInfo userInfo; |
||||
|
try { |
||||
|
AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); |
||||
|
userInfo = apiService.getGUserInfoBySSOToken(formDTO.getToken()); |
||||
|
} catch (Exception e) { |
||||
|
throw new RenException(e.getMessage()); |
||||
|
} |
||||
|
if (null == userInfo){ |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
||||
|
"【SSO enterOrg】调用第三方平台查询用户信息失败,用户信息为空"); |
||||
|
} |
||||
|
|
||||
|
//3、记录staff_wechat,并记录用户激活状态,激活时间
|
||||
|
this.savestaffwechat(customerStaff.getUserId(), userInfo.getOpenId()); |
||||
|
|
||||
|
//4、记录登录日志
|
||||
|
StaffLatestAgencyResultDTO staffLatestAgencyResultDTO = new StaffLatestAgencyResultDTO(); |
||||
|
staffLatestAgencyResultDTO.setCustomerId(formDTO.getCustomerId()); |
||||
|
staffLatestAgencyResultDTO.setStaffId(customerStaff.getUserId()); |
||||
|
staffLatestAgencyResultDTO.setWxOpenId(userInfo.getOpenId()); |
||||
|
staffLatestAgencyResultDTO.setMobile(formDTO.getMobile()); |
||||
|
staffLatestAgencyResultDTO.setAgencyId(formDTO.getRootAgencyId()); |
||||
|
this.saveStaffLoginRecord(staffLatestAgencyResultDTO); |
||||
|
|
||||
|
//5.1、获取用户token
|
||||
|
String token = this.generateGovWxmpToken(customerStaff.getUserId(), formDTO.getApp(), formDTO.getClient()); |
||||
|
//5.2、保存到redis
|
||||
|
StaffLatestAgencyResultDTO staffLatestAgency = new StaffLatestAgencyResultDTO(); |
||||
|
staffLatestAgency.setAgencyId(formDTO.getRootAgencyId()); |
||||
|
staffLatestAgency.setCustomerId(formDTO.getCustomerId()); |
||||
|
staffLatestAgency.setStaffId(customerStaff.getUserId()); |
||||
|
this.saveLatestGovTokenDto(staffLatestAgency, userInfo, token); |
||||
|
|
||||
|
UserTokenResultDTO userTokenResultDTO = new UserTokenResultDTO(); |
||||
|
userTokenResultDTO.setToken(token); |
||||
|
return userTokenResultDTO; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
String url = "https://epmet-ext9.elinkservice.cn/platform/unifiedAuth/loginCheck"; |
||||
|
String platformToken = "1348803062424166401_dd08e23b0d524879a5c67e7f2ffd1468"; |
||||
|
String appId = "7a5aec009ba4eba8e254ee64fe3775e1"; |
||||
|
String appKey = "14faef9af508d1c253b720ea5a43f9de"; |
||||
|
String appSecret = "38e7c2604c8dd33c445705d25eebbfc12a2f7ed8a87111e9e10a40312d3a1595"; |
||||
|
long ts = System.currentTimeMillis(); |
||||
|
String message = appId + appKey + appSecret + ts; |
||||
|
String accessToken = DigestUtils.md5Hex(message.getBytes(StandardCharsets.UTF_8)); |
||||
|
//ThirdPlatformEnum platformEnum = ThirdPlatformEnum.getEnum("pyld");
|
||||
|
JSONObject jsonObject = new JSONObject(); |
||||
|
jsonObject.put("platformToken", platformToken); |
||||
|
|
||||
|
Map<String, Object> headerMap = new HashMap<>(4); |
||||
|
headerMap.put("AppKey", appKey); |
||||
|
headerMap.put("Timestamp", ts); |
||||
|
headerMap.put("AccessToken", accessToken); |
||||
|
Result<String> stringResult = HttpClientManager.getInstance().sendPost(url, url.startsWith("https://"), jsonObject.toJSONString(), headerMap); |
||||
|
System.out.println(stringResult); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
<?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-rocketmq</artifactId> |
||||
|
|
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>org.apache.rocketmq</groupId> |
||||
|
<artifactId>rocketmq-spring-boot-starter</artifactId> |
||||
|
<version>2.0.1</version> |
||||
|
</dependency> |
||||
|
</dependencies> |
||||
|
</project> |
||||
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.commons.rocketmq.constants; |
||||
|
|
||||
|
/** |
||||
|
* 消费者组常量 |
||||
|
*/ |
||||
|
public interface ConsomerGroupConstants { |
||||
|
|
||||
|
/** |
||||
|
* 初始化客户角色消费者组 |
||||
|
*/ |
||||
|
String INIT_CUSTOMER_ROLES_GROUP = "init_customer_roles_group"; |
||||
|
/** |
||||
|
* 初始化客户自定义消费者组 |
||||
|
*/ |
||||
|
String INIT_CUSTOMER_COMPONENTS_GROUP = "init_customer_components_group"; |
||||
|
/** |
||||
|
* 初始化客户组织机构信息分组 |
||||
|
*/ |
||||
|
String INIT_CUSTOMER_ORG_ROLES_GROUP = "init_customer_org_roles_group"; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,5 @@ |
|||||
|
package com.epmet.commons.rocketmq.constants; |
||||
|
|
||||
|
public interface TopicConstants { |
||||
|
String INIT_CUSTOMER = "init_customer"; |
||||
|
} |
||||
@ -0,0 +1,148 @@ |
|||||
|
package com.epmet.commons.rocketmq.messages; |
||||
|
|
||||
|
public class InitCustomerMQMsg { |
||||
|
|
||||
|
private String customerId; |
||||
|
|
||||
|
private InitCustomerAgency agency; |
||||
|
|
||||
|
private InitCustomerStaff staff; |
||||
|
|
||||
|
public static class InitCustomerStaff { |
||||
|
private String agencyId; |
||||
|
private Integer gender; |
||||
|
private String mobile; |
||||
|
private String name; |
||||
|
private String workType; |
||||
|
|
||||
|
public String getAgencyId() { |
||||
|
return agencyId; |
||||
|
} |
||||
|
|
||||
|
public void setAgencyId(String agencyId) { |
||||
|
this.agencyId = agencyId; |
||||
|
} |
||||
|
|
||||
|
public Integer getGender() { |
||||
|
return gender; |
||||
|
} |
||||
|
|
||||
|
public void setGender(Integer gender) { |
||||
|
this.gender = gender; |
||||
|
} |
||||
|
|
||||
|
public String getMobile() { |
||||
|
return mobile; |
||||
|
} |
||||
|
|
||||
|
public void setMobile(String mobile) { |
||||
|
this.mobile = mobile; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public String getWorkType() { |
||||
|
return workType; |
||||
|
} |
||||
|
|
||||
|
public void setWorkType(String workType) { |
||||
|
this.workType = workType; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static class InitCustomerAgency { |
||||
|
private String agencyId; |
||||
|
private String organizationName; |
||||
|
private String level; |
||||
|
private String areaCode; |
||||
|
private String province; |
||||
|
private String city; |
||||
|
private String district; |
||||
|
|
||||
|
public String getAgencyId() { |
||||
|
return agencyId; |
||||
|
} |
||||
|
|
||||
|
public void setAgencyId(String agencyId) { |
||||
|
this.agencyId = agencyId; |
||||
|
} |
||||
|
|
||||
|
public String getOrganizationName() { |
||||
|
return organizationName; |
||||
|
} |
||||
|
|
||||
|
public void setOrganizationName(String organizationName) { |
||||
|
this.organizationName = organizationName; |
||||
|
} |
||||
|
|
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
|
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
public String getAreaCode() { |
||||
|
return areaCode; |
||||
|
} |
||||
|
|
||||
|
public void setAreaCode(String areaCode) { |
||||
|
this.areaCode = areaCode; |
||||
|
} |
||||
|
|
||||
|
public String getProvince() { |
||||
|
return province; |
||||
|
} |
||||
|
|
||||
|
public void setProvince(String province) { |
||||
|
this.province = province; |
||||
|
} |
||||
|
|
||||
|
public String getCity() { |
||||
|
return city; |
||||
|
} |
||||
|
|
||||
|
public void setCity(String city) { |
||||
|
this.city = city; |
||||
|
} |
||||
|
|
||||
|
public String getDistrict() { |
||||
|
return district; |
||||
|
} |
||||
|
|
||||
|
public void setDistrict(String district) { |
||||
|
this.district = district; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public String getCustomerId() { |
||||
|
return customerId; |
||||
|
} |
||||
|
|
||||
|
public void setCustomerId(String customerId) { |
||||
|
this.customerId = customerId; |
||||
|
} |
||||
|
|
||||
|
public InitCustomerAgency getAgency() { |
||||
|
return agency; |
||||
|
} |
||||
|
|
||||
|
public void setAgency(InitCustomerAgency agency) { |
||||
|
this.agency = agency; |
||||
|
} |
||||
|
|
||||
|
public InitCustomerStaff getStaff() { |
||||
|
return staff; |
||||
|
} |
||||
|
|
||||
|
public void setStaff(InitCustomerStaff staff) { |
||||
|
this.staff = staff; |
||||
|
} |
||||
|
} |
||||
@ -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("ssoTicket-jGOAW66udmRtUWBKgs3q7k1w7prGxd5I"); |
||||
|
|
||||
|
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,52 @@ |
|||||
|
package com.epmet.commons.thirdplat.apiservice; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; |
||||
|
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 abstract class AbstractApiService { |
||||
|
|
||||
|
protected ThirdplatProps thirdplatProps; |
||||
|
|
||||
|
/** |
||||
|
* 通过ticket查询用户信息 |
||||
|
* @param ticket |
||||
|
* @return |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public abstract ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws Exception; |
||||
|
|
||||
|
/** |
||||
|
* G端用户token获取用户信息 |
||||
|
* @param token |
||||
|
* @return |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public abstract ThirdPlatUserInfo getGUserInfoBySSOToken(String token) throws Exception; |
||||
|
|
||||
|
/** |
||||
|
* @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()); |
||||
|
} |
||||
|
|
||||
|
JSONObject jo = (JSONObject) jcetResult.getData(); |
||||
|
return jo.toJavaObject(resultType); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,147 @@ |
|||||
|
package com.epmet.commons.thirdplat.apiservice.jcet; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.epmet.commons.thirdplat.apiservice.AbstractApiService; |
||||
|
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; |
||||
|
import com.epmet.commons.thirdplat.constants.JcetConstants; |
||||
|
import com.epmet.commons.thirdplat.dto.form.jcet.SsoTicketFormDTO; |
||||
|
import com.epmet.commons.thirdplat.dto.result.jcet.JcetCUserInfoResultDTO; |
||||
|
import com.epmet.commons.thirdplat.dto.result.jcet.JcetGUserInfoResultDTO; |
||||
|
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.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.io.UnsupportedEncodingException; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public class JcetApiService extends AbstractApiService { |
||||
|
|
||||
|
Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
|
||||
|
private JcetThirdplatProps jcetThirdplatCendProps; |
||||
|
private JcetThirdplatProps jcetThirdplatGendProps; |
||||
|
|
||||
|
public JcetApiService(ThirdplatProps props) { |
||||
|
this.thirdplatProps = props; |
||||
|
jcetThirdplatCendProps = props.getJcetCend(); |
||||
|
jcetThirdplatGendProps = props.getJcetGend(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return |
||||
|
* @Description 通过第三方平台ticket获取用户信息 |
||||
|
* @author wxz |
||||
|
* @date 2021.01.19 10:26 |
||||
|
*/ |
||||
|
public ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws UnsupportedEncodingException { |
||||
|
|
||||
|
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口开始>>>>>>>>>>>>"); |
||||
|
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口入参 ticket:{}", ticket); |
||||
|
|
||||
|
SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO(); |
||||
|
ssoTicket.setSsoTicket(ticket); |
||||
|
|
||||
|
String domain = jcetThirdplatCendProps.getDomain(); |
||||
|
Result<String> result = HttpClientManager.getInstance().sendPost( |
||||
|
domain.concat(JcetConstants.URL_GET_USER_BY_TICKET), |
||||
|
domain.startsWith("https://"), |
||||
|
JSON.toJSONString(ssoTicket), |
||||
|
getHeaders(JSON.toJSONString(ssoTicket).getBytes("utf-8").length, jcetThirdplatCendProps.getAppkey(), jcetThirdplatCendProps.getAppsecret())); |
||||
|
|
||||
|
try { |
||||
|
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口返回:{}", result.getData()); |
||||
|
} catch (Exception e) { |
||||
|
//e.printStackTrace();
|
||||
|
} |
||||
|
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口结束<<<<<<<<<<<<"); |
||||
|
|
||||
|
JcetCUserInfoResultDTO resultDTO = parseResult(result, JcetCUserInfoResultDTO.class); |
||||
|
|
||||
|
ThirdPlatUserInfo userInfo = new ThirdPlatUserInfo(); |
||||
|
userInfo.setOpenId(resultDTO.getId()); |
||||
|
userInfo.setName(resultDTO.getName()); |
||||
|
userInfo.setMobile(resultDTO.getMobile()); |
||||
|
return userInfo; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ThirdPlatUserInfo getGUserInfoBySSOToken(String token) throws Exception { |
||||
|
|
||||
|
logger.info("【请求酒城e通第三方平台】getGUserInfoBySSOToken()接口开始>>>>>>>>>>>>"); |
||||
|
logger.info("【请求酒城e通第三方平台】getGUserInfoBySSOToken()接口入参 ticket:{}", token); |
||||
|
|
||||
|
HashMap<String, Object> params = new HashMap<>(); |
||||
|
params.put("ssoToken",token); |
||||
|
|
||||
|
String domain = jcetThirdplatGendProps.getDomain(); |
||||
|
Result<String> result = HttpClientManager.getInstance().sendGet( |
||||
|
domain.concat(JcetConstants.URL_GET_USER_BY_TOKEN), |
||||
|
domain.startsWith("https://"), |
||||
|
params, |
||||
|
getHeaders(0, jcetThirdplatGendProps.getAppkey(), jcetThirdplatGendProps.getAppsecret())); |
||||
|
|
||||
|
try { |
||||
|
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口返回:{}", result.getData()); |
||||
|
} catch (Exception e) { |
||||
|
//e.printStackTrace();
|
||||
|
} |
||||
|
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口结束<<<<<<<<<<<<"); |
||||
|
|
||||
|
JcetGUserInfoResultDTO resultDTO = parseResult(result, JcetGUserInfoResultDTO.class); |
||||
|
|
||||
|
ThirdPlatUserInfo userInfo = new ThirdPlatUserInfo(); |
||||
|
userInfo.setOpenId(resultDTO.getUid()); |
||||
|
userInfo.setName(resultDTO.getName()); |
||||
|
userInfo.setMobile(resultDTO.getMobile()); |
||||
|
return userInfo; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return |
||||
|
* @Description 通过token获取用户信息 |
||||
|
* @author wxz |
||||
|
* @date 2021.01.19 10:28 |
||||
|
*/ |
||||
|
//public JcetUserInfoResultDTO 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));
|
||||
|
//
|
||||
|
// JcetUserInfoResultDTO resultDTO = parseResult(result, JcetUserInfoResultDTO.class);
|
||||
|
// return resultDTO;
|
||||
|
//}
|
||||
|
|
||||
|
/** |
||||
|
* 获取请求所需要的头信息 |
||||
|
* |
||||
|
* @return |
||||
|
* @throws UnsupportedEncodingException |
||||
|
*/ |
||||
|
private Map<String, Object> getHeaders(int bodyLength, String appKey, String appSecret) throws UnsupportedEncodingException { |
||||
|
|
||||
|
Map<String, Object> headers = new HashMap(); |
||||
|
long timestamp = System.currentTimeMillis(); |
||||
|
headers.put(JcetConstants.PLAT_HEADER_OPEN_TIMESTAMP, timestamp); |
||||
|
headers.put(JcetConstants.PLAT_HEADER_OPEN_APP_ID, appKey); |
||||
|
String encryptContent = appKey + timestamp + bodyLength; |
||||
|
headers.put(JcetConstants.PLAT_HEADER_OPEN_SIGN, SignUtils.generate(encryptContent, appSecret)); |
||||
|
return headers; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,128 @@ |
|||||
|
package com.epmet.commons.thirdplat.apiservice.pyld; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.epmet.commons.thirdplat.apiservice.AbstractApiService; |
||||
|
import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; |
||||
|
import com.epmet.commons.thirdplat.constants.PyldConstants; |
||||
|
import com.epmet.commons.thirdplat.dto.result.jcet.PyldUserInfoResultDTO; |
||||
|
import com.epmet.commons.thirdplat.properties.PyldThirdplatProps; |
||||
|
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.HttpClientManager; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import org.apache.commons.codec.digest.DigestUtils; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* desc: 平阴联动指挥平台sso登陆服务类 接入文档:http://note.youdao.com/noteshare?id=167ad65365f9eccf7925e8c2629d2021&sub=555AE50510344CB5AACD5C06B9AA3B3B
|
||||
|
* |
||||
|
* @author LiuJanJun |
||||
|
* @date 2021/2/25 1:43 下午 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class PyldApiService extends AbstractApiService { |
||||
|
|
||||
|
Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
|
||||
|
private PyldThirdplatProps pyldThirdplatProps; |
||||
|
|
||||
|
public PyldApiService(ThirdplatProps props) { |
||||
|
this.thirdplatProps = props; |
||||
|
pyldThirdplatProps = props.getPyld(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws Exception { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return |
||||
|
* @Description 通过第三方平台ticket获取用户信息 |
||||
|
* @author wxz |
||||
|
* @date 2021.01.19 10:26 |
||||
|
*/ |
||||
|
@Override |
||||
|
public ThirdPlatUserInfo getGUserInfoBySSOToken(String platformToken) { |
||||
|
|
||||
|
logger.info("【请求平阴联动指挥平台第三方平台】getUserInfoByTicket()接口开始>>>>>>>>>>>>"); |
||||
|
logger.info("【请求平阴联动指挥平台第三方平台】getUserInfoByTicket()接口入参 platformToken:{}", platformToken); |
||||
|
|
||||
|
|
||||
|
JSONObject jsonParam = new JSONObject(); |
||||
|
jsonParam.put(PyldConstants.PLAT_PARAM_TOKEN, platformToken); |
||||
|
jsonParam.put(PyldConstants.PLAT_PARAM_MANAGEMENTKEY, PyldConstants.PLAT_PARAM_MANAGEMENTKEY_VALUE); |
||||
|
|
||||
|
String domain = pyldThirdplatProps.getDomain(); |
||||
|
Result<String> result = HttpClientManager.getInstance().sendPost( |
||||
|
domain.concat(PyldConstants.METHOD_CHECK_LOGIN), |
||||
|
domain.startsWith("https://"), |
||||
|
jsonParam.toJSONString(), |
||||
|
buildHeaders()); |
||||
|
|
||||
|
logger.info("【请求平阴联动指挥平台第三方平台】getUserInfoByTicket()接口返回:{}", result.getData()); |
||||
|
logger.info("【请求平阴联动指挥平台第三方平台】getUserInfoByTicket()接口结束<<<<<<<<<<<<"); |
||||
|
PyldUserInfoResultDTO resultDTO = this.parseResult(result); |
||||
|
|
||||
|
ThirdPlatUserInfo userInfo = new ThirdPlatUserInfo(); |
||||
|
userInfo.setMobile(resultDTO.getMobile()); |
||||
|
userInfo.setCustomerId(resultDTO.getReserved()); |
||||
|
return userInfo; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 构建请求头信息 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
private Map<String, Object> buildHeaders() { |
||||
|
Map<String, Object> headers = new HashMap(); |
||||
|
long timestamp = System.currentTimeMillis(); |
||||
|
headers.put(PyldConstants.PLAT_HEADER_TIMESTAMP, timestamp); |
||||
|
headers.put(PyldConstants.PLAT_HEADER_APP_KEY, pyldThirdplatProps.getAppkey()); |
||||
|
String encryptContent = pyldThirdplatProps.getAppId() + pyldThirdplatProps.getAppkey() + pyldThirdplatProps.getAppSecret() + timestamp; |
||||
|
headers.put(PyldConstants.PLAT_HEADER_ACCESS_TOKEN, DigestUtils.md5Hex(encryptContent.getBytes(StandardCharsets.UTF_8))); |
||||
|
return headers; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* desc: 解析结果 |
||||
|
* |
||||
|
* @param thResult |
||||
|
* @return com.epmet.commons.thirdplat.dto.result.jcet.JcetUserInfoResultDTO |
||||
|
* @author LiuJanJun |
||||
|
* @date 2021/2/24 10:11 上午 |
||||
|
*/ |
||||
|
private PyldUserInfoResultDTO parseResult(Result<String> thResult) { |
||||
|
if (!thResult.success()) { |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
||||
|
EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getMsg().concat(":").concat(thResult.getInternalMsg())); |
||||
|
} |
||||
|
JSONObject jcetResult = JSON.parseObject(thResult.getData()); |
||||
|
Integer code = jcetResult.getInteger("code"); |
||||
|
String msg = jcetResult.getString("msg"); |
||||
|
if (code == null || code != 0) { |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), msg.concat(",错误码:") + code); |
||||
|
} |
||||
|
JSONObject data = jcetResult.getJSONObject("data"); |
||||
|
if (data == null) { |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), |
||||
|
EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getMsg().concat(":").concat(PyldConstants.REPONSE_USER_NOT_LOGIN)); |
||||
|
} |
||||
|
PyldUserInfoResultDTO userInfo = data.getObject("userInfo", PyldUserInfoResultDTO.class); |
||||
|
if (userInfo == null || StringUtils.isBlank(userInfo.getMobile()) || StringUtils.isBlank(userInfo.getReserved())) { |
||||
|
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), PyldConstants.REPONSE_USER_NOT_LOGIN); |
||||
|
} |
||||
|
return userInfo; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.epmet.commons.thirdplat.bean; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class ThirdPlatUserInfo { |
||||
|
private String openId; |
||||
|
private String name; |
||||
|
private String mobile; |
||||
|
private String customerId; |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
package com.epmet.commons.thirdplat.config; |
||||
|
|
||||
|
import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; |
||||
|
import com.epmet.commons.thirdplat.constants.ApiServiceBeansConstants; |
||||
|
import com.epmet.commons.thirdplat.properties.ThirdplatProps; |
||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
/** |
||||
|
* 第三方平台的相关配置 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
@EnableConfigurationProperties(ThirdplatProps.class) |
||||
|
public class ThirdplatConfig { |
||||
|
|
||||
|
/** |
||||
|
* @Description 酒城e通的apiService,这个name需要注册进数据库,使用的时候去数据库根据客户id找对应的apiService出来用 |
||||
|
* @return |
||||
|
* @author wxz |
||||
|
* @date 2021.01.20 13:50 |
||||
|
*/ |
||||
|
@Bean(name = ApiServiceBeansConstants.JCET_API_SERVICE) |
||||
|
public JcetApiService JcetApiService(ThirdplatProps props) { |
||||
|
return new JcetApiService(props); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
package com.epmet.commons.thirdplat.constants; |
||||
|
|
||||
|
/** |
||||
|
* ApiService常量 |
||||
|
*/ |
||||
|
public interface ApiServiceBeansConstants { |
||||
|
// 酒城e通apiService
|
||||
|
String JCET_API_SERVICE = "jcetApiService"; |
||||
|
} |
||||
@ -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,18 @@ |
|||||
|
package com.epmet.commons.thirdplat.constants; |
||||
|
|
||||
|
public interface PyldConstants { |
||||
|
|
||||
|
String METHOD_CHECK_LOGIN = "/unifiedAuth/loginCheck"; |
||||
|
|
||||
|
|
||||
|
String PLAT_HEADER_TIMESTAMP = "timestamp"; |
||||
|
String PLAT_HEADER_APP_KEY = "appkey"; |
||||
|
String PLAT_HEADER_ACCESS_TOKEN = "accessToken"; |
||||
|
|
||||
|
|
||||
|
String PLAT_PARAM_TOKEN = "platformToken"; |
||||
|
String PLAT_PARAM_MANAGEMENTKEY = "managementKey"; |
||||
|
String PLAT_PARAM_MANAGEMENTKEY_VALUE = "epmet_work"; |
||||
|
|
||||
|
String REPONSE_USER_NOT_LOGIN = "token失效,请重新登陆"; |
||||
|
} |
||||
@ -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,29 @@ |
|||||
|
package com.epmet.commons.thirdplat.dto.result.jcet; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class JcetCUserInfoResultDTO { |
||||
|
private String id; |
||||
|
/** |
||||
|
* 用户名称 |
||||
|
*/ |
||||
|
private String userName; |
||||
|
/** |
||||
|
* 手机号码 |
||||
|
*/ |
||||
|
private String mobile; |
||||
|
/** |
||||
|
* 姓名 |
||||
|
*/ |
||||
|
private String name; |
||||
|
/** |
||||
|
* 邮箱 |
||||
|
*/ |
||||
|
private String email; |
||||
|
|
||||
|
/** |
||||
|
* sessionId,用于维持在线状态 |
||||
|
*/ |
||||
|
private String oaSessionId; |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
package com.epmet.commons.thirdplat.dto.result.jcet; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class JcetGUserInfoResultDTO { |
||||
|
private String uid; |
||||
|
/** |
||||
|
* 手机号码 |
||||
|
*/ |
||||
|
private String mobile; |
||||
|
/** |
||||
|
* 姓名 |
||||
|
*/ |
||||
|
private String name; |
||||
|
/** |
||||
|
* 账号 |
||||
|
*/ |
||||
|
private String account; |
||||
|
|
||||
|
/** |
||||
|
* 用户编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
} |
||||
@ -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,18 @@ |
|||||
|
package com.epmet.commons.thirdplat.dto.result.jcet; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
@Data |
||||
|
public class PyldUserInfoResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 6176427074670949388L; |
||||
|
/** |
||||
|
* 手机号 |
||||
|
*/ |
||||
|
private String mobile; |
||||
|
/** |
||||
|
* 客户Id |
||||
|
*/ |
||||
|
private String reserved; |
||||
|
} |
||||
@ -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,14 @@ |
|||||
|
package com.epmet.commons.thirdplat.properties; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* 酒城e通三方平台配置 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PyldThirdplatProps { |
||||
|
private String domain; |
||||
|
private String appId; |
||||
|
private String appkey; |
||||
|
private String appSecret; |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.commons.thirdplat.properties; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
|
||||
|
@Data |
||||
|
@ConfigurationProperties(prefix = "thirdplat") |
||||
|
public class ThirdplatProps { |
||||
|
|
||||
|
// C端
|
||||
|
private JcetThirdplatProps jcetCend; |
||||
|
|
||||
|
// G端
|
||||
|
private JcetThirdplatProps jcetGend; |
||||
|
|
||||
|
/** |
||||
|
* 平阴联动指挥平台 |
||||
|
*/ |
||||
|
private PyldThirdplatProps pyld; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,84 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* <p> |
||||
|
* https://www.renren.io
|
||||
|
* <p> |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.commons.tools.aspect; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.dingtalk.api.DefaultDingTalkClient; |
||||
|
import com.dingtalk.api.DingTalkClient; |
||||
|
import com.dingtalk.api.request.OapiRobotSendRequest; |
||||
|
import com.dingtalk.api.response.OapiRobotSendResponse; |
||||
|
import com.epmet.commons.tools.enums.EnvEnum; |
||||
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
||||
|
import com.taobao.api.ApiException; |
||||
|
import org.apache.logging.log4j.LogManager; |
||||
|
import org.apache.logging.log4j.Logger; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.boot.context.event.ApplicationFailedEvent; |
||||
|
import org.springframework.cloud.commons.util.InetUtils; |
||||
|
import org.springframework.context.ApplicationListener; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 应用 启动健康检查 通知类 |
||||
|
* CustomerApplicationRunner |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class ApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent> { |
||||
|
private static Logger logger = LogManager.getLogger(ApplicationFailedEventListener.class); |
||||
|
@Value("${spring.application.name}") |
||||
|
private String appName; |
||||
|
@Value("${server.version}") |
||||
|
private String version; |
||||
|
|
||||
|
@Override |
||||
|
public void onApplicationEvent(ApplicationFailedEvent applicationFailedEvent) { |
||||
|
Throwable exception = applicationFailedEvent.getException(); |
||||
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
||||
|
logger.info(currentEnv); |
||||
|
if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { |
||||
|
sendDingMarkDownMsg(exception); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private String getServerIp() { |
||||
|
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
||||
|
return inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
||||
|
} |
||||
|
|
||||
|
private void sendDingMarkDownMsg(Throwable exception) { |
||||
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"); |
||||
|
OapiRobotSendRequest request = new OapiRobotSendRequest(); |
||||
|
request.setMsgtype("markdown"); |
||||
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); |
||||
|
markdown.setTitle("部署失败通知"); |
||||
|
|
||||
|
markdown.setText("部署失败通知 \n" + |
||||
|
"> 服务:" + appName + "\n\n" + |
||||
|
"> 版本:" + version + "\n\n" + |
||||
|
"> 环境:" + EnvEnum.getCurrentEnv().getName() + "\n\n" + |
||||
|
"> IP: " + getServerIp() + "\n\n" + |
||||
|
"> 异常:" + exception.getMessage() + "\n\n" |
||||
|
); |
||||
|
request.setMarkdown(markdown); |
||||
|
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); |
||||
|
at.setIsAtAll(true); |
||||
|
request.setAt(at); |
||||
|
try { |
||||
|
OapiRobotSendResponse execute = client.execute(request); |
||||
|
logger.info("=====通知结果===>" + JSON.toJSONString(execute)); |
||||
|
} catch (ApiException e) { |
||||
|
logger.error("sendDingMarkDownMsg exception", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,109 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* <p> |
||||
|
* https://www.renren.io
|
||||
|
* <p> |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.commons.tools.aspect; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.dingtalk.api.DefaultDingTalkClient; |
||||
|
import com.dingtalk.api.DingTalkClient; |
||||
|
import com.dingtalk.api.request.OapiRobotSendRequest; |
||||
|
import com.dingtalk.api.response.OapiRobotSendResponse; |
||||
|
import com.epmet.commons.tools.dto.form.DingTalkTextMsg; |
||||
|
import com.epmet.commons.tools.enums.EnvEnum; |
||||
|
import com.epmet.commons.tools.utils.HttpClientManager; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.utils.SpringContextUtils; |
||||
|
import com.taobao.api.ApiException; |
||||
|
import org.apache.logging.log4j.LogManager; |
||||
|
import org.apache.logging.log4j.Logger; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent; |
||||
|
import org.springframework.cloud.commons.util.InetUtils; |
||||
|
import org.springframework.context.ApplicationListener; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 应用 启动健康检查 通知类 |
||||
|
* CustomerApplicationRunner |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> { |
||||
|
private static Logger logger = LogManager.getLogger(ApplicationReadyEventListener.class); |
||||
|
@Value("${spring.application.name}") |
||||
|
private String appName; |
||||
|
@Value("${server.version}") |
||||
|
private String version; |
||||
|
|
||||
|
@Override |
||||
|
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { |
||||
|
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
||||
|
logger.info(currentEnv); |
||||
|
if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { |
||||
|
//sendDingTextMsg();
|
||||
|
sendDingMarkDownMsg(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void sendDingTextMsg() { |
||||
|
//发送启动成功消息
|
||||
|
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
||||
|
String serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
||||
|
|
||||
|
//开发小组 群机器人地址
|
||||
|
String url = "https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; |
||||
|
StringBuilder stringBuilder = new StringBuilder(); |
||||
|
stringBuilder.append(EnvEnum.getCurrentEnv().getName()) |
||||
|
.append("【") |
||||
|
.append(appName) |
||||
|
.append("】") |
||||
|
.append("ip地址: ") |
||||
|
.append(serverIp) |
||||
|
.append("部署完毕!"); |
||||
|
DingTalkTextMsg msg = new DingTalkTextMsg(); |
||||
|
msg.setWebHook(url); |
||||
|
msg.setAtAll(true); |
||||
|
msg.setContent(stringBuilder.toString()); |
||||
|
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, msg.getMsgContent()); |
||||
|
logger.info(stringResult); |
||||
|
} |
||||
|
|
||||
|
private String getServerIp() { |
||||
|
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
||||
|
return inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
||||
|
} |
||||
|
|
||||
|
private void sendDingMarkDownMsg() { |
||||
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"); |
||||
|
OapiRobotSendRequest request = new OapiRobotSendRequest(); |
||||
|
request.setMsgtype("markdown"); |
||||
|
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); |
||||
|
markdown.setTitle("部署成功通知"); |
||||
|
|
||||
|
markdown.setText("部署成功通知 \n" + |
||||
|
"> 服务:" + appName + "\n\n" + |
||||
|
"> 版本:" + version + "\n\n" + |
||||
|
"> 环境:" + EnvEnum.getCurrentEnv().getName() + "\n\n" + |
||||
|
"> IP: " + getServerIp() + "\n\n" |
||||
|
); |
||||
|
request.setMarkdown(markdown); |
||||
|
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); |
||||
|
at.setIsAtAll(true); |
||||
|
request.setAt(at); |
||||
|
try { |
||||
|
OapiRobotSendResponse execute = client.execute(request); |
||||
|
logger.info("=====通知结果===>" + JSON.toJSONString(execute)); |
||||
|
} catch (ApiException e) { |
||||
|
logger.error("sendDingMarkDownMsg exception", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -1,67 +0,0 @@ |
|||||
/** |
|
||||
* Copyright (c) 2018 人人开源 All rights reserved. |
|
||||
* <p> |
|
||||
* https://www.renren.io
|
|
||||
* <p> |
|
||||
* 版权所有,侵权必究! |
|
||||
*/ |
|
||||
|
|
||||
package com.epmet.commons.tools.aspect; |
|
||||
|
|
||||
import com.epmet.commons.tools.dto.form.DingTalkTextMsg; |
|
||||
import com.epmet.commons.tools.enums.EnvEnum; |
|
||||
import com.epmet.commons.tools.utils.HttpClientManager; |
|
||||
import com.epmet.commons.tools.utils.Result; |
|
||||
import com.epmet.commons.tools.utils.SpringContextUtils; |
|
||||
import org.apache.logging.log4j.LogManager; |
|
||||
import org.apache.logging.log4j.Logger; |
|
||||
import org.springframework.beans.factory.annotation.Value; |
|
||||
import org.springframework.boot.ApplicationArguments; |
|
||||
import org.springframework.boot.ApplicationRunner; |
|
||||
import org.springframework.cloud.commons.util.InetUtils; |
|
||||
import org.springframework.core.annotation.Order; |
|
||||
import org.springframework.stereotype.Component; |
|
||||
|
|
||||
/** |
|
||||
* 应用 启动健康检查 通知类 |
|
||||
* CustomerApplicationRunner |
|
||||
* |
|
||||
* @author Mark sunlightcs@gmail.com |
|
||||
* @since 1.0.0 |
|
||||
*/ |
|
||||
@Component |
|
||||
@Order(value = 99) |
|
||||
public class CustomerApplicationRunner implements ApplicationRunner { |
|
||||
private static Logger logger = LogManager.getLogger(CustomerApplicationRunner.class); |
|
||||
@Value("${spring.application.name}") |
|
||||
private String appName; |
|
||||
|
|
||||
@Override |
|
||||
public void run(ApplicationArguments args) { |
|
||||
//发送启动成功消息
|
|
||||
EnvEnum currentEnv = EnvEnum.getCurrentEnv(); |
|
||||
logger.info(currentEnv); |
|
||||
if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { |
|
||||
InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); |
|
||||
String serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); |
|
||||
|
|
||||
//开发小组 群机器人地址
|
|
||||
String url = "https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; |
|
||||
StringBuilder stringBuilder = new StringBuilder(); |
|
||||
stringBuilder.append(EnvEnum.getCurrentEnv().getName()) |
|
||||
.append("【") |
|
||||
.append(appName) |
|
||||
.append("】") |
|
||||
.append("ip地址: ") |
|
||||
.append(serverIp) |
|
||||
.append("部署完毕!"); |
|
||||
DingTalkTextMsg msg = new DingTalkTextMsg(); |
|
||||
msg.setWebHook(url); |
|
||||
msg.setAtAll(true); |
|
||||
msg.setContent(stringBuilder.toString()); |
|
||||
Result<String> stringResult = HttpClientManager.getInstance().sendPostByJSON(url, msg.getMsgContent()); |
|
||||
logger.info(stringResult); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.commons.tools.config.shutdown; |
||||
|
|
||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; |
||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
/** |
||||
|
* 优雅停机配置 |
||||
|
* matchIfMissing:当缺少shutdown.graceful.enable配置的时候,是否加载该配置类。true:缺少也加载,false:默认的,缺少配置不加载,即不生效 |
||||
|
*/ |
||||
|
@Configuration |
||||
|
@ConditionalOnProperty(prefix = "shutdown.graceful", name = "enable", havingValue = "true", matchIfMissing = false) |
||||
|
public class GracefulShutdownConfig { |
||||
|
|
||||
|
@Bean |
||||
|
public ServletWebServerFactory servletContainer(GracefulShutdownTomcat gracefulShutdownTomcat) { |
||||
|
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); |
||||
|
tomcat.addConnectorCustomizers(gracefulShutdownTomcat); |
||||
|
return tomcat; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,52 @@ |
|||||
|
package com.epmet.commons.tools.config.shutdown; |
||||
|
|
||||
|
import org.apache.catalina.connector.Connector; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer; |
||||
|
import org.springframework.context.ApplicationListener; |
||||
|
import org.springframework.context.event.ContextClosedEvent; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.concurrent.Executor; |
||||
|
import java.util.concurrent.ThreadPoolExecutor; |
||||
|
import java.util.concurrent.TimeUnit; |
||||
|
|
||||
|
@EnableConfigurationProperties(ShutdownProperties.class) |
||||
|
@Component |
||||
|
@ConditionalOnProperty(prefix = "shutdown.graceful", name = "enable", havingValue = "true", matchIfMissing = false) |
||||
|
public class GracefulShutdownTomcat implements TomcatConnectorCustomizer, ApplicationListener<ContextClosedEvent> { |
||||
|
|
||||
|
private static final Logger logger = LoggerFactory.getLogger(GracefulShutdownTomcat.class); |
||||
|
|
||||
|
@Autowired |
||||
|
private ShutdownProperties shutdownProperties; |
||||
|
|
||||
|
private volatile Connector connector; |
||||
|
|
||||
|
@Override |
||||
|
public void customize(Connector connector) { |
||||
|
this.connector = connector; |
||||
|
} |
||||
|
@Override |
||||
|
public void onApplicationEvent(ContextClosedEvent contextClosedEvent) { |
||||
|
this.connector.pause(); |
||||
|
Executor executor = this.connector.getProtocolHandler().getExecutor(); |
||||
|
long waitTimeSecs = shutdownProperties.getGraceful().getWaitTimeSecs(); |
||||
|
if (executor instanceof ThreadPoolExecutor) { |
||||
|
try { |
||||
|
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor; |
||||
|
threadPoolExecutor.shutdown(); |
||||
|
if (!threadPoolExecutor.awaitTermination(waitTimeSecs, TimeUnit.SECONDS)) { |
||||
|
String msg = String.format("Tomcat在【%s】秒内优雅停机失败,请手动处理", waitTimeSecs); |
||||
|
logger.error(msg); |
||||
|
} |
||||
|
} catch (InterruptedException ex) { |
||||
|
Thread.currentThread().interrupt(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package com.epmet.commons.tools.config.shutdown; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
|
||||
|
@ConfigurationProperties(prefix = "shutdown") |
||||
|
@Data |
||||
|
public class ShutdownProperties { |
||||
|
|
||||
|
private GracefulShutdownProperties graceful; |
||||
|
|
||||
|
@Data |
||||
|
public static class GracefulShutdownProperties { |
||||
|
private long waitTimeSecs = 30; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
package com.epmet.commons.tools.scan.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import javax.validation.constraints.NotEmpty; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* (异步检测)请求参数 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2021/1/10 21:05 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VideoScanParamDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -7261993744367287072L; |
||||
|
/** |
||||
|
* 是否开启回调 |
||||
|
*/ |
||||
|
@NotNull(message = "openCallBack必填,true开启;false不开启") |
||||
|
private Boolean openCallBack; |
||||
|
|
||||
|
/** |
||||
|
* 异步检测结果回调地址,执行异步审查内容时 必填 |
||||
|
* openCallBack=true时,callback必填 |
||||
|
*/ |
||||
|
private String callback; |
||||
|
|
||||
|
@Valid |
||||
|
@NotEmpty(message = "任务列表不能为空") |
||||
|
private List<VideoTaskDTO> tasks; |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package com.epmet.commons.tools.scan.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* (异步检测)请求参数 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2021/1/10 21:06 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VideoTaskDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -5268462578193403270L; |
||||
|
/** |
||||
|
* 不必填 |
||||
|
* 要检测的数据id 非必填 |
||||
|
* 检测对象对应的数据ID。 |
||||
|
* 由大小写英文字母、数字、下划线(_)、短划线(-)、英文句号(.)组成,不超过128个字符,可以用于唯一标识您的业务数据。 |
||||
|
* */ |
||||
|
@NotBlank(message = "dataId不能为空") |
||||
|
private String dataId; |
||||
|
|
||||
|
/** |
||||
|
* 必填 |
||||
|
* 待检测视频的URL。该字段不能和frames同时为空,也不能和frames同时有值。 |
||||
|
*/ |
||||
|
@NotBlank(message = "音频URL不能为空") |
||||
|
private String url; |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
package com.epmet.commons.tools.scan.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import javax.validation.constraints.NotEmpty; |
||||
|
import javax.validation.constraints.NotNull; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 语音检测入参DTO |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/12/18 10:15 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VoiceScanParamDTO implements Serializable { |
||||
|
|
||||
|
/** |
||||
|
* 是否开启回调 |
||||
|
*/ |
||||
|
@NotNull(message = "openCallBack必填,true开启;false不开启") |
||||
|
private Boolean openCallBack; |
||||
|
|
||||
|
/** |
||||
|
* 异步检测结果回调地址,执行异步审查内容时 必填 |
||||
|
* openCallBack=true时,callback必填 |
||||
|
*/ |
||||
|
private String callback; |
||||
|
|
||||
|
@Valid |
||||
|
@NotEmpty(message = "任务列表不能为空") |
||||
|
private List<VoiceTaskDTO> tasks; |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
package com.epmet.commons.tools.scan.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 语音异步检测对象 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/12/18 10:21 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VoiceTaskDTO implements Serializable { |
||||
|
/** |
||||
|
* 不必填 |
||||
|
* 要检测的数据id 非必填 |
||||
|
* 检测对象对应的数据ID。 |
||||
|
* 由大小写英文字母、数字、下划线(_)、短划线(-)、英文句号(.)组成,不超过128个字符,可以用于唯一标识您的业务数据。 |
||||
|
* */ |
||||
|
@NotBlank(message = "dataId不能为空") |
||||
|
private String dataId; |
||||
|
|
||||
|
/** |
||||
|
* 必填 |
||||
|
* 需要检测的音频文件或语音流的下载地址。 |
||||
|
*/ |
||||
|
@NotBlank(message = "音频URL不能为空") |
||||
|
private String url; |
||||
|
} |
||||
@ -0,0 +1,49 @@ |
|||||
|
package com.epmet.commons.tools.scan.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 语音异步检测 返参 |
||||
|
* 视频异步检测 返参通用 |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/12/18 10:09 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AsyncScanResult implements Serializable { |
||||
|
private static final long serialVersionUID = -939433332419948118L; |
||||
|
|
||||
|
/** |
||||
|
* 随机字符串,该值用于回调通知请求中的签名。 |
||||
|
*/ |
||||
|
private String seed; |
||||
|
|
||||
|
/** |
||||
|
* 提交成功的失败对象 |
||||
|
*/ |
||||
|
private List<AsyncScanTaskDTO> successTasks=new ArrayList<>(); |
||||
|
|
||||
|
/** |
||||
|
* 提交失败的检测对象 |
||||
|
*/ |
||||
|
private List<AsyncScanTaskDTO> failTasks=new ArrayList<>(); |
||||
|
|
||||
|
/** |
||||
|
* 是否全部提交成功 |
||||
|
*/ |
||||
|
private boolean isAllSuccess; |
||||
|
|
||||
|
public boolean isAllSuccess() { |
||||
|
if (failTasks.isEmpty() && !successTasks.isEmpty()) { |
||||
|
return true; |
||||
|
} |
||||
|
return isAllSuccess; |
||||
|
} |
||||
|
|
||||
|
public void setAllSuccess(boolean allSuccess) { |
||||
|
isAllSuccess = allSuccess; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
package com.epmet.commons.tools.scan.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 语音异步检测 -返回的task集合 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/12/18 10:31 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AsyncScanTaskDTO implements Serializable { |
||||
|
/** |
||||
|
* 检测对象对应的数据ID。 |
||||
|
* 由大小写英文字母、数字、下划线(_)、短划线(-)、英文句号(.)组成,不超过128个字符,可以用于唯一标识您的业务数据。 |
||||
|
*/ |
||||
|
private String dataId; |
||||
|
|
||||
|
/** |
||||
|
* 任务id |
||||
|
*/ |
||||
|
private String taskId; |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
package com.epmet.commons.tools.scan.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 视频异步检测结果查询接口返参 |
||||
|
* 正在检测中的不返回,调用方继续轮询查询结果 |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/12/29 15:37 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VideoAsyncScanResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -7302168989456734818L; |
||||
|
/** |
||||
|
* 执行成功的任务Id集合 |
||||
|
* code=200,且所有语音+视频所有场景返回结果都为pass时则为成功 |
||||
|
*/ |
||||
|
private List<String> passDataIds = new ArrayList<>(); |
||||
|
/** |
||||
|
* 执行失败的任务Id集合 |
||||
|
*/ |
||||
|
private List<String> noPassDataIds = new ArrayList<>(); |
||||
|
|
||||
|
private List<String> passTaskIds = new ArrayList<>(); |
||||
|
private List<String> noPassTaskIds = new ArrayList<>(); |
||||
|
|
||||
|
/** |
||||
|
* desc:阿里内容审核API返回结果详情 |
||||
|
*/ |
||||
|
private List<VideoScanDetailDTO> details = new ArrayList<>(); |
||||
|
|
||||
|
/** |
||||
|
* 本地是否全部通过 |
||||
|
*/ |
||||
|
private Boolean isAllPass; |
||||
|
|
||||
|
public boolean isAllPass() { |
||||
|
if (noPassTaskIds.isEmpty() && !passTaskIds.isEmpty()) { |
||||
|
return true; |
||||
|
} |
||||
|
return isAllPass; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
package com.epmet.commons.tools.scan.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2021/1/10 21:24 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VideoScanDetailDTO implements Serializable { |
||||
|
/** |
||||
|
* 错误码,和HTTP状态码一致。 |
||||
|
* 更多信息,请参见公共错误码。 |
||||
|
*/ |
||||
|
private Integer code; |
||||
|
|
||||
|
private String codeDesc; |
||||
|
|
||||
|
/** |
||||
|
* 错误描述信息。 |
||||
|
*/ |
||||
|
private String msg; |
||||
|
/** |
||||
|
* 检测对象对应的数据ID。 |
||||
|
*/ |
||||
|
private String dataId; |
||||
|
|
||||
|
/** |
||||
|
* 检测任务的ID |
||||
|
*/ |
||||
|
private String taskId; |
||||
|
|
||||
|
/** |
||||
|
* 返回结果,调用成功时(code=200),返回结果中包含一个或多个元素。每个元素是个结构体,具体结构描述,请参见result。 |
||||
|
* 说明 视频流检测场景中,code返回280表示在检测中,返回200表示检测完成。在检测中状态时,检测结果中包含从开始检测到当前时间的检测到结果。 |
||||
|
*/ |
||||
|
private List<ResultDetail> results; |
||||
|
|
||||
|
/** |
||||
|
* 视频语音检测结果。具体结构描述,请参见audioScanResult。 |
||||
|
*/ |
||||
|
private List<ResultDetail> audioScanResults; |
||||
|
|
||||
|
|
||||
|
@Data |
||||
|
public static class ResultDetail { |
||||
|
private String scene; |
||||
|
private String label; |
||||
|
private String suggestion; |
||||
|
private Float rate; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
package com.epmet.commons.tools.scan.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 检测成功(检测成功+检测失败的)的任务详情 |
||||
|
* 处理中的该接口不返回,继续轮询即可 |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2020/12/18 13:10 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class VoiceResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 8006827312407034344L; |
||||
|
/** |
||||
|
* 检测对象对应的数据ID。 |
||||
|
*/ |
||||
|
private String dataId; |
||||
|
|
||||
|
/** |
||||
|
* 检测任务的ID |
||||
|
*/ |
||||
|
private String taskId; |
||||
|
|
||||
|
/** |
||||
|
* 建议您执行的后续操作。取值: |
||||
|
* pass:结果正常,无需进行其余操作。 |
||||
|
* review:结果不确定,需要进行人工审核。 |
||||
|
* block:结果违规,建议直接删除或者限制公开。 |
||||
|
*/ |
||||
|
private String suggestion; |
||||
|
|
||||
|
/** |
||||
|
* 检测结果的分类。取值: |
||||
|
* normal:正常文本 |
||||
|
* spam:含垃圾信息 |
||||
|
* ad:广告 |
||||
|
* politics:涉政 |
||||
|
* terrorism:暴恐 |
||||
|
* abuse:辱骂 |
||||
|
* porn:色情 |
||||
|
* flood:灌水 |
||||
|
* contraband:违禁 |
||||
|
* meaningless:无意义 |
||||
|
* customized:自定义(例如命中自定义关键词) |
||||
|
*/ |
||||
|
private String label; |
||||
|
|
||||
|
/** |
||||
|
* labelDesc是对label的说明,包含两种特殊说明: |
||||
|
* (1)如果检测任务失败labelDesc:智能检测任务失败,结果已失效,需要人工审核 |
||||
|
* (2)如果检测结果失效labelDesc:智能检测任务失败,需要人工审核 |
||||
|
*/ |
||||
|
private String labelDesc; |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
package com.epmet.commons.tools.utils; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 描述一下 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2021/2/4 20:49 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AgencyNode<T> implements Serializable { |
||||
|
|
||||
|
private String areaCode; |
||||
|
|
||||
|
private String parentAreaCode; |
||||
|
|
||||
|
/** |
||||
|
* 子节点列表 |
||||
|
*/ |
||||
|
private List<T> subAgencyList = new ArrayList<>(); |
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
package com.epmet.commons.tools.utils; |
||||
|
|
||||
|
|
||||
|
import com.epmet.commons.tools.validator.AssertUtils; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.LinkedHashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 描述一下 |
||||
|
* |
||||
|
* @author yinzuomei@elink-cn.com |
||||
|
* @date 2021/2/4 20:49 |
||||
|
*/ |
||||
|
public class AgencyTreeUtils { |
||||
|
|
||||
|
/** |
||||
|
* 根据pid,构建树节点 |
||||
|
*/ |
||||
|
public static <T extends AgencyNode> List<T> build(List<T> agencyNodes, String parentAreaCode) { |
||||
|
//pid不能为空
|
||||
|
AssertUtils.isNull(parentAreaCode, "parentAreaCode"); |
||||
|
|
||||
|
List<T> treeList = new ArrayList<>(); |
||||
|
for (T agencyNode : agencyNodes) { |
||||
|
if (parentAreaCode.equals(agencyNode.getParentAreaCode())) { |
||||
|
treeList.add(findChildren(agencyNodes, agencyNode)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return treeList; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查找子节点 |
||||
|
*/ |
||||
|
private static <T extends AgencyNode> T findChildren(List<T> agencyNodes, T rootNode) { |
||||
|
for (T agencyNode : agencyNodes) { |
||||
|
if (rootNode.getAreaCode().equals(agencyNode.getParentAreaCode())) { |
||||
|
rootNode.getSubAgencyList().add(findChildren(agencyNodes, agencyNode)); |
||||
|
} |
||||
|
} |
||||
|
return rootNode; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 构建树节点 |
||||
|
*/ |
||||
|
public static <T extends AgencyNode> List<T> build(List<T> agencyNodes) { |
||||
|
List<T> result = new ArrayList<>(); |
||||
|
|
||||
|
//list转map
|
||||
|
Map<String, T> nodeMap = new LinkedHashMap<>(agencyNodes.size()); |
||||
|
for (T agencyNode : agencyNodes) { |
||||
|
nodeMap.put(agencyNode.getAreaCode(), agencyNode); |
||||
|
} |
||||
|
|
||||
|
for (T node : nodeMap.values()) { |
||||
|
T parent = nodeMap.get(node.getParentAreaCode()); |
||||
|
if (parent != null && !(node.getAreaCode().equals(parent.getAreaCode()))) { |
||||
|
parent.getSubAgencyList().add(node); |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
result.add(node); |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,251 @@ |
|||||
|
package com.epmet.commons.tools.utils; |
||||
|
|
||||
|
import javax.crypto.Cipher; |
||||
|
import java.security.*; |
||||
|
import java.security.spec.PKCS8EncodedKeySpec; |
||||
|
import java.security.spec.X509EncodedKeySpec; |
||||
|
import java.util.Base64; |
||||
|
|
||||
|
/** |
||||
|
* @author jianjun liu |
||||
|
* @date 2020-06-05 16:48 |
||||
|
**/ |
||||
|
|
||||
|
public class RSASignature { |
||||
|
|
||||
|
|
||||
|
//非对称密钥算法
|
||||
|
private static final String KEY_ALGORITHM = "RSA"; |
||||
|
//密钥长度,在512到65536位之间,建议不要太长,否则速度很慢,生成的加密数据很长
|
||||
|
private static final int KEY_SIZE = 512; |
||||
|
//字符编码
|
||||
|
private static final String CHARSET = "UTF-8"; |
||||
|
|
||||
|
/** |
||||
|
* 生成密钥对 |
||||
|
* |
||||
|
* @return KeyPair 密钥对 |
||||
|
*/ |
||||
|
public static KeyPair getKeyPair() throws Exception { |
||||
|
return getKeyPair(null); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成密钥对 |
||||
|
* |
||||
|
* @param password 生成密钥对的密码 |
||||
|
* @return |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static KeyPair getKeyPair(String password) throws Exception { |
||||
|
//实例化密钥生成器
|
||||
|
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGORITHM); |
||||
|
//初始化密钥生成器
|
||||
|
if (password == null) { |
||||
|
keyPairGenerator.initialize(KEY_SIZE); |
||||
|
} else { |
||||
|
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); |
||||
|
secureRandom.setSeed(password.getBytes(CHARSET)); |
||||
|
keyPairGenerator.initialize(KEY_SIZE, secureRandom); |
||||
|
} |
||||
|
//生成密钥对
|
||||
|
return keyPairGenerator.generateKeyPair(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得私钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return byte[] 私钥 |
||||
|
*/ |
||||
|
public static byte[] getPrivateKeyBytes(KeyPair keyPair) { |
||||
|
return keyPair.getPrivate().getEncoded(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得Base64编码的私钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return String Base64编码的私钥 |
||||
|
*/ |
||||
|
public static String getPrivateKey(KeyPair keyPair) { |
||||
|
return Base64.getEncoder().encodeToString(getPrivateKeyBytes(keyPair)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得公钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return byte[] 公钥 |
||||
|
*/ |
||||
|
public static byte[] getPublicKeyBytes(KeyPair keyPair) { |
||||
|
return keyPair.getPublic().getEncoded(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 取得Base64编码的公钥 |
||||
|
* |
||||
|
* @param keyPair 密钥对 |
||||
|
* @return String Base64编码的公钥 |
||||
|
*/ |
||||
|
public static String getPublicKey(KeyPair keyPair) { |
||||
|
return Base64.getEncoder().encodeToString(getPublicKeyBytes(keyPair)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param privateKey 私钥字节数组 |
||||
|
* @return byte[] 加密数据 |
||||
|
*/ |
||||
|
public static byte[] encryptByPrivateKey(byte[] data, byte[] privateKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//生成私钥
|
||||
|
PrivateKey key = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey)); |
||||
|
//数据加密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.ENCRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param privateKey Base64编码的私钥 |
||||
|
* @return String Base64编码的加密数据 |
||||
|
*/ |
||||
|
public static String encryptByPrivateKey(String data, String privateKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(privateKey); |
||||
|
return Base64.getEncoder().encodeToString(encryptByPrivateKey(data.getBytes(CHARSET), key)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param publicKey 公钥字节数组 |
||||
|
* @return byte[] 加密数据 |
||||
|
*/ |
||||
|
public static byte[] encryptByPublicKey(byte[] data, byte[] publicKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//生成公钥
|
||||
|
PublicKey key = keyFactory.generatePublic(new X509EncodedKeySpec(publicKey)); |
||||
|
//数据加密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.ENCRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @param publicKey Base64编码的公钥 |
||||
|
* @return String Base64编码的加密数据 |
||||
|
*/ |
||||
|
public static String encryptByPublicKey(String data, String publicKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(publicKey); |
||||
|
return Base64.getEncoder().encodeToString(encryptByPublicKey(data.getBytes(CHARSET), key)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥解密 |
||||
|
* |
||||
|
* @param data 待解密数据 |
||||
|
* @param privateKey 私钥字节数组 |
||||
|
* @return byte[] 解密数据 |
||||
|
*/ |
||||
|
public static byte[] decryptByPrivateKey(byte[] data, byte[] privateKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//生成私钥
|
||||
|
PrivateKey key = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey)); |
||||
|
//数据解密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.DECRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 私钥解密 |
||||
|
* |
||||
|
* @param data Base64编码的待解密数据 |
||||
|
* @param privateKey Base64编码的私钥 |
||||
|
* @return String 解密数据 |
||||
|
*/ |
||||
|
public static String decryptByPrivateKey(String data, String privateKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(privateKey); |
||||
|
return new String(decryptByPrivateKey(Base64.getDecoder().decode(data), key), CHARSET); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥解密 |
||||
|
* |
||||
|
* @param data 待解密数据 |
||||
|
* @param publicKey 公钥字节数组 |
||||
|
* @return byte[] 解密数据 |
||||
|
*/ |
||||
|
public static byte[] decryptByPublicKey(byte[] data, byte[] publicKey) throws Exception { |
||||
|
//实例化密钥工厂
|
||||
|
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); |
||||
|
//产生公钥
|
||||
|
PublicKey key = keyFactory.generatePublic(new X509EncodedKeySpec(publicKey)); |
||||
|
//数据解密
|
||||
|
Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); |
||||
|
cipher.init(Cipher.DECRYPT_MODE, key); |
||||
|
return cipher.doFinal(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 公钥解密 |
||||
|
* |
||||
|
* @param data Base64编码的待解密数据 |
||||
|
* @param publicKey Base64编码的公钥 |
||||
|
* @return String 解密数据 |
||||
|
*/ |
||||
|
public static String decryptByPublicKey(String data, String publicKey) throws Exception { |
||||
|
byte[] key = Base64.getDecoder().decode(publicKey); |
||||
|
return new String(decryptByPublicKey(Base64.getDecoder().decode(data), key), CHARSET); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 测试加解密方法 |
||||
|
* |
||||
|
* @param args |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void main(String[] args) throws Exception { |
||||
|
//生成密钥对,一般生成之后可以放到配置文件中
|
||||
|
KeyPair keyPair = RSASignature.getKeyPair(); |
||||
|
//公钥
|
||||
|
String publicKey = RSASignature.getPublicKey(keyPair); |
||||
|
//私钥
|
||||
|
String privateKey = RSASignature.getPrivateKey(keyPair); |
||||
|
|
||||
|
System.out.println("公钥:\n" + publicKey); |
||||
|
System.out.println("私钥:\n" + privateKey); |
||||
|
|
||||
|
String data = "RSA 加解密测试!"; |
||||
|
{ |
||||
|
System.out.println("\n===========私钥加密,公钥解密=============="); |
||||
|
String s1 = RSASignature.encryptByPrivateKey(data, privateKey); |
||||
|
System.out.println("加密后的数据:" + s1); |
||||
|
String s2 = RSASignature.decryptByPublicKey(s1, publicKey); |
||||
|
System.out.println("解密后的数据:" + s2 + "\n\n"); |
||||
|
} |
||||
|
//=====
|
||||
|
{ |
||||
|
System.out.println("\n===========公钥加密,私钥解密=============="); |
||||
|
String s1 = RSASignature.encryptByPublicKey(data, publicKey); |
||||
|
System.out.println("加密后的数据:" + s1); |
||||
|
String s2 = RSASignature.decryptByPrivateKey(s1, privateKey); |
||||
|
System.out.println("解密后的数据:" + s2 + "\n\n"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -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>data-aggregator</artifactId> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<version>2.0.0</version> |
||||
|
</parent> |
||||
|
<modelVersion>4.0.0</modelVersion> |
||||
|
|
||||
|
<artifactId>data-aggregator-client</artifactId> |
||||
|
|
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-commons-tools</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</dependency> |
||||
|
</dependencies> |
||||
|
|
||||
|
</project> |
||||
@ -0,0 +1,26 @@ |
|||||
|
package com.epmet.dataaggre.constant; |
||||
|
|
||||
|
/** |
||||
|
* 数据源常量 |
||||
|
*/ |
||||
|
public interface DataSourceConstant { |
||||
|
|
||||
|
String GOV_ORG = "govorg"; |
||||
|
String GOV_ISSUE = "govissue"; |
||||
|
|
||||
|
/** |
||||
|
* 项目 |
||||
|
*/ |
||||
|
String GOV_PROJECT = "govproject"; |
||||
|
|
||||
|
/** |
||||
|
* 小组 |
||||
|
*/ |
||||
|
String RESI_GROUP = "resigroup"; |
||||
|
|
||||
|
/** |
||||
|
* 用户 |
||||
|
*/ |
||||
|
String EPMET_USER = "epmetuser"; |
||||
|
|
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue