mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-04 22:41:24 +08:00
Added spring security
This commit is contained in:
@@ -43,6 +43,10 @@
|
|||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
@@ -75,6 +79,19 @@
|
|||||||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
|
||||||
<version>4.1.0</version>
|
<version>4.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.auth0</groupId>
|
||||||
|
<artifactId>java-jwt</artifactId>
|
||||||
|
<version>4.3.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -93,5 +110,12 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>maven_central</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<url>https://repo.maven.apache.org/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.cfive.pinnacle;
|
|||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
//@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class PinnacleApplication {
|
public class PinnacleApplication {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.cfive.pinnacle.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RedisConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory)
|
||||||
|
{
|
||||||
|
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||||
|
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||||
|
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||||
|
Jackson2JsonRedisSerializer<Object> objectJackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
||||||
|
|
||||||
|
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||||
|
redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||||
|
redisTemplate.setValueSerializer(objectJackson2JsonRedisSerializer);
|
||||||
|
|
||||||
|
// Hash的key也采用StringRedisSerializer的序列化方式
|
||||||
|
redisTemplate.setHashKeySerializer(stringRedisSerializer);
|
||||||
|
redisTemplate.setHashValueSerializer(objectJackson2JsonRedisSerializer);
|
||||||
|
|
||||||
|
redisTemplate.afterPropertiesSet();
|
||||||
|
return redisTemplate;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.cfive.pinnacle.config;
|
||||||
|
|
||||||
|
import com.cfive.pinnacle.filter.JwtAuthenticationTokenFilter;
|
||||||
|
import com.cfive.pinnacle.service.permission.impl.UserDetailsServiceImpl;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class SecurityConfig {
|
||||||
|
private UserDetailsServiceImpl userDetailsService;
|
||||||
|
private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setUserDetailsService(UserDetailsServiceImpl userDetailsService) {
|
||||||
|
this.userDetailsService = userDetailsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setJwtAuthenticationTokenFilter(JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter) {
|
||||||
|
this.jwtAuthenticationTokenFilter = jwtAuthenticationTokenFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new BCryptPasswordEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
AuthenticationManager authenticationManager(HttpSecurity httpSecurity, PasswordEncoder passwordEncoder) throws Exception {
|
||||||
|
return httpSecurity.getSharedObject(AuthenticationManagerBuilder.class)
|
||||||
|
.userDetailsService(userDetailsService)
|
||||||
|
.passwordEncoder(passwordEncoder)
|
||||||
|
.and()
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws Exception {
|
||||||
|
return httpSecurity
|
||||||
|
// Disable CSRF
|
||||||
|
.csrf().disable()
|
||||||
|
|
||||||
|
// Do not get SecurityContent by Session
|
||||||
|
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||||
|
.and()
|
||||||
|
|
||||||
|
// Allow anonymous access
|
||||||
|
.authorizeHttpRequests()
|
||||||
|
.requestMatchers("/user/login").anonymous()
|
||||||
|
|
||||||
|
// Authentication required
|
||||||
|
.anyRequest().authenticated()
|
||||||
|
.and()
|
||||||
|
|
||||||
|
.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-页面元素 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/powerElement")
|
|
||||||
public class PowerElementController {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-文件 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/powerFile")
|
|
||||||
public class PowerFileController {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-菜单 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/powerMenu")
|
|
||||||
public class PowerMenuController {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-功能 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/powerOperation")
|
|
||||||
public class PowerOperationController {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-角色 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/powerRole")
|
|
||||||
public class PowerRoleController {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 权限类型 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/powerType")
|
|
||||||
public class PowerTypeController {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,16 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller;
|
||||||
|
|
||||||
|
import com.cfive.pinnacle.entity.User;
|
||||||
|
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||||
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
|
import com.cfive.pinnacle.service.IUserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 用户 前端控制器
|
* 用户 前端控制器
|
||||||
@@ -14,5 +22,16 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user")
|
@RequestMapping("/user")
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
private IUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setUserService(IUserService userService) {
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseResult getAllUser() {
|
||||||
|
List<User> users = userService.list();
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", users);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
|
import com.cfive.pinnacle.entity.User;
|
||||||
|
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||||
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
|
import com.cfive.pinnacle.service.permission.ILoginService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/user")
|
||||||
|
public class LoginController {
|
||||||
|
|
||||||
|
private ILoginService loginService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setLoginService(ILoginService loginService) {
|
||||||
|
this.loginService = loginService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/login")
|
||||||
|
public ResponseResult login(@RequestBody User user) {
|
||||||
|
HashMap<String, String> hashMap = loginService.login(user);
|
||||||
|
return ResponseResult.build(ResponseCode.LOGIN_SUCCESS, "success", hashMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.controller;
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.cfive.pinnacle.controller.permission;
|
||||||
|
|
||||||
|
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||||
|
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||||
|
import com.cfive.pinnacle.entity.permission.*;
|
||||||
|
import com.cfive.pinnacle.service.permission.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 权限类型 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author FatttSnake
|
||||||
|
* @since 2023-04-30
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/powerType")
|
||||||
|
public class PowerTypeController {
|
||||||
|
IPowerService powerTypeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setPowerTypeService(IPowerService powerTypeService) {
|
||||||
|
this.powerTypeService = powerTypeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public ResponseResult getAllPowerType() {
|
||||||
|
List<Power> powerTypes = powerTypeService.list();
|
||||||
|
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", powerTypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-页面元素
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@TableName("t_power_element")
|
|
||||||
public class PowerElement implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限
|
|
||||||
*/
|
|
||||||
@TableField("power_id")
|
|
||||||
private Long powerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面元素
|
|
||||||
*/
|
|
||||||
@TableField("element_id")
|
|
||||||
private Long elementId;
|
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-文件
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@TableName("t_power_file")
|
|
||||||
public class PowerFile implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限
|
|
||||||
*/
|
|
||||||
@TableField("power_id")
|
|
||||||
private Long powerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件
|
|
||||||
*/
|
|
||||||
@TableField("file_id")
|
|
||||||
private Long fileId;
|
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-菜单
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@TableName("t_power_menu")
|
|
||||||
public class PowerMenu implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限
|
|
||||||
*/
|
|
||||||
@TableField("power_id")
|
|
||||||
private Long powerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 菜单
|
|
||||||
*/
|
|
||||||
@TableField("menu_id")
|
|
||||||
private Long menuId;
|
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-功能
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@TableName("t_power_operation")
|
|
||||||
public class PowerOperation implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@TableId("id")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 权限
|
|
||||||
*/
|
|
||||||
@TableField("power_id")
|
|
||||||
private Long powerId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 功能
|
|
||||||
*/
|
|
||||||
@TableField("operation_id")
|
|
||||||
private Long operationId;
|
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,8 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class ResponseCode {
|
public class ResponseCode {
|
||||||
public static final int SYSTEM_OK = 20000;
|
public static final int SYSTEM_OK = 20000;
|
||||||
|
public static final int LOGIN_SUCCESS = 20010;
|
||||||
|
public static final int LOGIN_USERNAME_PASSWORD_ERROR = 20011;
|
||||||
public static final int DATABASE_SELECT_OK = 20021;
|
public static final int DATABASE_SELECT_OK = 20021;
|
||||||
public static final int DATABASE_SAVE_OK = 20022;
|
public static final int DATABASE_SAVE_OK = 20022;
|
||||||
public static final int DATABASE_UPDATE_OK = 20023;
|
public static final int DATABASE_UPDATE_OK = 20023;
|
||||||
@@ -14,9 +16,10 @@ public class ResponseCode {
|
|||||||
public static final int DATABASE_SAVE_ERROR = 20032;
|
public static final int DATABASE_SAVE_ERROR = 20032;
|
||||||
public static final int DATABASE_UPDATE_ERROR = 20033;
|
public static final int DATABASE_UPDATE_ERROR = 20033;
|
||||||
public static final int DATABASE_DELETE_ERROR = 20034;
|
public static final int DATABASE_DELETE_ERROR = 20034;
|
||||||
public static final int DATABASE_TIMEOUT = 20035;
|
public static final int DATABASE_TIMEOUT_ERROR = 20035;
|
||||||
public static final int DATABASE_CONNECT_ERROR = 20036;
|
public static final int DATABASE_CONNECT_ERROR = 20036;
|
||||||
|
|
||||||
|
|
||||||
public static final int SYSTEM_ERROR = 50001;
|
public static final int SYSTEM_ERROR = 50001;
|
||||||
public static final int SYSTEM_TIMEOUT = 50002;
|
public static final int SYSTEM_TIMEOUT = 50002;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_element")
|
@TableName("t_element")
|
||||||
public class Element implements Serializable {
|
public class Element implements Serializable {
|
||||||
@@ -37,11 +39,9 @@ public class Element implements Serializable {
|
|||||||
@TableField("name")
|
@TableField("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@TableField("deleted")
|
/**
|
||||||
@TableLogic
|
* 权限ID
|
||||||
private Integer deleted;
|
*/
|
||||||
|
@TableField("power_id")
|
||||||
@TableField("version")
|
private Long powerId;
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_file")
|
@TableName("t_file")
|
||||||
public class File implements Serializable {
|
public class File implements Serializable {
|
||||||
@@ -43,11 +45,9 @@ public class File implements Serializable {
|
|||||||
@TableField("path")
|
@TableField("path")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
@TableField("deleted")
|
/**
|
||||||
@TableLogic
|
* 权限ID
|
||||||
private Integer deleted;
|
*/
|
||||||
|
@TableField("power_id")
|
||||||
@TableField("version")
|
private Long powerId;
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
|
import com.cfive.pinnacle.entity.User;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class LoginUser implements UserDetails {
|
||||||
|
private User user;
|
||||||
|
private Collection<? extends GrantedAuthority> authorities;
|
||||||
|
private String password;
|
||||||
|
private String username;
|
||||||
|
private Boolean accountNonExpired;
|
||||||
|
private Boolean accountNonLocked;
|
||||||
|
private Boolean credentialsNonExpired;
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
public LoginUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPassword() {
|
||||||
|
return user.getPasswd();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsername() {
|
||||||
|
return user.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAccountNonExpired() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAccountNonLocked() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCredentialsNonExpired() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return user.getEnable() == 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_menu")
|
@TableName("t_menu")
|
||||||
public class Menu implements Serializable {
|
public class Menu implements Serializable {
|
||||||
@@ -43,17 +45,15 @@ public class Menu implements Serializable {
|
|||||||
@TableField("url")
|
@TableField("url")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限ID
|
||||||
|
*/
|
||||||
|
@TableField("power_id")
|
||||||
|
private Long powerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父ID
|
* 父ID
|
||||||
*/
|
*/
|
||||||
@TableField("parent_id")
|
@TableField("parent_id")
|
||||||
private String parentId;
|
private Long parentId;
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_operation")
|
@TableName("t_operation")
|
||||||
public class Operation implements Serializable {
|
public class Operation implements Serializable {
|
||||||
@@ -49,17 +51,15 @@ public class Operation implements Serializable {
|
|||||||
@TableField("url_prefix")
|
@TableField("url_prefix")
|
||||||
private String urlPrefix;
|
private String urlPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限ID
|
||||||
|
*/
|
||||||
|
@TableField("power_id")
|
||||||
|
private Long powerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 父ID
|
* 父ID
|
||||||
*/
|
*/
|
||||||
@TableField("parent_id")
|
@TableField("parent_id")
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@@ -10,7 +10,9 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +24,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_operation_log")
|
@TableName("t_operation_log")
|
||||||
public class OperationLog implements Serializable {
|
public class OperationLog implements Serializable {
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_power")
|
@TableName("t_power")
|
||||||
public class Power implements Serializable {
|
public class Power implements Serializable {
|
||||||
@@ -36,12 +38,4 @@ public class Power implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("type_id")
|
@TableField("type_id")
|
||||||
private Long typeId;
|
private Long typeId;
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@@ -9,7 +9,9 @@ import com.baomidou.mybatisplus.annotation.Version;
|
|||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +23,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_power_role")
|
@TableName("t_power_role")
|
||||||
public class PowerRole implements Serializable {
|
public class PowerRole implements Serializable {
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.cfive.pinnacle.entity;
|
package com.cfive.pinnacle.entity.permission;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.baomidou.mybatisplus.annotation.Version;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +21,8 @@ import lombok.experimental.Accessors;
|
|||||||
* @since 2023-04-30
|
* @since 2023-04-30
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("t_power_type")
|
@TableName("t_power_type")
|
||||||
public class PowerType implements Serializable {
|
public class PowerType implements Serializable {
|
||||||
@@ -36,12 +38,4 @@ public class PowerType implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("name")
|
@TableField("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@TableField("deleted")
|
|
||||||
@TableLogic
|
|
||||||
private Integer deleted;
|
|
||||||
|
|
||||||
@TableField("version")
|
|
||||||
@Version
|
|
||||||
private Integer version;
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.cfive.pinnacle.filter;
|
||||||
|
|
||||||
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||||
|
import com.cfive.pinnacle.entity.permission.LoginUser;
|
||||||
|
import com.cfive.pinnacle.utils.JwtUtil;
|
||||||
|
import com.cfive.pinnacle.utils.RedisCache;
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setRedisCache(RedisCache redisCache) {
|
||||||
|
this.redisCache = redisCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
if (!StringUtils.hasText(token)) {
|
||||||
|
filterChain.doFilter(request, response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String userId;
|
||||||
|
try {
|
||||||
|
DecodedJWT decodedJWT = JwtUtil.parseJWT(token);
|
||||||
|
userId = decodedJWT.getSubject();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Token is illegal");
|
||||||
|
}
|
||||||
|
|
||||||
|
String redisKey = "login:" + userId;
|
||||||
|
System.out.println(redisCache.getCacheObject(redisKey).toString());
|
||||||
|
LoginUser loginUser = redisCache.getCacheObject(redisKey);
|
||||||
|
if (Objects.isNull(loginUser)) {
|
||||||
|
throw new RuntimeException("Not logged in");
|
||||||
|
}
|
||||||
|
|
||||||
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, null);
|
||||||
|
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
||||||
|
|
||||||
|
filterChain.doFilter(request, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerElement;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-页面元素 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface PowerElementMapper extends BaseMapper<PowerElement> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerFile;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-文件 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface PowerFileMapper extends BaseMapper<PowerFile> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerMenu;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-菜单 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface PowerMenuMapper extends BaseMapper<PowerMenu> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerOperation;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-功能 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface PowerOperationMapper extends BaseMapper<PowerOperation> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Element;
|
import com.cfive.pinnacle.entity.permission.Element;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.File;
|
import com.cfive.pinnacle.entity.permission.File;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Menu;
|
import com.cfive.pinnacle.entity.permission.Menu;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.OperationLog;
|
import com.cfive.pinnacle.entity.permission.OperationLog;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Operation;
|
import com.cfive.pinnacle.entity.permission.Operation;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Power;
|
import com.cfive.pinnacle.entity.permission.Power;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerRole;
|
import com.cfive.pinnacle.entity.permission.PowerRole;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.mapper;
|
package com.cfive.pinnacle.mapper.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerType;
|
import com.cfive.pinnacle.entity.permission.PowerType;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerElement;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-页面元素 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
public interface IPowerElementService extends IService<PowerElement> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerFile;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-文件 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
public interface IPowerFileService extends IService<PowerFile> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerMenu;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-菜单 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
public interface IPowerMenuService extends IService<PowerMenu> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerOperation;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-功能 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
public interface IPowerOperationService extends IService<PowerOperation> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerElement;
|
|
||||||
import com.cfive.pinnacle.mapper.PowerElementMapper;
|
|
||||||
import com.cfive.pinnacle.service.IPowerElementService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-页面元素 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class PowerElementServiceImpl extends ServiceImpl<PowerElementMapper, PowerElement> implements IPowerElementService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerFile;
|
|
||||||
import com.cfive.pinnacle.mapper.PowerFileMapper;
|
|
||||||
import com.cfive.pinnacle.service.IPowerFileService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-文件 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class PowerFileServiceImpl extends ServiceImpl<PowerFileMapper, PowerFile> implements IPowerFileService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerMenu;
|
|
||||||
import com.cfive.pinnacle.mapper.PowerMenuMapper;
|
|
||||||
import com.cfive.pinnacle.service.IPowerMenuService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-菜单 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class PowerMenuServiceImpl extends ServiceImpl<PowerMenuMapper, PowerMenu> implements IPowerMenuService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerOperation;
|
|
||||||
import com.cfive.pinnacle.mapper.PowerOperationMapper;
|
|
||||||
import com.cfive.pinnacle.service.IPowerOperationService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 中间表-权限-功能 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author FatttSnake
|
|
||||||
* @since 2023-04-30
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class PowerOperationServiceImpl extends ServiceImpl<PowerOperationMapper, PowerOperation> implements IPowerOperationService {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Element;
|
import com.cfive.pinnacle.entity.permission.Element;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.File;
|
import com.cfive.pinnacle.entity.permission.File;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
|
import com.cfive.pinnacle.entity.User;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public interface ILoginService {
|
||||||
|
HashMap<String, String> login(User user);
|
||||||
|
|
||||||
|
void logout();
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Menu;
|
import com.cfive.pinnacle.entity.permission.Menu;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.OperationLog;
|
import com.cfive.pinnacle.entity.permission.OperationLog;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Operation;
|
import com.cfive.pinnacle.entity.permission.Operation;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerRole;
|
import com.cfive.pinnacle.entity.permission.PowerRole;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Power;
|
import com.cfive.pinnacle.entity.permission.Power;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.cfive.pinnacle.service;
|
package com.cfive.pinnacle.service.permission;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerType;
|
import com.cfive.pinnacle.entity.permission.PowerType;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Element;
|
import com.cfive.pinnacle.entity.permission.Element;
|
||||||
import com.cfive.pinnacle.mapper.ElementMapper;
|
import com.cfive.pinnacle.mapper.permission.ElementMapper;
|
||||||
import com.cfive.pinnacle.service.IElementService;
|
import com.cfive.pinnacle.service.permission.IElementService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.File;
|
import com.cfive.pinnacle.entity.permission.File;
|
||||||
import com.cfive.pinnacle.mapper.FileMapper;
|
import com.cfive.pinnacle.mapper.permission.FileMapper;
|
||||||
import com.cfive.pinnacle.service.IFileService;
|
import com.cfive.pinnacle.service.permission.IFileService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
|
import com.cfive.pinnacle.entity.User;
|
||||||
|
import com.cfive.pinnacle.entity.permission.LoginUser;
|
||||||
|
import com.cfive.pinnacle.service.permission.ILoginService;
|
||||||
|
import com.cfive.pinnacle.utils.JwtUtil;
|
||||||
|
import com.cfive.pinnacle.utils.RedisCache;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class LoginServiceImpl implements ILoginService {
|
||||||
|
private AuthenticationManager authenticationManager;
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
|
||||||
|
this.authenticationManager = authenticationManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setRedisCache(RedisCache redisCache) {
|
||||||
|
this.redisCache = redisCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, String> login(User user) {
|
||||||
|
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPasswd());
|
||||||
|
Authentication authentication = authenticationManager.authenticate(usernamePasswordAuthenticationToken);
|
||||||
|
if (Objects.isNull(authentication)) {
|
||||||
|
throw new RuntimeException("Login failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||||
|
String userId = loginUser.getUser().getId().toString();
|
||||||
|
String jwt = JwtUtil.createJWT(userId);
|
||||||
|
|
||||||
|
HashMap<String, String> hashMap = new HashMap<>();
|
||||||
|
hashMap.put("token", jwt);
|
||||||
|
|
||||||
|
redisCache.setCacheObject("login:" + userId, loginUser);
|
||||||
|
|
||||||
|
return hashMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logout() {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||||
|
|
||||||
|
Long userId = loginUser.getUser().getId();
|
||||||
|
redisCache.deleteObject("login:" + userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Menu;
|
import com.cfive.pinnacle.entity.permission.Menu;
|
||||||
import com.cfive.pinnacle.mapper.MenuMapper;
|
import com.cfive.pinnacle.mapper.permission.MenuMapper;
|
||||||
import com.cfive.pinnacle.service.IMenuService;
|
import com.cfive.pinnacle.service.permission.IMenuService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.OperationLog;
|
import com.cfive.pinnacle.entity.permission.OperationLog;
|
||||||
import com.cfive.pinnacle.mapper.OperationLogMapper;
|
import com.cfive.pinnacle.mapper.permission.OperationLogMapper;
|
||||||
import com.cfive.pinnacle.service.IOperationLogService;
|
import com.cfive.pinnacle.service.permission.IOperationLogService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Operation;
|
import com.cfive.pinnacle.entity.permission.Operation;
|
||||||
import com.cfive.pinnacle.mapper.OperationMapper;
|
import com.cfive.pinnacle.mapper.permission.OperationMapper;
|
||||||
import com.cfive.pinnacle.service.IOperationService;
|
import com.cfive.pinnacle.service.permission.IOperationService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerRole;
|
import com.cfive.pinnacle.entity.permission.PowerRole;
|
||||||
import com.cfive.pinnacle.mapper.PowerRoleMapper;
|
import com.cfive.pinnacle.mapper.permission.PowerRoleMapper;
|
||||||
import com.cfive.pinnacle.service.IPowerRoleService;
|
import com.cfive.pinnacle.service.permission.IPowerRoleService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.Power;
|
import com.cfive.pinnacle.entity.permission.Power;
|
||||||
import com.cfive.pinnacle.mapper.PowerMapper;
|
import com.cfive.pinnacle.mapper.permission.PowerMapper;
|
||||||
import com.cfive.pinnacle.service.IPowerService;
|
import com.cfive.pinnacle.service.permission.IPowerService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.cfive.pinnacle.service.impl;
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
import com.cfive.pinnacle.entity.PowerType;
|
import com.cfive.pinnacle.entity.permission.PowerType;
|
||||||
import com.cfive.pinnacle.mapper.PowerTypeMapper;
|
import com.cfive.pinnacle.mapper.permission.PowerTypeMapper;
|
||||||
import com.cfive.pinnacle.service.IPowerTypeService;
|
import com.cfive.pinnacle.service.permission.IPowerTypeService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.cfive.pinnacle.service.permission.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.cfive.pinnacle.entity.User;
|
||||||
|
import com.cfive.pinnacle.entity.permission.LoginUser;
|
||||||
|
import com.cfive.pinnacle.service.IUserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserDetailsServiceImpl implements UserDetailsService {
|
||||||
|
private IUserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setUserService(IUserService userService) {
|
||||||
|
this.userService = userService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
|
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(User::getUsername, username);
|
||||||
|
User user = userService.getOne(wrapper);
|
||||||
|
if (Objects.isNull(user)) {
|
||||||
|
throw new UsernameNotFoundException("Username not found in database");
|
||||||
|
}
|
||||||
|
return new LoginUser(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
115
Pinnacle/src/main/java/com/cfive/pinnacle/utils/JwtUtil.java
Normal file
115
Pinnacle/src/main/java/com/cfive/pinnacle/utils/JwtUtil.java
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
package com.cfive.pinnacle.utils;
|
||||||
|
|
||||||
|
import com.auth0.jwt.JWT;
|
||||||
|
import com.auth0.jwt.JWTVerifier;
|
||||||
|
import com.auth0.jwt.algorithms.Algorithm;
|
||||||
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||||
|
|
||||||
|
import javax.crypto.SecretKey;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JWT 工具类
|
||||||
|
*/
|
||||||
|
public class JwtUtil {
|
||||||
|
|
||||||
|
// 有效期
|
||||||
|
public static final Long JWT_TTL = 60 * 60 * 1000L; // 60 * 60 * 1000 一个小时
|
||||||
|
// 秘钥明文
|
||||||
|
public static final String JWT_KEY = "pinnacle";
|
||||||
|
//签发者
|
||||||
|
public static final String ISSUER = "cfive";
|
||||||
|
|
||||||
|
public static String getUUID() {
|
||||||
|
return UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成加密后的秘钥 secretKey
|
||||||
|
*
|
||||||
|
* @return 密钥
|
||||||
|
*/
|
||||||
|
public static SecretKey generalKey() {
|
||||||
|
byte[] encodedKey = Base64.getDecoder().decode(JwtUtil.JWT_KEY);
|
||||||
|
return new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Algorithm algorithm() {
|
||||||
|
SecretKey secretKey = generalKey();
|
||||||
|
return Algorithm.HMAC256(secretKey.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getJwt(String subject, Long ttlMillis, String uuid) {
|
||||||
|
long nowMillis = System.currentTimeMillis();
|
||||||
|
Date now = new Date(nowMillis);
|
||||||
|
if (ttlMillis == null) {
|
||||||
|
ttlMillis = JwtUtil.JWT_TTL;
|
||||||
|
}
|
||||||
|
long expMillis = nowMillis + ttlMillis;
|
||||||
|
Date expDate = new Date(expMillis);
|
||||||
|
return JWT.create()
|
||||||
|
.withJWTId(uuid)
|
||||||
|
.withSubject(subject)
|
||||||
|
.withIssuer(ISSUER)
|
||||||
|
.withIssuedAt(now)
|
||||||
|
.withExpiresAt(expDate)
|
||||||
|
.sign(algorithm());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成 jwt
|
||||||
|
*
|
||||||
|
* @param subject token 中要存放的数据(json 格式)
|
||||||
|
* @return jwt 字符串
|
||||||
|
*/
|
||||||
|
public static String createJWT(String subject) {
|
||||||
|
return getJwt(subject, null, getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成 jwt
|
||||||
|
*
|
||||||
|
* @param subject token 中要存放的数据(json格式)
|
||||||
|
* @param ttlMillis token 超时时间
|
||||||
|
* @return jwt 字符串
|
||||||
|
*/
|
||||||
|
public static String createJWT(String subject, Long ttlMillis) {
|
||||||
|
return getJwt(subject, ttlMillis, getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建 token
|
||||||
|
*
|
||||||
|
* @param id 唯一的 ID
|
||||||
|
* @param subject token 中要存放的数据(json 格式)
|
||||||
|
* @param ttlMillis token 超时时间
|
||||||
|
* @return jwt 字符串
|
||||||
|
*/
|
||||||
|
public static String createJWT(String id, String subject, Long ttlMillis) {
|
||||||
|
return getJwt(subject, ttlMillis, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析 jwt
|
||||||
|
*
|
||||||
|
* @param jwt 字符串
|
||||||
|
* @return 解析内容
|
||||||
|
*/
|
||||||
|
public static DecodedJWT parseJWT(String jwt) {
|
||||||
|
JWTVerifier jwtVerifier = JWT.require(algorithm())
|
||||||
|
.build();
|
||||||
|
return jwtVerifier.verify(jwt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// String token = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJjYWM2ZDVhZi1mNjVlLTQ0MDAtYjcxMi0zYWEwOGIyOTIwYjQiLCJzdWIiOiJzZyIsImlzcyI6InNnIiwiaWF0IjoxNjM4MTA2NzEyLCJleHAiOjE2MzgxMTAzMTJ9.JVsSbkP94wuczb4QryQbAke3ysBDIL5ou8fWsbt_ebg";
|
||||||
|
// Claims claims = parseJWT(token);
|
||||||
|
|
||||||
|
System.out.println(parseJWT("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJxd2UiLCJpc3MiOiJjZml2ZSIsImV4cCI6MTY4MzE5MzkyOSwiaWF0IjoxNjgzMTkwMzI5LCJqdGkiOiIzOWY5YTcxYTllY2E0Mjg1OGVjNGExODU2ZmQwYjk4OCJ9.4YOOILGWxlnmToWTdo4YoCbfXqvzdJF_Ds4zulDWX1o")
|
||||||
|
.getClaims());
|
||||||
|
}
|
||||||
|
}
|
||||||
222
Pinnacle/src/main/java/com/cfive/pinnacle/utils/RedisCache.java
Normal file
222
Pinnacle/src/main/java/com/cfive/pinnacle/utils/RedisCache.java
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
package com.cfive.pinnacle.utils;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.BoundSetOperations;
|
||||||
|
import org.springframework.data.redis.core.HashOperations;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||||
|
@Component
|
||||||
|
public class RedisCache {
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public void setRedisTemplate(RedisTemplate redisTemplate) {
|
||||||
|
this.redisTemplate = redisTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存基本的对象,Integer、String、实体类等
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @param value 缓存的值
|
||||||
|
*/
|
||||||
|
public <T> void setCacheObject(final String key, final T value) {
|
||||||
|
redisTemplate.opsForValue().set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存基本的对象,Integer、String、实体类等
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @param value 缓存的值
|
||||||
|
* @param timeout 超时时间
|
||||||
|
* @param timeUnit 时间颗粒度
|
||||||
|
*/
|
||||||
|
public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
|
||||||
|
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置有效时间
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @param timeout 超时时间
|
||||||
|
* @return true=设置成功;false=设置失败
|
||||||
|
*/
|
||||||
|
public boolean expire(final String key, final long timeout) {
|
||||||
|
return expire(key, timeout, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置有效时间
|
||||||
|
*
|
||||||
|
* @param key Redis 键
|
||||||
|
* @param timeout 超时时间
|
||||||
|
* @param unit 时间颗粒度
|
||||||
|
* @return true=设置成功;false=设置失败
|
||||||
|
*/
|
||||||
|
public boolean expire(final String key, final long timeout, final TimeUnit unit) {
|
||||||
|
return Boolean.TRUE.equals(redisTemplate.expire(key, timeout, unit));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得缓存的基本对象
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @return 缓存的值
|
||||||
|
*/
|
||||||
|
public <T> T getCacheObject(final String key) {
|
||||||
|
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||||
|
return operation.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除单个对象
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @return true=删除成功;false=删除失败
|
||||||
|
*/
|
||||||
|
public boolean deleteObject(final String key) {
|
||||||
|
return Boolean.TRUE.equals(redisTemplate.delete(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除集合对象
|
||||||
|
*
|
||||||
|
* @param collection 多个键
|
||||||
|
* @return 删除个数
|
||||||
|
*/
|
||||||
|
public long deleteObject(final Collection collection) {
|
||||||
|
return redisTemplate.delete(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存 List 数据
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @param dataList 缓存的 List 数据
|
||||||
|
* @return 缓存的个数
|
||||||
|
*/
|
||||||
|
public <T> long setCacheList(final String key, final List<T> dataList) {
|
||||||
|
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
||||||
|
return count == null ? 0 : count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得缓存的 List 数据
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @return 缓存的键对应的 List 数据
|
||||||
|
*/
|
||||||
|
public <T> List<T> getCacheList(final String key) {
|
||||||
|
return redisTemplate.opsForList().range(key, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存 Set 数据
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @param dataSet 缓存的 Set 数据
|
||||||
|
* @return 缓存数据的对象
|
||||||
|
*/
|
||||||
|
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
|
||||||
|
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||||
|
for (T t : dataSet) {
|
||||||
|
setOperation.add(t);
|
||||||
|
}
|
||||||
|
return setOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得缓存的 Set 数据
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @return 缓存的键对应的 Set 数据
|
||||||
|
*/
|
||||||
|
public <T> Set<T> getCacheSet(final String key) {
|
||||||
|
return redisTemplate.opsForSet().members(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缓存 Map 数据
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @param dataMap 缓存的 Map 数据
|
||||||
|
*/
|
||||||
|
public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
|
||||||
|
if (dataMap != null) {
|
||||||
|
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得缓存的 Map 据
|
||||||
|
*
|
||||||
|
* @param key 缓存的键
|
||||||
|
* @return 缓存的键对应的 Map 数据
|
||||||
|
*/
|
||||||
|
public <T> Map<String, T> getCacheMap(final String key) {
|
||||||
|
return redisTemplate.opsForHash().entries(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 往 Hash 中存入数据
|
||||||
|
*
|
||||||
|
* @param key Redis 键
|
||||||
|
* @param hKey Hash 键
|
||||||
|
* @param value 值
|
||||||
|
*/
|
||||||
|
public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
|
||||||
|
redisTemplate.opsForHash().put(key, hKey, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取 Hash 中的数据
|
||||||
|
*
|
||||||
|
* @param key Redis 键
|
||||||
|
* @param hKey Hash 键
|
||||||
|
* @return Hash 中的对象
|
||||||
|
*/
|
||||||
|
public <T> T getCacheMapValue(final String key, final String hKey) {
|
||||||
|
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
||||||
|
return opsForHash.get(key, hKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除 Hash 中的数据
|
||||||
|
*
|
||||||
|
* @param key Redis 键
|
||||||
|
* @param hkey Hash 键
|
||||||
|
*/
|
||||||
|
public void delCacheMapValue(final String key, final String hkey) {
|
||||||
|
HashOperations hashOperations = redisTemplate.opsForHash();
|
||||||
|
hashOperations.delete(key, hkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取多个 Hash 中的数据
|
||||||
|
*
|
||||||
|
* @param key Redis 键
|
||||||
|
* @param hKeys Hash 键集合
|
||||||
|
* @return Hash 对象集合
|
||||||
|
*/
|
||||||
|
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
|
||||||
|
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得缓存的基本对象列表
|
||||||
|
*
|
||||||
|
* @param pattern 字符串前缀
|
||||||
|
* @return 对象列表
|
||||||
|
*/
|
||||||
|
public Collection<String> keys(final String pattern) {
|
||||||
|
return redisTemplate.keys(pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?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.cfive.pinnacle.mapper.PowerElementMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?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.cfive.pinnacle.mapper.PowerFileMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?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.cfive.pinnacle.mapper.PowerMenuMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<?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.cfive.pinnacle.mapper.PowerOperationMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.ElementMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.ElementMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.FileMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.FileMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.MenuMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.MenuMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.OperationLogMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.OperationLogMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.OperationMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.OperationMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.PowerMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.PowerMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.PowerRoleMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.PowerRoleMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.cfive.pinnacle.mapper.PowerTypeMapper">
|
<mapper namespace="com.cfive.pinnacle.mapper.permission.PowerTypeMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.cfive.pinnacle.service;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class IUserServiceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getAllUser(@Autowired IUserService userService) {
|
||||||
|
userService.list().forEach(System.out::println);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getBCy(@Autowired PasswordEncoder passwordEncoder) {
|
||||||
|
System.out.println(passwordEncoder.encode("123"));
|
||||||
|
}
|
||||||
|
}
|
||||||
168
sql/init.sql
168
sql/init.sql
@@ -1,102 +1,80 @@
|
|||||||
|
drop table if exists `t_affair`;
|
||||||
|
drop table if exists `t_affair_type`;
|
||||||
|
drop table if exists `t_attendance`;
|
||||||
|
drop table if exists `t_user_work`;
|
||||||
|
drop table if exists `t_work`;
|
||||||
|
drop table if exists `t_notice_receive`;
|
||||||
|
drop table if exists `t_notice`;
|
||||||
|
drop table if exists `t_notice_type`;
|
||||||
|
drop table if exists `t_staff`;
|
||||||
|
drop table if exists `t_operation_log`;
|
||||||
|
drop table if exists `t_user_role`;
|
||||||
|
drop table if exists `t_user_group`;
|
||||||
|
drop table if exists `t_user`;
|
||||||
|
drop table if exists `t_department`;
|
||||||
|
drop table if exists `t_role_group`;
|
||||||
|
drop table if exists `t_group`;
|
||||||
|
drop table if exists `t_power_role`;
|
||||||
|
drop table if exists `t_role`;
|
||||||
|
drop table if exists `t_operation`;
|
||||||
|
drop table if exists `t_menu`;
|
||||||
|
drop table if exists `t_element`;
|
||||||
|
drop table if exists `t_file`;
|
||||||
|
drop table if exists `t_power`;
|
||||||
|
drop table if exists `t_power_type`;
|
||||||
|
|
||||||
|
|
||||||
create table `t_power_type`
|
create table `t_power_type`
|
||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key auto_increment,
|
||||||
`name` varchar(50) not null comment '权限类型名',
|
`name` varchar(50) not null comment '权限类型名'
|
||||||
`deleted` int not null default 0,
|
|
||||||
`version` int not null default 0
|
|
||||||
) comment '权限类型';
|
) comment '权限类型';
|
||||||
|
|
||||||
create table `t_power`
|
create table `t_power`
|
||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key auto_increment,
|
||||||
`type_id` bigint not null comment '权限类型',
|
`type_id` bigint not null comment '权限类型',
|
||||||
`deleted` int not null default 0,
|
|
||||||
`version` int not null default 0,
|
|
||||||
constraint t_power_type_id_fk foreign key (type_id) references t_power_type (id)
|
constraint t_power_type_id_fk foreign key (type_id) references t_power_type (id)
|
||||||
) comment '权限';
|
) comment '权限';
|
||||||
|
|
||||||
create table `t_menu`
|
create table `t_menu`
|
||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key auto_increment,
|
||||||
`name` varchar(30) not null comment ' 菜单名',
|
`name` varchar(30) not null comment ' 菜单名',
|
||||||
`url` varchar(100) null comment 'URL',
|
`url` varchar(100) null comment 'URL',
|
||||||
`parent_id` long null comment '父ID',
|
`power_id` bigint not null comment '权限ID',
|
||||||
`deleted` int not null default 0,
|
`parent_id` bigint null comment '父ID',
|
||||||
`version` int not null default 0
|
constraint t_menu_power_id_fk foreign key (power_id) references t_power (id)
|
||||||
) comment '菜单';
|
) comment '菜单';
|
||||||
|
|
||||||
create table `t_power_menu`
|
|
||||||
(
|
|
||||||
`id` bigint not null primary key,
|
|
||||||
`power_id` bigint not null comment '权限',
|
|
||||||
`menu_id` bigint not null comment '菜单',
|
|
||||||
`deleted` int not null default 0,
|
|
||||||
`version` int not null default 0,
|
|
||||||
constraint t_power_menu_power_id_fk foreign key (power_id) references t_power (id),
|
|
||||||
constraint t_power_menu_menu_id_fk foreign key (menu_id) references t_menu (id)
|
|
||||||
) comment '中间表-权限-菜单';
|
|
||||||
|
|
||||||
create table `t_element`
|
create table `t_element`
|
||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key auto_increment,
|
||||||
`name` varchar(100) not null comment '元素名',
|
`name` varchar(100) not null comment '元素名',
|
||||||
`deleted` int not null default 0,
|
`power_id` bigint not null comment '权限ID',
|
||||||
`version` int not null default 0
|
constraint t_element_power_id_fk foreign key (power_id) references t_power (id)
|
||||||
) comment '页面元素';
|
) comment '页面元素';
|
||||||
|
|
||||||
create table `t_power_element`
|
|
||||||
(
|
|
||||||
`id` bigint not null primary key,
|
|
||||||
`power_id` bigint not null comment '权限',
|
|
||||||
`element_id` bigint not null comment '页面元素',
|
|
||||||
`deleted` int not null default 0,
|
|
||||||
`version` int not null default 0,
|
|
||||||
constraint t_power_element_power_id_fk foreign key (power_id) references t_power (id),
|
|
||||||
constraint t_power_element_element_id_fk foreign key (element_id) references t_element (id)
|
|
||||||
) comment '中间表-权限-页面元素';
|
|
||||||
|
|
||||||
create table `t_file`
|
create table `t_file`
|
||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key auto_increment,
|
||||||
`name` varchar(50) not null comment '文件名',
|
`name` varchar(50) not null comment '文件名',
|
||||||
`path` varchar(100) not null comment '文件路径',
|
`path` varchar(100) not null comment '文件路径',
|
||||||
`deleted` int not null default 0,
|
`power_id` bigint not null comment '权限ID',
|
||||||
`version` int not null default 0
|
constraint t_file_power_id_fk foreign key (power_id) references t_power (id)
|
||||||
) comment '文件';
|
) comment '文件';
|
||||||
|
|
||||||
create table `t_power_file`
|
|
||||||
(
|
|
||||||
`id` bigint not null primary key,
|
|
||||||
`power_id` bigint not null comment '权限',
|
|
||||||
`file_id` bigint not null comment '文件',
|
|
||||||
`deleted` int not null default 0,
|
|
||||||
`version` int not null default 0,
|
|
||||||
constraint t_power_file_power_id_fk foreign key (power_id) references t_power (id),
|
|
||||||
constraint t_power_file_file_id_fk foreign key (file_id) references t_file (id)
|
|
||||||
) comment '中间表-权限-文件';
|
|
||||||
|
|
||||||
create table `t_operation`
|
create table `t_operation`
|
||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key auto_increment,
|
||||||
`name` varchar(50) not null comment '功能名',
|
`name` varchar(50) not null comment '功能名',
|
||||||
`code` varchar(50) null comment '功能编码',
|
`code` varchar(50) null comment '功能编码',
|
||||||
`url_prefix` varchar(100) null comment 'URL 前缀',
|
`url_prefix` varchar(100) null comment 'URL 前缀',
|
||||||
|
`power_id` bigint not null comment '权限ID',
|
||||||
`parent_id` bigint null comment '父ID',
|
`parent_id` bigint null comment '父ID',
|
||||||
`deleted` int not null default 0,
|
constraint t_operation_power_id_fk foreign key (power_id) references t_power (id)
|
||||||
`version` int not null default 0
|
|
||||||
) comment '功能';
|
) comment '功能';
|
||||||
|
|
||||||
create table `t_power_operation`
|
|
||||||
(
|
|
||||||
`id` bigint not null primary key,
|
|
||||||
`power_id` bigint not null comment '权限',
|
|
||||||
`operation_id` bigint not null comment '功能',
|
|
||||||
`deleted` int not null default 0,
|
|
||||||
`version` int not null default 0,
|
|
||||||
constraint t_power_operation_power_id_fk foreign key (power_id) references t_power (id),
|
|
||||||
constraint t_power_operation_operation_id_fk foreign key (operation_id) references t_operation (id)
|
|
||||||
) comment '中间表-权限-功能';
|
|
||||||
|
|
||||||
create table `t_department`
|
create table `t_department`
|
||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key,
|
||||||
@@ -175,8 +153,8 @@ create table `t_power_role`
|
|||||||
`role_id` bigint not null comment '角色',
|
`role_id` bigint not null comment '角色',
|
||||||
`deleted` int not null default 0,
|
`deleted` int not null default 0,
|
||||||
`version` int not null default 0,
|
`version` int not null default 0,
|
||||||
constraint t_power_role_power_id foreign key (power_id) references t_power (id),
|
constraint t_power_role_power_id_fk foreign key (power_id) references t_power (id),
|
||||||
constraint t_power_role_role_id foreign key (role_id) references t_role (id)
|
constraint t_power_role_role_id_fk foreign key (role_id) references t_role (id)
|
||||||
) comment '中间表-权限-角色';
|
) comment '中间表-权限-角色';
|
||||||
|
|
||||||
create table `t_operation_log`
|
create table `t_operation_log`
|
||||||
@@ -185,11 +163,11 @@ create table `t_operation_log`
|
|||||||
`user_id` bigint not null comment '用户',
|
`user_id` bigint not null comment '用户',
|
||||||
`operation_id` bigint not null comment '功能',
|
`operation_id` bigint not null comment '功能',
|
||||||
`content` varchar(500) not null comment '操作内容',
|
`content` varchar(500) not null comment '操作内容',
|
||||||
`operating_time` datetime not null default CURRENT_TIMESTAMP comment '操作时间',
|
`operating_time` datetime not null default (utc_timestamp()) comment '操作时间',
|
||||||
`deleted` int not null default 0,
|
`deleted` int not null default 0,
|
||||||
`version` int not null default 0,
|
`version` int not null default 0,
|
||||||
constraint t_operation_log_user_id foreign key (user_id) references t_user (id),
|
constraint t_operation_log_user_id_fk foreign key (user_id) references t_user (id),
|
||||||
constraint t_operation_log_operation_id foreign key (operation_id) references t_operation (id)
|
constraint t_operation_log_operation_id_fk foreign key (operation_id) references t_operation (id)
|
||||||
) comment '操作日志';
|
) comment '操作日志';
|
||||||
|
|
||||||
create table `t_staff`
|
create table `t_staff`
|
||||||
@@ -224,12 +202,12 @@ create table `t_notice`
|
|||||||
`content` text not null comment '公告内容',
|
`content` text not null comment '公告内容',
|
||||||
`type_id` bigint not null comment '公告类型',
|
`type_id` bigint not null comment '公告类型',
|
||||||
`sender_id` bigint not null comment '发布者',
|
`sender_id` bigint not null comment '发布者',
|
||||||
`create_time` datetime not null default CURRENT_TIMESTAMP comment '创建时间',
|
`create_time` datetime not null default (utc_timestamp()) comment '创建时间',
|
||||||
`send_time` datetime not null comment '发送时间',
|
`send_time` datetime not null comment '发送时间',
|
||||||
`end_time` datetime not null comment '失效时间',
|
`end_time` datetime not null comment '失效时间',
|
||||||
`priority` int not null default 1 comment '优先级',
|
`priority` int not null default 1 comment '优先级',
|
||||||
`top` int not null default 0 comment '置顶',
|
`top` int not null default 0 comment '置顶',
|
||||||
`modify_time` datetime not null default CURRENT_TIMESTAMP comment '修改时间',
|
`modify_time` datetime not null default (utc_timestamp()) comment '修改时间',
|
||||||
`origin_id` bigint null comment '源ID',
|
`origin_id` bigint null comment '源ID',
|
||||||
`old` int not null default 0 comment '已修改',
|
`old` int not null default 0 comment '已修改',
|
||||||
`deleted` int not null default 0,
|
`deleted` int not null default 0,
|
||||||
@@ -255,9 +233,9 @@ create table `t_work`
|
|||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key,
|
||||||
`content` varchar(100) not null comment '工作内容',
|
`content` varchar(100) not null comment '工作内容',
|
||||||
`publisher_id` bigint not null comment '发布者',
|
`publisher_id` bigint not null comment '发布者',
|
||||||
`create_time` datetime not null default CURRENT_TIMESTAMP comment '创建时间',
|
`create_time` datetime not null default (utc_timestamp()) comment '创建时间',
|
||||||
`deadline` datetime not null comment '截止时间',
|
`deadline` datetime not null comment '截止时间',
|
||||||
`modify_time` datetime not null default CURRENT_TIMESTAMP comment '修改时间',
|
`modify_time` datetime not null default (utc_timestamp()) comment '修改时间',
|
||||||
`old` int not null default 0 comment '已修改',
|
`old` int not null default 0 comment '已修改',
|
||||||
`origin_id` bigint null comment '源ID',
|
`origin_id` bigint null comment '源ID',
|
||||||
`deleted` int not null default 0,
|
`deleted` int not null default 0,
|
||||||
@@ -295,10 +273,10 @@ create table `t_affair`
|
|||||||
`status` int not null default 0 comment '事务状态',
|
`status` int not null default 0 comment '事务状态',
|
||||||
`applicant_id` bigint not null comment '申请者',
|
`applicant_id` bigint not null comment '申请者',
|
||||||
`inspector_id` bigint not null comment '审核者',
|
`inspector_id` bigint not null comment '审核者',
|
||||||
`create_time` datetime not null default CURRENT_TIMESTAMP comment '创建时间',
|
`create_time` datetime not null default (utc_timestamp()) comment '创建时间',
|
||||||
`inspect_time` datetime null comment '审核时间',
|
`inspect_time` datetime null comment '审核时间',
|
||||||
`priority` int not null default 1 comment '优先级',
|
`priority` int not null default 1 comment '优先级',
|
||||||
`modify_time` datetime default CURRENT_TIMESTAMP comment '修改时间',
|
`modify_time` datetime default (utc_timestamp()) comment '修改时间',
|
||||||
`origin_id` bigint null comment '源ID',
|
`origin_id` bigint null comment '源ID',
|
||||||
`old` int not null default 0 comment '已修改',
|
`old` int not null default 0 comment '已修改',
|
||||||
`deleted` int not null default 0,
|
`deleted` int not null default 0,
|
||||||
@@ -312,12 +290,40 @@ create table `t_attendance`
|
|||||||
(
|
(
|
||||||
`id` bigint not null primary key,
|
`id` bigint not null primary key,
|
||||||
`user_id` bigint not null comment '用户',
|
`user_id` bigint not null comment '用户',
|
||||||
`att_time` datetime not null default CURRENT_TIMESTAMP comment '考勤时间',
|
`att_time` datetime not null default (utc_timestamp()) comment '考勤时间',
|
||||||
`status` int not null default 0 comment '考勤状态',
|
`status` int not null default 0 comment '考勤状态',
|
||||||
`modify_id` bigint not null comment '修改人',
|
`modify_id` bigint not null comment '修改人',
|
||||||
`modify_time` datetime not null default CURRENT_TIMESTAMP comment '修改时间',
|
`modify_time` datetime not null default (utc_timestamp()) comment '修改时间',
|
||||||
`deleted` int not null default 0,
|
`deleted` int not null default 0,
|
||||||
`version` int not null default 0,
|
`version` int not null default 0,
|
||||||
constraint t_attendance_user_id_fk foreign key (user_id) references t_user (id),
|
constraint t_attendance_user_id_fk foreign key (user_id) references t_user (id),
|
||||||
constraint t_attendance_modify_id_fk foreign key (modify_id) references t_user (id)
|
constraint t_attendance_modify_id_fk foreign key (modify_id) references t_user (id)
|
||||||
) comment '考勤';
|
) comment '考勤';
|
||||||
|
|
||||||
|
insert into t_power_type (id, name)
|
||||||
|
values (1, 'operation'),
|
||||||
|
(2, 'menu'),
|
||||||
|
(3, 'element'),
|
||||||
|
(4, 'file');
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power (type_id)
|
||||||
|
values (1);
|
||||||
|
insert into t_operation (name, code, url_prefix, power_id, parent_id)
|
||||||
|
values ('Select All Power Type', 'select_all_power_type', 'GET:/powerType', last_insert_id(), null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power (type_id)
|
||||||
|
values (1);
|
||||||
|
insert into t_operation (name, code, url_prefix, power_id, parent_id)
|
||||||
|
values ('Select All Power Type', 'select_all_power_type', 'GET:/powerType', last_insert_id(), null);
|
||||||
|
commit;
|
||||||
|
|
||||||
|
begin;
|
||||||
|
insert into t_power (type_id)
|
||||||
|
values (1);
|
||||||
|
insert into t_operation (name, code, url_prefix, power_id, parent_id)
|
||||||
|
values ('Select All User', 'select_all_user', 'GET:/user', last_insert_id(), null);
|
||||||
|
commit;
|
||||||
Reference in New Issue
Block a user