feat(cms): 添加网站密钥和字段加密功能
- 在 CmsWebsite 实体中新增 websiteSecret 字段 - 在 CmsWebsiteField 和 CmsWebsiteFieldParam 中新增 encrypted 字段 - 在 CmsWebsiteParam 中新增 websiteSecret 字段- 优化 MybatisPlusConfig 中租户ID获取逻辑,增强空值判断- 移除 ShopUserRefereeController 中多余的权限注解 - 添加清除缓存时的控制台输出日志- 修复潜在的空指针异常并统一异常日志输出格式
This commit is contained in:
@@ -525,6 +525,7 @@ public class CmsWebsiteController extends BaseController {
|
||||
@DeleteMapping("/clearSiteInfo/{key}")
|
||||
public ApiResult<?> clearSiteInfo(@PathVariable("key") String key) {
|
||||
log.info("清除缓存开始,key: {}", key);
|
||||
System.out.println("清除缓存开始,key = " + key);
|
||||
// 清除指定key
|
||||
redisUtil.delete(key);
|
||||
// 清除缓存
|
||||
|
||||
@@ -41,6 +41,9 @@ public class CmsWebsite implements Serializable {
|
||||
@Schema(description = "网站标识")
|
||||
private String websiteCode;
|
||||
|
||||
@Schema(description = "网站密钥")
|
||||
private String websiteSecret;
|
||||
|
||||
@Schema(description = "网站LOGO")
|
||||
private String websiteIcon;
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ public class CmsWebsiteField implements Serializable {
|
||||
@Schema(description = "国际化语言")
|
||||
private String lang;
|
||||
|
||||
@Schema(description = "是否加密")
|
||||
private Boolean encrypted;
|
||||
|
||||
@Schema(description = "商户ID")
|
||||
private Long merchantId;
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ public class CmsWebsiteFieldParam extends BaseParam {
|
||||
@Schema(description = "名称")
|
||||
private String value;
|
||||
|
||||
@Schema(description = "是否加密")
|
||||
private Boolean encrypted;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@@ -41,6 +41,9 @@ public class CmsWebsiteParam extends BaseParam {
|
||||
@Schema(description = "网站标识")
|
||||
private String websiteCode;
|
||||
|
||||
@Schema(description = "网站密钥")
|
||||
private String websiteSecret;
|
||||
|
||||
@Schema(description = "网站LOGO")
|
||||
private String websiteIcon;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class MybatisPlusConfig {
|
||||
if (request != null) {
|
||||
// 从请求头拿ID
|
||||
tenantId = request.getHeader("tenantId");
|
||||
if(tenantId != null){
|
||||
if(tenantId != null && !tenantId.trim().isEmpty()){
|
||||
return new LongValue(tenantId);
|
||||
}
|
||||
// 从域名拿ID
|
||||
@@ -57,7 +57,7 @@ public class MybatisPlusConfig {
|
||||
if (StrUtil.isNotBlank(Domain)) {
|
||||
String key = "Domain:" + Domain;
|
||||
tenantId = redisUtil.get(key);
|
||||
if(tenantId != null){
|
||||
if(tenantId != null && !tenantId.trim().isEmpty()){
|
||||
System.out.println("从域名拿TID = " + tenantId);
|
||||
return new LongValue(tenantId);
|
||||
}
|
||||
@@ -65,8 +65,17 @@ public class MybatisPlusConfig {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 忽略异常,使用默认逻辑
|
||||
System.err.println("获取租户ID异常: " + e.getMessage());
|
||||
}
|
||||
return getLoginUserTenantId();
|
||||
|
||||
// 最后尝试从登录用户获取
|
||||
Expression loginUserTenantId = getLoginUserTenantId();
|
||||
if (loginUserTenantId instanceof LongValue) {
|
||||
return loginUserTenantId;
|
||||
}
|
||||
|
||||
// 如果都获取不到,返回null而不是undefined
|
||||
return new NullValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,11 +128,14 @@ public class MybatisPlusConfig {
|
||||
if (authentication != null) {
|
||||
Object object = authentication.getPrincipal();
|
||||
if (object instanceof User) {
|
||||
return new LongValue(((User) object).getTenantId());
|
||||
Integer tenantId = ((User) object).getTenantId();
|
||||
if (tenantId != null) {
|
||||
return new LongValue(tenantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
System.err.println("获取登录用户租户ID异常: " + e.getMessage());
|
||||
}
|
||||
return new NullValue();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ public class ShopUserRefereeController extends BaseController {
|
||||
@Resource
|
||||
private ShopUserRefereeService shopUserRefereeService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:shopUserReferee:list')")
|
||||
@Operation(summary = "分页查询用户推荐关系表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ShopUserReferee>> page(ShopUserRefereeParam param) {
|
||||
@@ -39,7 +38,6 @@ public class ShopUserRefereeController extends BaseController {
|
||||
return success(shopUserRefereeService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:shopUserReferee:list')")
|
||||
@Operation(summary = "查询全部用户推荐关系表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ShopUserReferee>> list(ShopUserRefereeParam param) {
|
||||
|
||||
Reference in New Issue
Block a user