oauth
This commit is contained in:
parent
53b52e7ba2
commit
133848976f
|
|
@ -0,0 +1,242 @@
|
|||
package com.bonus.common.houqin.framework.secure;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@JsonIgnoreProperties(
|
||||
ignoreUnknown = true
|
||||
)
|
||||
public class AccessToken {
|
||||
private static final Logger log = LoggerFactory.getLogger(AccessToken.class);
|
||||
@JsonIgnore
|
||||
protected static ObjectMapper objectMapper;
|
||||
@JsonIgnore
|
||||
protected static SecureProperties secureProperties;
|
||||
@JsonIgnore
|
||||
protected static StringRedisTemplate redisTemplate;
|
||||
@JsonIgnore
|
||||
protected static AuthenticationPredicate authenticationPredicate;
|
||||
private String id;
|
||||
private Long subjectId;
|
||||
private String subjectName;
|
||||
private Map<String, String> subjectData = Maps.newHashMap();
|
||||
private String scope;
|
||||
private boolean identified;
|
||||
private long createTime;
|
||||
private long lastTime;
|
||||
|
||||
public static Optional<AccessToken> recovery(String clientToken) {
|
||||
StringRedisTemplate var10000 = redisTemplate;
|
||||
String var10001 = secureProperties.getServer().getStoreKey();
|
||||
clientToken = (String)var10000.boundValueOps(var10001 + ":" + clientToken).get();
|
||||
if (StringUtils.isBlank(clientToken)) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
try {
|
||||
AccessToken existToken = (AccessToken)objectMapper.readValue(clientToken, AccessToken.class);
|
||||
return authenticationPredicate.authenticated(existToken) ? Optional.of(existToken) : Optional.empty();
|
||||
} catch (Exception var2) {
|
||||
log.error("Deserialize exist token error", var2);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AccessToken create(long subjectId) {
|
||||
AccessToken accessToken = create();
|
||||
accessToken.setSubjectId(subjectId);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public static AccessToken create(long subjectId, String subjectName) {
|
||||
AccessToken accessToken = create(subjectId);
|
||||
accessToken.setSubjectName(subjectName);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public static AccessToken create() {
|
||||
AccessToken accessToken = new AccessToken();
|
||||
accessToken.setId(UUID.randomUUID().toString());
|
||||
accessToken.setCreateTime(Instant.now().getEpochSecond());
|
||||
accessToken.setLastTime(Instant.now().getEpochSecond());
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public AccessToken touch() {
|
||||
this.identified = this.isAuthenticated();
|
||||
this.lastTime = Instant.now().getEpochSecond();
|
||||
return this.store();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isAuthenticated() {
|
||||
return this.identified && !this.isExpired();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private boolean isExpired() {
|
||||
return this.lastTime + secureProperties.getExpireAfter() < Instant.now().getEpochSecond();
|
||||
}
|
||||
|
||||
public AccessToken withData(Map<String, String> data) {
|
||||
this.subjectData = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccessToken setData(String name, String value) {
|
||||
this.subjectData.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccessToken removeData(String... keys) {
|
||||
if (ArrayUtil.isEmpty(keys)) {
|
||||
return this;
|
||||
} else {
|
||||
String[] var2 = keys;
|
||||
int var3 = keys.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
String key = var2[var4];
|
||||
this.subjectData.remove(key);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public AccessToken revokeAuthenticate() {
|
||||
this.identified = false;
|
||||
return this.store();
|
||||
}
|
||||
|
||||
public AccessToken authenticate() {
|
||||
if (this.subjectId == null) {
|
||||
throw new RuntimeException("required subjectId is not provide");
|
||||
} else {
|
||||
this.identified = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public AccessToken store() {
|
||||
try {
|
||||
StringRedisTemplate var10000 = redisTemplate;
|
||||
DefaultRedisScript var10001 = new DefaultRedisScript("redis.call('SET',KEYS[1],ARGV[1],'EX',ARGV[3]);redis.call('SET',KEYS[2],ARGV[2],'EX',ARGV[3]);");
|
||||
String[] var10002 = new String[2];
|
||||
String var10005 = secureProperties.getServer().getStoreKey();
|
||||
var10002[0] = var10005 + ":" + this.getId();
|
||||
var10005 = secureProperties.getServer().getSubjectRefTokenKey();
|
||||
var10002[1] = var10005 + ":" + this.getSubjectId() + ":" + this.getId() + ":" + this.getCreateTime();
|
||||
var10000.execute(var10001, Lists.newArrayList(var10002), new Object[]{objectMapper.writeValueAsString(this), this.getId(), String.valueOf(secureProperties.getServer().getTtl())});
|
||||
} catch (Exception var2) {
|
||||
log.error("Token store error", var2);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccessToken bind() {
|
||||
WebContext.get().setAccessToken(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void write() {
|
||||
WebContext.get().getResponse().ifPresent((response) -> {
|
||||
response.setHeader(secureProperties.getTokenSymbol(), this.getId());
|
||||
});
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
try {
|
||||
StringRedisTemplate var10000 = redisTemplate;
|
||||
DefaultRedisScript var10001 = new DefaultRedisScript("redis.call('DEL',KEYS[1],KEYS[2]);");
|
||||
String[] var10002 = new String[2];
|
||||
String var10005 = secureProperties.getServer().getStoreKey();
|
||||
var10002[0] = var10005 + ":" + this.getId();
|
||||
var10005 = secureProperties.getServer().getSubjectRefTokenKey();
|
||||
var10002[1] = var10005 + ":" + this.getSubjectId() + ":" + this.getId() + ":" + this.getCreateTime();
|
||||
var10000.execute(var10001, Lists.newArrayList(var10002), new Object[0]);
|
||||
} catch (Exception var2) {
|
||||
log.error("Token clear error", var2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long getSubjectId() {
|
||||
return this.subjectId;
|
||||
}
|
||||
|
||||
public String getSubjectName() {
|
||||
return this.subjectName;
|
||||
}
|
||||
|
||||
public Map<String, String> getSubjectData() {
|
||||
return this.subjectData;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
public boolean isIdentified() {
|
||||
return this.identified;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public long getLastTime() {
|
||||
return this.lastTime;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setSubjectId(final Long subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectName(final String subjectName) {
|
||||
this.subjectName = subjectName;
|
||||
}
|
||||
|
||||
public void setSubjectData(final Map<String, String> subjectData) {
|
||||
this.subjectData = subjectData;
|
||||
}
|
||||
|
||||
public void setScope(final String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public void setIdentified(final boolean identified) {
|
||||
this.identified = identified;
|
||||
}
|
||||
|
||||
public void setCreateTime(final long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public void setLastTime(final long lastTime) {
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package com.bonus.common.houqin.framework.secure;
|
||||
|
||||
public interface AuthenticationPredicate {
|
||||
boolean authenticated(AccessToken accessToken);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.bonus.common.houqin.framework.secure;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface AuthorizingService {
|
||||
default Set<String> roles(long accountId) {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
|
||||
default Set<String> permissions(long accountId) {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.bonus.common.houqin.framework.secure;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
|
||||
public class PmsCache {
|
||||
private long expireTime;
|
||||
private Set<String> pms;
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isExpired() {
|
||||
return Instant.now().getEpochSecond() > this.expireTime;
|
||||
}
|
||||
|
||||
public long getExpireTime() {
|
||||
return this.expireTime;
|
||||
}
|
||||
|
||||
public Set<String> getPms() {
|
||||
return this.pms;
|
||||
}
|
||||
|
||||
public void setExpireTime(final long expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public void setPms(final Set<String> pms) {
|
||||
this.pms = pms;
|
||||
}
|
||||
|
||||
public PmsCache(final long expireTime, final Set<String> pms) {
|
||||
this.expireTime = expireTime;
|
||||
this.pms = pms;
|
||||
}
|
||||
|
||||
public PmsCache() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
package com.bonus.common.houqin.framework.secure;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.BoundHashOperations;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class SecureManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(SecureManager.class);
|
||||
private static SecureProperties secureProperties;
|
||||
private static StringRedisTemplate redisTemplate;
|
||||
private static AuthorizingService authorizingService;
|
||||
private static ObjectMapper objectMapper;
|
||||
|
||||
private SecureManager() {
|
||||
}
|
||||
|
||||
public static void setSecureProperties(SecureProperties secureProperties) {
|
||||
if (SecureManager.secureProperties == null) {
|
||||
SecureManager.secureProperties = secureProperties;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setRedisTemplate(StringRedisTemplate redisTemplate) {
|
||||
if (SecureManager.redisTemplate == null) {
|
||||
SecureManager.redisTemplate = redisTemplate;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setAuthorizingService(AuthorizingService authorizingService) {
|
||||
if (SecureManager.authorizingService == null) {
|
||||
SecureManager.authorizingService = authorizingService;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setObjectMapper(ObjectMapper objectMapper) {
|
||||
if (SecureManager.objectMapper == null) {
|
||||
SecureManager.objectMapper = objectMapper;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPmsKey(long subjectId) {
|
||||
return "permissions:subject_id:" + subjectId;
|
||||
}
|
||||
|
||||
private static String getRoleKey(long subjectId) {
|
||||
return "roles:subject_id:" + subjectId;
|
||||
}
|
||||
|
||||
public static void clearAllRoleAndPermission() {
|
||||
redisTemplate.delete(secureProperties.getPermissionKey());
|
||||
}
|
||||
|
||||
public static void clearRoleAndPermission(long subjectId) {
|
||||
redisTemplate.boundHashOps(secureProperties.getPermissionKey()).delete(new Object[]{getRoleKey(subjectId), getPmsKey(subjectId)});
|
||||
}
|
||||
|
||||
public static void clearRole(long subjectId) {
|
||||
redisTemplate.boundHashOps(secureProperties.getPermissionKey()).delete(new Object[]{getRoleKey(subjectId)});
|
||||
}
|
||||
|
||||
public static void clearPermission(long subjectId) {
|
||||
redisTemplate.boundHashOps(secureProperties.getPermissionKey()).delete(new Object[]{getPmsKey(subjectId)});
|
||||
}
|
||||
|
||||
public static Set<String> getPermission() {
|
||||
return getPms(SecureManager::getPmsKey, (subjectId) -> {
|
||||
return authorizingService.permissions(subjectId);
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<String> getRole() {
|
||||
return getPms(SecureManager::getRoleKey, (subjectId) -> {
|
||||
return authorizingService.roles(subjectId);
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean hasRole(String... role) {
|
||||
return getRole().containsAll(Arrays.asList(role));
|
||||
}
|
||||
|
||||
public static boolean hasAnyRole(String... role) {
|
||||
Stream var10000 = Stream.of(role);
|
||||
Set var10001 = getRole();
|
||||
Objects.requireNonNull(var10001);
|
||||
return var10000.anyMatch(var10001::contains);
|
||||
}
|
||||
|
||||
public static boolean hasPermission(String... pms) {
|
||||
return getPermission().containsAll(Arrays.asList(pms));
|
||||
}
|
||||
|
||||
public static boolean hasAnyPermission(String... pms) {
|
||||
Stream var10000 = Stream.of(pms);
|
||||
Set var10001 = getPermission();
|
||||
Objects.requireNonNull(var10001);
|
||||
return var10000.anyMatch(var10001::contains);
|
||||
}
|
||||
|
||||
public static boolean isLogin() {
|
||||
return (Boolean)WebContext.get().getAccessToken().map(AccessToken::isAuthenticated).orElse(false);
|
||||
}
|
||||
|
||||
public static Optional<Long> getSubjectId() {
|
||||
return WebContext.get().getAccessToken().map(AccessToken::getSubjectId);
|
||||
}
|
||||
|
||||
public static Optional<String> getSubjectName() {
|
||||
return WebContext.get().getAccessToken().map(AccessToken::getSubjectName);
|
||||
}
|
||||
|
||||
public static Map<String, String> getSubjectData() {
|
||||
return (Map)WebContext.get().getAccessToken().map(AccessToken::getSubjectData).orElse(Maps.newHashMap());
|
||||
}
|
||||
|
||||
public static Map<String, String> attachData(Map<String, String> data) {
|
||||
try {
|
||||
if (MapUtil.isEmpty(data)) {
|
||||
return Maps.newHashMapWithExpectedSize(0);
|
||||
} else {
|
||||
AccessToken accessToken = (AccessToken)WebContext.get().getAccessToken().orElse(AccessToken.create());
|
||||
Objects.requireNonNull(accessToken);
|
||||
data.forEach(accessToken::setData);
|
||||
accessToken.bind().store();
|
||||
return accessToken.getSubjectData();
|
||||
}
|
||||
} catch (Throwable var2) {
|
||||
throw var2;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> attachData(String key, String value) {
|
||||
try {
|
||||
return attachData(Collections.singletonMap(key, value));
|
||||
} catch (Throwable var3) {
|
||||
throw var3;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> removeData(String... key) {
|
||||
try {
|
||||
Optional<AccessToken> accessToken = WebContext.get().getAccessToken();
|
||||
return (Map)(!accessToken.isPresent() ? Maps.newHashMap() : ((AccessToken)accessToken.get()).removeData(key).getSubjectData());
|
||||
} catch (Throwable var2) {
|
||||
throw var2;
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getPms(Function<Long, String> keySupplier, Function<Long, Set<String>> pmsSupplier) {
|
||||
if (!WebContext.get().getAccessToken().isPresent()) {
|
||||
return Sets.newHashSetWithExpectedSize(0);
|
||||
} else {
|
||||
Long subjectId = ((AccessToken)WebContext.get().getAccessToken().get()).getSubjectId();
|
||||
if (subjectId == null) {
|
||||
return Sets.newHashSetWithExpectedSize(0);
|
||||
} else {
|
||||
BoundHashOperations<String, String, String> pmsStore = redisTemplate.boundHashOps(secureProperties.getPermissionKey());
|
||||
String pmsKey = (String)keySupplier.apply(subjectId);
|
||||
if (BooleanUtils.isNotTrue(pmsStore.hasKey(pmsKey))) {
|
||||
Set<String> pms = (Set)pmsSupplier.apply(subjectId);
|
||||
if (pms == null) {
|
||||
pms = Sets.newHashSetWithExpectedSize(0);
|
||||
}
|
||||
|
||||
try {
|
||||
pmsStore.put(pmsKey, objectMapper.writeValueAsString(new PmsCache(Instant.now().plusSeconds(secureProperties.getPermissionTTL()).getEpochSecond(), (Set)pms)));
|
||||
} catch (JsonProcessingException var8) {
|
||||
log.error("Save permission error", var8);
|
||||
}
|
||||
|
||||
return (Set)pms;
|
||||
} else {
|
||||
String permissionValue = (String)pmsStore.get(pmsKey);
|
||||
if (permissionValue == null) {
|
||||
return getPms(keySupplier, pmsSupplier);
|
||||
} else {
|
||||
PmsCache cachedPms;
|
||||
try {
|
||||
cachedPms = (PmsCache)objectMapper.readValue(permissionValue, PmsCache.class);
|
||||
} catch (JsonProcessingException var9) {
|
||||
log.error("Read permission error", var9);
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
|
||||
if (cachedPms.isExpired()) {
|
||||
log.info("Permission cache expired, read new");
|
||||
redisTemplate.boundHashOps(secureProperties.getPermissionKey()).delete(new Object[]{pmsKey});
|
||||
return getPms(keySupplier, pmsSupplier);
|
||||
} else {
|
||||
return cachedPms.getPms();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void logout() {
|
||||
WebContext.get().getAccessToken().ifPresent(AccessToken::clear);
|
||||
}
|
||||
|
||||
public static void revokeAuthenticate() {
|
||||
WebContext.get().getAccessToken().ifPresent((accessToken) -> {
|
||||
accessToken.revokeAuthenticate().store();
|
||||
});
|
||||
}
|
||||
|
||||
public static void revokeAuthenticate(long subjectId, int reservedRecentNum) {
|
||||
StringRedisTemplate var10000 = redisTemplate;
|
||||
String var10001 = secureProperties.getServer().getSubjectRefTokenKey();
|
||||
Set<String> keys = var10000.keys(var10001 + ":" + subjectId + ":*");
|
||||
if (CollectionUtils.size(keys) > reservedRecentNum) {
|
||||
assert keys != null;
|
||||
|
||||
Map<Long, List<String>> createTimeAsc_keys = (Map)keys.stream().collect(Collectors.groupingBy((key) -> {
|
||||
return Long.parseLong(key.split(":")[4]);
|
||||
}, TreeMap::new, Collectors.toList()));
|
||||
List<String> keysAsc = createTimeAsc_keys.values().stream().flatMap(Collection::stream).collect(Collectors.toList());
|
||||
List<String> beDeleteRefKeys = keysAsc.subList(0, keysAsc.size() - reservedRecentNum);
|
||||
List<String> beDeleteTokenKeys = beDeleteRefKeys.stream().map((dk) -> {
|
||||
String var100001 = secureProperties.getServer().getStoreKey();
|
||||
return var100001 + ":" + dk.split(":")[3];
|
||||
}).collect(Collectors.toList());
|
||||
redisTemplate.delete(ListUtils.sum(beDeleteRefKeys, beDeleteTokenKeys));
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "SecureManager()";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,374 @@
|
|||
package com.bonus.common.houqin.framework.secure;
|
||||
|
||||
import cn.hutool.core.codec.Base64Decoder;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@RefreshScope
|
||||
@Component
|
||||
@ConfigurationProperties(
|
||||
prefix = "secure"
|
||||
)
|
||||
public class SecureProperties {
|
||||
public static final String PREFIX = "secure";
|
||||
private boolean enabled = true;
|
||||
private boolean prohibitUnannotatedHandler = false;
|
||||
private String tokenSymbol = "X-Token";
|
||||
private String permissionKey = "secure:pms";
|
||||
private long permissionTTL = 7200L;
|
||||
private long expireAfter = 7200L;
|
||||
private ServerStore server = new ServerStore();
|
||||
private Security security = new Security();
|
||||
private MdcLogParameter mdc = new MdcLogParameter();
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public boolean isProhibitUnannotatedHandler() {
|
||||
return this.prohibitUnannotatedHandler;
|
||||
}
|
||||
|
||||
public String getTokenSymbol() {
|
||||
return this.tokenSymbol;
|
||||
}
|
||||
|
||||
public String getPermissionKey() {
|
||||
return this.permissionKey;
|
||||
}
|
||||
|
||||
public long getPermissionTTL() {
|
||||
return this.permissionTTL;
|
||||
}
|
||||
|
||||
public long getExpireAfter() {
|
||||
return this.expireAfter;
|
||||
}
|
||||
|
||||
public ServerStore getServer() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
public Security getSecurity() {
|
||||
return this.security;
|
||||
}
|
||||
|
||||
public MdcLogParameter getMdc() {
|
||||
return this.mdc;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setProhibitUnannotatedHandler(final boolean prohibitUnannotatedHandler) {
|
||||
this.prohibitUnannotatedHandler = prohibitUnannotatedHandler;
|
||||
}
|
||||
|
||||
public void setTokenSymbol(final String tokenSymbol) {
|
||||
this.tokenSymbol = tokenSymbol;
|
||||
}
|
||||
|
||||
public void setPermissionKey(final String permissionKey) {
|
||||
this.permissionKey = permissionKey;
|
||||
}
|
||||
|
||||
public void setPermissionTTL(final long permissionTTL) {
|
||||
this.permissionTTL = permissionTTL;
|
||||
}
|
||||
|
||||
public void setExpireAfter(final long expireAfter) {
|
||||
this.expireAfter = expireAfter;
|
||||
}
|
||||
|
||||
public void setServer(final ServerStore server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public void setSecurity(final Security security) {
|
||||
this.security = security;
|
||||
}
|
||||
|
||||
public void setMdc(final MdcLogParameter mdc) {
|
||||
this.mdc = mdc;
|
||||
}
|
||||
|
||||
public static class ServerStore {
|
||||
private String storeKey = "secure:token";
|
||||
private String subjectRefTokenKey = "secure:subject-token";
|
||||
private long ttl = 14400L;
|
||||
|
||||
public String getStoreKey() {
|
||||
return this.storeKey;
|
||||
}
|
||||
|
||||
public String getSubjectRefTokenKey() {
|
||||
return this.subjectRefTokenKey;
|
||||
}
|
||||
|
||||
public long getTtl() {
|
||||
return this.ttl;
|
||||
}
|
||||
|
||||
public void setStoreKey(final String storeKey) {
|
||||
this.storeKey = storeKey;
|
||||
}
|
||||
|
||||
public void setSubjectRefTokenKey(final String subjectRefTokenKey) {
|
||||
this.subjectRefTokenKey = subjectRefTokenKey;
|
||||
}
|
||||
|
||||
public void setTtl(final long ttl) {
|
||||
this.ttl = ttl;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Security {
|
||||
private String encryptUriPrefix = "/security";
|
||||
private String keyExchangePath = "/exchange/key";
|
||||
private String publicKeyExchangePath = "/exchange/public-key";
|
||||
private Set<String> ignoredUri = Sets.newHashSet();
|
||||
private String requestBodySignParamName = "body";
|
||||
private String clientKeySignParamName = "clientKey";
|
||||
private Set<String> addonSignHeaderPrefix = Sets.newHashSet(new String[]{"X-Security-Ext"});
|
||||
private Set<String> tokenHeaderNames = Sets.newHashSet(new String[]{"X-Security-Token", "X-Security-Tenant-Id", "X-Security-Sn"});
|
||||
private String tokenSignHeaderName = "X-Security-Token-Sign";
|
||||
private String serverKeySignParamName = "serverKey";
|
||||
private String serverSm4Key = "McaCOPft5/J3bUG4pdVjhg==";
|
||||
private byte[] serverSm4KeyBytes;
|
||||
private String serverSm2Key;
|
||||
private byte[] serverSm2KeyBytes;
|
||||
private String clientSm2Key;
|
||||
private byte[] clientSm2KeyBytes;
|
||||
private String timestampHeaderName;
|
||||
private String nonceHeaderName;
|
||||
private String signHeaderName;
|
||||
private String serverEncryptedClientKeyHeaderName;
|
||||
private long maxWindowSeconds;
|
||||
private String playKey;
|
||||
|
||||
public void setServerSm4Key(String serverSm4Key) {
|
||||
this.serverSm4Key = serverSm4Key;
|
||||
this.serverSm4KeyBytes = Base64Decoder.decode(serverSm4Key);
|
||||
}
|
||||
|
||||
public Security() {
|
||||
this.serverSm4KeyBytes = Base64Decoder.decode(this.serverSm4Key);
|
||||
this.serverSm2Key = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgCtqk5Jj7pPWh91d9mPA4Kd7fOfzBULrnAERNDV+4XBCgCgYIKoEcz1UBgi2hRANCAARykhB6sXHWTbB60Pr+laPqEP5JBRpEcySONKKP5Q03o/g3OpnQXc7aVMdLUxL8wD1wQHEu4KHmHQr7jvVt0rkM";
|
||||
this.serverSm2KeyBytes = Base64Decoder.decode(this.serverSm2Key);
|
||||
this.clientSm2Key = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEcpIQerFx1k2wetD6/pWj6hD+SQUaRHMkjjSij+UNN6P4NzqZ0F3O2lTHS1MS/MA9cEBxLuCh5h0K+471bdK5DA==";
|
||||
this.clientSm2KeyBytes = Base64Decoder.decode(this.serverSm2Key);
|
||||
this.timestampHeaderName = "X-Security-Timestamp";
|
||||
this.nonceHeaderName = "X-Security-Nonce";
|
||||
this.signHeaderName = "X-Security-Sign";
|
||||
this.serverEncryptedClientKeyHeaderName = "X-Security-Server-Encrypted-Client-Key";
|
||||
this.maxWindowSeconds = 90L;
|
||||
this.playKey = "__play:";
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String serverSm2Key = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgCtqk5Jj7pPWh91d9mPA4Kd7fOfzBULrnAERNDV+4XBCgCgYIKoEcz1UBgi2hRANCAARykhB6sXHWTbB60Pr+laPqEP5JBRpEcySONKKP5Q03o/g3OpnQXc7aVMdLUxL8wD1wQHEu4KHmHQr7jvVt0rkM";
|
||||
System.out.println(Base64Decoder.decode(serverSm2Key));
|
||||
String clientSm2Key = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEcpIQerFx1k2wetD6/pWj6hD+SQUaRHMkjjSij+UNN6P4NzqZ0F3O2lTHS1MS/MA9cEBxLuCh5h0K+471bdK5DA==";
|
||||
System.out.println(Base64Decoder.decode(clientSm2Key));
|
||||
}
|
||||
|
||||
public String getEncryptUriPrefix() {
|
||||
return this.encryptUriPrefix;
|
||||
}
|
||||
|
||||
public String getKeyExchangePath() {
|
||||
return this.keyExchangePath;
|
||||
}
|
||||
|
||||
public String getPublicKeyExchangePath() {
|
||||
return this.publicKeyExchangePath;
|
||||
}
|
||||
|
||||
public Set<String> getIgnoredUri() {
|
||||
return this.ignoredUri;
|
||||
}
|
||||
|
||||
public String getRequestBodySignParamName() {
|
||||
return this.requestBodySignParamName;
|
||||
}
|
||||
|
||||
public String getClientKeySignParamName() {
|
||||
return this.clientKeySignParamName;
|
||||
}
|
||||
|
||||
public Set<String> getAddonSignHeaderPrefix() {
|
||||
return this.addonSignHeaderPrefix;
|
||||
}
|
||||
|
||||
public Set<String> getTokenHeaderNames() {
|
||||
return this.tokenHeaderNames;
|
||||
}
|
||||
|
||||
public String getTokenSignHeaderName() {
|
||||
return this.tokenSignHeaderName;
|
||||
}
|
||||
|
||||
public String getServerKeySignParamName() {
|
||||
return this.serverKeySignParamName;
|
||||
}
|
||||
|
||||
public String getServerSm4Key() {
|
||||
return this.serverSm4Key;
|
||||
}
|
||||
|
||||
public byte[] getServerSm4KeyBytes() {
|
||||
return this.serverSm4KeyBytes;
|
||||
}
|
||||
|
||||
public String getServerSm2Key() {
|
||||
return this.serverSm2Key;
|
||||
}
|
||||
|
||||
public byte[] getServerSm2KeyBytes() {
|
||||
return this.serverSm2KeyBytes;
|
||||
}
|
||||
|
||||
public String getClientSm2Key() {
|
||||
return this.clientSm2Key;
|
||||
}
|
||||
|
||||
public byte[] getClientSm2KeyBytes() {
|
||||
return this.clientSm2KeyBytes;
|
||||
}
|
||||
|
||||
public String getTimestampHeaderName() {
|
||||
return this.timestampHeaderName;
|
||||
}
|
||||
|
||||
public String getNonceHeaderName() {
|
||||
return this.nonceHeaderName;
|
||||
}
|
||||
|
||||
public String getSignHeaderName() {
|
||||
return this.signHeaderName;
|
||||
}
|
||||
|
||||
public String getServerEncryptedClientKeyHeaderName() {
|
||||
return this.serverEncryptedClientKeyHeaderName;
|
||||
}
|
||||
|
||||
public long getMaxWindowSeconds() {
|
||||
return this.maxWindowSeconds;
|
||||
}
|
||||
|
||||
public String getPlayKey() {
|
||||
return this.playKey;
|
||||
}
|
||||
|
||||
public void setEncryptUriPrefix(final String encryptUriPrefix) {
|
||||
this.encryptUriPrefix = encryptUriPrefix;
|
||||
}
|
||||
|
||||
public void setKeyExchangePath(final String keyExchangePath) {
|
||||
this.keyExchangePath = keyExchangePath;
|
||||
}
|
||||
|
||||
public void setPublicKeyExchangePath(final String publicKeyExchangePath) {
|
||||
this.publicKeyExchangePath = publicKeyExchangePath;
|
||||
}
|
||||
|
||||
public void setIgnoredUri(final Set<String> ignoredUri) {
|
||||
this.ignoredUri = ignoredUri;
|
||||
}
|
||||
|
||||
public void setRequestBodySignParamName(final String requestBodySignParamName) {
|
||||
this.requestBodySignParamName = requestBodySignParamName;
|
||||
}
|
||||
|
||||
public void setClientKeySignParamName(final String clientKeySignParamName) {
|
||||
this.clientKeySignParamName = clientKeySignParamName;
|
||||
}
|
||||
|
||||
public void setAddonSignHeaderPrefix(final Set<String> addonSignHeaderPrefix) {
|
||||
this.addonSignHeaderPrefix = addonSignHeaderPrefix;
|
||||
}
|
||||
|
||||
public void setTokenHeaderNames(final Set<String> tokenHeaderNames) {
|
||||
this.tokenHeaderNames = tokenHeaderNames;
|
||||
}
|
||||
|
||||
public void setTokenSignHeaderName(final String tokenSignHeaderName) {
|
||||
this.tokenSignHeaderName = tokenSignHeaderName;
|
||||
}
|
||||
|
||||
public void setServerKeySignParamName(final String serverKeySignParamName) {
|
||||
this.serverKeySignParamName = serverKeySignParamName;
|
||||
}
|
||||
|
||||
public void setServerSm4KeyBytes(final byte[] serverSm4KeyBytes) {
|
||||
this.serverSm4KeyBytes = serverSm4KeyBytes;
|
||||
}
|
||||
|
||||
public void setServerSm2Key(final String serverSm2Key) {
|
||||
this.serverSm2Key = serverSm2Key;
|
||||
}
|
||||
|
||||
public void setServerSm2KeyBytes(final byte[] serverSm2KeyBytes) {
|
||||
this.serverSm2KeyBytes = serverSm2KeyBytes;
|
||||
}
|
||||
|
||||
public void setClientSm2Key(final String clientSm2Key) {
|
||||
this.clientSm2Key = clientSm2Key;
|
||||
}
|
||||
|
||||
public void setClientSm2KeyBytes(final byte[] clientSm2KeyBytes) {
|
||||
this.clientSm2KeyBytes = clientSm2KeyBytes;
|
||||
}
|
||||
|
||||
public void setTimestampHeaderName(final String timestampHeaderName) {
|
||||
this.timestampHeaderName = timestampHeaderName;
|
||||
}
|
||||
|
||||
public void setNonceHeaderName(final String nonceHeaderName) {
|
||||
this.nonceHeaderName = nonceHeaderName;
|
||||
}
|
||||
|
||||
public void setSignHeaderName(final String signHeaderName) {
|
||||
this.signHeaderName = signHeaderName;
|
||||
}
|
||||
|
||||
public void setServerEncryptedClientKeyHeaderName(final String serverEncryptedClientKeyHeaderName) {
|
||||
this.serverEncryptedClientKeyHeaderName = serverEncryptedClientKeyHeaderName;
|
||||
}
|
||||
|
||||
public void setMaxWindowSeconds(final long maxWindowSeconds) {
|
||||
this.maxWindowSeconds = maxWindowSeconds;
|
||||
}
|
||||
|
||||
public void setPlayKey(final String playKey) {
|
||||
this.playKey = playKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class MdcLogParameter {
|
||||
private String subjectId = "x-id";
|
||||
private String subjectName = "x-name";
|
||||
|
||||
public String getSubjectId() {
|
||||
return this.subjectId;
|
||||
}
|
||||
|
||||
public String getSubjectName() {
|
||||
return this.subjectName;
|
||||
}
|
||||
|
||||
public void setSubjectId(final String subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectName(final String subjectName) {
|
||||
this.subjectName = subjectName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.bonus.common.houqin.framework.secure;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class WebContext {
|
||||
private static final ThreadLocal<Context> THREAD_CONTEXT = new InheritableThreadLocal<Context>() {
|
||||
protected Context initialValue() {
|
||||
return new Context();
|
||||
}
|
||||
};
|
||||
|
||||
private WebContext() {
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
THREAD_CONTEXT.remove();
|
||||
}
|
||||
|
||||
public static Context get() {
|
||||
return (Context)THREAD_CONTEXT.get();
|
||||
}
|
||||
|
||||
public static void set(Context context) {
|
||||
THREAD_CONTEXT.set(context);
|
||||
}
|
||||
|
||||
public static class Context {
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
private AccessToken accessToken;
|
||||
private Map<String, Object> attributes = Maps.newHashMap();
|
||||
|
||||
public Context(HttpServletRequest request, HttpServletResponse response) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public void setAttribute(String key, Object data) {
|
||||
this.attributes.put(key, data);
|
||||
}
|
||||
|
||||
public Object getAttribute(String key) {
|
||||
return this.attributes.get(key);
|
||||
}
|
||||
|
||||
public void removeAttribute(String key) {
|
||||
this.attributes.remove(key);
|
||||
}
|
||||
|
||||
public void clearAttribute() {
|
||||
this.attributes.clear();
|
||||
}
|
||||
|
||||
public Optional<AccessToken> getAccessToken() {
|
||||
return Optional.ofNullable(this.accessToken);
|
||||
}
|
||||
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(this.request);
|
||||
}
|
||||
|
||||
public Optional<HttpServletResponse> getResponse() {
|
||||
return Optional.ofNullable(this.response);
|
||||
}
|
||||
|
||||
public Map<String, Object> getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
public void setRequest(final HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public void setResponse(final HttpServletResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public void setAccessToken(final AccessToken accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public void setAttributes(final Map<String, Object> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public Context() {
|
||||
}
|
||||
|
||||
public Context(final HttpServletRequest request, final HttpServletResponse response, final AccessToken accessToken, final Map<String, Object> attributes) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
this.accessToken = accessToken;
|
||||
this.attributes = attributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bonus.canteen.core.auth.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(
|
||||
prefix = "system.login"
|
||||
)
|
||||
public class LoginProperties {
|
||||
public static final String PREFIX = "system.login";
|
||||
private Integer reservedRecentNum;
|
||||
|
||||
public Integer getReservedRecentNum() {
|
||||
return this.reservedRecentNum;
|
||||
}
|
||||
|
||||
public void setReservedRecentNum(final Integer reservedRecentNum) {
|
||||
this.reservedRecentNum = reservedRecentNum;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "LoginProperties(reservedRecentNum=" + this.getReservedRecentNum() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
package com.bonus.canteen.core.auth.menu.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("菜单树")
|
||||
public class MgrMenuTreeVO {
|
||||
@TableId
|
||||
@ApiModelProperty("菜单id")
|
||||
private Long menuId;
|
||||
@ApiModelProperty("编码")
|
||||
private String menuCode;
|
||||
@ApiModelProperty("菜单名称")
|
||||
private @NotBlank(
|
||||
message = "菜单名称不能为空"
|
||||
) String name;
|
||||
@ApiModelProperty("菜单父id")
|
||||
private @NotNull(
|
||||
message = "菜单父ID不能为空"
|
||||
) Long parentId;
|
||||
@ApiModelProperty("删除标记")
|
||||
private Integer delFlag;
|
||||
@ApiModelProperty("是否默认选中")
|
||||
private Integer ifDefault;
|
||||
@ApiModelProperty("排序号")
|
||||
private Integer sort;
|
||||
@ApiModelProperty("是否有子级")
|
||||
private Integer hasChildren;
|
||||
@ApiModelProperty("节点状态:1全选;2半选")
|
||||
private Integer halfSelect;
|
||||
@ApiModelProperty("0:菜单;1:按钮;2:目录")
|
||||
private Integer type;
|
||||
@ApiModelProperty("页面是否缓存(1缓存 2不缓存)")
|
||||
private Integer ifCache;
|
||||
@ApiModelProperty("菜单状态(1显示 2隐藏)")
|
||||
private Integer ifVisible;
|
||||
@ApiModelProperty("组件路径")
|
||||
private String component;
|
||||
@ApiModelProperty("菜单图标")
|
||||
private String icon;
|
||||
@ApiModelProperty("菜单归属类型:1:web,2:app")
|
||||
private Integer webType;
|
||||
|
||||
public Long getMenuId() {
|
||||
return this.menuId;
|
||||
}
|
||||
|
||||
public String getMenuCode() {
|
||||
return this.menuCode;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
return this.delFlag;
|
||||
}
|
||||
|
||||
public Integer getIfDefault() {
|
||||
return this.ifDefault;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return this.sort;
|
||||
}
|
||||
|
||||
public Integer getHasChildren() {
|
||||
return this.hasChildren;
|
||||
}
|
||||
|
||||
public Integer getHalfSelect() {
|
||||
return this.halfSelect;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Integer getIfCache() {
|
||||
return this.ifCache;
|
||||
}
|
||||
|
||||
public Integer getIfVisible() {
|
||||
return this.ifVisible;
|
||||
}
|
||||
|
||||
public String getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public Integer getWebType() {
|
||||
return this.webType;
|
||||
}
|
||||
|
||||
public void setMenuId(final Long menuId) {
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
public void setMenuCode(final String menuCode) {
|
||||
this.menuCode = menuCode;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setParentId(final Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public void setDelFlag(final Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public void setIfDefault(final Integer ifDefault) {
|
||||
this.ifDefault = ifDefault;
|
||||
}
|
||||
|
||||
public void setSort(final Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public void setHasChildren(final Integer hasChildren) {
|
||||
this.hasChildren = hasChildren;
|
||||
}
|
||||
|
||||
public void setHalfSelect(final Integer halfSelect) {
|
||||
this.halfSelect = halfSelect;
|
||||
}
|
||||
|
||||
public void setType(final Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setIfCache(final Integer ifCache) {
|
||||
this.ifCache = ifCache;
|
||||
}
|
||||
|
||||
public void setIfVisible(final Integer ifVisible) {
|
||||
this.ifVisible = ifVisible;
|
||||
}
|
||||
|
||||
public void setComponent(final String component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public void setIcon(final String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public void setWebType(final Integer webType) {
|
||||
this.webType = webType;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getMenuId();
|
||||
return "MgrMenuTreeVO(menuId=" + var10000 + ", menuCode=" + this.getMenuCode() + ", name=" + this.getName() + ", parentId=" + this.getParentId() + ", delFlag=" + this.getDelFlag() + ", ifDefault=" + this.getIfDefault() + ", sort=" + this.getSort() + ", hasChildren=" + this.getHasChildren() + ", halfSelect=" + this.getHalfSelect() + ", type=" + this.getType() + ", ifCache=" + this.getIfCache() + ", ifVisible=" + this.getIfVisible() + ", component=" + this.getComponent() + ", icon=" + this.getIcon() + ", webType=" + this.getWebType() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
package com.bonus.canteen.core.auth.menu.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("菜单")
|
||||
public class MgrMenuVO {
|
||||
@ApiModelProperty("菜单ID")
|
||||
private String menuId;
|
||||
@ApiModelProperty("编码")
|
||||
private String menuCode;
|
||||
@ApiModelProperty("菜单名称")
|
||||
private @NotBlank(
|
||||
message = "菜单名称不能为空"
|
||||
) String name;
|
||||
@ApiModelProperty("菜单父id")
|
||||
private @NotNull(
|
||||
message = "菜单父ID不能为空"
|
||||
) Long parentId;
|
||||
@ApiModelProperty("删除标记")
|
||||
private Integer delFlag;
|
||||
@ApiModelProperty("是否默认选中")
|
||||
private Integer ifDefault;
|
||||
@ApiModelProperty("排序号")
|
||||
private Integer sort;
|
||||
@ApiModelProperty("0:菜单;1:按钮;2:目录")
|
||||
private Integer type;
|
||||
@ApiModelProperty("页面是否缓存(1缓存 2不缓存)")
|
||||
private Integer ifCache;
|
||||
@ApiModelProperty("菜单状态(1显示 2隐藏)")
|
||||
private Integer ifVisible;
|
||||
@ApiModelProperty("组件路径")
|
||||
private String component;
|
||||
@ApiModelProperty("菜单图标")
|
||||
private String icon;
|
||||
@ApiModelProperty("菜单归属类型:1:web,2:app")
|
||||
private Integer webType;
|
||||
|
||||
public String getMenuId() {
|
||||
return this.menuId;
|
||||
}
|
||||
|
||||
public String getMenuCode() {
|
||||
return this.menuCode;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
return this.delFlag;
|
||||
}
|
||||
|
||||
public Integer getIfDefault() {
|
||||
return this.ifDefault;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return this.sort;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public Integer getIfCache() {
|
||||
return this.ifCache;
|
||||
}
|
||||
|
||||
public Integer getIfVisible() {
|
||||
return this.ifVisible;
|
||||
}
|
||||
|
||||
public String getComponent() {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
public Integer getWebType() {
|
||||
return this.webType;
|
||||
}
|
||||
|
||||
public void setMenuId(final String menuId) {
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
public void setMenuCode(final String menuCode) {
|
||||
this.menuCode = menuCode;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setParentId(final Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public void setDelFlag(final Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public void setIfDefault(final Integer ifDefault) {
|
||||
this.ifDefault = ifDefault;
|
||||
}
|
||||
|
||||
public void setSort(final Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public void setType(final Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setIfCache(final Integer ifCache) {
|
||||
this.ifCache = ifCache;
|
||||
}
|
||||
|
||||
public void setIfVisible(final Integer ifVisible) {
|
||||
this.ifVisible = ifVisible;
|
||||
}
|
||||
|
||||
public void setComponent(final String component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public void setIcon(final String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public void setWebType(final Integer webType) {
|
||||
this.webType = webType;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String var10000 = this.getMenuId();
|
||||
return "MgrMenuVO(menuId=" + var10000 + ", menuCode=" + this.getMenuCode() + ", name=" + this.getName() + ", parentId=" + this.getParentId() + ", delFlag=" + this.getDelFlag() + ", ifDefault=" + this.getIfDefault() + ", sort=" + this.getSort() + ", type=" + this.getType() + ", ifCache=" + this.getIfCache() + ", ifVisible=" + this.getIfVisible() + ", component=" + this.getComponent() + ", icon=" + this.getIcon() + ", webType=" + this.getWebType() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -8,15 +8,21 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bonus.canteen.core.config.SecureProperties;
|
||||
import com.bonus.canteen.core.auth.oauth.util.OAuthUtil;
|
||||
import com.bonus.canteen.core.auth.user.dto.MgrUserLoginDTO;
|
||||
import com.bonus.canteen.core.auth.user.service.MgrUserService;
|
||||
import com.bonus.canteen.core.config.SmUtils;
|
||||
import com.bonus.canteen.core.customer.model.PigxUser;
|
||||
import com.bonus.canteen.core.device.mq.MacMessageService;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.houqin.framework.secure.SecureProperties;
|
||||
import com.google.common.base.Joiner;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.bonus.canteen.core.auth.oauth.vo.DeviceLoginResponseVo;
|
||||
import com.bonus.canteen.core.common.utils.HeaderFetchUtil;
|
||||
import com.bonus.common.houqin.framework.secure.AccessToken;
|
||||
import com.bonus.common.houqin.framework.secure.WebContext;
|
||||
import com.bonus.canteen.core.device.manage.controller.deprecated.vo.MessageConfigVO;
|
||||
import com.bonus.canteen.core.device.manage.model.DeviceInfoInSystem;
|
||||
import com.bonus.canteen.core.device.manage.service.DeviceInfoService;
|
||||
|
|
@ -44,8 +50,8 @@ public class AuthController {
|
|||
private static final String HEADER_SECURITY_TENANT_ID = "X-Security-Tenant-Id";
|
||||
private static final String HEADER_SECURITY_TOKEN = "X-Security-Token";
|
||||
private static final String HEADER_SECURITY_SN = "X-Security-Sn";
|
||||
// @Autowired
|
||||
// private MgrUserService mgrUserService;
|
||||
@Autowired
|
||||
private MgrUserService mgrUserService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private MercMerchantApi mercMerchantApi;
|
||||
|
|
@ -90,29 +96,29 @@ public class AuthController {
|
|||
//
|
||||
// return LeResponse.succ(object);
|
||||
// }
|
||||
//
|
||||
// @PostMapping({"/token"})
|
||||
// @RequiresGuest
|
||||
// @ApiOperation("设备登陆接口登陆")
|
||||
// public LeResponse<JSONObject> login(@RequestParam String content) {
|
||||
// MgrUserLoginDTO loginDTO = (MgrUserLoginDTO)JSON.parseObject(content, MgrUserLoginDTO.class);
|
||||
//
|
||||
// JSONObject object;
|
||||
// try {
|
||||
// PigxUser user = this.mgrUserService.login(loginDTO);
|
||||
// object = JSON.parseObject(JSON.toJSONString(user));
|
||||
// object.put("user_id", user.getId());
|
||||
// object.put("merchant_id", user.getMerchantId());
|
||||
// if (WebContext.get().getAccessToken().isPresent()) {
|
||||
// object.put("securityTokenSign", OAuthUtil.responseSetSecurityTokenSign(user.getMerchantId(), ((AccessToken)WebContext.get().getAccessToken().get()).getId()));
|
||||
// }
|
||||
// } catch (LeCheckedException var5) {
|
||||
// return LeResponse.fail(var5.getMessage());
|
||||
// }
|
||||
//
|
||||
// return LeResponse.succ(object);
|
||||
// }
|
||||
//
|
||||
|
||||
@PostMapping({"/token"})
|
||||
@ApiOperation("设备登陆接口登陆")
|
||||
public AjaxResult login(@RequestParam String content) {
|
||||
MgrUserLoginDTO loginDTO = (MgrUserLoginDTO)JSON.parseObject(content, MgrUserLoginDTO.class);
|
||||
|
||||
JSONObject object;
|
||||
try {
|
||||
PigxUser user = this.mgrUserService.login(loginDTO);
|
||||
object = JSON.parseObject(JSON.toJSONString(user));
|
||||
object.put("user_id", user.getId());
|
||||
object.put("merchant_id", user.getMerchantId());
|
||||
if (WebContext.get().getAccessToken().isPresent()) {
|
||||
object.put("securityTokenSign", OAuthUtil.responseSetSecurityTokenSign(user.getMerchantId(),
|
||||
((AccessToken)WebContext.get().getAccessToken().get()).getId()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
|
||||
return AjaxResult.success(object);
|
||||
}
|
||||
|
||||
// @DeleteMapping({"/logOut"})
|
||||
// @RequiresAuthentication
|
||||
// @ApiOperation("退出登陆")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
package com.bonus.canteen.core.auth.oauth.util;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.bonus.canteen.core.common.utils.SpringContextHolder;
|
||||
import com.bonus.common.houqin.framework.secure.SecureProperties;
|
||||
import com.bonus.canteen.core.config.SmUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import com.bonus.common.houqin.framework.secure.WebContext;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class OAuthUtil {
|
||||
private static final String HEADER_SECURITY_TENANT_ID = "X-Security-Tenant-Id";
|
||||
private static final String HEADER_SECURITY_TOKEN = "X-Security-Token";
|
||||
@Lazy
|
||||
private static final SecureProperties secureProperties = (SecureProperties) SpringContextHolder.getBean(SecureProperties.class);
|
||||
|
||||
private OAuthUtil() {
|
||||
}
|
||||
|
||||
public static String responseSetSecurityTokenSign(Long merchantId, String token) {
|
||||
TreeMap<String, String> needSignMap = new TreeMap();
|
||||
String securityTokenSign = null;
|
||||
if (WebContext.get().getRequest().isPresent()) {
|
||||
String encryptKey = ((HttpServletRequest)WebContext.get().getRequest().get()).getHeader(secureProperties.getSecurity().getServerEncryptedClientKeyHeaderName());
|
||||
if (ObjectUtil.isNotNull(encryptKey)) {
|
||||
if (ObjectUtil.isNotNull(merchantId)) {
|
||||
needSignMap.put("X-Security-Tenant-Id", String.valueOf(merchantId));
|
||||
}
|
||||
|
||||
needSignMap.put("X-Security-Token", token);
|
||||
String serverEncryptedClientKey = ((HttpServletRequest)WebContext.get().getRequest().get()).getHeader(secureProperties.getSecurity().getServerEncryptedClientKeyHeaderName());
|
||||
String clientKey = SmUtils.decryptBySm4WithServerKey(serverEncryptedClientKey);
|
||||
securityTokenSign = SmUtils.signAuthTokenBySm3(needSignMap, clientKey);
|
||||
}
|
||||
}
|
||||
|
||||
return securityTokenSign;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.canteen.core.auth.po;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class AuthOpsExpireMsgPO {
|
||||
@ApiModelProperty("tokenId")
|
||||
private String accessTokenId;
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
public String getAccessTokenId() {
|
||||
return this.accessTokenId;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public void setAccessTokenId(final String accessTokenId) {
|
||||
this.accessTokenId = accessTokenId;
|
||||
}
|
||||
|
||||
public void setUserId(final Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String var10000 = this.getAccessTokenId();
|
||||
return "AuthOpsExpireMsgPO(accessTokenId=" + var10000 + ", userId=" + this.getUserId() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.bonus.canteen.core.auth.role.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@TableName("mgr_role_menu")
|
||||
@ApiModel("角色菜单表")
|
||||
public class MgrRoleMenu extends Model<MgrRoleMenu> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("角色ID")
|
||||
private Long roleId;
|
||||
@ApiModelProperty("菜单ID")
|
||||
private Long menuId;
|
||||
@ApiModelProperty("节点状态:1全选;2半选")
|
||||
private Integer halfSelect;
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public Long getMenuId() {
|
||||
return this.menuId;
|
||||
}
|
||||
|
||||
public Integer getHalfSelect() {
|
||||
return this.halfSelect;
|
||||
}
|
||||
|
||||
public void setRoleId(final Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public void setMenuId(final Long menuId) {
|
||||
this.menuId = menuId;
|
||||
}
|
||||
|
||||
public void setHalfSelect(final Integer halfSelect) {
|
||||
this.halfSelect = halfSelect;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getRoleId();
|
||||
return "MgrRoleMenu(roleId=" + var10000 + ", menuId=" + this.getMenuId() + ", halfSelect=" + this.getHalfSelect() + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.bonus.canteen.core.auth.role.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.auth.menu.vo.MgrMenuTreeVO;
|
||||
import com.bonus.canteen.core.auth.menu.vo.MgrMenuVO;
|
||||
import com.bonus.canteen.core.auth.role.entity.MgrRoleMenu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MgrRoleMenuMapper extends BaseMapper<MgrRoleMenu> {
|
||||
int insertBatch(@Param("roleId") Long roleId, @Param("menus") List<Long> menus);
|
||||
|
||||
List<MgrMenuVO> listPermissions(@Param("userId") Long userId);
|
||||
|
||||
List<MgrMenuVO> listPermissionsByRoleCode(@Param("userId") Long userId, @Param("roleCode") String roleCode);
|
||||
|
||||
List<MgrMenuTreeVO> getTenantMenu(@Param("excludeMiddle") Integer excludeMiddle, @Param("userId") Long userId, @Param("isAdmin") boolean isAdmin);
|
||||
|
||||
List<MgrMenuTreeVO> listMenuListByRoleCode(@Param("userId") Long userId, @Param("roleCode") String roleCode, @Param("webType") Integer webType, @Param("typeList") List<Integer> typeList);
|
||||
|
||||
void clearUnUsedPermissions();
|
||||
|
||||
void insertBatchNew(@Param("insertList") List<MgrRoleMenu> insertList);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.bonus.canteen.core.auth.user.business;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.canteen.core.auth.user.dto.MgrUserLoginDTO;
|
||||
import com.bonus.canteen.core.common.custom.business.CustomBusiness;
|
||||
import com.bonus.canteen.core.customer.model.PigxUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MgrUserBurialPointBusiness implements CustomBusiness {
|
||||
public String name() {
|
||||
return "操作员";
|
||||
}
|
||||
|
||||
public List<CustomBusiness.Version> versions() {
|
||||
return CollUtil.newArrayList(new CustomBusiness.Version[]{CustomBusiness.Version.of("5.6.8", "初版")});
|
||||
}
|
||||
|
||||
public String didBeforeLogin(MgrUserLoginDTO loginDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public PigxUser didBeforeAppAccountLogin(MgrUserLoginDTO loginDTO) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package com.bonus.canteen.core.auth.user.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.bonus.canteen.core.auth.user.entity.MgrUser;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
|
||||
@ApiModel("用户信息")
|
||||
public class MgrUserInfo implements Serializable {
|
||||
@ApiModelProperty("用户基本信息")
|
||||
private MgrUser mgrUser;
|
||||
private Long tenantId;
|
||||
@ApiModelProperty("食堂类范围id")
|
||||
private Long canteenEffId;
|
||||
@ApiModelProperty("人员类范围id")
|
||||
private Long custEffId;
|
||||
@ApiModelProperty("菜品类范围id")
|
||||
private Long dishesEffId;
|
||||
@ApiModelProperty("角色标识")
|
||||
private String roleCode;
|
||||
@ApiModelProperty("权限标识集合")
|
||||
private Set<String> permissions;
|
||||
@ApiModelProperty("角色标识集合")
|
||||
private Set<String> roles;
|
||||
|
||||
public MgrUser getMgrUser() {
|
||||
return this.mgrUser;
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
public Long getCanteenEffId() {
|
||||
return this.canteenEffId;
|
||||
}
|
||||
|
||||
public Long getCustEffId() {
|
||||
return this.custEffId;
|
||||
}
|
||||
|
||||
public Long getDishesEffId() {
|
||||
return this.dishesEffId;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return this.roleCode;
|
||||
}
|
||||
|
||||
public Set<String> getPermissions() {
|
||||
return this.permissions;
|
||||
}
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return this.roles;
|
||||
}
|
||||
|
||||
public void setMgrUser(final MgrUser mgrUser) {
|
||||
this.mgrUser = mgrUser;
|
||||
}
|
||||
|
||||
public void setTenantId(final Long tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public void setCanteenEffId(final Long canteenEffId) {
|
||||
this.canteenEffId = canteenEffId;
|
||||
}
|
||||
|
||||
public void setCustEffId(final Long custEffId) {
|
||||
this.custEffId = custEffId;
|
||||
}
|
||||
|
||||
public void setDishesEffId(final Long dishesEffId) {
|
||||
this.dishesEffId = dishesEffId;
|
||||
}
|
||||
|
||||
public void setRoleCode(final String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public void setPermissions(final Set<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public void setRoles(final Set<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String var10000 = String.valueOf(this.getMgrUser());
|
||||
return "MgrUserInfo(mgrUser=" + var10000 + ", tenantId=" + this.getTenantId() + ", canteenEffId=" + this.getCanteenEffId() + ", custEffId=" + this.getCustEffId() + ", dishesEffId=" + this.getDishesEffId() + ", roleCode=" + this.getRoleCode() + ", permissions=" + String.valueOf(this.getPermissions()) + ", roles=" + String.valueOf(this.getRoles()) + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.bonus.canteen.core.auth.user.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel("登录入参")
|
||||
public class MgrUserLoginDTO implements Serializable {
|
||||
@ApiModelProperty("用户名")
|
||||
private @NotBlank(
|
||||
message = "用户名不能为空"
|
||||
) String username;
|
||||
@ApiModelProperty("密码")
|
||||
private @NotBlank(
|
||||
message = "密码不能为空"
|
||||
) String password;
|
||||
private String scope;
|
||||
private String grant_type;
|
||||
private String role;
|
||||
private String openid;
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
public String getGrant_type() {
|
||||
return this.grant_type;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return this.role;
|
||||
}
|
||||
|
||||
public String getOpenid() {
|
||||
return this.openid;
|
||||
}
|
||||
|
||||
public void setUsername(final String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setScope(final String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public void setGrant_type(final String grant_type) {
|
||||
this.grant_type = grant_type;
|
||||
}
|
||||
|
||||
public void setRole(final String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public void setOpenid(final String openid) {
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String var10000 = this.getUsername();
|
||||
return "MgrUserLoginDTO(username=" + var10000 + ", password=" + this.getPassword() + ", scope=" + this.getScope() + ", grant_type=" + this.getGrant_type() + ", role=" + this.getRole() + ", openid=" + this.getOpenid() + ")";
|
||||
}
|
||||
|
||||
public MgrUserLoginDTO(final String username, final String password, final String scope, final String grant_type, final String role, final String openid) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.scope = scope;
|
||||
this.grant_type = grant_type;
|
||||
this.role = role;
|
||||
this.openid = openid;
|
||||
}
|
||||
|
||||
public MgrUserLoginDTO() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,272 @@
|
|||
package com.bonus.canteen.core.auth.user.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.bonus.canteen.core.common.encrypt.SM4EncDecHandler;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName(
|
||||
value = "mgr_user",
|
||||
autoResultMap = true
|
||||
)
|
||||
public class MgrUserInSystem extends Model<MgrUserInSystem> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("用户编号")
|
||||
@TableId
|
||||
private Long userId;
|
||||
@ApiModelProperty("用户名")
|
||||
private String username;
|
||||
@ApiModelProperty("密码")
|
||||
private String password;
|
||||
@ApiModelProperty("真实姓名")
|
||||
@TableField(
|
||||
value = "real_name",
|
||||
typeHandler = SM4EncDecHandler.class
|
||||
)
|
||||
private String realName;
|
||||
@ApiModelProperty("随机盐")
|
||||
private String salt;
|
||||
@ApiModelProperty("电话号码")
|
||||
@TableField(
|
||||
value = "phone",
|
||||
typeHandler = SM4EncDecHandler.class
|
||||
)
|
||||
private String phone;
|
||||
@ApiModelProperty("操作员头像")
|
||||
private String avatar;
|
||||
@ApiModelProperty("部门id")
|
||||
private Long deptId;
|
||||
@ApiModelProperty("用户类型(0-本地用户, 1-AD账户)")
|
||||
private Integer userType;
|
||||
@ApiModelProperty("激活标识")
|
||||
private String lockFlag;
|
||||
@ApiModelProperty("标识")
|
||||
private Integer delFlag;
|
||||
@ApiModelProperty("微信登录openId")
|
||||
private String wxOpenid;
|
||||
@ApiModelProperty("小程序openId")
|
||||
private String miniOpenid;
|
||||
@ApiModelProperty("QQ openId")
|
||||
private String qqOpenid;
|
||||
@ApiModelProperty("码云标识")
|
||||
private String giteeLogin;
|
||||
@ApiModelProperty("开源中国标识")
|
||||
private String oscId;
|
||||
@ApiModelProperty("商户id")
|
||||
private Long tenantId;
|
||||
@ApiModelProperty("授权截止时间")
|
||||
private LocalDateTime endTime;
|
||||
@ApiModelProperty("乐观锁")
|
||||
private Integer revision;
|
||||
@ApiModelProperty("创建人")
|
||||
private String crby;
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime crtime;
|
||||
@ApiModelProperty("更新人")
|
||||
private String upby;
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime uptime;
|
||||
@ApiModelProperty("是否修改过密码")
|
||||
private Integer editFlag;
|
||||
|
||||
public Long getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public String getRealName() {
|
||||
return this.realName;
|
||||
}
|
||||
|
||||
public String getSalt() {
|
||||
return this.salt;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return this.phone;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return this.avatar;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return this.deptId;
|
||||
}
|
||||
|
||||
public Integer getUserType() {
|
||||
return this.userType;
|
||||
}
|
||||
|
||||
public String getLockFlag() {
|
||||
return this.lockFlag;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
return this.delFlag;
|
||||
}
|
||||
|
||||
public String getWxOpenid() {
|
||||
return this.wxOpenid;
|
||||
}
|
||||
|
||||
public String getMiniOpenid() {
|
||||
return this.miniOpenid;
|
||||
}
|
||||
|
||||
public String getQqOpenid() {
|
||||
return this.qqOpenid;
|
||||
}
|
||||
|
||||
public String getGiteeLogin() {
|
||||
return this.giteeLogin;
|
||||
}
|
||||
|
||||
public String getOscId() {
|
||||
return this.oscId;
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return this.tenantId;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return this.endTime;
|
||||
}
|
||||
|
||||
public Integer getRevision() {
|
||||
return this.revision;
|
||||
}
|
||||
|
||||
public String getCrby() {
|
||||
return this.crby;
|
||||
}
|
||||
|
||||
public LocalDateTime getCrtime() {
|
||||
return this.crtime;
|
||||
}
|
||||
|
||||
public String getUpby() {
|
||||
return this.upby;
|
||||
}
|
||||
|
||||
public LocalDateTime getUptime() {
|
||||
return this.uptime;
|
||||
}
|
||||
|
||||
public Integer getEditFlag() {
|
||||
return this.editFlag;
|
||||
}
|
||||
|
||||
public void setUserId(final Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public void setUsername(final String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public void setRealName(final String realName) {
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public void setSalt(final String salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public void setPhone(final String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public void setAvatar(final String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public void setDeptId(final Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
|
||||
public void setUserType(final Integer userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
public void setLockFlag(final String lockFlag) {
|
||||
this.lockFlag = lockFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(final Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public void setWxOpenid(final String wxOpenid) {
|
||||
this.wxOpenid = wxOpenid;
|
||||
}
|
||||
|
||||
public void setMiniOpenid(final String miniOpenid) {
|
||||
this.miniOpenid = miniOpenid;
|
||||
}
|
||||
|
||||
public void setQqOpenid(final String qqOpenid) {
|
||||
this.qqOpenid = qqOpenid;
|
||||
}
|
||||
|
||||
public void setGiteeLogin(final String giteeLogin) {
|
||||
this.giteeLogin = giteeLogin;
|
||||
}
|
||||
|
||||
public void setOscId(final String oscId) {
|
||||
this.oscId = oscId;
|
||||
}
|
||||
|
||||
public void setTenantId(final Long tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public void setEndTime(final LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public void setRevision(final Integer revision) {
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
public void setCrby(final String crby) {
|
||||
this.crby = crby;
|
||||
}
|
||||
|
||||
public void setCrtime(final LocalDateTime crtime) {
|
||||
this.crtime = crtime;
|
||||
}
|
||||
|
||||
public void setUpby(final String upby) {
|
||||
this.upby = upby;
|
||||
}
|
||||
|
||||
public void setUptime(final LocalDateTime uptime) {
|
||||
this.uptime = uptime;
|
||||
}
|
||||
|
||||
public void setEditFlag(final Integer editFlag) {
|
||||
this.editFlag = editFlag;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getUserId();
|
||||
return "MgrUserInSystem(userId=" + var10000 + ", username=" + this.getUsername() + ", password=" + this.getPassword() + ", realName=" + this.getRealName() + ", salt=" + this.getSalt() + ", phone=" + this.getPhone() + ", avatar=" + this.getAvatar() + ", deptId=" + this.getDeptId() + ", userType=" + this.getUserType() + ", lockFlag=" + this.getLockFlag() + ", delFlag=" + this.getDelFlag() + ", wxOpenid=" + this.getWxOpenid() + ", miniOpenid=" + this.getMiniOpenid() + ", qqOpenid=" + this.getQqOpenid() + ", giteeLogin=" + this.getGiteeLogin() + ", oscId=" + this.getOscId() + ", tenantId=" + this.getTenantId() + ", endTime=" + String.valueOf(this.getEndTime()) + ", revision=" + this.getRevision() + ", crby=" + this.getCrby() + ", crtime=" + String.valueOf(this.getCrtime()) + ", upby=" + this.getUpby() + ", uptime=" + String.valueOf(this.getUptime()) + ", editFlag=" + this.getEditFlag() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.bonus.canteen.core.auth.user.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@TableName("mgr_user_role")
|
||||
@ApiModel("用户角色关联")
|
||||
public class MgrUserRole extends Model<MgrUserRole> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
@ApiModelProperty("角色id")
|
||||
private Long roleId;
|
||||
@ApiModelProperty("是否默认,1:是,2:否")
|
||||
private Integer ifDefault;
|
||||
|
||||
public Long getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public Integer getIfDefault() {
|
||||
return this.ifDefault;
|
||||
}
|
||||
|
||||
public void setUserId(final Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public void setRoleId(final Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public void setIfDefault(final Integer ifDefault) {
|
||||
this.ifDefault = ifDefault;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getUserId();
|
||||
return "MgrUserRole(userId=" + var10000 + ", roleId=" + this.getRoleId() + ", ifDefault=" + this.getIfDefault() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.bonus.canteen.core.auth.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.auth.user.entity.MgrUserInSystem;
|
||||
import com.bonus.canteen.core.merchant.vo.MercMerchantEndTimeVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface MgrUserInSystemMapper extends BaseMapper<MgrUserInSystem> {
|
||||
MercMerchantEndTimeVO selectMerchantByMerchantId(Long merchantId);
|
||||
|
||||
@Select({"select username, password from mgr_user ${ew.customSqlSegment}"})
|
||||
MgrUserInSystem selectPasswordByUserId(@Param("ew") Wrapper<MgrUserInSystem> wrapper);
|
||||
|
||||
@Select({"select tenant_id from merc_merchant where third_merchant_id = #{thirdMerchantId}"})
|
||||
Long selectMerchantIdByThird(String thirdMerchantId);
|
||||
|
||||
@Select({"select user_type from mgr_user where username = #{username} and del_flag = #{delFlag}"})
|
||||
Integer selectUserTypeByUsername(@Param("username") String username, @Param("delFlag") Integer delFlag);
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.bonus.canteen.core.auth.role.dto.MgrRoleUserDTO;
|
||||
import com.bonus.canteen.core.auth.role.vo.MgrRoleUserVO;
|
||||
import com.bonus.canteen.core.auth.user.entity.MgrUser;
|
||||
import feign.Param;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -42,9 +43,9 @@ public interface MgrUserMapper extends BaseMapper<MgrUser> {
|
|||
// Long selectUserIdByCustId(@Param("custId") Long custId);
|
||||
//
|
||||
// String selectUserNameIdByCustId(@Param("custId") Long custId);
|
||||
//
|
||||
// Long selectCustIdByUserId(@Param("userId") Long userId);
|
||||
//
|
||||
|
||||
Long selectCustIdByUserId(@Param("userId") Long userId);
|
||||
|
||||
// List<MgrRoleUserVO> getUserExcludeSupplier(@Param("delFlag") Integer delFlag);
|
||||
//
|
||||
// MgrUser getUserByRoleCode(@Param("roleCode") String roleCode);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.bonus.canteen.core.auth.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.auth.user.entity.MgrUserRole;
|
||||
import com.bonus.canteen.core.auth.user.vo.MgrUserRoleInfoVO;
|
||||
import com.bonus.canteen.core.auth.user.vo.MgrUserRolePageVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface MgrUserRoleMapper extends BaseMapper<MgrUserRole> {
|
||||
Set<String> listRoles(@Param("userId") Long userId);
|
||||
|
||||
List<MgrUserRolePageVO> getUserRoleVOByUserIdList(@Param("userIdList") List<Long> userIdList);
|
||||
|
||||
List<MgrUserRoleInfoVO> getMgrUserRoleListByUserId(@Param("userId") Long userId);
|
||||
|
||||
void updateDefaultByRoleCode(@Param("roleCode") String roleCode, @Param("userId") Long userId, @Param("ifDefault") Integer ifDefault);
|
||||
}
|
||||
|
|
@ -1,50 +1,97 @@
|
|||
package com.bonus.canteen.core.auth.user.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bonus.canteen.core.auth.config.LoginProperties;
|
||||
import com.bonus.canteen.core.auth.enums.RoleCodeV2Enum;
|
||||
import com.bonus.canteen.core.auth.menu.vo.MgrMenuVO;
|
||||
import com.bonus.canteen.core.auth.po.AuthOpsExpireMsgPO;
|
||||
import com.bonus.canteen.core.auth.role.MgrRoleTypeV2Enum;
|
||||
import com.bonus.canteen.core.auth.role.dto.MgrRoleUserDTO;
|
||||
import com.bonus.canteen.core.auth.role.dto.MgrRoleUserListDTO;
|
||||
import com.bonus.canteen.core.auth.role.mapper.MgrRoleMenuMapper;
|
||||
import com.bonus.canteen.core.auth.role.vo.MgrRoleUserVO;
|
||||
import com.bonus.canteen.core.auth.user.business.MgrUserBurialPointBusiness;
|
||||
import com.bonus.canteen.core.auth.user.dto.MgrUserInfo;
|
||||
import com.bonus.canteen.core.auth.user.dto.MgrUserLoginDTO;
|
||||
import com.bonus.canteen.core.auth.user.entity.MgrUser;
|
||||
import com.bonus.canteen.core.auth.user.entity.MgrUserInSystem;
|
||||
import com.bonus.canteen.core.auth.user.mapper.MgrUserInSystemMapper;
|
||||
import com.bonus.canteen.core.auth.user.mapper.MgrUserMapper;
|
||||
import com.bonus.canteen.core.auth.user.mapper.MgrUserRoleMapper;
|
||||
import com.bonus.canteen.core.auth.user.vo.MgrUserRoleInfoVO;
|
||||
import com.bonus.canteen.core.common.constant.LeMqConstant;
|
||||
import com.bonus.canteen.core.common.enums.LogRecordOperTypeEnum;
|
||||
import com.bonus.canteen.core.common.utils.TenantContextHolder;
|
||||
import com.bonus.canteen.core.notice.hawkeye.service.AllocLogRecordService;
|
||||
import com.bonus.common.houqin.framework.secure.AccessToken;
|
||||
import com.bonus.canteen.core.customer.model.PigxUser;
|
||||
import com.bonus.canteen.core.customer.utils.DelFlagEnum;
|
||||
import com.bonus.canteen.core.data.dataset.Executors;
|
||||
import com.bonus.canteen.core.merchant.constant.MerchantStatusEnum;
|
||||
import com.bonus.canteen.core.merchant.vo.MercMerchantEndTimeVO;
|
||||
import com.bonus.canteen.core.notice.hawkeye.model.AllocLogRecord;
|
||||
import com.bonus.canteen.core.order.mq.MqUtil;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.houqin.constant.LeConstants;
|
||||
import com.bonus.common.houqin.framework.secure.SecureManager;
|
||||
import com.bonus.common.houqin.i18n.I18n;
|
||||
import com.bonus.common.houqin.utils.AesEncryptUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MgrUserService extends ServiceImpl<MgrUserMapper, MgrUser> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MgrUserService.class);
|
||||
private static final String USER_LOCK = "user-lock-";
|
||||
private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
||||
// @Autowired
|
||||
// private MgrUserInSystemMapper mgrUserInSystemMapper;
|
||||
@Autowired
|
||||
private MgrUserInSystemMapper mgrUserInSystemMapper;
|
||||
// @Autowired
|
||||
// private MgrRoleService mgrRoleService;
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private CustInfoApi custInfoApi;
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private AllocLogRecordService allocLogRecordService;
|
||||
// @Autowired
|
||||
// private MgrUserRoleMapper mgrUserRoleMapper;
|
||||
// @Autowired
|
||||
// private MgrUserMapper mgrUserMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private AllocLogRecordService allocLogRecordService;
|
||||
@Autowired
|
||||
private MgrUserRoleMapper mgrUserRoleMapper;
|
||||
@Autowired
|
||||
private MgrUserMapper mgrUserMapper;
|
||||
// @Autowired
|
||||
// private MgrRoleMapper mgrRoleMapper;
|
||||
// @Autowired
|
||||
// private StringRedisTemplate stringRedisTemplate;
|
||||
// @Autowired
|
||||
// private MgrRoleMenuMapper mgrRoleMenuMapper;
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Autowired
|
||||
private MgrRoleMenuMapper mgrRoleMenuMapper;
|
||||
// @Autowired
|
||||
// private MgrRoleAppMenuService mgrRoleAppMenuService;
|
||||
// @Autowired
|
||||
// private AesEncryptUtil aesEncryptUtil;
|
||||
// @Autowired
|
||||
// private LoginProperties loginProperties;
|
||||
@Autowired
|
||||
private AesEncryptUtil aesEncryptUtil;
|
||||
@Autowired
|
||||
private LoginProperties loginProperties;
|
||||
// @Autowired
|
||||
// private CustomBizApi customBizApi;
|
||||
// @Autowired
|
||||
|
|
@ -65,9 +112,9 @@ public class MgrUserService extends ServiceImpl<MgrUserMapper, MgrUser> {
|
|||
// @Autowired
|
||||
// @Lazy
|
||||
// private BackStaffApi backStaffApi;
|
||||
// @Autowired
|
||||
// @Lazy
|
||||
// private MgrUserBurialPointBusiness mgrUserBurialPointBusiness;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private MgrUserBurialPointBusiness mgrUserBurialPointBusiness;
|
||||
|
||||
// @Transactional(
|
||||
// rollbackFor = {Exception.class}
|
||||
|
|
@ -275,80 +322,80 @@ public class MgrUserService extends ServiceImpl<MgrUserMapper, MgrUser> {
|
|||
// int countDrpWarehouse = this.mgrUserMapper.checkDrpWarehouse(userId);
|
||||
// return countBasicsDining > 0 || countBasicsShopstalls > 0 || countDrpWarehouse > 0;
|
||||
// }
|
||||
//
|
||||
// public MgrUserInfo getUserInfoByUsername(String realUsername) throws LeCheckedException {
|
||||
// MgrUserInSystem mgrUser = (MgrUserInSystem)Executors.readInSystem(() -> {
|
||||
// return (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, realUsername)).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
||||
// });
|
||||
// if (mgrUser == null) {
|
||||
// log.info("***根据用户名 : {} 未查询到用户的数据, 返回用户名密码错误****************", realUsername);
|
||||
// throw new LeCheckedException(I18n.getMessage("auth_error_password", new Object[0]));
|
||||
// } else if (ObjectUtil.isNotNull(mgrUser.getEndTime()) && LocalDateTime.now().isAfter(mgrUser.getEndTime())) {
|
||||
// throw new LeCheckedException("授权已过期,请重新授权");
|
||||
// } else if (mgrUser.getUserId() == 0L) {
|
||||
// return this.createMgrUserInfo((MgrUser)BeanUtil.copyProperties(mgrUser, MgrUser.class, new String[0]), (Long)null, (Long)null, (Long)null, (Long)null, CollUtil.newHashSet(new String[]{RoleCodeV2Enum.ROLE_ADMIN.key()}), CollUtil.newHashSet(new String[]{"1"}));
|
||||
// } else {
|
||||
// MercMerchantEndTimeVO mercMerchantVO = (MercMerchantEndTimeVO)Executors.readInSystem(() -> {
|
||||
// return this.mgrUserInSystemMapper.selectMerchantByMerchantId(mgrUser.getTenantId());
|
||||
// });
|
||||
// if (mercMerchantVO != null && !LocalDateTime.now().isAfter(mercMerchantVO.getEndTime())) {
|
||||
// if (!MerchantStatusEnum.NORMAL.key().equals(mercMerchantVO.getStatus())) {
|
||||
// throw new LeCheckedException(I18n.getMessage("auth_disable_account", new Object[0]));
|
||||
// } else {
|
||||
// TenantContextHolder.setTenantId(mgrUser.getTenantId());
|
||||
// if (this.checkCustState(mgrUser.getUserId())) {
|
||||
// log.info("用户已注销,不可以登录~~~~~~~~");
|
||||
// throw new LeCheckedException(I18n.getMessage("auth_cust_cancel", new Object[0]));
|
||||
// } else {
|
||||
// List<MgrUserRoleInfoVO> userRoleInfoVOList = this.mgrUserRoleMapper.getMgrUserRoleListByUserId(mgrUser.getUserId());
|
||||
// if (ObjectUtil.isEmpty(userRoleInfoVOList)) {
|
||||
// log.info("用户未配置角色,不可以登录~~~~~~~~");
|
||||
// throw new LeCheckedException(I18n.getMessage("auth_no_role", new Object[0]));
|
||||
// } else {
|
||||
// Set<String> permissions = (Set)this.mgrRoleMenuMapper.listPermissions(mgrUser.getUserId()).stream().map(MgrMenuVO::getMenuCode).collect(Collectors.toSet());
|
||||
// Set<String> roles = (Set)userRoleInfoVOList.stream().map(MgrUserRoleInfoVO::getRoleCode).collect(Collectors.toSet());
|
||||
// MgrUserInfo userInfo = this.createMgrUserInfo((MgrUser)BeanUtil.copyProperties(mgrUser, MgrUser.class, new String[0]), -1L, -1L, -1L, mgrUser.getTenantId(), permissions, roles);
|
||||
// Iterator var8 = userRoleInfoVOList.iterator();
|
||||
//
|
||||
// while(true) {
|
||||
// MgrUserRoleInfoVO userRoleVO;
|
||||
// do {
|
||||
// if (!var8.hasNext()) {
|
||||
// log.info("商家操作员登录用户详细信息userInfo : {}", userInfo);
|
||||
// return userInfo;
|
||||
// }
|
||||
//
|
||||
// userRoleVO = (MgrUserRoleInfoVO)var8.next();
|
||||
// } while(!MgrRoleTypeV2Enum.ROLE_ADMIN.getKey().equals(userRoleVO.getRoleType()) && !LeConstants.COMMON_YES.equals(userRoleVO.getIfDefault()));
|
||||
//
|
||||
// userInfo.setRoleCode(userRoleVO.getRoleCode());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// throw new LeCheckedException(I18n.getMessage("auth_overtime_account", new Object[0]));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private boolean checkCustState(Long userId) {
|
||||
// Long custId = this.mgrUserMapper.selectCustIdByUserId(userId);
|
||||
// return ObjectUtil.isNull(custId);
|
||||
// }
|
||||
//
|
||||
// private MgrUserInfo createMgrUserInfo(MgrUser mgrUser, Long canteenEffId, Long custEffId, Long dishesEffId, Long tenantId, Set<String> permissions, Set<String> roles) {
|
||||
// MgrUserInfo userInfo = new MgrUserInfo();
|
||||
// userInfo.setMgrUser(mgrUser);
|
||||
// userInfo.setCanteenEffId(canteenEffId);
|
||||
// userInfo.setCustEffId(custEffId);
|
||||
// userInfo.setDishesEffId(dishesEffId);
|
||||
// userInfo.setTenantId(tenantId);
|
||||
// userInfo.setPermissions(permissions);
|
||||
// userInfo.setRoles(roles);
|
||||
// return userInfo;
|
||||
// }
|
||||
//
|
||||
|
||||
public MgrUserInfo getUserInfoByUsername(String realUsername) throws Exception {
|
||||
MgrUserInSystem mgrUser = (MgrUserInSystem)Executors.readInSystem(() -> {
|
||||
return null; // (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, realUsername)).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
||||
});
|
||||
if (mgrUser == null) {
|
||||
log.info("***根据用户名 : {} 未查询到用户的数据, 返回用户名密码错误****************", realUsername);
|
||||
throw new ServiceException(I18n.getMessage("auth_error_password", new Object[0]));
|
||||
} else if (ObjectUtil.isNotNull(mgrUser.getEndTime()) && LocalDateTime.now().isAfter(mgrUser.getEndTime())) {
|
||||
throw new ServiceException("授权已过期,请重新授权");
|
||||
} else if (mgrUser.getUserId() == 0L) {
|
||||
return this.createMgrUserInfo((MgrUser) BeanUtil.copyProperties(mgrUser, MgrUser.class, new String[0]), (Long)null, (Long)null, (Long)null, (Long)null, CollUtil.newHashSet(new String[]{RoleCodeV2Enum.ROLE_ADMIN.key()}), CollUtil.newHashSet(new String[]{"1"}));
|
||||
} else {
|
||||
MercMerchantEndTimeVO mercMerchantVO = (MercMerchantEndTimeVO)Executors.readInSystem(() -> {
|
||||
return this.mgrUserInSystemMapper.selectMerchantByMerchantId(mgrUser.getTenantId());
|
||||
});
|
||||
if (mercMerchantVO != null && !LocalDateTime.now().isAfter(mercMerchantVO.getEndTime())) {
|
||||
if (!MerchantStatusEnum.NORMAL.key().equals(mercMerchantVO.getStatus())) {
|
||||
throw new ServiceException(I18n.getMessage("auth_disable_account", new Object[0]));
|
||||
} else {
|
||||
TenantContextHolder.setTenantId(mgrUser.getTenantId());
|
||||
if (this.checkCustState(mgrUser.getUserId())) {
|
||||
log.info("用户已注销,不可以登录~~~~~~~~");
|
||||
throw new ServiceException(I18n.getMessage("auth_cust_cancel", new Object[0]));
|
||||
} else {
|
||||
List<MgrUserRoleInfoVO> userRoleInfoVOList = this.mgrUserRoleMapper.getMgrUserRoleListByUserId(mgrUser.getUserId());
|
||||
if (ObjectUtil.isEmpty(userRoleInfoVOList)) {
|
||||
log.info("用户未配置角色,不可以登录~~~~~~~~");
|
||||
throw new ServiceException(I18n.getMessage("auth_no_role", new Object[0]));
|
||||
} else {
|
||||
Set<String> permissions = (Set)this.mgrRoleMenuMapper.listPermissions(mgrUser.getUserId()).stream().map(MgrMenuVO::getMenuCode).collect(Collectors.toSet());
|
||||
Set<String> roles = (Set)userRoleInfoVOList.stream().map(MgrUserRoleInfoVO::getRoleCode).collect(Collectors.toSet());
|
||||
MgrUserInfo userInfo = this.createMgrUserInfo((MgrUser)BeanUtil.copyProperties(mgrUser, MgrUser.class, new String[0]), -1L, -1L, -1L, mgrUser.getTenantId(), permissions, roles);
|
||||
Iterator var8 = userRoleInfoVOList.iterator();
|
||||
|
||||
while(true) {
|
||||
MgrUserRoleInfoVO userRoleVO;
|
||||
do {
|
||||
if (!var8.hasNext()) {
|
||||
log.info("商家操作员登录用户详细信息userInfo : {}", userInfo);
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
userRoleVO = (MgrUserRoleInfoVO)var8.next();
|
||||
} while(!MgrRoleTypeV2Enum.ROLE_ADMIN.getKey().equals(userRoleVO.getRoleType()) && !LeConstants.COMMON_YES.equals(userRoleVO.getIfDefault()));
|
||||
|
||||
userInfo.setRoleCode(userRoleVO.getRoleCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception(I18n.getMessage("auth_overtime_account", new Object[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkCustState(Long userId) {
|
||||
Long custId = this.mgrUserMapper.selectCustIdByUserId(userId);
|
||||
return ObjectUtil.isNull(custId);
|
||||
}
|
||||
|
||||
private MgrUserInfo createMgrUserInfo(MgrUser mgrUser, Long canteenEffId, Long custEffId, Long dishesEffId, Long tenantId, Set<String> permissions, Set<String> roles) {
|
||||
MgrUserInfo userInfo = new MgrUserInfo();
|
||||
userInfo.setMgrUser(mgrUser);
|
||||
userInfo.setCanteenEffId(canteenEffId);
|
||||
userInfo.setCustEffId(custEffId);
|
||||
userInfo.setDishesEffId(dishesEffId);
|
||||
userInfo.setTenantId(tenantId);
|
||||
userInfo.setPermissions(permissions);
|
||||
userInfo.setRoles(roles);
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
// public MgrUserOpsPO authTempOpsUser() {
|
||||
// Long merchantId = TenantContextHolder.getTenantId();
|
||||
// MgrUserInSystem oldUserSystem = (MgrUserInSystem)Executors.readInSystem(() -> {
|
||||
|
|
@ -517,108 +564,114 @@ public class MgrUserService extends ServiceImpl<MgrUserMapper, MgrUser> {
|
|||
// return pigxUser;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public PigxUser login(MgrUserLoginDTO loginDTO) throws LeCheckedException {
|
||||
// String realUsername = this.mgrUserBurialPointBusiness.didBeforeLogin(loginDTO);
|
||||
// if (CharSequenceUtil.isNotBlank(realUsername)) {
|
||||
// return this.getPigxUser(realUsername);
|
||||
// } else {
|
||||
// realUsername = loginDTO.getUsername();
|
||||
// ValueOperations<String, String> valueOperations = this.stringRedisTemplate.opsForValue();
|
||||
// String s = (String)this.stringRedisTemplate.opsForValue().get("user-lock-" + realUsername);
|
||||
// if (CharSequenceUtil.isNotBlank(s)) {
|
||||
// if (Integer.parseInt(s) > 4 && Integer.parseInt(s) < 10) {
|
||||
// valueOperations.increment("user-lock-" + realUsername);
|
||||
// throw new LeException(I18n.getMessage("auth_lock_account", new Object[0]));
|
||||
// }
|
||||
//
|
||||
// if (Integer.parseInt(s) > 10) {
|
||||
// throw new LeException(I18n.getMessage("auth_lock_account_time", new Object[0]));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// boolean flag = this.matches(loginDTO);
|
||||
// if (!flag) {
|
||||
// this.handleLoginError(realUsername);
|
||||
// throw new LeException(I18n.getMessage("auth_error_password_username", new Object[0]));
|
||||
// } else {
|
||||
// return this.getPigxUser(realUsername);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected PigxUser getPigxUser(String realUsername) throws LeCheckedException {
|
||||
// MgrUserInfo info = this.getUserInfoByUsername(realUsername);
|
||||
// PigxUser user = PigxUser.builder().username(info.getMgrUser().getUsername()).id(info.getMgrUser().getUserId()).roleCode(info.getRoleCode()).merchantId(info.getTenantId()).canteenEffId(info.getCanteenEffId()).custEffId(info.getCustEffId()).dishesEffId(info.getDishesEffId()).build();
|
||||
//
|
||||
// try {
|
||||
// AccessToken accessToken = AccessToken.create(user.getId());
|
||||
// accessToken.setSubjectName(realUsername);
|
||||
// Map<String, String> subjectData = (Map)JSON.parseObject(JSON.toJSONString(user), new TypeReference<Map<String, String>>(this) {
|
||||
// }, new Feature[0]);
|
||||
// accessToken.setSubjectData(subjectData);
|
||||
// accessToken.setScope(user.getMerchantId() == null ? null : String.valueOf(user.getMerchantId()));
|
||||
// accessToken.bind().authenticate().store().write();
|
||||
// if (String.valueOf(TenantContextHolder.getTenantId()).equals(info.getMgrUser().getUsername())) {
|
||||
// AuthOpsExpireMsgPO opsExpireMsgPO = new AuthOpsExpireMsgPO();
|
||||
// opsExpireMsgPO.setUserId(info.getMgrUser().getUserId());
|
||||
// opsExpireMsgPO.setAccessTokenId(accessToken.getId());
|
||||
// MqUtil.sendDelay(JSON.toJSONString(opsExpireMsgPO), LeMqConstant.Topic.AUTH_OPS_USER_EXPIRE, 86400000);
|
||||
// }
|
||||
//
|
||||
// this.update((Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate().set(MgrUser::getLoginTime, LocalDateTime.now())).set(MgrUser::getUptime, LocalDateTime.now())).eq(MgrUser::getUserId, user.getId()));
|
||||
// if (Objects.nonNull(this.loginProperties.getReservedRecentNum())) {
|
||||
// SecureManager.revokeAuthenticate(user.getId(), this.loginProperties.getReservedRecentNum());
|
||||
// }
|
||||
// } catch (Exception var7) {
|
||||
// String var10002 = I18n.getMessage("auth_login_fail", new Object[0]);
|
||||
// throw new LeException(var10002 + var7.getMessage());
|
||||
// }
|
||||
//
|
||||
// if (!"admin".equals(user.getUsername())) {
|
||||
// AllocLogRecord logRecord = new AllocLogRecord(user.getId(), user.getUsername(), "/oauth/token", "人员登录", LogRecordOperTypeEnum.LOGIN.getKey());
|
||||
// this.allocLogRecordService.saveLogRecordForCustom(logRecord);
|
||||
// }
|
||||
//
|
||||
// return user;
|
||||
// }
|
||||
//
|
||||
// private boolean matches(MgrUserLoginDTO loginDTO) {
|
||||
// boolean flag = false;
|
||||
// String username = loginDTO.getUsername();
|
||||
// String password = loginDTO.getPassword();
|
||||
// password = this.aesEncryptUtil.aesDecode(password);
|
||||
// MgrUserInSystem user = (MgrUserInSystem)Executors.readInSystem(() -> {
|
||||
// return (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery().select(new SFunction[]{MgrUserInSystem::getPassword, MgrUserInSystem::getUserId, MgrUserInSystem::getLockFlag}).eq(MgrUserInSystem::getUsername, username)).eq(MgrUserInSystem::getDelFlag, LeConstants.COMMON_NO));
|
||||
// });
|
||||
// if (ObjectUtil.isNotNull(user) && encoder.matches(password, user.getPassword())) {
|
||||
// flag = true;
|
||||
// }
|
||||
//
|
||||
// return flag;
|
||||
// }
|
||||
//
|
||||
// private void handleLoginError(String username) {
|
||||
// ValueOperations<String, String> valueOperations = this.stringRedisTemplate.opsForValue();
|
||||
// String value = (String)valueOperations.get("user-lock-" + username);
|
||||
// if (CharSequenceUtil.isBlank(value)) {
|
||||
// valueOperations.increment("user-lock-" + username);
|
||||
// this.stringRedisTemplate.expire("user-lock-" + username, 30L, TimeUnit.SECONDS);
|
||||
// }
|
||||
//
|
||||
// Long increment = valueOperations.increment("user-lock-" + username);
|
||||
// if (!ObjectUtil.isNull(increment)) {
|
||||
// if (5 == increment.intValue()) {
|
||||
// this.stringRedisTemplate.expire("user-lock-" + username, 2L, TimeUnit.MINUTES);
|
||||
// }
|
||||
//
|
||||
// if (10 == increment.intValue()) {
|
||||
// this.stringRedisTemplate.expire("user-lock-" + username, 10L, TimeUnit.MINUTES);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
public PigxUser login(MgrUserLoginDTO loginDTO) throws Exception {
|
||||
String realUsername = this.mgrUserBurialPointBusiness.didBeforeLogin(loginDTO);
|
||||
if (CharSequenceUtil.isNotBlank(realUsername)) {
|
||||
return this.getPigxUser(realUsername);
|
||||
} else {
|
||||
realUsername = loginDTO.getUsername();
|
||||
ValueOperations<String, String> valueOperations = this.stringRedisTemplate.opsForValue();
|
||||
String s = (String)this.stringRedisTemplate.opsForValue().get("user-lock-" + realUsername);
|
||||
if (CharSequenceUtil.isNotBlank(s)) {
|
||||
if (Integer.parseInt(s) > 4 && Integer.parseInt(s) < 10) {
|
||||
valueOperations.increment("user-lock-" + realUsername);
|
||||
throw new ServiceException(I18n.getMessage("auth_lock_account", new Object[0]));
|
||||
}
|
||||
|
||||
if (Integer.parseInt(s) > 10) {
|
||||
throw new ServiceException(I18n.getMessage("auth_lock_account_time", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
boolean flag = this.matches(loginDTO);
|
||||
if (!flag) {
|
||||
this.handleLoginError(realUsername);
|
||||
throw new ServiceException(I18n.getMessage("auth_error_password_username", new Object[0]));
|
||||
} else {
|
||||
return this.getPigxUser(realUsername);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected PigxUser getPigxUser(String realUsername) throws Exception {
|
||||
MgrUserInfo info = this.getUserInfoByUsername(realUsername);
|
||||
PigxUser user = PigxUser.builder().username(info.getMgrUser().getUsername()).id(info.getMgrUser().getUserId()).roleCode(info.getRoleCode()).merchantId(info.getTenantId()).canteenEffId(info.getCanteenEffId()).custEffId(info.getCustEffId()).dishesEffId(info.getDishesEffId()).build();
|
||||
|
||||
try {
|
||||
AccessToken accessToken = AccessToken.create(user.getId());
|
||||
accessToken.setSubjectName(realUsername);
|
||||
Map<String, String> subjectData = (Map) JSON.parseObject(JSON.toJSONString(user));
|
||||
accessToken.setSubjectData(subjectData);
|
||||
accessToken.setScope(user.getMerchantId() == null ? null : String.valueOf(user.getMerchantId()));
|
||||
accessToken.bind().authenticate().store().write();
|
||||
if (String.valueOf(TenantContextHolder.getTenantId()).equals(info.getMgrUser().getUsername())) {
|
||||
AuthOpsExpireMsgPO opsExpireMsgPO = new AuthOpsExpireMsgPO();
|
||||
opsExpireMsgPO.setUserId(info.getMgrUser().getUserId());
|
||||
opsExpireMsgPO.setAccessTokenId(accessToken.getId());
|
||||
MqUtil.sendDelay(JSON.toJSONString(opsExpireMsgPO), LeMqConstant.Topic.AUTH_OPS_USER_EXPIRE, 86400000);
|
||||
}
|
||||
|
||||
// this.update((Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper) Wrappers.lambdaUpdate()
|
||||
// .set(MgrUser::getLoginTime, LocalDateTime.now()))
|
||||
// .set(MgrUser::getUptime, LocalDateTime.now()))
|
||||
// .eq(MgrUser::getUserId, user.getId()));
|
||||
if (Objects.nonNull(this.loginProperties.getReservedRecentNum())) {
|
||||
SecureManager.revokeAuthenticate(user.getId(), this.loginProperties.getReservedRecentNum());
|
||||
}
|
||||
} catch (Exception var7) {
|
||||
String var10002 = I18n.getMessage("auth_login_fail", new Object[0]);
|
||||
throw new ServiceException(var10002 + var7.getMessage());
|
||||
}
|
||||
|
||||
if (!"admin".equals(user.getUsername())) {
|
||||
AllocLogRecord logRecord = new AllocLogRecord(user.getId(), user.getUsername(), "/oauth/token", "人员登录", LogRecordOperTypeEnum.LOGIN.getKey());
|
||||
this.allocLogRecordService.saveLogRecordForCustom(logRecord);
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
private boolean matches(MgrUserLoginDTO loginDTO) {
|
||||
boolean flag = false;
|
||||
String username = loginDTO.getUsername();
|
||||
String password = loginDTO.getPassword();
|
||||
password = AesEncryptUtil.aesDecode(password);
|
||||
MgrUserInSystem user = (MgrUserInSystem) Executors.readInSystem(() -> {
|
||||
return null;
|
||||
// return (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery()
|
||||
// .select(MgrUserInSystem::getPassword, MgrUserInSystem::getUserId, MgrUserInSystem::getLockFlag)
|
||||
// .eq(MgrUserInSystem::getUsername, username))
|
||||
// .eq(MgrUserInSystem::getDelFlag, LeConstants.COMMON_NO));
|
||||
});
|
||||
if (ObjectUtil.isNotNull(user) && encoder.matches(password, user.getPassword())) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void handleLoginError(String username) {
|
||||
ValueOperations<String, String> valueOperations = this.stringRedisTemplate.opsForValue();
|
||||
String value = (String)valueOperations.get("user-lock-" + username);
|
||||
if (CharSequenceUtil.isBlank(value)) {
|
||||
valueOperations.increment("user-lock-" + username);
|
||||
this.stringRedisTemplate.expire("user-lock-" + username, 30L, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
Long increment = valueOperations.increment("user-lock-" + username);
|
||||
if (!ObjectUtil.isNull(increment)) {
|
||||
if (5 == increment.intValue()) {
|
||||
this.stringRedisTemplate.expire("user-lock-" + username, 2L, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
if (10 == increment.intValue()) {
|
||||
this.stringRedisTemplate.expire("user-lock-" + username, 10L, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// public MgrUserInfoVO getMgrUserInfo(Long userId) {
|
||||
// MgrUserDetailVO mgrUserDetailVO = ((MgrUserMapper)this.baseMapper).selectUserInfoByUserId(userId, DelFlagEnum.DEL_FALSE.key());
|
||||
// if (ObjectUtil.isNull(mgrUserDetailVO)) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
package com.bonus.canteen.core.auth.user.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class MgrUserRoleInfoVO {
|
||||
@ApiModelProperty("角色id")
|
||||
private Long roleId;
|
||||
@ApiModelProperty("角色code")
|
||||
private String roleCode;
|
||||
@ApiModelProperty("是否默认,1:是,2:否")
|
||||
private Integer ifDefault;
|
||||
@ApiModelProperty("角色类型")
|
||||
private Integer roleType;
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return this.roleCode;
|
||||
}
|
||||
|
||||
public Integer getIfDefault() {
|
||||
return this.ifDefault;
|
||||
}
|
||||
|
||||
public Integer getRoleType() {
|
||||
return this.roleType;
|
||||
}
|
||||
|
||||
public void setRoleId(final Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public void setRoleCode(final String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public void setIfDefault(final Integer ifDefault) {
|
||||
this.ifDefault = ifDefault;
|
||||
}
|
||||
|
||||
public void setRoleType(final Integer roleType) {
|
||||
this.roleType = roleType;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getRoleId();
|
||||
return "MgrUserRoleInfoVO(roleId=" + var10000 + ", roleCode=" + this.getRoleCode() + ", ifDefault=" + this.getIfDefault() + ", roleType=" + this.getRoleType() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.bonus.canteen.core.auth.user.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ApiModel("角色分页")
|
||||
public class MgrUserRolePageVO {
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
@ApiModelProperty("角色id")
|
||||
private Long roleId;
|
||||
@ApiModelProperty("角色名称")
|
||||
private String roleName;
|
||||
@ApiModelProperty("角色标识")
|
||||
private String roleCode;
|
||||
@ApiModelProperty("描述")
|
||||
private String roleDesc;
|
||||
|
||||
public Long getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return this.roleId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return this.roleName;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return this.roleCode;
|
||||
}
|
||||
|
||||
public String getRoleDesc() {
|
||||
return this.roleDesc;
|
||||
}
|
||||
|
||||
public void setUserId(final Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public void setRoleId(final Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public void setRoleName(final String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public void setRoleCode(final String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public void setRoleDesc(final String roleDesc) {
|
||||
this.roleDesc = roleDesc;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getUserId();
|
||||
return "MgrUserRolePageVO(userId=" + var10000 + ", roleId=" + this.getRoleId() + ", roleName=" + this.getRoleName() + ", roleCode=" + this.getRoleCode() + ", roleDesc=" + this.getRoleDesc() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.bonus.canteen.core.common.enums;
|
||||
|
||||
public enum LogRecordOperTypeEnum {
|
||||
LOGIN(1, "登录"),
|
||||
SIGN_OUT(2, "退出"),
|
||||
ADD(3, "新增"),
|
||||
MODIFY(4, "修改"),
|
||||
REMOVE(5, "删除"),
|
||||
QUERY(6, "查询");
|
||||
|
||||
private final int key;
|
||||
private final String desc;
|
||||
|
||||
private LogRecordOperTypeEnum(Integer key, String desc) {
|
||||
this.key = key;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,242 +1,242 @@
|
|||
package com.bonus.canteen.core.config;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@JsonIgnoreProperties(
|
||||
ignoreUnknown = true
|
||||
)
|
||||
public class AccessToken {
|
||||
private static final Logger log = LoggerFactory.getLogger(AccessToken.class);
|
||||
@JsonIgnore
|
||||
protected static ObjectMapper objectMapper;
|
||||
@JsonIgnore
|
||||
protected static SecureProperties secureProperties;
|
||||
@JsonIgnore
|
||||
protected static StringRedisTemplate redisTemplate;
|
||||
@JsonIgnore
|
||||
protected static AuthenticationPredicate authenticationPredicate;
|
||||
private String id;
|
||||
private Long subjectId;
|
||||
private String subjectName;
|
||||
private Map<String, String> subjectData = Maps.newHashMap();
|
||||
private String scope;
|
||||
private boolean identified;
|
||||
private long createTime;
|
||||
private long lastTime;
|
||||
|
||||
public static Optional<AccessToken> recovery(String clientToken) {
|
||||
StringRedisTemplate var10000 = redisTemplate;
|
||||
String var10001 = secureProperties.getServer().getStoreKey();
|
||||
clientToken = (String)var10000.boundValueOps(var10001 + ":" + clientToken).get();
|
||||
if (StringUtils.isBlank(clientToken)) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
try {
|
||||
AccessToken existToken = (AccessToken)objectMapper.readValue(clientToken, AccessToken.class);
|
||||
return authenticationPredicate.authenticated(existToken) ? Optional.of(existToken) : Optional.empty();
|
||||
} catch (Exception var2) {
|
||||
log.error("Deserialize exist token error", var2);
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static AccessToken create(long subjectId) {
|
||||
AccessToken accessToken = create();
|
||||
accessToken.setSubjectId(subjectId);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public static AccessToken create(long subjectId, String subjectName) {
|
||||
AccessToken accessToken = create(subjectId);
|
||||
accessToken.setSubjectName(subjectName);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public static AccessToken create() {
|
||||
AccessToken accessToken = new AccessToken();
|
||||
accessToken.setId(UUID.randomUUID().toString());
|
||||
accessToken.setCreateTime(Instant.now().getEpochSecond());
|
||||
accessToken.setLastTime(Instant.now().getEpochSecond());
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public AccessToken touch() {
|
||||
this.identified = this.isAuthenticated();
|
||||
this.lastTime = Instant.now().getEpochSecond();
|
||||
return this.store();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isAuthenticated() {
|
||||
return this.identified && !this.isExpired();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
private boolean isExpired() {
|
||||
return this.lastTime + secureProperties.getExpireAfter() < Instant.now().getEpochSecond();
|
||||
}
|
||||
|
||||
public AccessToken withData(Map<String, String> data) {
|
||||
this.subjectData = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccessToken setData(String name, String value) {
|
||||
this.subjectData.put(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccessToken removeData(String... keys) {
|
||||
if (ArrayUtil.isEmpty(keys)) {
|
||||
return this;
|
||||
} else {
|
||||
String[] var2 = keys;
|
||||
int var3 = keys.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
String key = var2[var4];
|
||||
this.subjectData.remove(key);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public AccessToken revokeAuthenticate() {
|
||||
this.identified = false;
|
||||
return this.store();
|
||||
}
|
||||
|
||||
public AccessToken authenticate() {
|
||||
if (this.subjectId == null) {
|
||||
throw new RuntimeException("required subjectId is not provide");
|
||||
} else {
|
||||
this.identified = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public AccessToken store() {
|
||||
try {
|
||||
StringRedisTemplate var10000 = redisTemplate;
|
||||
DefaultRedisScript var10001 = new DefaultRedisScript("redis.call('SET',KEYS[1],ARGV[1],'EX',ARGV[3]);redis.call('SET',KEYS[2],ARGV[2],'EX',ARGV[3]);");
|
||||
String[] var10002 = new String[2];
|
||||
String var10005 = secureProperties.getServer().getStoreKey();
|
||||
var10002[0] = var10005 + ":" + this.getId();
|
||||
var10005 = secureProperties.getServer().getSubjectRefTokenKey();
|
||||
var10002[1] = var10005 + ":" + this.getSubjectId() + ":" + this.getId() + ":" + this.getCreateTime();
|
||||
var10000.execute(var10001, Lists.newArrayList(var10002), new Object[]{objectMapper.writeValueAsString(this), this.getId(), String.valueOf(secureProperties.getServer().getTtl())});
|
||||
} catch (Exception var2) {
|
||||
log.error("Token store error", var2);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AccessToken bind() {
|
||||
WebContext.get().setAccessToken(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void write() {
|
||||
WebContext.get().getResponse().ifPresent((response) -> {
|
||||
response.setHeader(secureProperties.getTokenSymbol(), this.getId());
|
||||
});
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
try {
|
||||
StringRedisTemplate var10000 = redisTemplate;
|
||||
DefaultRedisScript var10001 = new DefaultRedisScript("redis.call('DEL',KEYS[1],KEYS[2]);");
|
||||
String[] var10002 = new String[2];
|
||||
String var10005 = secureProperties.getServer().getStoreKey();
|
||||
var10002[0] = var10005 + ":" + this.getId();
|
||||
var10005 = secureProperties.getServer().getSubjectRefTokenKey();
|
||||
var10002[1] = var10005 + ":" + this.getSubjectId() + ":" + this.getId() + ":" + this.getCreateTime();
|
||||
var10000.execute(var10001, Lists.newArrayList(var10002), new Object[0]);
|
||||
} catch (Exception var2) {
|
||||
log.error("Token clear error", var2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long getSubjectId() {
|
||||
return this.subjectId;
|
||||
}
|
||||
|
||||
public String getSubjectName() {
|
||||
return this.subjectName;
|
||||
}
|
||||
|
||||
public Map<String, String> getSubjectData() {
|
||||
return this.subjectData;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
public boolean isIdentified() {
|
||||
return this.identified;
|
||||
}
|
||||
|
||||
public long getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public long getLastTime() {
|
||||
return this.lastTime;
|
||||
}
|
||||
|
||||
public void setId(final String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setSubjectId(final Long subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectName(final String subjectName) {
|
||||
this.subjectName = subjectName;
|
||||
}
|
||||
|
||||
public void setSubjectData(final Map<String, String> subjectData) {
|
||||
this.subjectData = subjectData;
|
||||
}
|
||||
|
||||
public void setScope(final String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public void setIdentified(final boolean identified) {
|
||||
this.identified = identified;
|
||||
}
|
||||
|
||||
public void setCreateTime(final long createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public void setLastTime(final long lastTime) {
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
}
|
||||
//package com.bonus.canteen.core.config;
|
||||
//
|
||||
//import cn.hutool.core.util.ArrayUtil;
|
||||
//import com.bonus.common.houqin.framework.secure.SecureProperties;
|
||||
//import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
//import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
//import com.google.common.collect.Lists;
|
||||
//import com.google.common.collect.Maps;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
//import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
//import java.time.Instant;
|
||||
//import java.util.Map;
|
||||
//import java.util.Optional;
|
||||
//import java.util.UUID;
|
||||
//
|
||||
//@JsonIgnoreProperties(
|
||||
// ignoreUnknown = true
|
||||
//)
|
||||
//public class AccessToken {
|
||||
// private static final Logger log = LoggerFactory.getLogger(AccessToken.class);
|
||||
// @JsonIgnore
|
||||
// protected static ObjectMapper objectMapper;
|
||||
// @JsonIgnore
|
||||
// protected static SecureProperties secureProperties;
|
||||
// @JsonIgnore
|
||||
// protected static StringRedisTemplate redisTemplate;
|
||||
// @JsonIgnore
|
||||
// protected static AuthenticationPredicate authenticationPredicate;
|
||||
// private String id;
|
||||
// private Long subjectId;
|
||||
// private String subjectName;
|
||||
// private Map<String, String> subjectData = Maps.newHashMap();
|
||||
// private String scope;
|
||||
// private boolean identified;
|
||||
// private long createTime;
|
||||
// private long lastTime;
|
||||
//
|
||||
// public static Optional<AccessToken> recovery(String clientToken) {
|
||||
// StringRedisTemplate var10000 = redisTemplate;
|
||||
// String var10001 = secureProperties.getServer().getStoreKey();
|
||||
// clientToken = (String)var10000.boundValueOps(var10001 + ":" + clientToken).get();
|
||||
// if (StringUtils.isBlank(clientToken)) {
|
||||
// return Optional.empty();
|
||||
// } else {
|
||||
// try {
|
||||
// AccessToken existToken = (AccessToken)objectMapper.readValue(clientToken, AccessToken.class);
|
||||
// return authenticationPredicate.authenticated(existToken) ? Optional.of(existToken) : Optional.empty();
|
||||
// } catch (Exception var2) {
|
||||
// log.error("Deserialize exist token error", var2);
|
||||
// return Optional.empty();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static AccessToken create(long subjectId) {
|
||||
// AccessToken accessToken = create();
|
||||
// accessToken.setSubjectId(subjectId);
|
||||
// return accessToken;
|
||||
// }
|
||||
//
|
||||
// public static AccessToken create(long subjectId, String subjectName) {
|
||||
// AccessToken accessToken = create(subjectId);
|
||||
// accessToken.setSubjectName(subjectName);
|
||||
// return accessToken;
|
||||
// }
|
||||
//
|
||||
// public static AccessToken create() {
|
||||
// AccessToken accessToken = new AccessToken();
|
||||
// accessToken.setId(UUID.randomUUID().toString());
|
||||
// accessToken.setCreateTime(Instant.now().getEpochSecond());
|
||||
// accessToken.setLastTime(Instant.now().getEpochSecond());
|
||||
// return accessToken;
|
||||
// }
|
||||
//
|
||||
// public AccessToken touch() {
|
||||
// this.identified = this.isAuthenticated();
|
||||
// this.lastTime = Instant.now().getEpochSecond();
|
||||
// return this.store();
|
||||
// }
|
||||
//
|
||||
// @JsonIgnore
|
||||
// public boolean isAuthenticated() {
|
||||
// return this.identified && !this.isExpired();
|
||||
// }
|
||||
//
|
||||
// @JsonIgnore
|
||||
// private boolean isExpired() {
|
||||
// return this.lastTime + secureProperties.getExpireAfter() < Instant.now().getEpochSecond();
|
||||
// }
|
||||
//
|
||||
// public AccessToken withData(Map<String, String> data) {
|
||||
// this.subjectData = data;
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public AccessToken setData(String name, String value) {
|
||||
// this.subjectData.put(name, value);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public AccessToken removeData(String... keys) {
|
||||
// if (ArrayUtil.isEmpty(keys)) {
|
||||
// return this;
|
||||
// } else {
|
||||
// String[] var2 = keys;
|
||||
// int var3 = keys.length;
|
||||
//
|
||||
// for(int var4 = 0; var4 < var3; ++var4) {
|
||||
// String key = var2[var4];
|
||||
// this.subjectData.remove(key);
|
||||
// }
|
||||
//
|
||||
// return this;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public AccessToken revokeAuthenticate() {
|
||||
// this.identified = false;
|
||||
// return this.store();
|
||||
// }
|
||||
//
|
||||
// public AccessToken authenticate() {
|
||||
// if (this.subjectId == null) {
|
||||
// throw new RuntimeException("required subjectId is not provide");
|
||||
// } else {
|
||||
// this.identified = true;
|
||||
// return this;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public AccessToken store() {
|
||||
// try {
|
||||
// StringRedisTemplate var10000 = redisTemplate;
|
||||
// DefaultRedisScript var10001 = new DefaultRedisScript("redis.call('SET',KEYS[1],ARGV[1],'EX',ARGV[3]);redis.call('SET',KEYS[2],ARGV[2],'EX',ARGV[3]);");
|
||||
// String[] var10002 = new String[2];
|
||||
// String var10005 = secureProperties.getServer().getStoreKey();
|
||||
// var10002[0] = var10005 + ":" + this.getId();
|
||||
// var10005 = secureProperties.getServer().getSubjectRefTokenKey();
|
||||
// var10002[1] = var10005 + ":" + this.getSubjectId() + ":" + this.getId() + ":" + this.getCreateTime();
|
||||
// var10000.execute(var10001, Lists.newArrayList(var10002), new Object[]{objectMapper.writeValueAsString(this), this.getId(), String.valueOf(secureProperties.getServer().getTtl())});
|
||||
// } catch (Exception var2) {
|
||||
// log.error("Token store error", var2);
|
||||
// }
|
||||
//
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public AccessToken bind() {
|
||||
// WebContext.get().setAccessToken(this);
|
||||
// return this;
|
||||
// }
|
||||
//
|
||||
// public void write() {
|
||||
// WebContext.get().getResponse().ifPresent((response) -> {
|
||||
// response.setHeader(secureProperties.getTokenSymbol(), this.getId());
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public void clear() {
|
||||
// try {
|
||||
// StringRedisTemplate var10000 = redisTemplate;
|
||||
// DefaultRedisScript var10001 = new DefaultRedisScript("redis.call('DEL',KEYS[1],KEYS[2]);");
|
||||
// String[] var10002 = new String[2];
|
||||
// String var10005 = secureProperties.getServer().getStoreKey();
|
||||
// var10002[0] = var10005 + ":" + this.getId();
|
||||
// var10005 = secureProperties.getServer().getSubjectRefTokenKey();
|
||||
// var10002[1] = var10005 + ":" + this.getSubjectId() + ":" + this.getId() + ":" + this.getCreateTime();
|
||||
// var10000.execute(var10001, Lists.newArrayList(var10002), new Object[0]);
|
||||
// } catch (Exception var2) {
|
||||
// log.error("Token clear error", var2);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public String getId() {
|
||||
// return this.id;
|
||||
// }
|
||||
//
|
||||
// public Long getSubjectId() {
|
||||
// return this.subjectId;
|
||||
// }
|
||||
//
|
||||
// public String getSubjectName() {
|
||||
// return this.subjectName;
|
||||
// }
|
||||
//
|
||||
// public Map<String, String> getSubjectData() {
|
||||
// return this.subjectData;
|
||||
// }
|
||||
//
|
||||
// public String getScope() {
|
||||
// return this.scope;
|
||||
// }
|
||||
//
|
||||
// public boolean isIdentified() {
|
||||
// return this.identified;
|
||||
// }
|
||||
//
|
||||
// public long getCreateTime() {
|
||||
// return this.createTime;
|
||||
// }
|
||||
//
|
||||
// public long getLastTime() {
|
||||
// return this.lastTime;
|
||||
// }
|
||||
//
|
||||
// public void setId(final String id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
//
|
||||
// public void setSubjectId(final Long subjectId) {
|
||||
// this.subjectId = subjectId;
|
||||
// }
|
||||
//
|
||||
// public void setSubjectName(final String subjectName) {
|
||||
// this.subjectName = subjectName;
|
||||
// }
|
||||
//
|
||||
// public void setSubjectData(final Map<String, String> subjectData) {
|
||||
// this.subjectData = subjectData;
|
||||
// }
|
||||
//
|
||||
// public void setScope(final String scope) {
|
||||
// this.scope = scope;
|
||||
// }
|
||||
//
|
||||
// public void setIdentified(final boolean identified) {
|
||||
// this.identified = identified;
|
||||
// }
|
||||
//
|
||||
// public void setCreateTime(final long createTime) {
|
||||
// this.createTime = createTime;
|
||||
// }
|
||||
//
|
||||
// public void setLastTime(final long lastTime) {
|
||||
// this.lastTime = lastTime;
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
package com.bonus.canteen.core.config;
|
||||
|
||||
public interface AuthenticationPredicate {
|
||||
boolean authenticated(AccessToken accessToken);
|
||||
}
|
||||
//package com.bonus.canteen.core.config;
|
||||
//
|
||||
//public interface AuthenticationPredicate {
|
||||
// boolean authenticated(AccessToken accessToken);
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,368 +1,375 @@
|
|||
package com.bonus.canteen.core.config;
|
||||
|
||||
import cn.hutool.core.codec.Base64Decoder;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
@RefreshScope
|
||||
@Component
|
||||
@ConfigurationProperties(
|
||||
prefix = "secure"
|
||||
)
|
||||
public class SecureProperties {
|
||||
public static final String PREFIX = "secure";
|
||||
private boolean enabled = true;
|
||||
private boolean prohibitUnannotatedHandler = false;
|
||||
private String tokenSymbol = "X-Token";
|
||||
private String permissionKey = "secure:pms";
|
||||
private long permissionTTL = 7200L;
|
||||
private long expireAfter = 7200L;
|
||||
private ServerStore server = new ServerStore();
|
||||
private Security security = new Security();
|
||||
private MdcLogParameter mdc = new MdcLogParameter();
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public boolean isProhibitUnannotatedHandler() {
|
||||
return this.prohibitUnannotatedHandler;
|
||||
}
|
||||
|
||||
public String getTokenSymbol() {
|
||||
return this.tokenSymbol;
|
||||
}
|
||||
|
||||
public String getPermissionKey() {
|
||||
return this.permissionKey;
|
||||
}
|
||||
|
||||
public long getPermissionTTL() {
|
||||
return this.permissionTTL;
|
||||
}
|
||||
|
||||
public long getExpireAfter() {
|
||||
return this.expireAfter;
|
||||
}
|
||||
|
||||
public ServerStore getServer() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
public Security getSecurity() {
|
||||
return this.security;
|
||||
}
|
||||
|
||||
public MdcLogParameter getMdc() {
|
||||
return this.mdc;
|
||||
}
|
||||
|
||||
public void setEnabled(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setProhibitUnannotatedHandler(final boolean prohibitUnannotatedHandler) {
|
||||
this.prohibitUnannotatedHandler = prohibitUnannotatedHandler;
|
||||
}
|
||||
|
||||
public void setTokenSymbol(final String tokenSymbol) {
|
||||
this.tokenSymbol = tokenSymbol;
|
||||
}
|
||||
|
||||
public void setPermissionKey(final String permissionKey) {
|
||||
this.permissionKey = permissionKey;
|
||||
}
|
||||
|
||||
public void setPermissionTTL(final long permissionTTL) {
|
||||
this.permissionTTL = permissionTTL;
|
||||
}
|
||||
|
||||
public void setExpireAfter(final long expireAfter) {
|
||||
this.expireAfter = expireAfter;
|
||||
}
|
||||
|
||||
public void setServer(final ServerStore server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public void setSecurity(final Security security) {
|
||||
this.security = security;
|
||||
}
|
||||
|
||||
public void setMdc(final MdcLogParameter mdc) {
|
||||
this.mdc = mdc;
|
||||
}
|
||||
|
||||
public static class ServerStore {
|
||||
private String storeKey = "secure:token";
|
||||
private String subjectRefTokenKey = "secure:subject-token";
|
||||
private long ttl = 14400L;
|
||||
|
||||
public String getStoreKey() {
|
||||
return this.storeKey;
|
||||
}
|
||||
|
||||
public String getSubjectRefTokenKey() {
|
||||
return this.subjectRefTokenKey;
|
||||
}
|
||||
|
||||
public long getTtl() {
|
||||
return this.ttl;
|
||||
}
|
||||
|
||||
public void setStoreKey(final String storeKey) {
|
||||
this.storeKey = storeKey;
|
||||
}
|
||||
|
||||
public void setSubjectRefTokenKey(final String subjectRefTokenKey) {
|
||||
this.subjectRefTokenKey = subjectRefTokenKey;
|
||||
}
|
||||
|
||||
public void setTtl(final long ttl) {
|
||||
this.ttl = ttl;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Security {
|
||||
private String encryptUriPrefix = "/security";
|
||||
private String keyExchangePath = "/exchange/key";
|
||||
private String publicKeyExchangePath = "/exchange/public-key";
|
||||
private Set<String> ignoredUri = Sets.newHashSet();
|
||||
private String requestBodySignParamName = "body";
|
||||
private String clientKeySignParamName = "clientKey";
|
||||
private Set<String> addonSignHeaderPrefix = Sets.newHashSet(new String[]{"X-Security-Ext"});
|
||||
private Set<String> tokenHeaderNames = Sets.newHashSet(new String[]{"X-Security-Token", "X-Security-Tenant-Id", "X-Security-Sn"});
|
||||
private String tokenSignHeaderName = "X-Security-Token-Sign";
|
||||
private String serverKeySignParamName = "serverKey";
|
||||
private String serverSm4Key = "McaCOPft5/J3bUG4pdVjhg==";
|
||||
private byte[] serverSm4KeyBytes;
|
||||
private String serverSm2Key;
|
||||
private byte[] serverSm2KeyBytes;
|
||||
private String clientSm2Key;
|
||||
private byte[] clientSm2KeyBytes;
|
||||
private String timestampHeaderName;
|
||||
private String nonceHeaderName;
|
||||
private String signHeaderName;
|
||||
private String serverEncryptedClientKeyHeaderName;
|
||||
private long maxWindowSeconds;
|
||||
private String playKey;
|
||||
|
||||
public void setServerSm4Key(String serverSm4Key) {
|
||||
this.serverSm4Key = serverSm4Key;
|
||||
this.serverSm4KeyBytes = Base64Decoder.decode(serverSm4Key);
|
||||
}
|
||||
|
||||
public Security() {
|
||||
this.serverSm4KeyBytes = Base64Decoder.decode(this.serverSm4Key);
|
||||
this.serverSm2Key = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgCtqk5Jj7pPWh91d9mPA4Kd7fOfzBULrnAERNDV+4XBCgCgYIKoEcz1UBgi2hRANCAARykhB6sXHWTbB60Pr+laPqEP5JBRpEcySONKKP5Q03o/g3OpnQXc7aVMdLUxL8wD1wQHEu4KHmHQr7jvVt0rkM";
|
||||
this.serverSm2KeyBytes = Base64Decoder.decode(this.serverSm2Key);
|
||||
this.clientSm2Key = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEcpIQerFx1k2wetD6/pWj6hD+SQUaRHMkjjSij+UNN6P4NzqZ0F3O2lTHS1MS/MA9cEBxLuCh5h0K+471bdK5DA==";
|
||||
this.clientSm2KeyBytes = Base64Decoder.decode(this.serverSm2Key);
|
||||
this.timestampHeaderName = "X-Security-Timestamp";
|
||||
this.nonceHeaderName = "X-Security-Nonce";
|
||||
this.signHeaderName = "X-Security-Sign";
|
||||
this.serverEncryptedClientKeyHeaderName = "X-Security-Server-Encrypted-Client-Key";
|
||||
this.maxWindowSeconds = 90L;
|
||||
this.playKey = "__play:";
|
||||
}
|
||||
|
||||
public String getEncryptUriPrefix() {
|
||||
return this.encryptUriPrefix;
|
||||
}
|
||||
|
||||
public String getKeyExchangePath() {
|
||||
return this.keyExchangePath;
|
||||
}
|
||||
|
||||
public String getPublicKeyExchangePath() {
|
||||
return this.publicKeyExchangePath;
|
||||
}
|
||||
|
||||
public Set<String> getIgnoredUri() {
|
||||
return this.ignoredUri;
|
||||
}
|
||||
|
||||
public String getRequestBodySignParamName() {
|
||||
return this.requestBodySignParamName;
|
||||
}
|
||||
|
||||
public String getClientKeySignParamName() {
|
||||
return this.clientKeySignParamName;
|
||||
}
|
||||
|
||||
public Set<String> getAddonSignHeaderPrefix() {
|
||||
return this.addonSignHeaderPrefix;
|
||||
}
|
||||
|
||||
public Set<String> getTokenHeaderNames() {
|
||||
return this.tokenHeaderNames;
|
||||
}
|
||||
|
||||
public String getTokenSignHeaderName() {
|
||||
return this.tokenSignHeaderName;
|
||||
}
|
||||
|
||||
public String getServerKeySignParamName() {
|
||||
return this.serverKeySignParamName;
|
||||
}
|
||||
|
||||
public String getServerSm4Key() {
|
||||
return this.serverSm4Key;
|
||||
}
|
||||
|
||||
public byte[] getServerSm4KeyBytes() {
|
||||
return this.serverSm4KeyBytes;
|
||||
}
|
||||
|
||||
public String getServerSm2Key() {
|
||||
return this.serverSm2Key;
|
||||
}
|
||||
|
||||
public byte[] getServerSm2KeyBytes() {
|
||||
return this.serverSm2KeyBytes;
|
||||
}
|
||||
|
||||
public String getClientSm2Key() {
|
||||
return this.clientSm2Key;
|
||||
}
|
||||
|
||||
public byte[] getClientSm2KeyBytes() {
|
||||
return this.clientSm2KeyBytes;
|
||||
}
|
||||
|
||||
public String getTimestampHeaderName() {
|
||||
return this.timestampHeaderName;
|
||||
}
|
||||
|
||||
public String getNonceHeaderName() {
|
||||
return this.nonceHeaderName;
|
||||
}
|
||||
|
||||
public String getSignHeaderName() {
|
||||
return this.signHeaderName;
|
||||
}
|
||||
|
||||
public String getServerEncryptedClientKeyHeaderName() {
|
||||
return this.serverEncryptedClientKeyHeaderName;
|
||||
}
|
||||
|
||||
public long getMaxWindowSeconds() {
|
||||
return this.maxWindowSeconds;
|
||||
}
|
||||
|
||||
public String getPlayKey() {
|
||||
return this.playKey;
|
||||
}
|
||||
|
||||
public void setEncryptUriPrefix(final String encryptUriPrefix) {
|
||||
this.encryptUriPrefix = encryptUriPrefix;
|
||||
}
|
||||
|
||||
public void setKeyExchangePath(final String keyExchangePath) {
|
||||
this.keyExchangePath = keyExchangePath;
|
||||
}
|
||||
|
||||
public void setPublicKeyExchangePath(final String publicKeyExchangePath) {
|
||||
this.publicKeyExchangePath = publicKeyExchangePath;
|
||||
}
|
||||
|
||||
public void setIgnoredUri(final Set<String> ignoredUri) {
|
||||
this.ignoredUri = ignoredUri;
|
||||
}
|
||||
|
||||
public void setRequestBodySignParamName(final String requestBodySignParamName) {
|
||||
this.requestBodySignParamName = requestBodySignParamName;
|
||||
}
|
||||
|
||||
public void setClientKeySignParamName(final String clientKeySignParamName) {
|
||||
this.clientKeySignParamName = clientKeySignParamName;
|
||||
}
|
||||
|
||||
public void setAddonSignHeaderPrefix(final Set<String> addonSignHeaderPrefix) {
|
||||
this.addonSignHeaderPrefix = addonSignHeaderPrefix;
|
||||
}
|
||||
|
||||
public void setTokenHeaderNames(final Set<String> tokenHeaderNames) {
|
||||
this.tokenHeaderNames = tokenHeaderNames;
|
||||
}
|
||||
|
||||
public void setTokenSignHeaderName(final String tokenSignHeaderName) {
|
||||
this.tokenSignHeaderName = tokenSignHeaderName;
|
||||
}
|
||||
|
||||
public void setServerKeySignParamName(final String serverKeySignParamName) {
|
||||
this.serverKeySignParamName = serverKeySignParamName;
|
||||
}
|
||||
|
||||
public void setServerSm4KeyBytes(final byte[] serverSm4KeyBytes) {
|
||||
this.serverSm4KeyBytes = serverSm4KeyBytes;
|
||||
}
|
||||
|
||||
public void setServerSm2Key(final String serverSm2Key) {
|
||||
this.serverSm2Key = serverSm2Key;
|
||||
}
|
||||
|
||||
public void setServerSm2KeyBytes(final byte[] serverSm2KeyBytes) {
|
||||
this.serverSm2KeyBytes = serverSm2KeyBytes;
|
||||
}
|
||||
|
||||
public void setClientSm2Key(final String clientSm2Key) {
|
||||
this.clientSm2Key = clientSm2Key;
|
||||
}
|
||||
|
||||
public void setClientSm2KeyBytes(final byte[] clientSm2KeyBytes) {
|
||||
this.clientSm2KeyBytes = clientSm2KeyBytes;
|
||||
}
|
||||
|
||||
public void setTimestampHeaderName(final String timestampHeaderName) {
|
||||
this.timestampHeaderName = timestampHeaderName;
|
||||
}
|
||||
|
||||
public void setNonceHeaderName(final String nonceHeaderName) {
|
||||
this.nonceHeaderName = nonceHeaderName;
|
||||
}
|
||||
|
||||
public void setSignHeaderName(final String signHeaderName) {
|
||||
this.signHeaderName = signHeaderName;
|
||||
}
|
||||
|
||||
public void setServerEncryptedClientKeyHeaderName(final String serverEncryptedClientKeyHeaderName) {
|
||||
this.serverEncryptedClientKeyHeaderName = serverEncryptedClientKeyHeaderName;
|
||||
}
|
||||
|
||||
public void setMaxWindowSeconds(final long maxWindowSeconds) {
|
||||
this.maxWindowSeconds = maxWindowSeconds;
|
||||
}
|
||||
|
||||
public void setPlayKey(final String playKey) {
|
||||
this.playKey = playKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class MdcLogParameter {
|
||||
private String subjectId = "x-id";
|
||||
private String subjectName = "x-name";
|
||||
|
||||
public String getSubjectId() {
|
||||
return this.subjectId;
|
||||
}
|
||||
|
||||
public String getSubjectName() {
|
||||
return this.subjectName;
|
||||
}
|
||||
|
||||
public void setSubjectId(final String subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectName(final String subjectName) {
|
||||
this.subjectName = subjectName;
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.bonus.canteen.core.config;
|
||||
//
|
||||
//import cn.hutool.core.codec.Base64Decoder;
|
||||
//import com.google.common.collect.Sets;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.util.Arrays;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//@RefreshScope
|
||||
//@Component
|
||||
//@ConfigurationProperties(
|
||||
// prefix = "secure"
|
||||
//)
|
||||
//public class SecureProperties {
|
||||
// public static final String PREFIX = "secure";
|
||||
// private boolean enabled = true;
|
||||
// private boolean prohibitUnannotatedHandler = false;
|
||||
// private String tokenSymbol = "X-Token";
|
||||
// private String permissionKey = "secure:pms";
|
||||
// private long permissionTTL = 7200L;
|
||||
// private long expireAfter = 7200L;
|
||||
// private ServerStore server = new ServerStore();
|
||||
// private Security security = new Security();
|
||||
// private MdcLogParameter mdc = new MdcLogParameter();
|
||||
//
|
||||
// public boolean isEnabled() {
|
||||
// return this.enabled;
|
||||
// }
|
||||
//
|
||||
// public boolean isProhibitUnannotatedHandler() {
|
||||
// return this.prohibitUnannotatedHandler;
|
||||
// }
|
||||
//
|
||||
// public String getTokenSymbol() {
|
||||
// return this.tokenSymbol;
|
||||
// }
|
||||
//
|
||||
// public String getPermissionKey() {
|
||||
// return this.permissionKey;
|
||||
// }
|
||||
//
|
||||
// public long getPermissionTTL() {
|
||||
// return this.permissionTTL;
|
||||
// }
|
||||
//
|
||||
// public long getExpireAfter() {
|
||||
// return this.expireAfter;
|
||||
// }
|
||||
//
|
||||
// public ServerStore getServer() {
|
||||
// return this.server;
|
||||
// }
|
||||
//
|
||||
// public Security getSecurity() {
|
||||
// return this.security;
|
||||
// }
|
||||
//
|
||||
// public MdcLogParameter getMdc() {
|
||||
// return this.mdc;
|
||||
// }
|
||||
//
|
||||
// public void setEnabled(final boolean enabled) {
|
||||
// this.enabled = enabled;
|
||||
// }
|
||||
//
|
||||
// public void setProhibitUnannotatedHandler(final boolean prohibitUnannotatedHandler) {
|
||||
// this.prohibitUnannotatedHandler = prohibitUnannotatedHandler;
|
||||
// }
|
||||
//
|
||||
// public void setTokenSymbol(final String tokenSymbol) {
|
||||
// this.tokenSymbol = tokenSymbol;
|
||||
// }
|
||||
//
|
||||
// public void setPermissionKey(final String permissionKey) {
|
||||
// this.permissionKey = permissionKey;
|
||||
// }
|
||||
//
|
||||
// public void setPermissionTTL(final long permissionTTL) {
|
||||
// this.permissionTTL = permissionTTL;
|
||||
// }
|
||||
//
|
||||
// public void setExpireAfter(final long expireAfter) {
|
||||
// this.expireAfter = expireAfter;
|
||||
// }
|
||||
//
|
||||
// public void setServer(final ServerStore server) {
|
||||
// this.server = server;
|
||||
// }
|
||||
//
|
||||
// public void setSecurity(final Security security) {
|
||||
// this.security = security;
|
||||
// }
|
||||
//
|
||||
// public void setMdc(final MdcLogParameter mdc) {
|
||||
// this.mdc = mdc;
|
||||
// }
|
||||
//
|
||||
// public static class ServerStore {
|
||||
// private String storeKey = "secure:token";
|
||||
// private String subjectRefTokenKey = "secure:subject-token";
|
||||
// private long ttl = 14400L;
|
||||
//
|
||||
// public String getStoreKey() {
|
||||
// return this.storeKey;
|
||||
// }
|
||||
//
|
||||
// public String getSubjectRefTokenKey() {
|
||||
// return this.subjectRefTokenKey;
|
||||
// }
|
||||
//
|
||||
// public long getTtl() {
|
||||
// return this.ttl;
|
||||
// }
|
||||
//
|
||||
// public void setStoreKey(final String storeKey) {
|
||||
// this.storeKey = storeKey;
|
||||
// }
|
||||
//
|
||||
// public void setSubjectRefTokenKey(final String subjectRefTokenKey) {
|
||||
// this.subjectRefTokenKey = subjectRefTokenKey;
|
||||
// }
|
||||
//
|
||||
// public void setTtl(final long ttl) {
|
||||
// this.ttl = ttl;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static class Security {
|
||||
// private String encryptUriPrefix = "/security";
|
||||
// private String keyExchangePath = "/exchange/key";
|
||||
// private String publicKeyExchangePath = "/exchange/public-key";
|
||||
// private Set<String> ignoredUri = Sets.newHashSet();
|
||||
// private String requestBodySignParamName = "body";
|
||||
// private String clientKeySignParamName = "clientKey";
|
||||
// private Set<String> addonSignHeaderPrefix = Sets.newHashSet(new String[]{"X-Security-Ext"});
|
||||
// private Set<String> tokenHeaderNames = Sets.newHashSet(new String[]{"X-Security-Token", "X-Security-Tenant-Id", "X-Security-Sn"});
|
||||
// private String tokenSignHeaderName = "X-Security-Token-Sign";
|
||||
// private String serverKeySignParamName = "serverKey";
|
||||
// private String serverSm4Key = "McaCOPft5/J3bUG4pdVjhg==";
|
||||
// private byte[] serverSm4KeyBytes;
|
||||
// private String serverSm2Key;
|
||||
// private byte[] serverSm2KeyBytes;
|
||||
// private String clientSm2Key;
|
||||
// private byte[] clientSm2KeyBytes;
|
||||
// private String timestampHeaderName;
|
||||
// private String nonceHeaderName;
|
||||
// private String signHeaderName;
|
||||
// private String serverEncryptedClientKeyHeaderName;
|
||||
// private long maxWindowSeconds;
|
||||
// private String playKey;
|
||||
//
|
||||
// public void setServerSm4Key(String serverSm4Key) {
|
||||
// this.serverSm4Key = serverSm4Key;
|
||||
// this.serverSm4KeyBytes = Base64Decoder.decode(serverSm4Key);
|
||||
// }
|
||||
//
|
||||
// public Security() {
|
||||
// this.serverSm4KeyBytes = Base64Decoder.decode(this.serverSm4Key);
|
||||
// this.serverSm2Key = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgCtqk5Jj7pPWh91d9mPA4Kd7fOfzBULrnAERNDV+4XBCgCgYIKoEcz1UBgi2hRANCAARykhB6sXHWTbB60Pr+laPqEP5JBRpEcySONKKP5Q03o/g3OpnQXc7aVMdLUxL8wD1wQHEu4KHmHQr7jvVt0rkM";
|
||||
// this.serverSm2KeyBytes = Base64Decoder.decode(this.serverSm2Key);
|
||||
// this.clientSm2Key = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEcpIQerFx1k2wetD6/pWj6hD+SQUaRHMkjjSij+UNN6P4NzqZ0F3O2lTHS1MS/MA9cEBxLuCh5h0K+471bdK5DA==";
|
||||
// this.clientSm2KeyBytes = Base64Decoder.decode(this.serverSm2Key);
|
||||
// this.timestampHeaderName = "X-Security-Timestamp";
|
||||
// this.nonceHeaderName = "X-Security-Nonce";
|
||||
// this.signHeaderName = "X-Security-Sign";
|
||||
// this.serverEncryptedClientKeyHeaderName = "X-Security-Server-Encrypted-Client-Key";
|
||||
// this.maxWindowSeconds = 90L;
|
||||
// this.playKey = "__play:";
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// String serverSm2Key = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgCtqk5Jj7pPWh91d9mPA4Kd7fOfzBULrnAERNDV+4XBCgCgYIKoEcz1UBgi2hRANCAARykhB6sXHWTbB60Pr+laPqEP5JBRpEcySONKKP5Q03o/g3OpnQXc7aVMdLUxL8wD1wQHEu4KHmHQr7jvVt0rkM";
|
||||
// System.out.println(Base64Decoder.decode(serverSm2Key));
|
||||
// String clientSm2Key = "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEcpIQerFx1k2wetD6/pWj6hD+SQUaRHMkjjSij+UNN6P4NzqZ0F3O2lTHS1MS/MA9cEBxLuCh5h0K+471bdK5DA==";
|
||||
// System.out.println(Base64Decoder.decode(clientSm2Key));
|
||||
// }
|
||||
//
|
||||
// public String getEncryptUriPrefix() {
|
||||
// return this.encryptUriPrefix;
|
||||
// }
|
||||
//
|
||||
// public String getKeyExchangePath() {
|
||||
// return this.keyExchangePath;
|
||||
// }
|
||||
//
|
||||
// public String getPublicKeyExchangePath() {
|
||||
// return this.publicKeyExchangePath;
|
||||
// }
|
||||
//
|
||||
// public Set<String> getIgnoredUri() {
|
||||
// return this.ignoredUri;
|
||||
// }
|
||||
//
|
||||
// public String getRequestBodySignParamName() {
|
||||
// return this.requestBodySignParamName;
|
||||
// }
|
||||
//
|
||||
// public String getClientKeySignParamName() {
|
||||
// return this.clientKeySignParamName;
|
||||
// }
|
||||
//
|
||||
// public Set<String> getAddonSignHeaderPrefix() {
|
||||
// return this.addonSignHeaderPrefix;
|
||||
// }
|
||||
//
|
||||
// public Set<String> getTokenHeaderNames() {
|
||||
// return this.tokenHeaderNames;
|
||||
// }
|
||||
//
|
||||
// public String getTokenSignHeaderName() {
|
||||
// return this.tokenSignHeaderName;
|
||||
// }
|
||||
//
|
||||
// public String getServerKeySignParamName() {
|
||||
// return this.serverKeySignParamName;
|
||||
// }
|
||||
//
|
||||
// public String getServerSm4Key() {
|
||||
// return this.serverSm4Key;
|
||||
// }
|
||||
//
|
||||
// public byte[] getServerSm4KeyBytes() {
|
||||
// return this.serverSm4KeyBytes;
|
||||
// }
|
||||
//
|
||||
// public String getServerSm2Key() {
|
||||
// return this.serverSm2Key;
|
||||
// }
|
||||
//
|
||||
// public byte[] getServerSm2KeyBytes() {
|
||||
// return this.serverSm2KeyBytes;
|
||||
// }
|
||||
//
|
||||
// public String getClientSm2Key() {
|
||||
// return this.clientSm2Key;
|
||||
// }
|
||||
//
|
||||
// public byte[] getClientSm2KeyBytes() {
|
||||
// return this.clientSm2KeyBytes;
|
||||
// }
|
||||
//
|
||||
// public String getTimestampHeaderName() {
|
||||
// return this.timestampHeaderName;
|
||||
// }
|
||||
//
|
||||
// public String getNonceHeaderName() {
|
||||
// return this.nonceHeaderName;
|
||||
// }
|
||||
//
|
||||
// public String getSignHeaderName() {
|
||||
// return this.signHeaderName;
|
||||
// }
|
||||
//
|
||||
// public String getServerEncryptedClientKeyHeaderName() {
|
||||
// return this.serverEncryptedClientKeyHeaderName;
|
||||
// }
|
||||
//
|
||||
// public long getMaxWindowSeconds() {
|
||||
// return this.maxWindowSeconds;
|
||||
// }
|
||||
//
|
||||
// public String getPlayKey() {
|
||||
// return this.playKey;
|
||||
// }
|
||||
//
|
||||
// public void setEncryptUriPrefix(final String encryptUriPrefix) {
|
||||
// this.encryptUriPrefix = encryptUriPrefix;
|
||||
// }
|
||||
//
|
||||
// public void setKeyExchangePath(final String keyExchangePath) {
|
||||
// this.keyExchangePath = keyExchangePath;
|
||||
// }
|
||||
//
|
||||
// public void setPublicKeyExchangePath(final String publicKeyExchangePath) {
|
||||
// this.publicKeyExchangePath = publicKeyExchangePath;
|
||||
// }
|
||||
//
|
||||
// public void setIgnoredUri(final Set<String> ignoredUri) {
|
||||
// this.ignoredUri = ignoredUri;
|
||||
// }
|
||||
//
|
||||
// public void setRequestBodySignParamName(final String requestBodySignParamName) {
|
||||
// this.requestBodySignParamName = requestBodySignParamName;
|
||||
// }
|
||||
//
|
||||
// public void setClientKeySignParamName(final String clientKeySignParamName) {
|
||||
// this.clientKeySignParamName = clientKeySignParamName;
|
||||
// }
|
||||
//
|
||||
// public void setAddonSignHeaderPrefix(final Set<String> addonSignHeaderPrefix) {
|
||||
// this.addonSignHeaderPrefix = addonSignHeaderPrefix;
|
||||
// }
|
||||
//
|
||||
// public void setTokenHeaderNames(final Set<String> tokenHeaderNames) {
|
||||
// this.tokenHeaderNames = tokenHeaderNames;
|
||||
// }
|
||||
//
|
||||
// public void setTokenSignHeaderName(final String tokenSignHeaderName) {
|
||||
// this.tokenSignHeaderName = tokenSignHeaderName;
|
||||
// }
|
||||
//
|
||||
// public void setServerKeySignParamName(final String serverKeySignParamName) {
|
||||
// this.serverKeySignParamName = serverKeySignParamName;
|
||||
// }
|
||||
//
|
||||
// public void setServerSm4KeyBytes(final byte[] serverSm4KeyBytes) {
|
||||
// this.serverSm4KeyBytes = serverSm4KeyBytes;
|
||||
// }
|
||||
//
|
||||
// public void setServerSm2Key(final String serverSm2Key) {
|
||||
// this.serverSm2Key = serverSm2Key;
|
||||
// }
|
||||
//
|
||||
// public void setServerSm2KeyBytes(final byte[] serverSm2KeyBytes) {
|
||||
// this.serverSm2KeyBytes = serverSm2KeyBytes;
|
||||
// }
|
||||
//
|
||||
// public void setClientSm2Key(final String clientSm2Key) {
|
||||
// this.clientSm2Key = clientSm2Key;
|
||||
// }
|
||||
//
|
||||
// public void setClientSm2KeyBytes(final byte[] clientSm2KeyBytes) {
|
||||
// this.clientSm2KeyBytes = clientSm2KeyBytes;
|
||||
// }
|
||||
//
|
||||
// public void setTimestampHeaderName(final String timestampHeaderName) {
|
||||
// this.timestampHeaderName = timestampHeaderName;
|
||||
// }
|
||||
//
|
||||
// public void setNonceHeaderName(final String nonceHeaderName) {
|
||||
// this.nonceHeaderName = nonceHeaderName;
|
||||
// }
|
||||
//
|
||||
// public void setSignHeaderName(final String signHeaderName) {
|
||||
// this.signHeaderName = signHeaderName;
|
||||
// }
|
||||
//
|
||||
// public void setServerEncryptedClientKeyHeaderName(final String serverEncryptedClientKeyHeaderName) {
|
||||
// this.serverEncryptedClientKeyHeaderName = serverEncryptedClientKeyHeaderName;
|
||||
// }
|
||||
//
|
||||
// public void setMaxWindowSeconds(final long maxWindowSeconds) {
|
||||
// this.maxWindowSeconds = maxWindowSeconds;
|
||||
// }
|
||||
//
|
||||
// public void setPlayKey(final String playKey) {
|
||||
// this.playKey = playKey;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public static class MdcLogParameter {
|
||||
// private String subjectId = "x-id";
|
||||
// private String subjectName = "x-name";
|
||||
//
|
||||
// public String getSubjectId() {
|
||||
// return this.subjectId;
|
||||
// }
|
||||
//
|
||||
// public String getSubjectName() {
|
||||
// return this.subjectName;
|
||||
// }
|
||||
//
|
||||
// public void setSubjectId(final String subjectId) {
|
||||
// this.subjectId = subjectId;
|
||||
// }
|
||||
//
|
||||
// public void setSubjectName(final String subjectName) {
|
||||
// this.subjectName = subjectName;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import cn.hutool.crypto.SmUtil;
|
|||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import cn.hutool.crypto.asymmetric.SM2;
|
||||
import cn.hutool.crypto.symmetric.SM4;
|
||||
import com.bonus.common.houqin.framework.secure.SecureProperties;
|
||||
import com.google.common.base.Joiner;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -1,101 +1,101 @@
|
|||
package com.bonus.canteen.core.config;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class WebContext {
|
||||
private static final ThreadLocal<Context> THREAD_CONTEXT = new InheritableThreadLocal<Context>() {
|
||||
protected Context initialValue() {
|
||||
return new Context();
|
||||
}
|
||||
};
|
||||
|
||||
private WebContext() {
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
THREAD_CONTEXT.remove();
|
||||
}
|
||||
|
||||
public static Context get() {
|
||||
return (Context)THREAD_CONTEXT.get();
|
||||
}
|
||||
|
||||
public static void set(Context context) {
|
||||
THREAD_CONTEXT.set(context);
|
||||
}
|
||||
|
||||
public static class Context {
|
||||
private HttpServletRequest request;
|
||||
private HttpServletResponse response;
|
||||
private AccessToken accessToken;
|
||||
private Map<String, Object> attributes = Maps.newHashMap();
|
||||
|
||||
public Context(HttpServletRequest request, HttpServletResponse response) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public void setAttribute(String key, Object data) {
|
||||
this.attributes.put(key, data);
|
||||
}
|
||||
|
||||
public Object getAttribute(String key) {
|
||||
return this.attributes.get(key);
|
||||
}
|
||||
|
||||
public void removeAttribute(String key) {
|
||||
this.attributes.remove(key);
|
||||
}
|
||||
|
||||
public void clearAttribute() {
|
||||
this.attributes.clear();
|
||||
}
|
||||
|
||||
public Optional<AccessToken> getAccessToken() {
|
||||
return Optional.ofNullable(this.accessToken);
|
||||
}
|
||||
|
||||
public Optional<HttpServletRequest> getRequest() {
|
||||
return Optional.ofNullable(this.request);
|
||||
}
|
||||
|
||||
public Optional<HttpServletResponse> getResponse() {
|
||||
return Optional.ofNullable(this.response);
|
||||
}
|
||||
|
||||
public Map<String, Object> getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
public void setRequest(final HttpServletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public void setResponse(final HttpServletResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public void setAccessToken(final AccessToken accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public void setAttributes(final Map<String, Object> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public Context() {
|
||||
}
|
||||
|
||||
public Context(final HttpServletRequest request, final HttpServletResponse response, final AccessToken accessToken, final Map<String, Object> attributes) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
this.accessToken = accessToken;
|
||||
this.attributes = attributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.bonus.canteen.core.config;
|
||||
//
|
||||
//import com.google.common.collect.Maps;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//import java.util.Map;
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//public class WebContext {
|
||||
// private static final ThreadLocal<Context> THREAD_CONTEXT = new InheritableThreadLocal<Context>() {
|
||||
// protected Context initialValue() {
|
||||
// return new Context();
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// private WebContext() {
|
||||
// }
|
||||
//
|
||||
// public static void reset() {
|
||||
// THREAD_CONTEXT.remove();
|
||||
// }
|
||||
//
|
||||
// public static Context get() {
|
||||
// return (Context)THREAD_CONTEXT.get();
|
||||
// }
|
||||
//
|
||||
// public static void set(Context context) {
|
||||
// THREAD_CONTEXT.set(context);
|
||||
// }
|
||||
//
|
||||
// public static class Context {
|
||||
// private HttpServletRequest request;
|
||||
// private HttpServletResponse response;
|
||||
// private AccessToken accessToken;
|
||||
// private Map<String, Object> attributes = Maps.newHashMap();
|
||||
//
|
||||
// public Context(HttpServletRequest request, HttpServletResponse response) {
|
||||
// this.request = request;
|
||||
// this.response = response;
|
||||
// }
|
||||
//
|
||||
// public void setAttribute(String key, Object data) {
|
||||
// this.attributes.put(key, data);
|
||||
// }
|
||||
//
|
||||
// public Object getAttribute(String key) {
|
||||
// return this.attributes.get(key);
|
||||
// }
|
||||
//
|
||||
// public void removeAttribute(String key) {
|
||||
// this.attributes.remove(key);
|
||||
// }
|
||||
//
|
||||
// public void clearAttribute() {
|
||||
// this.attributes.clear();
|
||||
// }
|
||||
//
|
||||
// public Optional<AccessToken> getAccessToken() {
|
||||
// return Optional.ofNullable(this.accessToken);
|
||||
// }
|
||||
//
|
||||
// public Optional<HttpServletRequest> getRequest() {
|
||||
// return Optional.ofNullable(this.request);
|
||||
// }
|
||||
//
|
||||
// public Optional<HttpServletResponse> getResponse() {
|
||||
// return Optional.ofNullable(this.response);
|
||||
// }
|
||||
//
|
||||
// public Map<String, Object> getAttributes() {
|
||||
// return this.attributes;
|
||||
// }
|
||||
//
|
||||
// public void setRequest(final HttpServletRequest request) {
|
||||
// this.request = request;
|
||||
// }
|
||||
//
|
||||
// public void setResponse(final HttpServletResponse response) {
|
||||
// this.response = response;
|
||||
// }
|
||||
//
|
||||
// public void setAccessToken(final AccessToken accessToken) {
|
||||
// this.accessToken = accessToken;
|
||||
// }
|
||||
//
|
||||
// public void setAttributes(final Map<String, Object> attributes) {
|
||||
// this.attributes = attributes;
|
||||
// }
|
||||
//
|
||||
// public Context() {
|
||||
// }
|
||||
//
|
||||
// public Context(final HttpServletRequest request, final HttpServletResponse response, final AccessToken accessToken, final Map<String, Object> attributes) {
|
||||
// this.request = request;
|
||||
// this.response = response;
|
||||
// this.accessToken = accessToken;
|
||||
// this.attributes = attributes;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bonus.canteen.core.config.json;
|
||||
|
||||
import com.bonus.canteen.core.config.WebContext;
|
||||
import com.bonus.common.houqin.framework.secure.WebContext;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.Module;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
package com.bonus.canteen.core.customer.service;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface AuthorizingService {
|
||||
default Set<String> roles(long accountId) {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
|
||||
default Set<String> permissions(long accountId) {
|
||||
return Sets.newHashSet();
|
||||
}
|
||||
}
|
||||
//package com.bonus.canteen.core.customer.service;
|
||||
//
|
||||
//import com.google.common.collect.Sets;
|
||||
//
|
||||
//import java.util.Set;
|
||||
//
|
||||
//public interface AuthorizingService {
|
||||
// default Set<String> roles(long accountId) {
|
||||
// return Sets.newHashSet();
|
||||
// }
|
||||
//
|
||||
// default Set<String> permissions(long accountId) {
|
||||
// return Sets.newHashSet();
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.bonus.canteen.core.merchant.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ApiModel("商家信息")
|
||||
public class MercMerchantEndTimeVO {
|
||||
@ApiModelProperty("授权截止日期")
|
||||
private LocalDateTime endTime;
|
||||
@ApiModelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return this.endTime;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setEndTime(final LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public void setStatus(final Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String var10000 = String.valueOf(this.getEndTime());
|
||||
return "MercMerchantEndTimeVO(endTime=" + var10000 + ", status=" + this.getStatus() + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
package com.bonus.canteen.core.notice.hawkeye.model;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.bonus.canteen.core.common.encrypt.LeNiuDecryptDataProcess;
|
||||
import com.bonus.canteen.core.common.encrypt.LeNiuDecryptField;
|
||||
import com.bonus.canteen.core.common.encrypt.SM4EncDecHandler;
|
||||
import com.bonus.canteen.core.notice.hawkeye.util.LocalDateTimeConverter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName(
|
||||
value = "alloc_log_record",
|
||||
autoResultMap = true
|
||||
)
|
||||
@ApiModel("系统日志统计表")
|
||||
@LeNiuDecryptDataProcess
|
||||
public class AllocLogRecord extends Model<AllocLogRecord> {
|
||||
@TableId
|
||||
@ApiModelProperty("主键id")
|
||||
@ExcelIgnore
|
||||
private Long id;
|
||||
@ApiModelProperty("日志统计id")
|
||||
@ExcelIgnore
|
||||
private Long logRecordId;
|
||||
@ApiModelProperty("登录人员名称")
|
||||
@ExcelProperty(
|
||||
value = {"登录人员名称"},
|
||||
index = 0
|
||||
)
|
||||
private String loginUserName;
|
||||
@ApiModelProperty("登录人员手机号")
|
||||
@ExcelProperty(
|
||||
value = {"登录人员手机号"},
|
||||
index = 1
|
||||
)
|
||||
@TableField(
|
||||
value = "login_user_phone",
|
||||
typeHandler = SM4EncDecHandler.class
|
||||
)
|
||||
@LeNiuDecryptField
|
||||
private String loginUserPhone;
|
||||
@ApiModelProperty("登录人员手机号后缀")
|
||||
@TableField(
|
||||
value = "login_user_phone_suffix",
|
||||
typeHandler = SM4EncDecHandler.class
|
||||
)
|
||||
@LeNiuDecryptField
|
||||
@ExcelIgnore
|
||||
private String loginUserPhoneSuffix;
|
||||
@ApiModelProperty("登录ip地址")
|
||||
@ExcelProperty(
|
||||
value = {"登录ip地址"},
|
||||
index = 2
|
||||
)
|
||||
private String loginIp;
|
||||
@ApiModelProperty("请求uri")
|
||||
@ExcelProperty(
|
||||
value = {"请求URI"},
|
||||
index = 3
|
||||
)
|
||||
private String requestUri;
|
||||
@ApiModelProperty("访问功能")
|
||||
@ExcelProperty(
|
||||
value = {"操作类型"},
|
||||
index = 4
|
||||
)
|
||||
private String operateFunc;
|
||||
@ApiModelProperty("操作类型")
|
||||
@ExcelIgnore
|
||||
private Integer operateType;
|
||||
@ApiModelProperty("执行时间")
|
||||
@ExcelIgnore
|
||||
private Long executionTime;
|
||||
@ApiModelProperty("创建人")
|
||||
@ExcelIgnore
|
||||
private String crby;
|
||||
@ApiModelProperty("创建时间")
|
||||
@ExcelProperty(
|
||||
value = {"操作时间"},
|
||||
index = 5,
|
||||
converter = LocalDateTimeConverter.class
|
||||
)
|
||||
private LocalDateTime crtime;
|
||||
|
||||
public AllocLogRecord(Long logRecordId, String loginUserName, String requestUri, String operateFunc, Integer operateType) {
|
||||
this.logRecordId = logRecordId;
|
||||
this.loginUserName = loginUserName;
|
||||
this.requestUri = requestUri;
|
||||
this.operateFunc = operateFunc;
|
||||
this.operateType = operateType;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long getLogRecordId() {
|
||||
return this.logRecordId;
|
||||
}
|
||||
|
||||
public String getLoginUserName() {
|
||||
return this.loginUserName;
|
||||
}
|
||||
|
||||
public String getLoginUserPhone() {
|
||||
return this.loginUserPhone;
|
||||
}
|
||||
|
||||
public String getLoginUserPhoneSuffix() {
|
||||
return this.loginUserPhoneSuffix;
|
||||
}
|
||||
|
||||
public String getLoginIp() {
|
||||
return this.loginIp;
|
||||
}
|
||||
|
||||
public String getRequestUri() {
|
||||
return this.requestUri;
|
||||
}
|
||||
|
||||
public String getOperateFunc() {
|
||||
return this.operateFunc;
|
||||
}
|
||||
|
||||
public Integer getOperateType() {
|
||||
return this.operateType;
|
||||
}
|
||||
|
||||
public Long getExecutionTime() {
|
||||
return this.executionTime;
|
||||
}
|
||||
|
||||
public String getCrby() {
|
||||
return this.crby;
|
||||
}
|
||||
|
||||
public LocalDateTime getCrtime() {
|
||||
return this.crtime;
|
||||
}
|
||||
|
||||
public void setId(final Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setLogRecordId(final Long logRecordId) {
|
||||
this.logRecordId = logRecordId;
|
||||
}
|
||||
|
||||
public void setLoginUserName(final String loginUserName) {
|
||||
this.loginUserName = loginUserName;
|
||||
}
|
||||
|
||||
public void setLoginUserPhone(final String loginUserPhone) {
|
||||
this.loginUserPhone = loginUserPhone;
|
||||
}
|
||||
|
||||
public void setLoginUserPhoneSuffix(final String loginUserPhoneSuffix) {
|
||||
this.loginUserPhoneSuffix = loginUserPhoneSuffix;
|
||||
}
|
||||
|
||||
public void setLoginIp(final String loginIp) {
|
||||
this.loginIp = loginIp;
|
||||
}
|
||||
|
||||
public void setRequestUri(final String requestUri) {
|
||||
this.requestUri = requestUri;
|
||||
}
|
||||
|
||||
public void setOperateFunc(final String operateFunc) {
|
||||
this.operateFunc = operateFunc;
|
||||
}
|
||||
|
||||
public void setOperateType(final Integer operateType) {
|
||||
this.operateType = operateType;
|
||||
}
|
||||
|
||||
public void setExecutionTime(final Long executionTime) {
|
||||
this.executionTime = executionTime;
|
||||
}
|
||||
|
||||
public void setCrby(final String crby) {
|
||||
this.crby = crby;
|
||||
}
|
||||
|
||||
public void setCrtime(final LocalDateTime crtime) {
|
||||
this.crtime = crtime;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
Long var10000 = this.getId();
|
||||
return "AllocLogRecord(id=" + var10000 + ", logRecordId=" + this.getLogRecordId() + ", loginUserName=" + this.getLoginUserName() + ", loginUserPhone=" + this.getLoginUserPhone() + ", loginUserPhoneSuffix=" + this.getLoginUserPhoneSuffix() + ", loginIp=" + this.getLoginIp() + ", requestUri=" + this.getRequestUri() + ", operateFunc=" + this.getOperateFunc() + ", operateType=" + this.getOperateType() + ", executionTime=" + this.getExecutionTime() + ", crby=" + this.getCrby() + ", crtime=" + String.valueOf(this.getCrtime()) + ")";
|
||||
}
|
||||
|
||||
public AllocLogRecord() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.bonus.canteen.core.notice.hawkeye.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.bonus.canteen.core.common.utils.PageDTO;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class AllocLogRecordParam extends PageDTO {
|
||||
@ApiModelProperty("登录人员名称")
|
||||
private String loginUserName;
|
||||
@ApiModelProperty("登录人员手机号")
|
||||
private String loginUserPhone;
|
||||
@ApiModelProperty("时间")
|
||||
private LocalDateTime crtimeStart;
|
||||
private LocalDateTime crtimeEnd;
|
||||
|
||||
public String getLoginUserName() {
|
||||
return this.loginUserName;
|
||||
}
|
||||
|
||||
public String getLoginUserPhone() {
|
||||
return this.loginUserPhone;
|
||||
}
|
||||
|
||||
public LocalDateTime getCrtimeStart() {
|
||||
return this.crtimeStart;
|
||||
}
|
||||
|
||||
public LocalDateTime getCrtimeEnd() {
|
||||
return this.crtimeEnd;
|
||||
}
|
||||
|
||||
public void setLoginUserName(final String loginUserName) {
|
||||
this.loginUserName = loginUserName;
|
||||
}
|
||||
|
||||
public void setLoginUserPhone(final String loginUserPhone) {
|
||||
this.loginUserPhone = loginUserPhone;
|
||||
}
|
||||
|
||||
public void setCrtimeStart(final LocalDateTime crtimeStart) {
|
||||
this.crtimeStart = crtimeStart;
|
||||
}
|
||||
|
||||
public void setCrtimeEnd(final LocalDateTime crtimeEnd) {
|
||||
this.crtimeEnd = crtimeEnd;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String var10000 = this.getLoginUserName();
|
||||
return "AllocLogRecordParam(loginUserName=" + var10000 + ", loginUserPhone=" + this.getLoginUserPhone() + ", crtimeStart=" + String.valueOf(this.getCrtimeStart()) + ", crtimeEnd=" + String.valueOf(this.getCrtimeEnd()) + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.bonus.canteen.core.notice.hawkeye.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bonus.canteen.core.notice.hawkeye.model.AllocLogRecord;
|
||||
import com.bonus.canteen.core.notice.hawkeye.param.AllocLogRecordParam;
|
||||
|
||||
public interface AllocLogRecordService extends IService<AllocLogRecord> {
|
||||
Page<AllocLogRecord> pageLogRecord(AllocLogRecordParam param);
|
||||
|
||||
void saveLogRecord(AllocLogRecord logRecord);
|
||||
|
||||
void saveLogRecordForCustom(AllocLogRecord logRecord);
|
||||
|
||||
void genLogRecordExcelFile(AllocLogRecordParam param);
|
||||
|
||||
String getExcelFileUrl();
|
||||
}
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
package com.bonus.canteen.core.notice.hawkeye.service.impl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.DesensitizedUtil.DesensitizedType;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.extra.servlet.JakartaServletUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelWriter;
|
||||
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.pig4cloud.pigx.common.core.exception.LeException;
|
||||
import com.pig4cloud.pigx.common.core.util.LeBeanUtil;
|
||||
import com.pig4cloud.pigx.common.oss.OssProperties;
|
||||
import com.pig4cloud.pigx.common.oss.service.OssTemplate;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.xnzn.core.auth.api.MgrUserApi;
|
||||
import net.xnzn.core.common.constant.FileConstants;
|
||||
import net.xnzn.core.common.encrypt.SM4EncryptUtils;
|
||||
import net.xnzn.core.common.enums.FileUploadSourceEnum;
|
||||
import net.xnzn.core.common.redis.RedisUtil;
|
||||
import net.xnzn.core.common.utils.AesEncryptUtil;
|
||||
import net.xnzn.core.common.utils.SysUtil;
|
||||
import net.xnzn.core.notice.hawkeye.mapper.AllocLogRecordMapper;
|
||||
import net.xnzn.core.notice.hawkeye.model.AllocLogRecord;
|
||||
import net.xnzn.core.notice.hawkeye.param.AllocLogRecordParam;
|
||||
import net.xnzn.core.notice.hawkeye.service.AllocLogRecordService;
|
||||
import net.xnzn.framework.config.i18n.I18n;
|
||||
import net.xnzn.framework.data.dataset.Executors;
|
||||
import net.xnzn.framework.data.tenant.TenantContextHolder;
|
||||
import net.xnzn.framework.id.Id;
|
||||
import net.xnzn.framework.secure.SecureManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class AllocLogRecordServiceImpl extends ServiceImpl<AllocLogRecordMapper, AllocLogRecord> implements AllocLogRecordService {
|
||||
private static final Logger log = LoggerFactory.getLogger(AllocLogRecordServiceImpl.class);
|
||||
@Autowired
|
||||
@Lazy
|
||||
private MgrUserApi mgrUserApi;
|
||||
@Autowired
|
||||
private OssProperties ossProperties;
|
||||
@Autowired
|
||||
private OssTemplate ossTemplate;
|
||||
@Autowired
|
||||
private AesEncryptUtil aesEncryptUtil;
|
||||
private static final String GEN_LOG_EXCEL_KEY = "yst:merchantId:userId:gen:allocLog:excel";
|
||||
private static final String DOWNLOAD_LOG_EXCEL_URL_KEY = "yst:merchantId:userId:download:allocLog:excel:url";
|
||||
private static final String USER_ID = "user_id";
|
||||
|
||||
public Page<AllocLogRecord> pageLogRecord(AllocLogRecordParam param) {
|
||||
param.setLoginUserName(LeBeanUtil.fieldLikeHandle(param.getLoginUserName()));
|
||||
Page<AllocLogRecord> page = new Page(param.getCurrent(), param.getSize());
|
||||
Page<AllocLogRecord> recordPage = ((AllocLogRecordMapper)this.baseMapper).pageLogRecord(page, param);
|
||||
recordPage.getRecords().forEach((allocLogRecord) -> {
|
||||
allocLogRecord.setLoginUserPhone(SM4EncryptUtils.desensitizedByConfig(allocLogRecord.getLoginUserPhone(), DesensitizedType.MOBILE_PHONE));
|
||||
});
|
||||
return recordPage;
|
||||
}
|
||||
|
||||
public void saveLogRecord(AllocLogRecord logRecord) {
|
||||
if (!"admin".equals(logRecord.getLoginUserName())) {
|
||||
if (ObjectUtil.isNotNull(logRecord.getLogRecordId())) {
|
||||
logRecord.setLoginUserPhone(this.mgrUserApi.getPhoneByUserId(logRecord.getLogRecordId()));
|
||||
if (ObjectUtil.isNotEmpty(logRecord.getLoginUserPhone())) {
|
||||
logRecord.setLoginUserPhoneSuffix(logRecord.getLoginUserPhone().substring(logRecord.getLoginUserPhone().length() - 4));
|
||||
}
|
||||
}
|
||||
|
||||
logRecord.setLogRecordId(Id.next());
|
||||
((AllocLogRecordMapper)this.baseMapper).insert(logRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveLogRecordForCustom(AllocLogRecord logRecord) {
|
||||
HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
logRecord.setLoginIp(JakartaServletUtil.getClientIP(request, new String[0]));
|
||||
logRecord.setCrby(logRecord.getLoginUserName());
|
||||
logRecord.setCrtime(LocalDateTime.now());
|
||||
this.saveLogRecord(logRecord);
|
||||
}
|
||||
|
||||
public void genLogRecordExcelFile(AllocLogRecordParam param) {
|
||||
Long userId = (Long)SecureManager.getSubjectId().get();
|
||||
Long merchantId = TenantContextHolder.getTenantId();
|
||||
String key = "yst:merchantId:userId:gen:allocLog:excel".replace("merchantId", merchantId.toString()).replace("user_id", userId.toString());
|
||||
String downLoadKey = "yst:merchantId:userId:download:allocLog:excel:url".replace("merchantId", merchantId.toString()).replace("user_id", userId.toString());
|
||||
if (ObjectUtil.isNotEmpty(RedisUtil.getString(key))) {
|
||||
throw new LeException(I18n.getMessage("notice_alloc_log_record_gen_excel_file_wait_exception", new Object[0]));
|
||||
} else if (ObjectUtil.isNotEmpty(RedisUtil.getString(downLoadKey))) {
|
||||
throw new LeException(I18n.getMessage("notice_alloc_log_record_gen_excel_file_done_exception", new Object[0]));
|
||||
} else {
|
||||
RedisUtil.setString(key, "user_id");
|
||||
Executors.doInTenant(merchantId, (status) -> {
|
||||
int maxSize = 10000;
|
||||
ExcelWriter excelWriter = null;
|
||||
|
||||
try {
|
||||
param.setLoginUserName(LeBeanUtil.fieldLikeHandle(param.getLoginUserName()));
|
||||
List<AllocLogRecord> records = ((AllocLogRecordMapper)this.baseMapper).listLogRecord(param);
|
||||
if (!ObjectUtil.isEmpty(records)) {
|
||||
List<List<AllocLogRecord>> lists = Lists.partition(records, maxSize);
|
||||
String fileName = this.getFileNameByParam(param);
|
||||
String var10000 = FileConstants.tempPath;
|
||||
String filePath = var10000 + TenantContextHolder.getTenantId() + File.separator + "logExcel";
|
||||
File path = new File(filePath);
|
||||
if (!path.exists()) {
|
||||
path.mkdirs();
|
||||
}
|
||||
|
||||
String fullFileName = filePath + File.separator + fileName;
|
||||
log.info("本地excel文件路径:{}", fullFileName);
|
||||
File excelFile = FileUtil.file(fullFileName);
|
||||
OutputStream os = FileUtil.getOutputStream(excelFile);
|
||||
|
||||
try {
|
||||
excelWriter = EasyExcel.write(os, AllocLogRecord.class).build();
|
||||
int i = 0;
|
||||
|
||||
while(true) {
|
||||
if (i >= lists.size()) {
|
||||
excelWriter.finish();
|
||||
break;
|
||||
}
|
||||
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet(i, "日志明细" + (i + 1)).build();
|
||||
List<AllocLogRecord> data = (List)lists.get(i);
|
||||
excelWriter.write(data, writeSheet);
|
||||
++i;
|
||||
}
|
||||
} catch (Throwable var29) {
|
||||
if (os != null) {
|
||||
try {
|
||||
os.close();
|
||||
} catch (Throwable var27) {
|
||||
var29.addSuppressed(var27);
|
||||
}
|
||||
}
|
||||
|
||||
throw var29;
|
||||
}
|
||||
|
||||
if (os != null) {
|
||||
os.close();
|
||||
}
|
||||
|
||||
Long var34 = TenantContextHolder.getTenantId();
|
||||
String objectName = "" + var34 + "/" + FileUploadSourceEnum.CUST.key() + "/" + fileName;
|
||||
String bucketName = this.ossProperties.getBucketName();
|
||||
InputStream inputStream = FileUtil.getInputStream(excelFile);
|
||||
|
||||
try {
|
||||
this.ossTemplate.putObject(bucketName, objectName, inputStream);
|
||||
} catch (Throwable var28) {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (Throwable var26) {
|
||||
var28.addSuppressed(var26);
|
||||
}
|
||||
}
|
||||
|
||||
throw var28;
|
||||
}
|
||||
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
|
||||
FileUtil.del(excelFile);
|
||||
RedisUtil.setObj(downLoadKey, SysUtil.getCutFileUrl("/" + bucketName + "/" + objectName));
|
||||
log.info("系统日志导出生成结束");
|
||||
return;
|
||||
}
|
||||
} catch (Exception var30) {
|
||||
log.info("生成日志导出文件错误:{}", var30.getMessage(), var30);
|
||||
return;
|
||||
} finally {
|
||||
RedisUtil.delete(key);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private String getFileNameByParam(AllocLogRecordParam param) {
|
||||
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||
StringBuilder sb = new StringBuilder("日志明细");
|
||||
if (ObjectUtil.isNotEmpty(param.getLoginUserName())) {
|
||||
sb.append("_").append(param.getLoginUserName());
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(param.getLoginUserPhone())) {
|
||||
sb.append("_").append(param.getLoginUserPhone());
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(param.getCrtimeStart())) {
|
||||
sb.append("_").append(param.getCrtimeStart().format(df));
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(param.getCrtimeEnd())) {
|
||||
sb.append("_").append(param.getCrtimeEnd().format(df));
|
||||
}
|
||||
|
||||
sb.append("_").append(LocalDateTime.now().format(df));
|
||||
sb.append(".xlsx");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getExcelFileUrl() {
|
||||
Long userId = (Long)SecureManager.getSubjectId().get();
|
||||
String key = "yst:merchantId:userId:download:allocLog:excel:url".replace("merchantId", TenantContextHolder.getTenantId().toString()).replace("user_id", userId.toString());
|
||||
Object fileUrl = RedisUtil.getObj(key);
|
||||
if (ObjectUtil.isEmpty(fileUrl)) {
|
||||
throw new LeException(I18n.getMessage("notice_alloc_log_record_get_excel_empty_url_exception", new Object[0]));
|
||||
} else {
|
||||
RedisUtil.delete(key);
|
||||
return (String)fileUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.bonus.canteen.core.notice.hawkeye.util;
|
||||
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LocalDateTimeConverter implements Converter<LocalDateTime> {
|
||||
public Class<LocalDateTime> supportJavaTypeKey() {
|
||||
return LocalDateTime.class;
|
||||
}
|
||||
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
public LocalDateTime convertToJavaData(ReadCellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public WriteCellData<String> convertToExcelData(LocalDateTime localDateTime, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if (Objects.isNull(localDateTime)) {
|
||||
return new WriteCellData("");
|
||||
} else {
|
||||
String dateStr = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return new WriteCellData(dateStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +1,40 @@
|
|||
package com.bonus.canteen.core.secure;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
|
||||
public class PmsCache {
|
||||
private long expireTime;
|
||||
private Set<String> pms;
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isExpired() {
|
||||
return Instant.now().getEpochSecond() > this.expireTime;
|
||||
}
|
||||
|
||||
public long getExpireTime() {
|
||||
return this.expireTime;
|
||||
}
|
||||
|
||||
public Set<String> getPms() {
|
||||
return this.pms;
|
||||
}
|
||||
|
||||
public void setExpireTime(final long expireTime) {
|
||||
this.expireTime = expireTime;
|
||||
}
|
||||
|
||||
public void setPms(final Set<String> pms) {
|
||||
this.pms = pms;
|
||||
}
|
||||
|
||||
public PmsCache(final long expireTime, final Set<String> pms) {
|
||||
this.expireTime = expireTime;
|
||||
this.pms = pms;
|
||||
}
|
||||
|
||||
public PmsCache() {
|
||||
}
|
||||
}
|
||||
//package com.bonus.canteen.core.secure;
|
||||
//
|
||||
//import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
//
|
||||
//import java.time.Instant;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//public class PmsCache {
|
||||
// private long expireTime;
|
||||
// private Set<String> pms;
|
||||
//
|
||||
// @JsonIgnore
|
||||
// public boolean isExpired() {
|
||||
// return Instant.now().getEpochSecond() > this.expireTime;
|
||||
// }
|
||||
//
|
||||
// public long getExpireTime() {
|
||||
// return this.expireTime;
|
||||
// }
|
||||
//
|
||||
// public Set<String> getPms() {
|
||||
// return this.pms;
|
||||
// }
|
||||
//
|
||||
// public void setExpireTime(final long expireTime) {
|
||||
// this.expireTime = expireTime;
|
||||
// }
|
||||
//
|
||||
// public void setPms(final Set<String> pms) {
|
||||
// this.pms = pms;
|
||||
// }
|
||||
//
|
||||
// public PmsCache(final long expireTime, final Set<String> pms) {
|
||||
// this.expireTime = expireTime;
|
||||
// this.pms = pms;
|
||||
// }
|
||||
//
|
||||
// public PmsCache() {
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.bonus.canteen.core.starter.threadpool;
|
||||
|
||||
import com.bonus.canteen.core.common.utils.TenantContextHolder;
|
||||
import com.bonus.canteen.core.config.WebContext;
|
||||
import com.bonus.common.houqin.framework.secure.WebContext;
|
||||
import com.bonus.canteen.core.dataset.rule.RoutingRule;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.auth.user.mapper.MgrUserInSystemMapper">
|
||||
<!-- 根据商户id获取商户信息 -->
|
||||
<select id="selectMerchantByMerchantId" resultType="com.bonus.canteen.core.merchant.vo.MercMerchantEndTimeVO">
|
||||
select end_time endTime,
|
||||
status
|
||||
from merc_merchant
|
||||
where tenant_id = #{tenantId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.canteen.core.auth.user.mapper.MgrUserRoleMapper">
|
||||
<resultMap id="mgrUserRoleMap" type="com.bonus.canteen.core.auth.user.entity.MgrUserRole">
|
||||
<id property="userId" column="user_id"/>
|
||||
<result property="roleId" column="role_id"/>
|
||||
</resultMap>
|
||||
<select id="listRoles" resultType="java.lang.String">
|
||||
SELECT r.role_code
|
||||
FROM mgr_role r
|
||||
WHERE EXISTS(SELECT 1 FROM mgr_user_role u WHERE u.user_id = #{userId} AND r.role_id = u.role_id)
|
||||
AND r.del_flag = 2
|
||||
</select>
|
||||
|
||||
<select id="getMgrUserRoleListByUserId" resultType="com.bonus.canteen.core.auth.user.vo.MgrUserRoleInfoVO">
|
||||
SELECT r.role_id,
|
||||
r.role_code,
|
||||
r.role_type,
|
||||
ur.if_default
|
||||
FROM mgr_role r
|
||||
JOIN mgr_user_role ur ON ur.role_id = r.role_id
|
||||
WHERE r.del_flag = 2 AND ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<update id="updateDefaultByRoleCode">
|
||||
UPDATE mgr_user_role ur , mgr_role r
|
||||
SET ur.if_default = #{ifDefault}
|
||||
WHERE ur.user_id = #{userId}
|
||||
AND ur.role_id = r.role_id
|
||||
AND r.role_code = #{roleCode}
|
||||
</update>
|
||||
|
||||
<select id="getUserRoleVOByUserIdList" resultType="com.bonus.canteen.core.auth.user.vo.MgrUserRolePageVO">
|
||||
SELECT mur.user_id,
|
||||
mr.role_id,
|
||||
mr.role_code,
|
||||
mr.role_name,
|
||||
mr.role_desc
|
||||
FROM mgr_user_role mur
|
||||
LEFT JOIN mgr_role mr ON mur.role_id = mr.role_id
|
||||
where mur.user_id IN
|
||||
<foreach collection="userIdList" open="(" close=")" item="userId" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue