mirror of
https://gitee.com/wangkang/udf.git
synced 2026-11-27 18:04:12 +00:00
更新
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.itkk.udf.api.rbac.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("TM_RBAC_USER")
|
||||
public class UserEntity {
|
||||
/**
|
||||
* 主键(PK)(非空)
|
||||
*/
|
||||
@TableId("ID")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 用户ID(UK_1)(非空)
|
||||
*/
|
||||
@TableField("USER_ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户密码(MD5加密)(非空)
|
||||
*/
|
||||
@TableField("USER_PSWD")
|
||||
private String userPswd;
|
||||
|
||||
/**
|
||||
* 用户昵称(非空)
|
||||
*/
|
||||
@TableField("NICK_NAME")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户头像文件ID(非空)
|
||||
*/
|
||||
@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>
|
||||
Reference in New Issue
Block a user