diff --git a/core/src/main/java/com/dite/znpt/domain/entity/RegulationTypeEntity.java b/core/src/main/java/com/dite/znpt/domain/entity/RegulationTypeEntity.java new file mode 100644 index 0000000..7d69b98 --- /dev/null +++ b/core/src/main/java/com/dite/znpt/domain/entity/RegulationTypeEntity.java @@ -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; +} \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/domain/vo/RegulationTypeReq.java b/core/src/main/java/com/dite/znpt/domain/vo/RegulationTypeReq.java new file mode 100644 index 0000000..ebe1aab --- /dev/null +++ b/core/src/main/java/com/dite/znpt/domain/vo/RegulationTypeReq.java @@ -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; +} \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/domain/vo/RegulationTypeResp.java b/core/src/main/java/com/dite/znpt/domain/vo/RegulationTypeResp.java new file mode 100644 index 0000000..d6093c2 --- /dev/null +++ b/core/src/main/java/com/dite/znpt/domain/vo/RegulationTypeResp.java @@ -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; +} \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/mapper/RegulationTypeMapper.java b/core/src/main/java/com/dite/znpt/mapper/RegulationTypeMapper.java new file mode 100644 index 0000000..02d48b8 --- /dev/null +++ b/core/src/main/java/com/dite/znpt/mapper/RegulationTypeMapper.java @@ -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 { +} \ No newline at end of file diff --git a/core/src/main/java/com/dite/znpt/service/RegulationTypeService.java b/core/src/main/java/com/dite/znpt/service/RegulationTypeService.java new file mode 100644 index 0000000..9eadc8c --- /dev/null +++ b/core/src/main/java/com/dite/znpt/service/RegulationTypeService.java @@ -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 { + + List page(String regulationTypeName, Integer status, String remark); + List 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); +} \ No newline at end of file diff --git a/sa-token-demo/pom.xml b/sa-token-demo/pom.xml new file mode 100644 index 0000000..a54c2e0 --- /dev/null +++ b/sa-token-demo/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.7.18 + + + com.example + sa-token-demo + 1.0.0 + jar + + + 17 + 1.37.0 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + cn.dev33 + sa-token-spring-boot-starter + ${sa-token.version} + + + + + cn.dev33 + sa-token-redis-jackson + ${sa-token.version} + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + com.baomidou + mybatis-plus-boot-starter + 3.5.3.1 + + + + + mysql + mysql-connector-java + 8.0.33 + + + + + org.projectlombok + lombok + true + + + + + cn.hutool + hutool-all + 5.8.24 + + + + + io.springfox + springfox-boot-starter + 3.0.0 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + \ No newline at end of file diff --git a/sa-token-demo/src/main/java/com/example/SaTokenDemoApplication.java b/sa-token-demo/src/main/java/com/example/SaTokenDemoApplication.java new file mode 100644 index 0000000..db7b848 --- /dev/null +++ b/sa-token-demo/src/main/java/com/example/SaTokenDemoApplication.java @@ -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); + } +} \ No newline at end of file diff --git a/sa-token-demo/src/main/java/com/example/config/SaTokenConfig.java b/sa-token-demo/src/main/java/com/example/config/SaTokenConfig.java new file mode 100644 index 0000000..df491bb --- /dev/null +++ b/sa-token-demo/src/main/java/com/example/config/SaTokenConfig.java @@ -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 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" // 网站图标 + ); + } +} \ No newline at end of file diff --git a/sa-token-demo/src/main/java/com/example/config/StpInterfaceImpl.java b/sa-token-demo/src/main/java/com/example/config/StpInterfaceImpl.java new file mode 100644 index 0000000..5f9b31e --- /dev/null +++ b/sa-token-demo/src/main/java/com/example/config/StpInterfaceImpl.java @@ -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 getPermissionList(Object loginId, String loginType) { + return userService.getPermissionList(Long.valueOf(loginId.toString())); + } + + /** + * 返回指定账号id所拥有的角色标识集合 + */ + @Override + public List getRoleList(Object loginId, String loginType) { + return userService.getRoleList(Long.valueOf(loginId.toString())); + } +} \ No newline at end of file diff --git a/sa-token-demo/src/main/java/com/example/controller/AuthController.java b/sa-token-demo/src/main/java/com/example/controller/AuthController.java new file mode 100644 index 0000000..1b4dcc1 --- /dev/null +++ b/sa-token-demo/src/main/java/com/example/controller/AuthController.java @@ -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 login(@RequestParam String username, @RequestParam String password) { + String token = userService.login(username, password); + Map result = new HashMap<>(); + result.put("code", 200); + result.put("message", "登录成功"); + result.put("token", token); + return result; + } + + @ApiOperation("用户登出") + @SaCheckLogin + @PostMapping("/logout") + public Map logout() { + userService.logout(); + Map result = new HashMap<>(); + result.put("code", 200); + result.put("message", "登出成功"); + return result; + } + + @ApiOperation("获取当前用户信息") + @SaCheckLogin + @GetMapping("/info") + public Map getUserInfo() { + Long userId = StpUtil.getLoginIdAsLong(); + Map 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 testAdmin() { + Map result = new HashMap<>(); + result.put("code", 200); + result.put("message", "您有ADMIN角色权限"); + return result; + } + + @ApiOperation("测试权限 - 需要user:add权限") + @SaCheckPermission("user:add") + @GetMapping("/test/permission") + public Map testPermission() { + Map result = new HashMap<>(); + result.put("code", 200); + result.put("message", "您有user:add权限"); + return result; + } +} \ No newline at end of file diff --git a/sa-token-demo/src/main/java/com/example/mapper/UserMapper.java b/sa-token-demo/src/main/java/com/example/mapper/UserMapper.java new file mode 100644 index 0000000..1883a7d --- /dev/null +++ b/sa-token-demo/src/main/java/com/example/mapper/UserMapper.java @@ -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 { + + /** + * 获取用户权限列表 + */ + @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 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 getRoleList(@Param("userId") Long userId); +} \ No newline at end of file diff --git a/sa-token-demo/src/main/resources/application.yml b/sa-token-demo/src/main/resources/application.yml new file mode 100644 index 0000000..9a06268 --- /dev/null +++ b/sa-token-demo/src/main/resources/application.yml @@ -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 \ No newline at end of file diff --git a/sa-token-demo/src/main/resources/sql/init.sql b/sa-token-demo/src/main/resources/sql/init.sql new file mode 100644 index 0000000..cbfa97a --- /dev/null +++ b/sa-token-demo/src/main/resources/sql/init.sql @@ -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); \ No newline at end of file diff --git a/sip/src/main/java/com/dite/znpt/monitor/media/zlm/impl/ZlmServiceImpl.java b/sip/src/main/java/com/dite/znpt/monitor/media/zlm/impl/ZlmServiceImpl.java index b4b52de..3f3feb5 100644 --- a/sip/src/main/java/com/dite/znpt/monitor/media/zlm/impl/ZlmServiceImpl.java +++ b/sip/src/main/java/com/dite/znpt/monitor/media/zlm/impl/ZlmServiceImpl.java @@ -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 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); } //初始化参数 diff --git a/web/src/main/java/com/dite/znpt/web/controller/RegulationTypeController.java b/web/src/main/java/com/dite/znpt/web/controller/RegulationTypeController.java new file mode 100644 index 0000000..585aaae --- /dev/null +++ b/web/src/main/java/com/dite/znpt/web/controller/RegulationTypeController.java @@ -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 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(@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 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(); + } +} \ No newline at end of file diff --git a/web/src/main/resources/application-dev.yml b/web/src/main/resources/application-dev.yml index b21b663..5779995 100644 --- a/web/src/main/resources/application-dev.yml +++ b/web/src/main/resources/application-dev.yml @@ -109,6 +109,11 @@ sip-config: password: 123456 mediaType: mp4 +# 功能开关配置 +feature: + # 是否启用视频流媒体功能 + enable-video-stream: false + zlm-config: # 流媒体名称 mediaName: 媒体服务 diff --git a/zlm-config.ini b/zlm-config.ini new file mode 100644 index 0000000..98564a6 --- /dev/null +++ b/zlm-config.ini @@ -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 \ No newline at end of file