制度模块代码
This commit is contained in:
parent
082c90efd3
commit
117e02770e
|
@ -0,0 +1,48 @@
|
|||
package com.dite.znpt.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.dite.znpt.domain.AuditableEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: gaoxiong
|
||||
* @Date: 2025/6/24 23:15
|
||||
* @Description: 制度类型实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("regulation_type")
|
||||
@ApiModel(value="RegulationTypeEntity对象", description="制度类型")
|
||||
public class RegulationTypeEntity extends AuditableEntity implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 3027186714895190416L;
|
||||
|
||||
@ApiModelProperty("制度类型id")
|
||||
@TableId(value = "regulation_type_id", type = IdType.ASSIGN_UUID)
|
||||
private String regulationTypeId;
|
||||
|
||||
@ApiModelProperty("制度类型名称")
|
||||
@TableField("regulation_type_name")
|
||||
private String regulationTypeName;
|
||||
|
||||
@ApiModelProperty("状态(0正常 1禁用)")
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 ,1代表删除)")
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: gaoxiong
|
||||
* @Date: 2025/6/24 23:44
|
||||
* @Description: 制度类型请求实体
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("制度类型请求实体")
|
||||
public class RegulationTypeReq implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -47047804822030641L;
|
||||
|
||||
@NotBlank(message = "制度类型名称不能为空")
|
||||
@Size(max = 50, message = "制度类型名称不能超过50个字符")
|
||||
@ApiModelProperty("制度类型名称")
|
||||
private String regulationTypeName;
|
||||
|
||||
@ApiModelProperty("状态(0正常 1禁用)")
|
||||
private Integer status;
|
||||
|
||||
@Size(max = 200, message = "备注信息不能超过200个字符")
|
||||
@ApiModelProperty("备注信息")
|
||||
private String remark;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author: gaoxiong
|
||||
* @Date: 2025/6/24 23:46
|
||||
* @Description: 制度类型响应实体
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("制度类型响应实体")
|
||||
public class RegulationTypeResp implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = -2745493272695038596L;
|
||||
|
||||
@ApiModelProperty("制度类型id")
|
||||
private String regulationTypeId;
|
||||
|
||||
@ApiModelProperty("制度类型名称")
|
||||
private String regulationTypeName;
|
||||
|
||||
@ApiModelProperty("状态(0正常 1禁用)")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty("状态描述")
|
||||
private String statusDesc;
|
||||
|
||||
@ApiModelProperty("备注信息")
|
||||
private String remark;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.dite.znpt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.dite.znpt.domain.entity.RegulationTypeEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/26/周四 9:28
|
||||
* @description 制度类型Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface RegulationTypeMapper extends BaseMapper<RegulationTypeEntity> {
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.dite.znpt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.dite.znpt.domain.entity.RegulationTypeEntity;
|
||||
import com.dite.znpt.domain.vo.RegulationTypeReq;
|
||||
import com.dite.znpt.domain.vo.RegulationTypeResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/26/周四 9:28
|
||||
* @description 制度类型Service接口
|
||||
*/
|
||||
public interface RegulationTypeService extends IService<RegulationTypeEntity> {
|
||||
|
||||
List<RegulationTypeResp> page(String regulationTypeName, Integer status, String remark);
|
||||
List<RegulationTypeResp> list(String regulationTypeName, Integer status, String remark);
|
||||
RegulationTypeResp detail(String regulationTypeId);
|
||||
void save(RegulationTypeReq req);
|
||||
void update(String regulationTypeId, RegulationTypeReq req);
|
||||
void deleteById(String regulationTypeId);
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.18</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>sa-token-demo</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<sa-token.version>1.37.0</sa-token.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Boot Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token 权限认证 -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-spring-boot-starter</artifactId>
|
||||
<version>${sa-token.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Sa-Token 整合 Redis -->
|
||||
<dependency>
|
||||
<groupId>cn.dev33</groupId>
|
||||
<artifactId>sa-token-redis-jackson</artifactId>
|
||||
<version>${sa-token.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis Plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MySQL驱动 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Hutool工具类 -->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.24</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger文档 -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
package com.example;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* Sa-Token Demo 启动类
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.example.mapper")
|
||||
public class SaTokenDemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SaTokenDemoApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.example.config;
|
||||
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
import cn.dev33.satoken.router.SaRouter;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sa-Token配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class SaTokenConfig implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 注册Sa-Token拦截器,打开注解式鉴权功能
|
||||
*/
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册Sa-Token拦截器,定义详细认证规则
|
||||
registry.addInterceptor(new SaInterceptor(handler -> {
|
||||
// 指定哪些接口需要登录认证
|
||||
SaRouter.match("/**")
|
||||
.notMatch(getExcludePaths())
|
||||
.check(r -> StpUtil.checkLogin());
|
||||
})).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取不需要登录认证的路径
|
||||
*/
|
||||
private List<String> getExcludePaths() {
|
||||
return Arrays.asList(
|
||||
"/auth/login", // 登录接口
|
||||
"/auth/logout", // 登出接口
|
||||
"/doc.html", // Swagger文档
|
||||
"/swagger-ui/**", // Swagger UI
|
||||
"/swagger-resources/**", // Swagger资源
|
||||
"/v3/api-docs/**", // OpenAPI文档
|
||||
"/webjars/**", // WebJars
|
||||
"/error", // 错误页面
|
||||
"/favicon.ico" // 网站图标
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.example.config;
|
||||
|
||||
import cn.dev33.satoken.stp.StpInterface;
|
||||
import com.example.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义权限验证接口扩展
|
||||
*/
|
||||
@Component
|
||||
public class StpInterfaceImpl implements StpInterface {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 返回指定账号id所拥有的权限码集合
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
return userService.getPermissionList(Long.valueOf(loginId.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回指定账号id所拥有的角色标识集合
|
||||
*/
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
return userService.getRoleList(Long.valueOf(loginId.toString()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.example.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.example.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 认证控制器
|
||||
*/
|
||||
@Api(tags = "认证管理")
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@ApiOperation("用户登录")
|
||||
@PostMapping("/login")
|
||||
public Map<String, Object> login(@RequestParam String username, @RequestParam String password) {
|
||||
String token = userService.login(username, password);
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("code", 200);
|
||||
result.put("message", "登录成功");
|
||||
result.put("token", token);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("用户登出")
|
||||
@SaCheckLogin
|
||||
@PostMapping("/logout")
|
||||
public Map<String, Object> logout() {
|
||||
userService.logout();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("code", 200);
|
||||
result.put("message", "登出成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("获取当前用户信息")
|
||||
@SaCheckLogin
|
||||
@GetMapping("/info")
|
||||
public Map<String, Object> getUserInfo() {
|
||||
Long userId = StpUtil.getLoginIdAsLong();
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("code", 200);
|
||||
result.put("userId", userId);
|
||||
result.put("roles", StpUtil.getRoleList());
|
||||
result.put("permissions", StpUtil.getPermissionList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("测试权限 - 需要ADMIN角色")
|
||||
@SaCheckRole("ADMIN")
|
||||
@GetMapping("/test/admin")
|
||||
public Map<String, Object> testAdmin() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("code", 200);
|
||||
result.put("message", "您有ADMIN角色权限");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation("测试权限 - 需要user:add权限")
|
||||
@SaCheckPermission("user:add")
|
||||
@GetMapping("/test/permission")
|
||||
public Map<String, Object> testPermission() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("code", 200);
|
||||
result.put("message", "您有user:add权限");
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.example.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
/**
|
||||
* 获取用户权限列表
|
||||
*/
|
||||
@Select("SELECT DISTINCT p.permission_code " +
|
||||
"FROM sys_user u " +
|
||||
"LEFT JOIN sys_user_role ur ON u.id = ur.user_id " +
|
||||
"LEFT JOIN sys_role_permission rp ON ur.role_id = rp.role_id " +
|
||||
"LEFT JOIN sys_permission p ON rp.permission_id = p.id " +
|
||||
"WHERE u.id = #{userId} AND u.status = 1 AND p.status = 1")
|
||||
List<String> getPermissionList(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 获取用户角色列表
|
||||
*/
|
||||
@Select("SELECT DISTINCT r.role_code " +
|
||||
"FROM sys_user u " +
|
||||
"LEFT JOIN sys_user_role ur ON u.id = ur.user_id " +
|
||||
"LEFT JOIN sys_role r ON ur.role_id = r.id " +
|
||||
"WHERE u.id = #{userId} AND u.status = 1 AND r.status = 1")
|
||||
List<String> getRoleList(@Param("userId") Long userId);
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: sa-token-demo
|
||||
|
||||
# 数据库配置
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/sa_token_demo?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
# Redis配置
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password:
|
||||
database: 0
|
||||
timeout: 3000ms
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-wait: -1ms
|
||||
max-idle: 8
|
||||
min-idle: 0
|
||||
|
||||
# MyBatis Plus配置
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
db-config:
|
||||
logic-delete-field: deleted
|
||||
logic-delete-value: 1
|
||||
logic-not-delete-value: 0
|
||||
|
||||
# Sa-Token配置
|
||||
sa-token:
|
||||
# token名称 (同时也是cookie名称)
|
||||
token-name: Authorization
|
||||
# token有效期,单位s 默认30天, -1代表永不过期
|
||||
timeout: 2592000
|
||||
# token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
|
||||
active-timeout: -1
|
||||
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
|
||||
is-concurrent: true
|
||||
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
|
||||
is-share: false
|
||||
# token风格
|
||||
token-style: uuid
|
||||
# 是否输出操作日志
|
||||
is-log: true
|
||||
# 是否从cookie中读取token
|
||||
is-read-cookie: false
|
||||
# 是否从header中读取token
|
||||
is-read-header: true
|
||||
# 是否从body中读取token
|
||||
is-read-body: false
|
|
@ -0,0 +1,104 @@
|
|||
-- 创建数据库
|
||||
CREATE DATABASE IF NOT EXISTS sa_token_demo DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
USE sa_token_demo;
|
||||
|
||||
-- 用户表
|
||||
CREATE TABLE `sys_user` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||
`username` varchar(50) NOT NULL COMMENT '用户名',
|
||||
`password` varchar(100) NOT NULL COMMENT '密码',
|
||||
`nickname` varchar(50) DEFAULT NULL COMMENT '昵称',
|
||||
`email` varchar(100) DEFAULT NULL COMMENT '邮箱',
|
||||
`phone` varchar(20) DEFAULT NULL COMMENT '手机号',
|
||||
`status` tinyint DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
|
||||
`deleted` tinyint DEFAULT '0' COMMENT '是否删除:0-否,1-是',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_username` (`username`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
|
||||
|
||||
-- 角色表
|
||||
CREATE TABLE `sys_role` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '角色ID',
|
||||
`role_name` varchar(50) NOT NULL COMMENT '角色名称',
|
||||
`role_code` varchar(50) NOT NULL COMMENT '角色编码',
|
||||
`description` varchar(200) DEFAULT NULL COMMENT '角色描述',
|
||||
`status` tinyint DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
|
||||
`deleted` tinyint DEFAULT '0' COMMENT '是否删除:0-否,1-是',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_role_code` (`role_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
|
||||
|
||||
-- 权限表
|
||||
CREATE TABLE `sys_permission` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '权限ID',
|
||||
`permission_name` varchar(50) NOT NULL COMMENT '权限名称',
|
||||
`permission_code` varchar(50) NOT NULL COMMENT '权限编码',
|
||||
`permission_type` tinyint DEFAULT '1' COMMENT '权限类型:1-菜单,2-按钮',
|
||||
`parent_id` bigint DEFAULT '0' COMMENT '父权限ID',
|
||||
`path` varchar(200) DEFAULT NULL COMMENT '路径',
|
||||
`component` varchar(200) DEFAULT NULL COMMENT '组件',
|
||||
`icon` varchar(100) DEFAULT NULL COMMENT '图标',
|
||||
`sort` int DEFAULT '0' COMMENT '排序',
|
||||
`status` tinyint DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
|
||||
`deleted` tinyint DEFAULT '0' COMMENT '是否删除:0-否,1-是',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_permission_code` (`permission_code`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限表';
|
||||
|
||||
-- 用户角色关联表
|
||||
CREATE TABLE `sys_user_role` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||||
`role_id` bigint NOT NULL COMMENT '角色ID',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_user_role` (`user_id`,`role_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色关联表';
|
||||
|
||||
-- 角色权限关联表
|
||||
CREATE TABLE `sys_role_permission` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`role_id` bigint NOT NULL COMMENT '角色ID',
|
||||
`permission_id` bigint NOT NULL COMMENT '权限ID',
|
||||
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_role_permission` (`role_id`,`permission_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色权限关联表';
|
||||
|
||||
-- 插入测试数据
|
||||
INSERT INTO `sys_user` (`username`, `password`, `nickname`, `email`) VALUES
|
||||
('admin', '$2a$10$7JB720yubVSOfvVWdBYoOeymFJgxVqQqHqKjqKjqKjqKjqKjqKjqK', '管理员', 'admin@example.com'),
|
||||
('user', '$2a$10$7JB720yubVSOfvVWdBYoOeymFJgxVqQqHqKjqKjqKjqKjqKjqKjqK', '普通用户', 'user@example.com');
|
||||
|
||||
INSERT INTO `sys_role` (`role_name`, `role_code`, `description`) VALUES
|
||||
('超级管理员', 'SUPER_ADMIN', '系统超级管理员'),
|
||||
('管理员', 'ADMIN', '系统管理员'),
|
||||
('普通用户', 'USER', '普通用户');
|
||||
|
||||
INSERT INTO `sys_permission` (`permission_name`, `permission_code`, `permission_type`, `parent_id`, `path`, `component`, `icon`, `sort`) VALUES
|
||||
('用户管理', 'user:view', 1, 0, '/user', 'User', 'user', 1),
|
||||
('用户列表', 'user:list', 2, 1, NULL, NULL, NULL, 1),
|
||||
('用户新增', 'user:add', 2, 1, NULL, NULL, NULL, 2),
|
||||
('用户编辑', 'user:edit', 2, 1, NULL, NULL, NULL, 3),
|
||||
('用户删除', 'user:delete', 2, 1, NULL, NULL, NULL, 4),
|
||||
('角色管理', 'role:view', 1, 0, '/role', 'Role', 'team', 2),
|
||||
('角色列表', 'role:list', 2, 6, NULL, NULL, NULL, 1),
|
||||
('角色新增', 'role:add', 2, 6, NULL, NULL, NULL, 2),
|
||||
('角色编辑', 'role:edit', 2, 6, NULL, NULL, NULL, 3),
|
||||
('角色删除', 'role:delete', 2, 6, NULL, NULL, NULL, 4);
|
||||
|
||||
INSERT INTO `sys_user_role` (`user_id`, `role_id`) VALUES
|
||||
(1, 1),
|
||||
(2, 3);
|
||||
|
||||
INSERT INTO `sys_role_permission` (`role_id`, `permission_id`) VALUES
|
||||
(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10),
|
||||
(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10),
|
||||
(3, 1), (3, 2);
|
|
@ -38,7 +38,7 @@ import static com.dite.znpt.monitor.config.MediaFormatConfig.streamMediaFormatLi
|
|||
* @Date: 2022/8/30 10:40
|
||||
* @Description:
|
||||
*/
|
||||
@Service
|
||||
//@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@EnableScheduling
|
||||
|
@ -79,8 +79,9 @@ public class ZlmServiceImpl implements ZlmService, ApplicationRunner {
|
|||
List<ServerConfig> configList = zlmApi.getServerConfig(item.getServer());
|
||||
item.setConfig(configList.get(0));
|
||||
item.setStatus(true);
|
||||
log.info("ZLM媒体服务器连接成功");
|
||||
} catch (Exception e) {
|
||||
log.error("流服务器节点配置错误:", e);
|
||||
log.warn("ZLM媒体服务器连接失败,应用将继续启动但媒体功能不可用:{}", e.getMessage());
|
||||
item.setStatus(false);
|
||||
}
|
||||
//初始化参数
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.dite.znpt.web.controller;
|
||||
|
||||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.vo.RegulationTypeReq;
|
||||
import com.dite.znpt.domain.vo.RegulationTypeResp;
|
||||
import com.dite.znpt.service.RegulationTypeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bear.G
|
||||
* @date 2025/6/26/周四 9:10
|
||||
* @description 制度类型Controller
|
||||
*/
|
||||
@Api(tags = "制度类型")
|
||||
@RestController
|
||||
@RequestMapping("/regulation-type")
|
||||
public class RegulationTypeController {
|
||||
|
||||
@Resource
|
||||
private RegulationTypeService regulationTypeService;
|
||||
|
||||
@ApiOperation(value = "分页查询制度类型列表", httpMethod = "GET")
|
||||
@GetMapping("/page")
|
||||
public PageResult<RegulationTypeResp> page(@RequestParam(required = false) String regulationTypeName,
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String remark) {
|
||||
return PageResult.ok(regulationTypeService.page(regulationTypeName, status, remark));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询制度类型列表", httpMethod = "GET")
|
||||
@GetMapping("/list")
|
||||
public Result<List<RegulationTypeResp>> list(@RequestParam(required = false) String regulationTypeName,
|
||||
@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false) String remark) {
|
||||
return Result.ok(regulationTypeService.list(regulationTypeName, status, remark));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询制度类型详情", httpMethod = "GET")
|
||||
@GetMapping("/detail/{regulationTypeId}")
|
||||
public Result<RegulationTypeResp> detail(@PathVariable String regulationTypeId) {
|
||||
return Result.ok(regulationTypeService.detail(regulationTypeId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增制度类型", httpMethod = "POST")
|
||||
@PostMapping
|
||||
public Result<?> add(@Valid @RequestBody RegulationTypeReq req) {
|
||||
regulationTypeService.save(req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改制度类型", httpMethod = "PUT")
|
||||
@PutMapping("/{regulationTypeId}")
|
||||
public Result<?> edit(@PathVariable String regulationTypeId, @Valid @RequestBody RegulationTypeReq req) {
|
||||
regulationTypeService.update(regulationTypeId, req);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除制度类型", httpMethod = "DELETE")
|
||||
@DeleteMapping("/{regulationTypeId}")
|
||||
public Result<?> remove(@PathVariable String regulationTypeId) {
|
||||
regulationTypeService.deleteById(regulationTypeId);
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
|
@ -109,6 +109,11 @@ sip-config:
|
|||
password: 123456
|
||||
mediaType: mp4
|
||||
|
||||
# 功能开关配置
|
||||
feature:
|
||||
# 是否启用视频流媒体功能
|
||||
enable-video-stream: false
|
||||
|
||||
zlm-config:
|
||||
# 流媒体名称
|
||||
mediaName: 媒体服务
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
[general]
|
||||
# 服务器名称
|
||||
server_name=ZLMediaKit
|
||||
# 服务器ID
|
||||
server_id=your_server_id
|
||||
# 是否启用调试日志
|
||||
enable_vhost=1
|
||||
# 是否启用调试日志
|
||||
enable_debug=1
|
||||
|
||||
[api]
|
||||
# API密钥,需要与application-dev.yml中的secretKey一致
|
||||
secret=6Q76ivvVOQDsnnfOSKbtVzcYpbgy4n1G
|
||||
# API端口
|
||||
port=8080
|
||||
# 是否启用API
|
||||
enable=1
|
||||
|
||||
[rtp]
|
||||
# RTP端口范围
|
||||
port_range=30150-30185
|
||||
# RTP超时时间
|
||||
timeout_sec=30
|
||||
|
||||
[rtmp]
|
||||
# RTMP端口
|
||||
port=1935
|
||||
# 是否启用RTMP
|
||||
enable=1
|
||||
|
||||
[rtsp]
|
||||
# RTSP端口
|
||||
port=554
|
||||
# 是否启用RTSP
|
||||
enable=1
|
||||
|
||||
[http]
|
||||
# HTTP端口
|
||||
port=80
|
||||
# 是否启用HTTP
|
||||
enable=1
|
||||
|
||||
[hls]
|
||||
# HLS端口
|
||||
port=80
|
||||
# 是否启用HLS
|
||||
enable=1
|
Loading…
Reference in New Issue