Merge remote-tracking branch 'origin/uat' into uat
This commit is contained in:
@ -152,15 +152,15 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
}
|
||||
|
||||
/**
|
||||
* 区块链调用天擎接口
|
||||
*
|
||||
* 调用天擎接口
|
||||
* 使用对象:中信支付、
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Async
|
||||
public String callUniInterfaceJson(CrypBean bean) {
|
||||
log.info("区块链------callUniInterface:---入参-----" + JSON.toJSONString(bean));
|
||||
log.info("天擎接口------callUniInterface:---入参-----" + JSON.toJSONString(bean));
|
||||
BlockChainLog blockChainLog = new BlockChainLog();
|
||||
blockChainLog.setId(PropertyUtils.getSnowflakeId());
|
||||
//天擎地址
|
||||
@ -189,10 +189,9 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
|
||||
map.put("SIGN", sign);
|
||||
|
||||
json = getUniBss(bean.getReqName(), map);
|
||||
json = getCiticUniBss(bean.getReqName(), map);
|
||||
|
||||
str = UniBssServiceImpl.uniBssHttpPost(bean.getUrl(), json);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("区块链调用失败!~-----------------",e);
|
||||
}
|
||||
@ -335,7 +334,10 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
|
||||
/**
|
||||
* 获取加密签名
|
||||
*
|
||||
* 使用对象:区块链
|
||||
* REQ:{
|
||||
* body:{}
|
||||
* }
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
@ -383,6 +385,33 @@ public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMappe
|
||||
return JSON.toJSONString(uniBss);
|
||||
}
|
||||
|
||||
/**
|
||||
* 中信天擎接口 数据格式 获取加密签名
|
||||
* REQ:{
|
||||
* header:{}
|
||||
* body:{}
|
||||
* }
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
private String getCiticUniBss(String reqName, Map<String, Object> map) {
|
||||
|
||||
UniBss uniBss = new UniBss();
|
||||
uniBss.setUniBssAttached(new UniBssAttached().setMediaInf(""));
|
||||
//天擎部分head
|
||||
UniBssUtil util = new UniBssUtil(app_id, app_secret);
|
||||
uniBss.setUniBssHead(util.getUniBssHead());
|
||||
|
||||
log.info("业务参数封装前:" + map);
|
||||
Map reqMap = new HashMap();
|
||||
reqMap.put(reqName, map);
|
||||
uniBss.setUniBssBodyMap(reqMap);
|
||||
log.info("业务参数封装后:" + JSON.toJSONString(reqMap));
|
||||
log.info("业务参数封装后uniBss:" + JSON.toJSONString(uniBss));
|
||||
|
||||
return JSON.toJSONString(uniBss);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
|
@ -1,16 +1,13 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.userinfo.controller;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.service.UserInfoService;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.service.EbtpUserInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@ -18,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
public class UserInfoController {
|
||||
|
||||
@Autowired
|
||||
private UserInfoService service;
|
||||
private EbtpUserInfoService ebtpUserInfoService;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
@ -33,7 +30,18 @@ public class UserInfoController {
|
||||
log.error("access token is empty");
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
||||
}
|
||||
return ResponseEntity.ok(service.getUserInfo(token));
|
||||
return ResponseEntity.ok(ebtpUserInfoService.getUserInfo(token));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新redis缓存的信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("refresh")
|
||||
public ResponseEntity<Boolean> refreshToken() {
|
||||
return ResponseEntity.ok(ebtpUserInfoService.refresh());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.userinfo.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.entity.BaseRole;
|
||||
|
||||
public interface BaseRoleMapper extends BaseMapper<BaseRole> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.userinfo.dao;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.entity.BaseUser;
|
||||
|
||||
public interface BaseUserMapper extends BaseMapper<BaseUser> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.userinfo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 功能模块bean
|
||||
*
|
||||
* @author zyx
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel
|
||||
@TableName(value = "maint_base_role", autoResultMap = true)
|
||||
public class BaseRole implements Serializable {
|
||||
|
||||
private static final Long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@ApiModelProperty(value = "角色")
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* role_id
|
||||
*/
|
||||
@ApiModelProperty(value = "role_id")
|
||||
private String roleId;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@ApiModelProperty(value = "状态,0-默认")
|
||||
private int status;
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.userinfo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 功能模块bean
|
||||
*
|
||||
* @author zyx
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel
|
||||
@TableName(value = "maint_base_user", autoResultMap = true)
|
||||
public class BaseUser implements Serializable {
|
||||
|
||||
private static final Long serialVersionUID = 1L;
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty(value = "编号")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
@ApiModelProperty(value = "账号")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
@ApiModelProperty(value = "省份")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
@ApiModelProperty(value = "角色")
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* 租户
|
||||
*/
|
||||
@ApiModelProperty(value = "租户")
|
||||
private String tenant;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.userinfo.service;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||
|
||||
public interface EbtpUserInfoService {
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public BaseCacheUser getUserInfo(String token);
|
||||
|
||||
/**
|
||||
* 刷新redis缓存的信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean refresh();
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.userinfo.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.AuthorityEntity;
|
||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.service.UserInfoService;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseCacheUser;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.dao.BaseRoleMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.dao.BaseUserMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.entity.BaseRole;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.entity.BaseUser;
|
||||
import com.chinaunicom.mall.ebtp.extend.userinfo.service.EbtpUserInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class EbtpUserInfoServiceImpl implements EbtpUserInfoService {
|
||||
|
||||
@Autowired
|
||||
private UserInfoService service;
|
||||
@Autowired
|
||||
private BaseUserMapper baseUserMapper;
|
||||
@Autowired
|
||||
private BaseRoleMapper baseRoleMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
@Qualifier("cacheRedisTemplate")
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
private static final String EXTEND_USER_KEY = "ebtpUserTableCache";
|
||||
private static final String USERS = "users";
|
||||
private static final String ROLES = "roles";
|
||||
|
||||
@Override
|
||||
public BaseCacheUser getUserInfo(String token) {
|
||||
//查询山分库
|
||||
BaseCacheUser user = service.getUserInfo(token);
|
||||
|
||||
if (Objects.isNull(user)) {
|
||||
return new BaseCacheUser();
|
||||
}
|
||||
|
||||
//获取redis缓存
|
||||
Map<String, Object> userTable = getUserTable();
|
||||
|
||||
//获取用户信息
|
||||
List<BaseUser> users = (List<BaseUser>) userTable.get(USERS);
|
||||
BaseUser baseUser = users.stream().filter(u -> u.getAccount().equals(user.getLoginName())).findFirst().orElse(null);
|
||||
if (Objects.isNull(baseUser)) {
|
||||
return user;
|
||||
}
|
||||
|
||||
List<BaseRole> roles = (List<BaseRole>) userTable.get(ROLES);
|
||||
user.setProvince(baseUser.getProvince())
|
||||
//覆盖角色
|
||||
.setAuthorityList(
|
||||
Optional.of(roles
|
||||
.stream()
|
||||
.filter(r -> baseUser.getRole().contains(r.getRole()))
|
||||
.map(br ->
|
||||
new AuthorityEntity()
|
||||
.setRoleId(br.getRoleId())
|
||||
.setRoleCode(br.getRole())
|
||||
.setRoleName(br.getRemarks())
|
||||
.setRoleScope("EBTP")
|
||||
.setAuthorities(Collections.emptyList()))
|
||||
.collect(Collectors.toList()))
|
||||
.orElseGet(Collections::emptyList));
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> getUserTable() {
|
||||
Object o = redisTemplate.opsForValue().get(EXTEND_USER_KEY);
|
||||
|
||||
if (Objects.isNull(o)) {
|
||||
o = cacheUserTable();
|
||||
}
|
||||
return (Map<String, Object>) o ;
|
||||
}
|
||||
|
||||
private Map<String, Object> cacheUserTable() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(USERS, baseUserMapper.selectList(Wrappers.lambdaQuery(BaseUser.class).eq(BaseUser::getTenant, "ebtp_mall")));
|
||||
map.put(ROLES, baseRoleMapper.selectList(Wrappers.emptyWrapper()));
|
||||
redisTemplate.opsForValue().set(EXTEND_USER_KEY, map, 8, TimeUnit.HOURS);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除token缓存
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean refresh() {
|
||||
cacheUserTable();
|
||||
return true;
|
||||
}
|
||||
|
||||
public EbtpUserInfoServiceImpl() {
|
||||
super();
|
||||
}
|
||||
}
|
@ -36,8 +36,8 @@ spring:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: mall
|
||||
password: unicom
|
||||
jdbc-url: jdbc:mysql://10.125.160.26:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://10.125.160.26:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
jdbc-url: jdbc:mysql://10.125.160.30:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
url: jdbc:mysql://10.125.160.30:3306/ebtp_mall_extend?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
|
||||
filters: stat,wall,log4j
|
||||
maxActive: 20
|
||||
initialSize: 1
|
||||
@ -91,6 +91,12 @@ spring:
|
||||
master: eshop-redis
|
||||
nodes: 10.125.164.124:32718, 10.125.164.118:32716, 10.125.164.121:32716
|
||||
password: Unicom#135
|
||||
database:
|
||||
idempotent: 0
|
||||
sharding: 1
|
||||
cache: 2
|
||||
backup: 3
|
||||
|
||||
|
||||
# 天宫Eureka配置
|
||||
eureka:
|
||||
@ -172,6 +178,8 @@ mconfig:
|
||||
bss:
|
||||
app-id: 2ICalrrQ0F
|
||||
app-secret: 1mb6n6635cJkDb3pEQPUFXc2nRJ8RPaS
|
||||
app-url-test: 10.124.150.230:8000
|
||||
app-url: 10.245.34.209:8000
|
||||
document:
|
||||
clientHttpUrl: http://10.242.31.158:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749
|
||||
|
||||
@ -197,3 +205,14 @@ xxl:
|
||||
port: 18181
|
||||
logpath: /data/applogs/xxl-job/jobhandler
|
||||
logretentiondays: 30
|
||||
client:
|
||||
clientHttpUrl: http://10.242.31.158:8100/auth/oauth/token?grant_type=client_credentials&client_id=bVS46ElU&client_secret=58ea04ba02475c8da2321cc99849d2a10f15b749
|
||||
allow:
|
||||
apis :
|
||||
- ^GET\./?v1/userinfo/get$
|
||||
unifast:
|
||||
sso:
|
||||
public-key: 0428D625CEEB71CE823BD7D78DFEE7B122F2DA5C4D21E32253AD684D0FE21810394A799639C0CDFBFEB535A1DFD6A366A637E582CE0B1466A5FE7858841135DE6B
|
||||
clientId: p6IPukcJ
|
||||
redirectUrl: http://10.125.86.213:18000/redirect
|
||||
getCode.url: http://10.125.86.213:18808/outer/v1.0/sso/decide
|
||||
|
Reference in New Issue
Block a user