feat: nacos网关微服务搭建/注册登录缓存用户角色权限信息
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.schisandra.auth.application.convert;
|
||||
|
||||
import com.schisandra.auth.application.dto.SchisandraAuthRolePermissionDTO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthRolePermissionBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* dto转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraAuthRolePermissionDTOConverter {
|
||||
|
||||
SchisandraAuthRolePermissionDTOConverter INSTANCE = Mappers.getMapper(SchisandraAuthRolePermissionDTOConverter.class);
|
||||
|
||||
SchisandraAuthRolePermissionBO convertDTOToBO(SchisandraAuthRolePermissionDTO schisandraAuthRolePermissionDTO);
|
||||
SchisandraAuthRolePermissionDTO convertBOToDTO(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO);
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.schisandra.auth.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* dto
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraAuthRolePermissionDTO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long permissionId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,58 @@
|
||||
package com.schisandra.auth.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* bo
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraAuthRolePermissionBO implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long permissionId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package com.schisandra.auth.domain.convert;
|
||||
|
||||
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthRolePermissionBO;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* bo转换器
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraAuthRolePermissionBOConverter {
|
||||
|
||||
SchisandraAuthRolePermissionBOConverter INSTANCE = Mappers.getMapper(SchisandraAuthRolePermissionBOConverter.class);
|
||||
|
||||
SchisandraAuthRolePermission convertBOToEntity(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO);
|
||||
SchisandraAuthRolePermissionBO convertEntityToBO(SchisandraAuthRolePermission schisandraAuthRolePermission);
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.schisandra.auth.domain.service;
|
||||
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthRolePermissionBO;
|
||||
|
||||
/**
|
||||
* 领域service
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
public interface SchisandraAuthRolePermissionDomainService {
|
||||
|
||||
/**
|
||||
* 添加 信息
|
||||
*/
|
||||
Boolean add(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO);
|
||||
|
||||
/**
|
||||
* 更新 信息
|
||||
*/
|
||||
Boolean update(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO);
|
||||
|
||||
/**
|
||||
* 删除 信息
|
||||
*/
|
||||
Boolean delete(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO);
|
||||
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.schisandra.auth.domain.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthRolePermissionBO;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthRolePermissionBOConverter;
|
||||
import com.schisandra.auth.domain.service.SchisandraAuthRolePermissionDomainService;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthRolePermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 领域service实现了
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraAuthRolePermissionDomainServiceImpl implements SchisandraAuthRolePermissionDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthRolePermissionService schisandraAuthRolePermissionService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO) {
|
||||
SchisandraAuthRolePermission schisandraAuthRolePermission = SchisandraAuthRolePermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRolePermissionBO);
|
||||
schisandraAuthRolePermission.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraAuthRolePermissionService.insert(schisandraAuthRolePermission) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO) {
|
||||
SchisandraAuthRolePermission schisandraAuthRolePermission = SchisandraAuthRolePermissionBOConverter.INSTANCE.convertBOToEntity(schisandraAuthRolePermissionBO);
|
||||
return schisandraAuthRolePermissionService.update(schisandraAuthRolePermission) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraAuthRolePermissionBO schisandraAuthRolePermissionBO) {
|
||||
SchisandraAuthRolePermission schisandraAuthRolePermission = new SchisandraAuthRolePermission();
|
||||
schisandraAuthRolePermission.setId(schisandraAuthRolePermissionBO.getId());
|
||||
schisandraAuthRolePermission.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraAuthRolePermissionService.update(schisandraAuthRolePermission) > 0;
|
||||
}
|
||||
|
||||
}
|
@@ -4,10 +4,12 @@ package com.schisandra.auth.domain.service.impl;
|
||||
import cn.dev33.satoken.stp.SaLoginConfig;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.schisandra.auth.common.entity.Result;
|
||||
import com.schisandra.auth.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.auth.common.enums.UserRoleEnum;
|
||||
import com.schisandra.auth.common.enums.UserStatusEnum;
|
||||
import com.schisandra.auth.common.redis.RedisUtil;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserBO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthSocialUserMapperBO;
|
||||
import com.schisandra.auth.domain.bo.SchisandraAuthUserBO;
|
||||
@@ -17,14 +19,8 @@ import com.schisandra.auth.domain.convert.SchisandraAuthSocialUserMapperBOConver
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthUserBOConverter;
|
||||
import com.schisandra.auth.domain.convert.SchisandraAuthUserRoleBOConverter;
|
||||
import com.schisandra.auth.domain.service.SchisandraAuthUserDomainService;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUser;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthSocialUserMapper;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUserRole;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserMapperService;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthSocialUserService;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserRoleService;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthUserService;
|
||||
import com.schisandra.auth.infra.basic.entity.*;
|
||||
import com.schisandra.auth.infra.basic.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.zhyd.oauth.model.AuthToken;
|
||||
import me.zhyd.oauth.model.AuthUser;
|
||||
@@ -33,7 +29,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 领域service实现了
|
||||
@@ -57,6 +56,23 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
@Resource
|
||||
private SchisandraAuthSocialUserMapperService schisandraAuthSocialUserMapperService;
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthRoleService schisandraAuthRoleService;
|
||||
|
||||
|
||||
private final String AUTH_PERMISSION_PREFIX = "auth.permission";
|
||||
|
||||
private final String AUTH_ROLE_PREFIX = "auth.role";
|
||||
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthRolePermissionService schisandraAuthRolePermissionService;
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthPermissionService schisandraAuthPermissionService;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 注册用户
|
||||
@@ -92,9 +108,9 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
public SchisandraAuthUserBO login(SchisandraAuthUserBO schisandraAuthUserBO) {
|
||||
|
||||
Pattern pattern = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
|
||||
Boolean emailmatch = pattern.matcher(schisandraAuthUserBO.getUserName()).matches();
|
||||
Boolean emailMatch = pattern.matcher(schisandraAuthUserBO.getUserName()).matches();
|
||||
SchisandraAuthUser schisandraAuthUser;
|
||||
if (emailmatch) {
|
||||
if (emailMatch) {
|
||||
schisandraAuthUser = schisandraAuthUserService.queryByEmail(schisandraAuthUserBO.getUserName());
|
||||
} else {
|
||||
schisandraAuthUser = schisandraAuthUserService.queryByPhone(schisandraAuthUserBO.getUserName());
|
||||
@@ -155,7 +171,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
/**
|
||||
* @param id
|
||||
* @return java.lang.Object
|
||||
* @description 添加用户信息
|
||||
* @description 删除用户信息
|
||||
* @author msz
|
||||
* @date 2024/4/3 22:30
|
||||
*/
|
||||
@@ -191,7 +207,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
AuthToken token = data.getToken();
|
||||
SchisandraAuthSocialUser authSocialUser = schisandraAuthSocialUserService.selectByUuidAndType(uuid, type);
|
||||
if (ObjectUtils.isNotEmpty(authSocialUser)) {
|
||||
// 更新社会用户信息表
|
||||
// 如果用户登录过就更新社会用户信息表
|
||||
SchisandraAuthSocialUserBO schisandraAuthSocialUserBO = new SchisandraAuthSocialUserBO();
|
||||
schisandraAuthSocialUserBO.setAccessToken(token.getAccessToken());
|
||||
schisandraAuthSocialUserBO.setSource(data.getSource());
|
||||
@@ -215,6 +231,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
}
|
||||
return Result.fail("Social User update fail");
|
||||
}
|
||||
// 获取用户id
|
||||
SchisandraAuthSocialUserMapper schisandraAuthSocialUserMapper = new SchisandraAuthSocialUserMapper();
|
||||
schisandraAuthSocialUserMapper.setSocialUserId(authSocialUser.getId());
|
||||
SchisandraAuthSocialUserMapper result = schisandraAuthSocialUserMapperService.queryBySocialUserId(schisandraAuthSocialUserMapper);
|
||||
@@ -225,8 +242,10 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
return Result.fail("Social Mapper is empty");
|
||||
}
|
||||
Long userId = result.getUserId();
|
||||
|
||||
// redis存储用户角色与权限信息
|
||||
userInfoPersistence(userId);
|
||||
StpUtil.login(userId, SaLoginConfig.setToken(token.getAccessToken()));
|
||||
return Result.ok();
|
||||
} else {
|
||||
// 插入用户信息表
|
||||
SchisandraAuthUserBO schisandraAuthUserBO = new SchisandraAuthUserBO();
|
||||
@@ -297,7 +316,7 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
// 建立用户与角色映射关系
|
||||
SchisandraAuthUserRoleBO schisandraAuthUserRoleBO = new SchisandraAuthUserRoleBO();
|
||||
schisandraAuthUserRoleBO.setUserId(authUserId);
|
||||
schisandraAuthUserRoleBO.setRoleId((long) UserRoleEnum.NORMAL_USER.getCode());
|
||||
schisandraAuthUserRoleBO.setRoleId(UserRoleEnum.NORMAL_USER.getCode());
|
||||
schisandraAuthUserRoleBO.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
SchisandraAuthUserRole schisandraAuthUserRole = SchisandraAuthUserRoleBOConverter.INSTANCE.convertBOToEntity(schisandraAuthUserRoleBO);
|
||||
int insert = schisandraAuthUserRoleService.insert(schisandraAuthUserRole);
|
||||
@@ -307,10 +326,40 @@ public class SchisandraAuthUserDomainServiceImpl implements SchisandraAuthUserDo
|
||||
}
|
||||
return Result.fail("insertUserRole fail");
|
||||
}
|
||||
|
||||
// redis存储用户角色与权限信息
|
||||
userInfoPersistence(authUserId);
|
||||
|
||||
StpUtil.login(authUserId, SaLoginConfig.setToken(token.getAccessToken()));
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.ok();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 用户信息持久化
|
||||
* @param: [authUserId]
|
||||
* @return: void
|
||||
* @author: landaiqing
|
||||
* @date: 2024/6/2 0:37
|
||||
*/
|
||||
private void userInfoPersistence(Long authUserId) {
|
||||
// 查询用户角色并存入redis
|
||||
SchisandraAuthRole schisandraAuthRole = schisandraAuthRoleService.queryByRoleId(UserRoleEnum.NORMAL_USER.getCode());
|
||||
String roleKey = redisUtil.buildKey(AUTH_ROLE_PREFIX, String.valueOf(authUserId));
|
||||
List<SchisandraAuthRole> roleList = new LinkedList<>();
|
||||
roleList.add(schisandraAuthRole);
|
||||
redisUtil.set(roleKey, new Gson().toJson(roleList));
|
||||
|
||||
// 查询用户权限并存入redis
|
||||
SchisandraAuthRolePermission schisandraAuthRolePermission = new SchisandraAuthRolePermission();
|
||||
schisandraAuthRolePermission.setRoleId(UserRoleEnum.NORMAL_USER.getCode());
|
||||
List<SchisandraAuthRolePermission> rolePermissionList = schisandraAuthRolePermissionService.queryByRoleId(schisandraAuthRolePermission);
|
||||
List<Long> permissionIdList = rolePermissionList.stream()
|
||||
.map(SchisandraAuthRolePermission::getPermissionId).collect(Collectors.toList());
|
||||
List<SchisandraAuthPermission> permissionList = schisandraAuthPermissionService.queryListByIds(permissionIdList);
|
||||
String permissionKey = redisUtil.buildKey(AUTH_PERMISSION_PREFIX, String.valueOf(authUserId));
|
||||
redisUtil.set(permissionKey, new Gson().toJson(permissionList));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.schisandra.auth.infra.basic.dao;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -14,7 +16,7 @@ import java.util.List;
|
||||
* @since 2024-04-11 13:00:10
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraAuthPermissionDao {
|
||||
public interface SchisandraAuthPermissionDao extends BaseMapper<SchisandraAuthPermission> {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.schisandra.auth.infra.basic.dao;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -14,7 +16,7 @@ import java.util.List;
|
||||
* @since 2024-03-22 21:35:31
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraAuthRoleDao {
|
||||
public interface SchisandraAuthRoleDao extends BaseMapper<SchisandraAuthRole> {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
|
@@ -0,0 +1,18 @@
|
||||
package com.schisandra.auth.infra.basic.dao;
|
||||
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 权限角色表数据库访问层
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraAuthRolePermissionDao extends BaseMapper<SchisandraAuthRolePermission> {
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,13 @@
|
||||
package com.schisandra.auth.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* (SchisandraAuthPermission)实体类
|
||||
@@ -14,6 +16,7 @@ import java.io.Serializable;
|
||||
* @since 2024-04-11 13:00:10
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "schisandra_auth_permission")
|
||||
public class SchisandraAuthPermission implements Serializable {
|
||||
|
||||
@Id(value = "id", keyType = KeyType.Auto)
|
||||
@@ -51,6 +54,7 @@ public class SchisandraAuthPermission implements Serializable {
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@Column(isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.schisandra.auth.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -14,6 +16,7 @@ import java.io.Serializable;
|
||||
* @since 2024-03-22 21:35:31
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "schisandra_auth_role")
|
||||
public class SchisandraAuthRole implements Serializable {
|
||||
|
||||
/**
|
||||
@@ -55,6 +58,7 @@ public class SchisandraAuthRole implements Serializable {
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@Column(isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
|
||||
|
@@ -0,0 +1,71 @@
|
||||
package com.schisandra.auth.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Data
|
||||
@Table("schisandra_auth_role_permission")
|
||||
public class SchisandraAuthRolePermission implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Id(value = "id", keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("role_id")
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("permission_id")
|
||||
private Long permissionId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Column("created_by")
|
||||
private String createdBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column("created_time")
|
||||
private Date createdTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Column("update_by")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("is_deleted")
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -160,7 +160,7 @@ public class SchisandraAuthSocialUser implements Serializable {
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@Column("is_deleted")
|
||||
@Column(value = "is_deleted",isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
* 实体类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-05-23 20:13:10
|
||||
@@ -20,7 +20,7 @@ import java.util.Date;
|
||||
public class SchisandraAuthSocialUserMapper implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Id(value = "id", keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
@@ -62,9 +62,9 @@ public class SchisandraAuthSocialUserMapper implements Serializable {
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Column("is_deleted")
|
||||
@Column(value = "is_deleted",isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ public class SchisandraAuthUser implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("is_deleted")
|
||||
@Column(value = "is_deleted",isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
/**
|
||||
|
@@ -65,7 +65,7 @@ public class SchisandraAuthUserRole implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("is_deleted")
|
||||
@Column(value = "is_deleted",isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.schisandra.auth.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -14,6 +16,7 @@ import java.io.Serializable;
|
||||
* @since 2024-05-11 15:47:59
|
||||
*/
|
||||
@Data
|
||||
@Table(value = "schisandra_sms_config")
|
||||
public class SchisandraSmsConfig implements Serializable {
|
||||
|
||||
/**
|
||||
@@ -170,6 +173,7 @@ public class SchisandraSmsConfig implements Serializable {
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
@Column(isLogicDelete = true)
|
||||
private Integer isDeleted;
|
||||
|
||||
private String extraJson;
|
||||
|
@@ -4,6 +4,8 @@ import com.schisandra.auth.infra.basic.entity.SchisandraAuthPermission;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (SchisandraAuthPermission)表服务接口
|
||||
*
|
||||
@@ -53,4 +55,5 @@ public interface SchisandraAuthPermissionService {
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
List<SchisandraAuthPermission> queryListByIds(List<Long> permissionIdList);
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package com.schisandra.auth.infra.basic.service;
|
||||
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表服务接口
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
public interface SchisandraAuthRolePermissionService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SchisandraAuthRolePermission queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraAuthRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(SchisandraAuthRolePermission schisandraAuthRolePermission);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraAuthRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SchisandraAuthRolePermission schisandraAuthRolePermission);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
|
||||
List<SchisandraAuthRolePermission> queryByRoleId(SchisandraAuthRolePermission schisandraAuthRolePermission);
|
||||
}
|
@@ -53,4 +53,5 @@ public interface SchisandraAuthRoleService {
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
SchisandraAuthRole queryByRoleId(Long code);
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (SchisandraAuthPermission)表服务实现类
|
||||
@@ -79,4 +80,9 @@ public class SchisandraAuthPermissionServiceImpl implements SchisandraAuthPermis
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraAuthPermissionDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchisandraAuthPermission> queryListByIds(List<Long> permissionIdList) {
|
||||
return schisandraAuthPermissionDao.selectListByIds(permissionIdList);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,75 @@
|
||||
package com.schisandra.auth.infra.basic.service.impl;
|
||||
|
||||
|
||||
import com.schisandra.auth.infra.basic.dao.SchisandraAuthRolePermissionDao;
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission;
|
||||
import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthRolePermissionTableDef;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthRolePermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 表服务实现类
|
||||
*
|
||||
* @author landaiqing
|
||||
* @since 2024-06-02 00:14:38
|
||||
*/
|
||||
@Service("SchisandraAuthRolePermissionService")
|
||||
public class SchisandraAuthRolePermissionServiceImpl implements SchisandraAuthRolePermissionService {
|
||||
|
||||
@Resource
|
||||
private SchisandraAuthRolePermissionDao schisandraAuthRolePermissionDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraAuthRolePermission queryById(Long id) {
|
||||
return this.schisandraAuthRolePermissionDao.selectOneById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraAuthRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraAuthRolePermission schisandraAuthRolePermission) {
|
||||
return this.schisandraAuthRolePermissionDao.insert(schisandraAuthRolePermission, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraAuthRolePermission 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraAuthRolePermission schisandraAuthRolePermission) {
|
||||
return this.schisandraAuthRolePermissionDao.update(schisandraAuthRolePermission, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraAuthRolePermissionDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchisandraAuthRolePermission> queryByRoleId(SchisandraAuthRolePermission schisandraAuthRolePermission) {
|
||||
return schisandraAuthRolePermissionDao.selectListByCondition(SchisandraAuthRolePermissionTableDef.SCHISANDRA_AUTH_ROLE_PERMISSION.ROLE_ID.eq(schisandraAuthRolePermission.getRoleId()));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -2,6 +2,7 @@ package com.schisandra.auth.infra.basic.service.impl;
|
||||
|
||||
import com.schisandra.auth.infra.basic.entity.SchisandraAuthRole;
|
||||
import com.schisandra.auth.infra.basic.dao.SchisandraAuthRoleDao;
|
||||
import com.schisandra.auth.infra.basic.entity.table.SchisandraAuthRoleTableDef;
|
||||
import com.schisandra.auth.infra.basic.service.SchisandraAuthRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -81,4 +82,9 @@ public class SchisandraAuthRoleServiceImpl implements SchisandraAuthRoleService
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraAuthRoleDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchisandraAuthRole queryByRoleId(Long code) {
|
||||
return schisandraAuthRoleDao.selectOneByCondition(SchisandraAuthRoleTableDef.SCHISANDRA_AUTH_ROLE.ID.eq(code));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,16 @@
|
||||
<?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.schisandra.auth.infra.basic.dao.SchisandraAuthRolePermissionDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.auth.infra.basic.entity.SchisandraAuthRolePermission">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="role_id" jdbcType="BIGINT" property="roleId"/>
|
||||
<result column="permission_id" jdbcType="BIGINT" property="permissionId"/>
|
||||
<result column="created_by" jdbcType="VARCHAR" property="createdBy"/>
|
||||
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@@ -1,11 +1,12 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.schisandra</groupId>
|
||||
<groupId>com.schisandra.gateway</groupId>
|
||||
<artifactId>schisandra-cloud-storage-gateway</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>schisandra-cloud-storage-gateway</name>
|
||||
|
||||
<properties>
|
||||
@@ -25,16 +26,16 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
<version>1.18.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
@@ -69,6 +70,11 @@
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@@ -26,32 +26,32 @@ public class StpInterfaceImpl implements StpInterface {
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
private String authPermissionPrefix = "auth.permission";
|
||||
private final String AUTH_PERMISSION_PREFIX = "auth.permission";
|
||||
|
||||
private String authRolePrefix = "auth.role";
|
||||
private final String AUTH_ROLE_PREFIX = "auth.role";
|
||||
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
return getAuth(loginId.toString(), authPermissionPrefix);
|
||||
public List<String> getPermissionList(Object userId, String loginType) {
|
||||
return getAuth(userId.toString(), AUTH_PERMISSION_PREFIX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
return getAuth(loginId.toString(), authRolePrefix);
|
||||
public List<String> getRoleList(Object userId, String loginType) {
|
||||
return getAuth(userId.toString(), AUTH_ROLE_PREFIX);
|
||||
}
|
||||
|
||||
private List<String> getAuth(String loginId, String prefix) {
|
||||
String authKey = redisUtil.buildKey(prefix, loginId.toString());
|
||||
private List<String> getAuth(String userId, String prefix) {
|
||||
String authKey = redisUtil.buildKey(prefix, userId);
|
||||
String authValue = redisUtil.get(authKey);
|
||||
if (StringUtils.isBlank(authValue)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> authList = new LinkedList<>();
|
||||
if (authRolePrefix.equals(prefix)) {
|
||||
if (AUTH_ROLE_PREFIX.equals(prefix)) {
|
||||
List<AuthRole> roleList = new Gson().fromJson(authValue, new TypeToken<List<AuthRole>>() {
|
||||
}.getType());
|
||||
authList = roleList.stream().map(AuthRole::getRoleKey).collect(Collectors.toList());
|
||||
} else if (authPermissionPrefix.equals(prefix)) {
|
||||
} else if (AUTH_PERMISSION_PREFIX.equals(prefix)) {
|
||||
List<AuthPermission> permissionList = new Gson().fromJson(authValue, new TypeToken<List<AuthPermission>>() {
|
||||
}.getType());
|
||||
authList = permissionList.stream().map(AuthPermission::getPermissionKey).collect(Collectors.toList());
|
||||
|
@@ -31,16 +31,16 @@ public class LoginFilter implements GlobalFilter {
|
||||
ServerHttpRequest.Builder mutate = request.mutate();
|
||||
String url = request.getURI().getPath();
|
||||
log.info("LoginFilter.filter.url:{}", url);
|
||||
if (url.equals("/user/doLogin") || url.equals("/user/getUserInfo")) {
|
||||
return chain.filter(exchange);
|
||||
if (url.equals("/auth/render/") || url.equals("/auth/callback/") || url.equals("/auth/user/register") || url.equals("/auth/user/login") || url.equals("/system/getConfigByKey")) {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
|
||||
String loginId = (String) tokenInfo.getLoginId();
|
||||
if (StringUtils.isEmpty(loginId)) {
|
||||
String userId = (String) tokenInfo.getLoginId();
|
||||
if (StringUtils.isEmpty(userId)) {
|
||||
throw new Exception("未获取到用户信息");
|
||||
}
|
||||
|
||||
mutate.header("loginId", loginId);
|
||||
mutate.header("userId", userId);
|
||||
|
||||
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 6000
|
||||
port: 5050
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
@@ -59,5 +59,6 @@ sa-token:
|
||||
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
|
||||
token-style: random-32
|
||||
# 是否输出操作日志
|
||||
is-log: true
|
||||
token-prefix: schisandra
|
||||
is-log: false
|
||||
token-prefix: schisandra
|
||||
is-print: false
|
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
,---,
|
||||
,--.' | ,--, ,---,
|
||||
| | : ,--.'| ,---, ,---.'| __ ,-.
|
||||
.--.--. : : : | |, .--.--. ,-+-. / | | | :,' ,'/ /|
|
||||
/ / ' ,---. : | |,--.`--'_ / / ' ,--.--. ,--.'|' | | | |' | |' | ,--.--.
|
||||
| : /`./ / \ | : ' |,' ,'| | : /`./ / \ | | ,"' | ,--.__| || | ,'/ \
|
||||
| : ;_ / / ' | | /' :' | | | : ;_ .--. .-. | | | / | | / ,' |' : / .--. .-. |
|
||||
\ \ `. . ' / ' : | | || | : \ \ `. \__\/: . . | | | | |. ' / || | ' \__\/: . .
|
||||
`----. \' ; :__ | | ' | :' : |__ `----. \ ," .--.; | | | | |/ ' ; |: |; : | ," .--.; |
|
||||
/ /`--' /' | '.'|| : :_:,'| | '.'| / /`--' // / ,. | | | |--' | | '/ '| , ; / / ,. |
|
||||
'--'. / | : :| | ,' ; : ;'--'. /; : .' \| |/ | : :| ---' ; : .' \
|
||||
`--'---' \ \ / `--'' | , / `--'---' | , .-./'---' \ \ / | , .-./
|
||||
`----' ---`-' `--`---' `----' `--`---'
|
||||
|
||||
Spring Boot: ${spring-boot.formatted-version}
|
||||
五味子云存储
|
@@ -6,12 +6,13 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
config:
|
||||
server-addr: 116.196.80.239:8848
|
||||
server-addr: 1.95.0.111:8848
|
||||
prefix: ${spring.application.name}
|
||||
group: DEFAULT_GROUP
|
||||
namespace:
|
||||
file-extension: yaml
|
||||
timeout: 60000
|
||||
discovery:
|
||||
enabled: true
|
||||
server-addr: 116.196.80.239:8848
|
||||
server-addr: 1.95.0.111:8848
|
||||
|
||||
|
@@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--Configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出-->
|
||||
<!--monitorInterval:Log4j能够自动检测修改配置 文件和重新配置本身,设置间隔秒数-->
|
||||
<configuration status="INFO" monitorInterval="5">
|
||||
<!--日志级别以及优先级排序: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL -->
|
||||
<!--变量配置-->
|
||||
<Properties>
|
||||
<!-- 格式化输出:%date表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度 %msg:日志消息,%n是换行符-->
|
||||
<!-- %logger{36} 表示 Logger 名字最长36个字符 -->
|
||||
<property name="LOG_PATTERN" value="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%thread]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx" />
|
||||
<!-- 定义日志存储的路径 -->
|
||||
<property name="FILE_PATH" value="../log" />
|
||||
<property name="FILE_NAME" value="schisandra-cloud-storage-gateway.log" />
|
||||
</Properties>
|
||||
|
||||
<!--https://logging.apache.org/log4j/2.x/manual/appenders.html-->
|
||||
<appenders>
|
||||
|
||||
<console name="Console" target="SYSTEM_OUT">
|
||||
<!--输出日志的格式-->
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<!--控制台只输出level及其以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
</console>
|
||||
|
||||
<!--文件会打印出所有信息,这个log每次运行程序会自动清空,由append属性决定,适合临时测试用-->
|
||||
<File name="fileLog" fileName="${FILE_PATH}/temp.log" append="false">
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
</File>
|
||||
|
||||
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||
<RollingFile name="RollingFileInfo" fileName="${FILE_PATH}/info.log" filePattern="${FILE_PATH}/${FILE_NAME}-INFO-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 这个会打印出所有的warn及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||
<RollingFile name="RollingFileWarn" fileName="${FILE_PATH}/warn.log" filePattern="${FILE_PATH}/${FILE_NAME}-WARN-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
<!-- 这个会打印出所有的error及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档-->
|
||||
<RollingFile name="RollingFileError" fileName="${FILE_PATH}/error.log" filePattern="${FILE_PATH}/${FILE_NAME}-ERROR-%d{yyyy-MM-dd}_%i.log.gz">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)-->
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="${LOG_PATTERN}"/>
|
||||
<Policies>
|
||||
<!--interval属性用来指定多久滚动一次,默认是1 hour-->
|
||||
<TimeBasedTriggeringPolicy interval="1"/>
|
||||
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||
</Policies>
|
||||
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件开始覆盖-->
|
||||
<DefaultRolloverStrategy max="15"/>
|
||||
</RollingFile>
|
||||
|
||||
</appenders>
|
||||
|
||||
<!--Logger节点用来单独指定日志的形式,比如要为指定包下的class指定不同的日志级别等。-->
|
||||
<!--然后定义loggers,只有定义了logger并引入的appender,appender才会生效-->
|
||||
<loggers>
|
||||
<root level="info">
|
||||
<appender-ref ref="Console"/>
|
||||
<appender-ref ref="RollingFileInfo"/>
|
||||
<appender-ref ref="RollingFileWarn"/>
|
||||
<appender-ref ref="RollingFileError"/>
|
||||
<appender-ref ref="fileLog"/>
|
||||
</root>
|
||||
</loggers>
|
||||
|
||||
</configuration>
|
@@ -8,7 +8,7 @@
|
||||
# 数据库连接信息
|
||||
jdbc:
|
||||
dbName: schisandra-cloud-storage
|
||||
tableName: schisandra_sys_oauth
|
||||
tableName: schisandra_auth_role_permission
|
||||
url: jdbc:mysql://1.95.0.111:3306/
|
||||
username: root
|
||||
password: LDQ20020618xxx
|
||||
@@ -22,9 +22,9 @@ params:
|
||||
# 作者
|
||||
author: landaiqing
|
||||
# 模块
|
||||
module: system
|
||||
module: auth
|
||||
# controller 通用前缀
|
||||
api: /system/oauth/
|
||||
api: /auth/permission/
|
||||
# 生成对象是否移除前缀
|
||||
removePre: false
|
||||
# 使用内置函数赋值给变量 FunctionUtils 中替换
|
||||
|
@@ -71,7 +71,11 @@
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>3.1.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
Reference in New Issue
Block a user