mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-21 10:03:41 +00:00
更新
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
<module>udf-api-server</module>
|
||||
<module>udf-api-common</module>
|
||||
<module>udf-api-general</module>
|
||||
<module>udf-api-rbac</module>
|
||||
</modules>
|
||||
<!-- 依赖管理 -->
|
||||
<dependencyManagement>
|
||||
@@ -39,6 +40,12 @@
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!--udf-api-rbac-->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-api-rbac</artifactId>
|
||||
<version>${udf-api.version}</version>
|
||||
</dependency>
|
||||
<!--udf-api-general-->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
|
||||
@@ -13,12 +13,12 @@ public class CommonConstant {
|
||||
/**
|
||||
* 需认证的web根路径
|
||||
*/
|
||||
public static final String URL_ROOT_WEB_PRIVATE = URL_ROOT_WEB + "/private";
|
||||
public static final String URL_ROOT_WEB_PRIVATE = URL_ROOT_WEB + "/private/";
|
||||
|
||||
/**
|
||||
* 无需认证的web根路径
|
||||
*/
|
||||
public static final String URL_ROOT_WEB_PUBLIC = URL_ROOT_WEB + "/public";
|
||||
public static final String URL_ROOT_WEB_PUBLIC = URL_ROOT_WEB + "/public/";
|
||||
|
||||
/**
|
||||
* 默认时间格式
|
||||
@@ -65,6 +65,33 @@ public class CommonConstant {
|
||||
*/
|
||||
public static final String SEND_EMAIL_QUEUE_HANDLE = "SEND_EMAIL_QUEUE_HANDLE";
|
||||
|
||||
/**
|
||||
* 数据状态(正常,删除)
|
||||
*/
|
||||
public enum DATA_STATUS {
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
STATUS_F1(-1),
|
||||
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
STATUS_1(1);
|
||||
|
||||
private Integer value;
|
||||
|
||||
DATA_STATUS(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer value() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 私有化构造函数
|
||||
*/
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package org.itkk.udf.api.common.repository;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.itkk.udf.api.common.entity.DataHisEntity;
|
||||
|
||||
@Mapper
|
||||
public interface IDataHisRepository extends BaseMapper<DataHisEntity> {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<!-- maven坐标 -->
|
||||
<artifactId>udf-api-rbac</artifactId>
|
||||
<name>udf-api-rbac</name>
|
||||
<packaging>jar</packaging>
|
||||
<url>https://www.itkk.org/</url>
|
||||
<!-- 父依赖 -->
|
||||
<parent>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<!-- 依赖 -->
|
||||
<dependencies>
|
||||
<!-- udf-api-common -->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-api-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.itkk.udf.api.rbac;
|
||||
|
||||
import org.itkk.udf.api.common.CommonConstant;
|
||||
import org.itkk.udf.api.rbac.auth.WebHandlerInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class RbacConfiguration implements WebMvcConfigurer {
|
||||
/**
|
||||
* webHandlerInterceptor
|
||||
*/
|
||||
@Autowired
|
||||
private WebHandlerInterceptor webHandlerInterceptor;
|
||||
|
||||
/**
|
||||
* 添加拦截器
|
||||
*
|
||||
* @param registry registry
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//身份认证拦截器
|
||||
registry.addInterceptor(webHandlerInterceptor).order(1).addPathPatterns(CommonConstant.URL_ROOT_WEB_PRIVATE + "**");
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package org.itkk.udf.api.rbac.auth;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.itkk.udf.api.common.CommonConstant;
|
||||
import org.itkk.udf.api.common.CommonProperties;
|
||||
import org.itkk.udf.starter.cache.db.service.DbCacheService;
|
||||
import org.itkk.udf.starter.core.CoreUtil;
|
||||
import org.itkk.udf.starter.core.exception.AuthException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WebHandlerInterceptor implements HandlerInterceptor {
|
||||
/**
|
||||
* dbCacheService
|
||||
*/
|
||||
@Autowired
|
||||
private DbCacheService dbCacheService;
|
||||
|
||||
/**
|
||||
* commonPropertiesl
|
||||
*/
|
||||
@Autowired
|
||||
private CommonProperties commonProperties;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
//排除options
|
||||
if (!HttpMethod.OPTIONS.toString().equals(request.getMethod())) {
|
||||
//获得token
|
||||
final String token = CoreUtil.getParameter(request, CommonConstant.PARAMETER_NAME_TOKEN);
|
||||
//判空
|
||||
if (StringUtils.isBlank(token)) {
|
||||
throw new AuthException("缺少必要参数token");
|
||||
}
|
||||
}
|
||||
//正常返回
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+39
-21
@@ -1,4 +1,4 @@
|
||||
package org.itkk.udf.api.common.entity;
|
||||
package org.itkk.udf.api.rbac.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -14,41 +14,59 @@ import java.util.Date;
|
||||
@Accessors(chain = true)
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("TF_DATA_HIS")
|
||||
public class DataHisEntity {
|
||||
@TableName("TM_RBAC_USER")
|
||||
public class UserEntity {
|
||||
/**
|
||||
* 主键
|
||||
* 主键(PK)(非空)
|
||||
*/
|
||||
@TableId("ID")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 追踪ID
|
||||
* 用户ID(UK_1)(非空)
|
||||
*/
|
||||
@TableField("TRACE_ID")
|
||||
private String traceId;
|
||||
@TableField("USER_ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
* 用户密码(MD5加密)(非空)
|
||||
*/
|
||||
@TableField("TABLE_NAME")
|
||||
private String TABLE_NAME;
|
||||
@TableField("USER_PSWD")
|
||||
private String userPswd;
|
||||
|
||||
/**
|
||||
* 表主键
|
||||
* 用户昵称(非空)
|
||||
*/
|
||||
@TableField("TABLE_PK")
|
||||
private String TABLE_PK;
|
||||
@TableField("NICK_NAME")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 表内容
|
||||
* 用户头像文件ID(非空)
|
||||
*/
|
||||
@TableField("CONTENT")
|
||||
private String content;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("CREATE_DATE")
|
||||
private Date createDate;
|
||||
@TableField("AVATAR_FILE_ID")
|
||||
private String avatarFileId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("CREATE_BY")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("CREATE_DATE")
|
||||
private Date createDate;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField("UPDATE_BY")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("UPDATE_DATE")
|
||||
private Date updateDate;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package org.itkk.udf.api.rbac.repository;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.itkk.udf.api.rbac.entity.UserEntity;
|
||||
|
||||
@Mapper
|
||||
public interface IUserRepository extends BaseMapper<UserEntity> {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?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="org.itkk.udf.api.rbac.repository.IUserRepository">
|
||||
|
||||
</mapper>
|
||||
@@ -25,6 +25,11 @@
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-api-general</artifactId>
|
||||
</dependency>
|
||||
<!--udf-api-rbac-->
|
||||
<dependency>
|
||||
<groupId>org.itkk.udf</groupId>
|
||||
<artifactId>udf-api-rbac</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- 构建 -->
|
||||
<build>
|
||||
|
||||
@@ -2,13 +2,13 @@ package org.itkk.udf.starter.core;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.itkk.udf.starter.core.exception.AuthException;
|
||||
import org.itkk.udf.starter.core.exception.ParameterValidException;
|
||||
import org.itkk.udf.starter.core.exception.SystemRuntimeException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.itkk.udf.starter.core.exception.AuthException;
|
||||
import org.itkk.udf.starter.core.exception.ParameterValidException;
|
||||
import org.itkk.udf.starter.core.exception.SystemRuntimeException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeanWrapper;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
@@ -430,6 +430,29 @@ public class CoreUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得参数(先从问号后面取,如果为空,再从header里取,如果为空,从作用域中取,如果都为空,则返回null)
|
||||
*
|
||||
* @param request request
|
||||
* @param parameterName parameterName
|
||||
* @return String
|
||||
*/
|
||||
public static String getParameter(HttpServletRequest request, String parameterName) {
|
||||
//获得token
|
||||
String token = request.getParameter(parameterName);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
token = request.getHeader(parameterName);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
Object tokenObj = request.getAttribute(parameterName);
|
||||
if (tokenObj != null) {
|
||||
token = tokenObj.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
//返回
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 私有化构造函数
|
||||
|
||||
Reference in New Issue
Block a user