This commit is contained in:
2025-12-02 13:21:18 +08:00
parent fab8c13cb3
commit ee6dd64f98
192 changed files with 25783 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
<?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.xyzh</groupId>
<artifactId>urban-lifeline</artifactId>
<version>1.0.0</version>
</parent>
<groupId>org.xyzh</groupId>
<artifactId>system</artifactId>
<version>${urban-lifeline.version}</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<dependencies>
<!-- 项目内部模块 -->
<dependency>
<groupId>org.xyzh.common</groupId>
<artifactId>common-all</artifactId>
</dependency>
<dependency>
<groupId>org.xyzh.apis</groupId>
<artifactId>api-system</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Spring Boot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Dubbo Spring Boot Starter -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
</dependency>
<!-- Dubbo Nacos Spring Boot Starter (服务注册与发现) -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-nacos-spring-boot-starter</artifactId>
</dependency>
<!-- Spring Cloud Alibaba Nacos Discovery (可选,用于服务发现) -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.version}</version>
</dependency>
<!-- MyBatis-Plus (可选,如不需要增强 CRUD 可移除) -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis.plus.version}</version>
<exclusions>
<!-- 排除旧版 mybatis-spring防止与 3.x 冲突 -->
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 强制引入与 Spring Boot 3.x 匹配的 mybatis-spring 3.x -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,28 @@
package org.xyzh.system;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
/**
* System 服务启动类
*
* @author yslg
*/
@SpringBootApplication
@EnableDubbo // 启用 Dubbo 服务
@ComponentScan(basePackages = {
"org.xyzh.system", // 当前system模块
"org.xyzh.common" // 公共模块
})
public class SystemApp {
private static final Logger logger = LoggerFactory.getLogger(SystemApp.class);
public static void main(String[] args) {
logger.info("======================== SystemApp 启动中 =========================");
SpringApplication.run(SystemApp.class, args);
logger.info("======================== SystemApp 启动成功 =========================");
}
}

View File

@@ -0,0 +1,58 @@
package org.xyzh.system.config;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.List;
/**
* OpenAPI 配置类 - System 服务
* 配置 Swagger/OpenAPI 文档,方便 Apifox 导入接口和对象进行测试
*
* @author yslg
*/
@Configuration
public class OpenApiConfig {
@Bean
public OpenAPI systemOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("系统服务 API 文档")
.description("""
系统服务接口文档,包括用户管理、角色管理、权限管理、部门管理等功能。
## 使用说明
1. 访问 Swagger UI: http://localhost:8082/urban-lifeline/system/swagger-ui.html
2. 访问 OpenAPI JSON: http://localhost:8082/urban-lifeline/system/v3/api-docs
3. 在 Apifox 中导入 OpenAPI JSON 进行接口测试
""")
.version("1.0.0")
.contact(new Contact()
.name("yslg")
.email("3401275564@qq.com"))
.license(new License()
.name("Apache 2.0")
.url("https://www.apache.org/licenses/LICENSE-2.0.html")))
.servers(List.of(
new Server().url("http://localhost:8082/urban-lifeline/system").description("本地开发环境")
))
.addSecurityItem(new SecurityRequirement().addList("Bearer Authentication"))
.components(new Components()
.addSecuritySchemes("Bearer Authentication",
new SecurityScheme()
.type(SecurityScheme.Type.HTTP)
.scheme("bearer")
.bearerFormat("JWT")
.description("请输入JWT Token格式Bearer {token}")));
}
}

View File

@@ -0,0 +1,202 @@
package org.xyzh.system.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xyzh.api.system.service.DeptRoleService;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.api.system.vo.UserDeptRoleVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysDeptDTO;
import org.xyzh.common.dto.sys.TbSysRoleDTO;
@RestController
@RequestMapping("/system/deptRole")
public class DeptRoleController {
private static final Logger logger = LoggerFactory.getLogger(DeptRoleController.class);
@Autowired
private DeptRoleService deptRoleService;
// ================= 部门角色相关接口 =================
/**
* @description 创建部门
* @param deptDTO 部门DTO
* @return ResultDomain<TbSysDeptDTO> 创建结果
* @author yslg
* @since 2025-11-10
*/
@PostMapping("/dept")
public ResultDomain<TbSysDeptDTO> createDept(@RequestBody TbSysDeptDTO deptDTO) {
return deptRoleService.insertDept(deptDTO);
}
/**
* @description 更新部门
* @param deptDTO 部门DTO
* @return ResultDomain<TbSysDeptDTO> 更新结果
* @author yslg
* @since 2025-11-10
*/
@PutMapping("/dept")
public ResultDomain<TbSysDeptDTO> updateDept(@RequestBody TbSysDeptDTO deptDTO) {
return deptRoleService.updateDept(deptDTO);
}
/**
* @description 删除部门
* @param deptDTO 部门DTO
* @return ResultDomain<Boolean> 删除结果
* @author yslg
* @since 2025-11-10
*/
@DeleteMapping("/dept")
public ResultDomain<Boolean> deleteDept(@RequestBody TbSysDeptDTO deptDTO) {
return deptRoleService.deleteDept(deptDTO);
}
/**
* @description 根据条件查询部门分页列表
* @param PageRequest<UserDeptRoleVO> pageRequest 分页请求
* @return ResultDomain<UserDeptRoleVO> 分页列表
* @author yslg
* @since 2025-11-10
*/
@GetMapping("/dept/page")
public ResultDomain<UserDeptRoleVO> getDeptPage(@RequestBody PageRequest<UserDeptRoleVO> pageRequest) {
return deptRoleService.getDeptPage(pageRequest);
}
/**
* @description 根据条件查询部门列表
* @param filter 部门VO
* @return ResultDomain<UserDeptRoleVO> 部门列表
* @author yslg
* @since 2025-11-10
*/
@GetMapping("/dept/list")
public ResultDomain<UserDeptRoleVO> getDeptList(@RequestBody UserDeptRoleVO filter) {
return deptRoleService.getDeptList(filter);
}
// ================= 角色相关接口 =================
/**
* @description 创建角色
* @param roleDTO 角色DTO
* @return ResultDomain<TbSysRoleDTO> 创建结果
* @author yslg
* @since 2025-11-10
*/
@PostMapping("/role")
public ResultDomain<TbSysRoleDTO> createRole(@RequestBody TbSysRoleDTO roleDTO) {
return deptRoleService.insertRole(roleDTO);
}
/**
* @description 更新角色
* @param roleDTO 角色DTO
* @return ResultDomain<TbSysRoleDTO> 更新结果
* @author yslg
* @since 2025-11-10
*/
@PutMapping("/role")
public ResultDomain<TbSysRoleDTO> updateRole(@RequestBody TbSysRoleDTO roleDTO) {
return deptRoleService.updateRole(roleDTO);
}
/**
* @description 删除角色
* @param roleDTO 角色DTO
* @return ResultDomain<Boolean> 删除结果
* @author yslg
* @since 2025-11-10
*/
@DeleteMapping("/role")
public ResultDomain<Boolean> deleteRole(@RequestBody TbSysRoleDTO roleDTO) {
return deptRoleService.deleteRole(roleDTO);
}
/**
* @description 根据条件查询角色分页列表
* @param PageRequest<UserDeptRoleVO> pageRequest 分页请求
* @return ResultDomain<UserDeptRoleVO> 分页列表
* @author yslg
* @since 2025-11-10
*/
@GetMapping("/role/page")
public ResultDomain<UserDeptRoleVO> getRolePage(@RequestBody PageRequest<UserDeptRoleVO> pageRequest) {
return deptRoleService.getRolePage(pageRequest);
}
/**
* @description 根据条件查询角色列表
* @param filter 角色VO
* @return ResultDomain<UserDeptRoleVO> 角色列表
* @author yslg
* @since 2025-11-10
*/
@GetMapping("/role/list")
public ResultDomain<UserDeptRoleVO> getRoleList(@RequestBody UserDeptRoleVO filter) {
return deptRoleService.getRoleList(filter);
}
// ================= 部门角色信息相关接口 ==================
/**
* @description 根据条件查询部门角色关联分页列表
* @param PageRequest<UserDeptRoleVO> pageRequest 分页请求
* @return ResultDomain<UserDeptRoleVO> 分页列表
* @author yslg
* @since 2025-11-10
*/
@GetMapping("/deptRole/page")
public ResultDomain<UserDeptRoleVO> getDeptRolePage(@RequestBody PageRequest<UserDeptRoleVO> pageRequest) {
return deptRoleService.getDeptRolePage(pageRequest);
}
/**
* @description 根据条件查询部门角色关联列表
* @param filter 部门角色VO
* @return ResultDomain<UserDeptRoleVO> 部门角色关联列表
* @author yslg
* @since 2025-11-10
*/
@GetMapping("/deptRole/list")
public ResultDomain<UserDeptRoleVO> getDeptRoleList(@RequestBody UserDeptRoleVO filter) {
return deptRoleService.getDeptRoleList(filter);
}
// ================== 角色权限相关接口 ==================
/**
* @description 给一个角色设置权限
* @param
* @return 返回值描述
* @author yslg
* @since 2025-11-11
*/
@PostMapping("/rolePermission/bind")
public ResultDomain<PermissionVO> getRolePermission(@RequestBody PermissionVO permissionVO) {
return deptRoleService.setRolePermission(permissionVO);
}
/**
* @description 获取一个角色的权限列表
* @param
* @return 返回值描述
* @author yslg
* @since 2025-11-11
*/
@PostMapping("/rolePermission/list")
public ResultDomain<PermissionVO> getRolePermissionList(@RequestBody PermissionVO permissionVO) {
return deptRoleService.getRolePermissionList(permissionVO);
}
}

View File

@@ -0,0 +1,152 @@
package org.xyzh.system.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xyzh.api.system.service.ModulePermissionService;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysModuleDTO;
import org.xyzh.common.dto.sys.TbSysPermissionDTO;
@RestController
@RequestMapping("/system/permission")
public class PermissionController {
private static final Logger logger = LoggerFactory.getLogger(PermissionController.class);
@Autowired
private ModulePermissionService modulePermissionService;
// ================= 模块相关接口 =================
/**
* @description 创建模块
* @param moduleDTO 模块DTO
* @return 创建结果
* @author yslg
* @since 2025-11-10
*/
@PostMapping("/module")
public ResultDomain<TbSysModuleDTO> createModule(@RequestBody TbSysModuleDTO moduleDTO) {
return modulePermissionService.insertModule(moduleDTO);
}
/**
* @description 更新模块
* @param moduleDTO 模块DTO
* @return 更新结果
* @author yslg
* @since 2025-11-10
*/
@PutMapping("/moudule")
public ResultDomain<TbSysModuleDTO> updateModule(@RequestBody TbSysModuleDTO moduleDTO) {
return modulePermissionService.updateModule(moduleDTO);
}
/**
* @description 删除模块
* @param moduleDTO 模块DTO
* @return 删除结果
* @author yslg
* @since 2025-11-10
*/
@DeleteMapping("/module")
public ResultDomain<Boolean> deleteModule(@RequestBody TbSysModuleDTO moduleDTO) {
return modulePermissionService.deleteModule(moduleDTO);
}
/**
* @description 获取模块分页数据
* @param PageRequest<TbSysModuleDTO> pageRequest 分页请求参数
* @return 返回值描述
* @author yslg
* @since 2025-11-10
*/
@PostMapping("/module/page")
public ResultDomain<PermissionVO> getModulePage(@RequestBody PageRequest<PermissionVO> pageRequest) {
return modulePermissionService.getModulePage(pageRequest);
}
/**
* @description 获取模块列表
* @param filter 模块DTO
* @return 返回值描述
* @author yslg
* @since 2025-11-10
*/
@PostMapping("/module/list")
public ResultDomain<PermissionVO> getModuleList(@RequestBody PermissionVO filter) {
return modulePermissionService.getModuleList(filter);
}
// ================= 权限相关接口 =================
/**
* @description 创建权限
* @param permissionDTO 权限DTO
* @return ResultDomain<TbSysPermissionDTO> 创建结果
* @author yslg
* @since 2025-11-10
*/
@PostMapping
public ResultDomain<TbSysPermissionDTO> createPermission(@RequestBody TbSysPermissionDTO permissionDTO) {
return modulePermissionService.insertPermission(permissionDTO);
}
/**
* @description 更新权限
* @param permissionDTO 权限DTO
* @return 更新结果
* @author yslg
* @since 2025-11-10
*/
@PutMapping
public ResultDomain<TbSysPermissionDTO> updatePermission(@RequestBody TbSysPermissionDTO permissionDTO) {
return modulePermissionService.updatePermission(permissionDTO);
}
/**
* @description 删除权限
* @param permissionDTO 权限DTO
* @return 删除结果
* @author yslg
* @since 2025-11-10
*/
@DeleteMapping
public ResultDomain<Boolean> deletePermission(@RequestBody TbSysPermissionDTO permissionDTO) {
return modulePermissionService.deletePermission(permissionDTO);
}
/**
* @description 获取权限分页数据
* @param PageRequest<TbSysPermissionDTO> pageRequest 分页请求参数
* @return 分页数据
* @author yslg
* @since 2025-11-10
*/
@PostMapping("/page")
public ResultDomain<PermissionVO> getModulePermissionPage(@RequestBody PageRequest<PermissionVO> pageRequest) {
return modulePermissionService.getModulePermissionPage(pageRequest);
}
/**
* @description 获取权限列表
* @param filter 权限VO
* @return 列表数据
* @author yslg
* @since 2025-11-10
*/
@PostMapping("/list")
public ResultDomain<PermissionVO> getModulePermissionList(@RequestBody PermissionVO filter) {
return modulePermissionService.getModulePermissionList(filter);
}
}

View File

@@ -0,0 +1,57 @@
package org.xyzh.system.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xyzh.api.system.service.SysConfigService;
import org.xyzh.api.system.vo.SysConfigVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysConfigDTO;
@RestController
@RequestMapping("/system/config")
public class SysConfigController {
private static final Logger logger = LoggerFactory.getLogger(SysConfigController.class);
@Autowired
private SysConfigService sysConfigService;
// ================= 系统配置相关接口 =================
@PostMapping
public ResultDomain<TbSysConfigDTO> createConfig(@RequestBody TbSysConfigDTO configDTO) {
return sysConfigService.insertConfig(configDTO);
}
@PutMapping
public ResultDomain<TbSysConfigDTO> updateConfig(@RequestBody TbSysConfigDTO configDTO) {
return sysConfigService.updateConfig(configDTO);
}
@DeleteMapping
public ResultDomain<Boolean> deleteConfig(@RequestBody TbSysConfigDTO configDTO) {
return sysConfigService.deleteConfig(configDTO);
}
@PostMapping("/page")
public ResultDomain<SysConfigVO> getConfigPage(@RequestBody PageRequest<SysConfigVO> pageRequest) {
return sysConfigService.getConfigPage(pageRequest);
}
@PostMapping("/list")
public ResultDomain<SysConfigVO> getConfigList(@RequestBody SysConfigVO filter) {
return sysConfigService.getConfigList(filter);
}
}

View File

@@ -0,0 +1,78 @@
package org.xyzh.system.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.xyzh.api.system.service.SysUserService;
import org.xyzh.api.system.vo.SysUserVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysUserDTO;
import org.xyzh.common.dto.sys.TbSysUserInfoDTO;
@RestController
@RequestMapping("/system/user")
public class UserController {
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
@Autowired
private SysUserService sysUserService;
// ================= 用户相关接口 =================
@PostMapping
@PreAuthorize("hasAuthority('system:user:create')")
public ResultDomain<TbSysUserDTO> createUser(@RequestBody SysUserVO userVO) {
return sysUserService.insertUser(userVO);
}
@PutMapping
@PreAuthorize("hasAuthority('system:user:update')")
public ResultDomain<TbSysUserDTO> updateUser(@RequestBody SysUserVO userVO) {
return sysUserService.updateUser(userVO);
}
@DeleteMapping
@PreAuthorize("hasAuthority('system:user:delete')")
public ResultDomain<Boolean> deleteUser(@RequestBody TbSysUserDTO userDTO) {
return sysUserService.deleteUser(userDTO);
}
@PostMapping("/page")
@PreAuthorize("hasAuthority('system:user:query')")
public ResultDomain<SysUserVO> getUserPage(@RequestBody PageRequest<SysUserVO> pageRequest) {
return sysUserService.getUserPage(pageRequest);
}
@PostMapping("/list")
@PreAuthorize("hasAuthority('system:user:query')")
public ResultDomain<SysUserVO> getUserList(@RequestBody SysUserVO filter) {
return sysUserService.getUserList(filter);
}
// ================= 用户信息相关接口 ==================
@PutMapping("/info")
@PreAuthorize("hasAuthority('system:userinfo:update')")
public ResultDomain<TbSysUserInfoDTO> updateUserInfo(@RequestBody TbSysUserInfoDTO userInfoDTO) {
return sysUserService.updateUserInfo(userInfoDTO);
}
@GetMapping("/info/{userId}")
@PreAuthorize("hasAuthority('system:userinfo:read')")
public ResultDomain<SysUserVO> getUserInfo(@PathVariable("userId") String userId) {
return sysUserService.getUserInfo(userId);
}
}

View File

@@ -0,0 +1,63 @@
package org.xyzh.system.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xyzh.api.system.service.ViewService;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysViewDTO;
@RestController
@RequestMapping("/system/view")
public class ViewController {
private static final Logger logger = LoggerFactory.getLogger(ViewController.class);
@Autowired
private ViewService viewService;
// ================= 视图相关接口 =================
@PostMapping
public ResultDomain<TbSysViewDTO> createView(@RequestBody TbSysViewDTO viewDTO) {
return viewService.insertView(viewDTO);
}
@PutMapping
public ResultDomain<TbSysViewDTO> updateView(@RequestBody TbSysViewDTO viewDTO) {
return viewService.updateView(viewDTO);
}
@DeleteMapping
public ResultDomain<Boolean> deleteView(@RequestBody TbSysViewDTO viewDTO) {
return viewService.deleteView(viewDTO);
}
@PostMapping("/page")
public ResultDomain<PermissionVO> getViewPage(@RequestBody PageRequest<PermissionVO> pageRequest) {
return viewService.getViewPage(pageRequest);
}
@PostMapping("/list")
public ResultDomain<PermissionVO> getViewList(@RequestBody PermissionVO filter) {
return viewService.getViewList(filter);
}
// ================= 视图权限相关接口 ==================
@PostMapping("/permission/bind")
public ResultDomain<PermissionVO> bindViewPermission(@RequestBody PermissionVO permissionVO) {
return viewService.setViewPermissions(permissionVO);
}
@PostMapping("/permission/list")
public ResultDomain<PermissionVO> getViewPermissions(@RequestBody PermissionVO permissionVO) {
return viewService.getViewPermissionList(permissionVO);
}
}

View File

@@ -0,0 +1,96 @@
package org.xyzh.system.mapper.acl;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.AclVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysAclDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统访问控制列表Mapper接口
* @filename TbSysAclMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysAclMapper extends BaseMapper<TbSysAclDTO> {
/**
* @description 插入系统访问控制列表
* @param aclDTO 系统访问控制列表DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertAcl(TbSysAclDTO aclDTO);
/**
* @description 更新系统访问控制列表
* @param aclDTO 系统访问控制列表DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateAcl(TbSysAclDTO aclDTO);
/**
* @description 删除系统访问控制列表
* @param aclDTO 系统访问控制列表DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteAcl(TbSysAclDTO aclDTO);
/**
* @description 根据访问控制列表ID查询系统访问控制列表
* @param aclId 访问控制列表ID
* @return AclVO 访问控制列表VO
* @author yslg
* @since 2025-11-07
*/
AclVO getAclById(String aclId);
/**
* @description 根据对象ID查询系统访问控制列表
* @param objectId 对象ID
* @return List<AclVO> 访问控制列表VO列表
* @author yslg
* @since 2025-11-07
*/
List<AclVO> getAclByObjectId(String objectId);
/**
* @description 根据条件查询系统访问控制列表
* @param filter 系统访问控制列表DTO
* @return List<AclVO> 访问控制列表VO列表
* @author yslg
* @since 2025-11-07
*/
List<AclVO> getAclByFilter(@Param("filter") TbSysAclDTO filter);
/**
* @description 根据条件查询系统访问控制列表分页列表
* @param filter 系统访问控制列表DTO
* @param pageParam 分页参数
* @return List<AclVO> 访问控制列表VO列表
* @author yslg
* @since 2025-11-07
*/
List<AclVO> getAclPageByFilter(@Param("filter") TbSysAclDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统访问控制列表数量
* @param filter 系统访问控制列表DTO
* @return int 系统访问控制列表数量
* @author yslg
* @since 2025-11-07
*/
int getAclCount(TbSysAclDTO filter);
}

View File

@@ -0,0 +1,87 @@
package org.xyzh.system.mapper.acl;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.AclVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysAclPolicyDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统访问控制策略Mapper接口
* @filename TbSysAclPolicyMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysAclPolicyMapper extends BaseMapper<TbSysAclPolicyDTO> {
/**
* @description 插入系统访问控制策略
* @param aclPolicyDTO 系统访问控制策略DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertAclPolicy(TbSysAclPolicyDTO aclPolicyDTO);
/**
* @description 更新系统访问控制策略
* @param aclPolicyDTO 系统访问控制策略DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateAclPolicy(TbSysAclPolicyDTO aclPolicyDTO);
/**
* @description 删除系统访问控制策略
* @param aclPolicyDTO 系统访问控制策略DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteAclPolicy(TbSysAclPolicyDTO aclPolicyDTO);
/**
* @description 根据策略ID查询系统访问控制策略
* @param policyId 策略ID
* @return AclVO 访问控制列表VO
* @author yslg
* @since 2025-11-07
*/
AclVO getAclPolicyById(String policyId);
/**
* @description 根据条件查询系统访问控制策略列表
* @param filter 系统访问控制策略DTO
* @return List<AclVO> 访问控制列表VO列表
* @author yslg
* @since 2025-11-07
*/
List<AclVO> getAclPolicyByFilter(@Param("filter") TbSysAclPolicyDTO filter);
/**
* @description 根据条件查询系统访问控制策略分页列表
* @param filter 系统访问控制策略DTO
* @param pageParam 分页参数
* @return List<AclVO> 访问控制列表VO列表
* @author yslg
* @since 2025-11-07
*/
List<AclVO> getAclPolicyPageByFilter(@Param("filter") TbSysAclPolicyDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统访问控制策略数量
* @param filter 系统访问控制策略DTO
* @return int 系统访问控制策略数量
* @author yslg
* @since 2025-11-07
*/
int getAclPolicyCount(TbSysAclPolicyDTO filter);
}

View File

@@ -0,0 +1,78 @@
package org.xyzh.system.mapper.config;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.SysConfigVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysConfigDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统配置Mapper接口
* @filename TbSysConfigMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysConfigMapper extends BaseMapper<TbSysConfigDTO> {
/**
* @description 插入系统配置
* @param configDTO 系统配置DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertConfig(TbSysConfigDTO configDTO);
/**
* @description 更新系统配置
* @param configDTO 系统配置DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateConfig(TbSysConfigDTO configDTO);
/**
* @description 删除系统配置
* @param configDTO 系统配置DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteConfig(TbSysConfigDTO configDTO);
/**
* @description 根据条件查询系统配置列表
* @param filter 系统配置DTO
* @return List<SysConfigVO> 系统配置VO列表
* @author yslg
* @since 2025-11-07
*/
List<SysConfigVO> getConfigByFilter(@Param("filter") TbSysConfigDTO filter);
/**
* @description 根据条件查询系统配置分页列表
* @param filter 系统配置DTO
* @param pageParam 分页参数
* @return List<SysConfigVO> 系统配置VO列表
* @author yslg
* @since 2025-11-07
*/
List<SysConfigVO> getConfigPageByFilter(@Param("filter") TbSysConfigDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统配置数量
* @param filter 系统配置DTO
* @return int 系统配置数量
* @author yslg
* @since 2025-11-07
*/
int getConfigCount(TbSysConfigDTO filter);
}

View File

@@ -0,0 +1,78 @@
package org.xyzh.system.mapper.dept;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysDeptDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统部门Mapper接口
* @filename TbSysDeptMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysDeptMapper extends BaseMapper<TbSysDeptDTO> {
/**
* @description 插入系统部门
* @param deptDTO 系统部门DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertDept(TbSysDeptDTO deptDTO);
/**
* @description 更新系统部门
* @param deptDTO 系统部门DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateDept(TbSysDeptDTO deptDTO);
/**
* @description 删除系统部门
* @param deptDTO 系统部门DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteDept(TbSysDeptDTO deptDTO);
/**
* @description 根据条件查询系统部门列表
* @param filter 系统部门DTO
* @return List<TbSysDeptDTO> 系统部门列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getDeptByFilter(@Param("filter") TbSysDeptDTO filter);
/**
* @description 根据条件查询系统部门分页列表
* @param filter 系统部门DTO
* @param pageParam 分页参数
* @return List<TbSysDeptDTO> 系统部门列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getDeptPageByFilter(@Param("filter") TbSysDeptDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统部门数量
* @param filter 系统部门DTO
* @return int 系统部门数量
* @author yslg
* @since 2025-11-07
*/
int getDeptCount(TbSysDeptDTO filter);
}

View File

@@ -0,0 +1,88 @@
package org.xyzh.system.mapper.dept;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysDeptRoleDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统部门角色关系Mapper接口
* @filename TbSysDeptRoleMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysDeptRoleMapper extends BaseMapper<TbSysDeptRoleDTO> {
/**
* @description 插入系统部门角色关系
* @param deptRoleDTO 系统部门角色关系DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertDeptRole(TbSysDeptRoleDTO deptRoleDTO);
/**
* @description 更新系统部门角色关系
* @param deptRoleDTO 系统部门角色关系DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateDeptRole(TbSysDeptRoleDTO deptRoleDTO);
/**
* @description 删除系统部门角色关系
* @param deptRoleDTO 系统部门角色关系DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteDeptRole(TbSysDeptRoleDTO deptRoleDTO);
/**
* @description 根据部门ID查询系统部门角色关系
* @param deptId 部门ID
* @param roleId 角色ID
* @return UserDeptRoleVO 用户部门角色VO
* @author yslg
* @since 2025-11-07
*/
PermissionVO getDeptRoleByDeptId(String deptId, String roleId);
/**
* @description 根据条件查询系统部门角色关系列表
* @param filter 系统部门角色关系DTO
* @return List<UserDeptRoleVO> 用户部门角色VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getDeptRoleByFilter(@Param("filter") TbSysDeptRoleDTO filter);
/**
* @description 根据条件查询系统部门角色关系分页列表
* @param filter 系统部门角色关系DTO
* @param pageParam 分页参数
* @return List<UserDeptRoleVO> 用户部门角色VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getDeptRolePageByFilter(@Param("filter") TbSysDeptRoleDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统部门角色关系数量
* @param filter 系统部门角色关系DTO
* @return int 系统部门角色关系数量
* @author yslg
* @since 2025-11-07
*/
int getDeptRoleCount(TbSysDeptRoleDTO filter);
}

View File

@@ -0,0 +1,87 @@
package org.xyzh.system.mapper.module;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysModuleDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统模块Mapper接口
* @filename TbSysModuleMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysModuleMapper extends BaseMapper<TbSysModuleDTO> {
/**
* @description 插入系统模块
* @param moduleDTO 系统模块DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertModule(TbSysModuleDTO moduleDTO);
/**
* @description 更新系统模块
* @param moduleDTO 系统模块DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateModule(TbSysModuleDTO moduleDTO);
/**
* @description 删除系统模块
* @param moduleDTO 系统模块DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteModule(TbSysModuleDTO moduleDTO);
/**
* @description 根据模块ID查询系统模块
* @param moduleId 模块ID
* @return SysModuleVO 系统模块VO
* @author yslg
* @since 2025-11-07
*/
PermissionVO getModuleById(String moduleId);
/**
* @description 根据条件查询系统模块列表
* @param filter 系统模块DTO
* @return List<SysModuleVO> 系统模块VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getModuleByFilter(@Param("filter") TbSysModuleDTO filter);
/**
* @description 根据条件查询系统模块分页列表
* @param filter 系统模块DTO
* @param pageParam 分页参数
* @return List<SysModuleVO> 系统模块VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getModulePageByFilter(@Param("filter") TbSysModuleDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统模块数量
* @param filter 系统模块DTO
* @return int 系统模块数量
* @author yslg
* @since 2025-11-07
*/
int getModuleCount(TbSysModuleDTO filter);
}

View File

@@ -0,0 +1,87 @@
package org.xyzh.system.mapper.permission;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysPermissionDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统权限Mapper接口
* @filename TbSysPermissionMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysPermissionMapper extends BaseMapper<TbSysPermissionDTO> {
/**
* @description 插入系统权限
* @param permissionDTO 系统权限DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertPermission(TbSysPermissionDTO permissionDTO);
/**
* @description 更新系统权限
* @param permissionDTO 系统权限DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updatePermission(TbSysPermissionDTO permissionDTO);
/**
* @description 删除系统权限
* @param permissionDTO 系统权限DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deletePermission(TbSysPermissionDTO permissionDTO);
/**
* @description 根据权限ID查询系统权限
* @param permissionId 权限ID
* @return PermissionVO 权限VO
* @author yslg
* @since 2025-11-07
*/
PermissionVO getPermissionById(String permissionId);
/**
* @description 根据条件查询系统权限列表
* @param filter 系统权限DTO
* @return List<PermissionVO> 权限VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getPermissionByFilter(@Param("filter") TbSysPermissionDTO filter);
/**
* @description 根据条件查询系统权限分页列表
* @param filter 系统权限DTO
* @param pageParam 分页参数
* @return List<PermissionVO> 权限VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getPermissionPageByFilter(@Param("filter") TbSysPermissionDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统权限数量
* @param filter 系统权限DTO
* @return int 系统权限数量
* @author yslg
* @since 2025-11-07
*/
int getPermissionCount(TbSysPermissionDTO filter);
}

View File

@@ -0,0 +1,88 @@
package org.xyzh.system.mapper.permission;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysViewPermissionDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统视图权限关系Mapper接口
* @filename TbSysViewPermissionMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysViewPermissionMapper extends BaseMapper<TbSysViewPermissionDTO> {
/**
* @description 插入系统视图权限关系
* @param viewPermissionDTO 系统视图权限关系DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertViewPermission(TbSysViewPermissionDTO viewPermissionDTO);
/**
* @description 更新系统视图权限关系
* @param viewPermissionDTO 系统视图权限关系DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateViewPermission(TbSysViewPermissionDTO viewPermissionDTO);
/**
* @description 删除系统视图权限关系
* @param viewPermissionDTO 系统视图权限关系DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteViewPermission(TbSysViewPermissionDTO viewPermissionDTO);
/**
* @description 根据视图ID查询系统视图权限关系
* @param viewId 视图ID
* @param permissionId 权限ID
* @return PermissionVO 权限VO
* @author yslg
* @since 2025-11-07
*/
PermissionVO getViewPermissionByViewId(String viewId, String permissionId);
/**
* @description 根据条件查询系统视图权限关系列表
* @param filter 系统视图权限关系DTO
* @return List<PermissionVO> 权限VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getViewPermissionByFilter(@Param("filter") TbSysViewPermissionDTO filter);
/**
* @description 根据条件查询系统视图权限关系分页列表
* @param filter 系统视图权限关系DTO
* @param pageParam 分页参数
* @return List<PermissionVO> 权限VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getViewPermissionPageByFilter(@Param("filter") TbSysViewPermissionDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统视图权限关系数量
* @param filter 系统视图权限关系DTO
* @return int 系统视图权限关系数量
* @author yslg
* @since 2025-11-07
*/
int getViewPermissionCount(TbSysViewPermissionDTO filter);
}

View File

@@ -0,0 +1,78 @@
package org.xyzh.system.mapper.role;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysRoleDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统角色Mapper接口
* @filename TbSysRoleMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysRoleMapper extends BaseMapper<TbSysRoleDTO> {
/**
* @description 插入系统角色
* @param roleDTO 系统角色DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertRole(TbSysRoleDTO roleDTO);
/**
* @description 更新系统角色
* @param roleDTO 系统角色DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateRole(TbSysRoleDTO roleDTO);
/**
* @description 删除系统角色
* @param roleDTO 系统角色DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteRole(TbSysRoleDTO roleDTO);
/**
* @description 根据条件查询系统角色列表
* @param filter 系统角色DTO
* @return List<SysRoleVO> 系统角色VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getRoleByFilter(@Param("filter") TbSysRoleDTO filter);
/**
* @description 根据条件查询系统角色分页列表
* @param filter 系统角色DTO
* @param pageParam 分页参数
* @return List<SysRoleVO> 系统角色VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getRolePageByFilter(@Param("filter") TbSysRoleDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统角色数量
* @param filter 系统角色DTO
* @return int 系统角色数量
* @author yslg
* @since 2025-11-07
*/
int getRoleCount(TbSysRoleDTO filter);
}

View File

@@ -0,0 +1,95 @@
package org.xyzh.system.mapper.role;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysRolePermissionDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统角色权限关系Mapper接口
* @filename TbSysRolePermissionMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysRolePermissionMapper extends BaseMapper<TbSysRolePermissionDTO> {
/**
* @description 插入系统角色权限关系
* @param rolePermissionDTO 系统角色权限关系DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertRolePermission(TbSysRolePermissionDTO rolePermissionDTO);
/**
* @description 更新系统角色权限关系
* @param rolePermissionDTO 系统角色权限关系DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateRolePermission(TbSysRolePermissionDTO rolePermissionDTO);
/**
* @description 删除系统角色权限关系
* @param rolePermissionDTO 系统角色权限关系DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteRolePermission(TbSysRolePermissionDTO rolePermissionDTO);
/**
* @description 根据角色ID查询系统角色权限关系
* @param roleId 角色ID
* @return List<PermissionVO> 权限VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getRolePermissionByRoleId(String roleId);
/**
* @description 根据条件查询系统角色权限关系列表
* @param filter 系统角色权限关系DTO
* @return List<PermissionVO> 权限VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getRolePermissionByFilter(@Param("filter") TbSysRolePermissionDTO filter);
/**
* @description 根据条件查询系统角色权限关系分页列表
* @param filter 系统角色权限关系DTO
* @param pageParam 分页参数
* @return List<PermissionVO> 权限VO列表
* @author yslg
* @since 2025-11-07
*/
List<PermissionVO> getRolePermissionPageByFilter(@Param("filter") TbSysRolePermissionDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统角色权限关系数量
* @param filter 系统角色权限关系DTO
* @return int 系统角色权限关系数量
* @author yslg
* @since 2025-11-07
*/
int getRolePermissionCount(TbSysRolePermissionDTO filter);
/**
* @description 根据用户ID一次性查询该用户所有权限连表 user_role -> role_permission -> permission
* @param userId 用户ID
* @return List<PermissionVO> 权限VO列表
*/
List<PermissionVO> getPermissionsByUserId(@Param("userId") String userId);
}

View File

@@ -0,0 +1,86 @@
package org.xyzh.system.mapper.user;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysUserInfoDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统用户信息Mapper接口
* @filename TbSysUserInfoMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysUserInfoMapper extends BaseMapper<TbSysUserInfoDTO> {
/**
* @description 插入系统用户信息
* @param userInfoDTO 系统用户信息DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertUserInfo(TbSysUserInfoDTO userInfoDTO);
/**
* @description 更新系统用户信息
* @param userInfoDTO 系统用户信息DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateUserInfo(TbSysUserInfoDTO userInfoDTO);
/**
* @description 删除系统用户信息
* @param userInfoDTO 系统用户信息DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteUserInfo(TbSysUserInfoDTO userInfoDTO);
/**
* @description 根据用户ID查询系统用户信息
* @param userId 用户ID
* @return TbSysUserInfoDTO 系统用户信息DTO
* @author yslg
* @since 2025-11-07
*/
TbSysUserInfoDTO getUserInfoById(String userId);
/**
* @description 根据条件查询系统用户信息列表
* @param filter 系统用户信息DTO
* @return List<TbSysUserInfoDTO> 系统用户信息列表
* @author yslg
* @since 2025-11-07
*/
List<TbSysUserInfoDTO> getUserInfoByFilter(@Param("filter") TbSysUserInfoDTO filter);
/**
* @description 根据条件查询系统用户信息分页列表
* @param filter 系统用户信息DTO
* @param pageParam 分页参数
* @return List<TbSysUserInfoDTO> 系统用户信息列表
* @author yslg
* @since 2025-11-07
*/
List<TbSysUserInfoDTO> getUserInfoPageByFilter(@Param("filter") TbSysUserInfoDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统用户信息数量
* @param filter 系统用户信息DTO
* @return int 系统用户信息数量
* @author yslg
* @since 2025-11-07
*/
int getUserInfoCount(TbSysUserInfoDTO filter);
}

View File

@@ -0,0 +1,87 @@
package org.xyzh.system.mapper.user;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.SysUserVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysUserDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统用户Mapper接口
* @filename TbSysUserMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysUserMapper extends BaseMapper<TbSysUserDTO> {
/**
* @description 插入系统用户
* @param userDTO 系统用户DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertUser(TbSysUserDTO userDTO);
/**
* @description 更新系统用户
* @param userDTO 系统用户DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateUser(TbSysUserDTO userDTO);
/**
* @description 删除系统用户
* @param userDTO 系统用户DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteUser(TbSysUserDTO userDTO);
/**
* @description 根据用户ID查询系统用户
* @param userId 用户ID
* @return SysUserVO 系统用户VO
* @author yslg
* @since 2025-11-07
*/
SysUserVO getUserById(String userId);
/**
* @description 根据条件查询系统用户列表
* @param filter 系统用户DTO
* @return List<SysUserVO> 系统用户VO列表
* @author yslg
* @since 2025-11-07
*/
List<SysUserVO> getUserByFilter(@Param("filter") TbSysUserDTO filter);
/**
* @description 根据条件查询系统用户分页列表
* @param filter 系统用户DTO
* @param pageParam 分页参数
* @return List<SysUserVO> 系统用户VO列表
* @author yslg
* @since 2025-11-07
*/
List<SysUserVO> getUserPageByFilter(@Param("filter") TbSysUserDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统用户数量
* @param filter 系统用户DTO
* @return int 系统用户数量
* @author yslg
* @since 2025-11-07
*/
int getUserCount(TbSysUserDTO filter);
}

View File

@@ -0,0 +1,87 @@
package org.xyzh.system.mapper.user;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.api.system.vo.UserDeptRoleVO;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysUserRoleDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统用户角色关系Mapper接口
* @filename TbSysUserRoleMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysUserRoleMapper extends BaseMapper<TbSysUserRoleDTO> {
/**
* @description 插入系统用户角色关系
* @param userRoleDTO 系统用户角色关系DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertUserRole(TbSysUserRoleDTO userRoleDTO);
/**
* @description 更新系统用户角色关系
* @param userRoleDTO 系统用户角色关系DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateUserRole(TbSysUserRoleDTO userRoleDTO);
/**
* @description 删除系统用户角色关系
* @param userRoleDTO 系统用户角色关系DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteUserRole(TbSysUserRoleDTO userRoleDTO);
/**
* @description 根据用户ID查询系统用户角色关系
* @param userId 用户ID
* @return List<UserDeptRoleVO> 用户部门角色VO列表
* @author yslg
* @since 2025-11-07
*/
List<UserDeptRoleVO> getUserRoleByUserId(String userId);
/**
* @description 根据条件查询系统用户角色关系列表
* @param filter 系统用户角色关系DTO
* @return List<UserDeptRoleVO> 用户部门角色VO列表
* @author yslg
* @since 2025-11-07
*/
List<UserDeptRoleVO> getUserRoleByFilter(@Param("filter") TbSysUserRoleDTO filter);
/**
* @description 根据条件查询系统用户角色关系分页列表
* @param filter 系统用户角色关系DTO
* @param pageParam 分页参数
* @return List<UserDeptRoleVO> 用户部门角色VO列表
* @author yslg
* @since 2025-11-07
*/
List<UserDeptRoleVO> getUserRolePageByFilter(@Param("filter") TbSysUserRoleDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统用户角色关系数量
* @param filter 系统用户角色关系DTO
* @return int 系统用户角色关系数量
* @author yslg
* @since 2025-11-07
*/
int getUserRoleCount(TbSysUserRoleDTO filter);
}

View File

@@ -0,0 +1,86 @@
package org.xyzh.system.mapper.view;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.dto.sys.TbSysViewDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @description 系统视图Mapper接口
* @filename TbSysViewMapper.java
* @author yslg
* @copyright yslg
* @since 2025-11-07
*/
@Mapper
public interface TbSysViewMapper extends BaseMapper<TbSysViewDTO> {
/**
* @description 插入系统视图
* @param viewDTO 系统视图DTO
* @return int 插入结果
* @author yslg
* @since 2025-11-07
*/
int insertView(TbSysViewDTO viewDTO);
/**
* @description 更新系统视图
* @param viewDTO 系统视图DTO
* @return int 更新结果
* @author yslg
* @since 2025-11-07
*/
int updateView(TbSysViewDTO viewDTO);
/**
* @description 删除系统视图
* @param viewDTO 系统视图DTO
* @return int 删除结果
* @author yslg
* @since 2025-11-07
*/
int deleteView(TbSysViewDTO viewDTO);
/**
* @description 根据视图ID查询系统视图
* @param viewId 视图ID
* @return TbSysViewDTO 系统视图DTO
* @author yslg
* @since 2025-11-07
*/
TbSysViewDTO getViewById(String viewId);
/**
* @description 根据条件查询系统视图列表
* @param filter 系统视图DTO
* @return List<TbSysViewDTO> 系统视图列表
* @author yslg
* @since 2025-11-07
*/
List<TbSysViewDTO> getViewByFilter(@Param("filter") TbSysViewDTO filter);
/**
* @description 根据条件查询系统视图分页列表
* @param filter 系统视图DTO
* @param pageParam 分页参数
* @return List<TbSysViewDTO> 系统视图列表
* @author yslg
* @since 2025-11-07
*/
List<TbSysViewDTO> getViewPageByFilter(@Param("filter") TbSysViewDTO filter, @Param("pageParam") PageParam pageParam);
/**
* @description 根据条件查询系统视图数量
* @param filter 系统视图DTO
* @return int 系统视图数量
* @author yslg
* @since 2025-11-07
*/
int getViewCount(TbSysViewDTO filter);
}

View File

@@ -0,0 +1,429 @@
package org.xyzh.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import java.util.Date;
import java.util.Collections;
import java.util.List;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xyzh.api.system.service.DeptRoleService;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.api.system.vo.UserDeptRoleVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageDomain;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysDeptDTO;
import org.xyzh.common.dto.sys.TbSysDeptRoleDTO;
import org.xyzh.common.dto.sys.TbSysRoleDTO;
import org.xyzh.common.dto.sys.TbSysRolePermissionDTO;
import org.xyzh.common.dto.sys.TbSysUserRoleDTO;
import org.xyzh.common.utils.IDUtils;
import org.xyzh.common.utils.StringUtils;
import org.xyzh.system.mapper.dept.TbSysDeptMapper;
import org.xyzh.system.mapper.dept.TbSysDeptRoleMapper;
import org.xyzh.system.mapper.role.TbSysRoleMapper;
import org.xyzh.system.mapper.role.TbSysRolePermissionMapper;
import org.xyzh.system.mapper.user.TbSysUserRoleMapper;
/**
* @description 部门角色服务实现类
* @filename DeptRoleServiceImpl.java
*/
@DubboService(
version = "1.0.0",
group = "system",
timeout = 3000,
retries = 0
)
public class DeptRoleServiceImpl implements DeptRoleService {
private static final Logger logger = LoggerFactory.getLogger(DeptRoleServiceImpl.class);
private static final String MSG_DEPT_PARAM_REQUIRED = "部门参数不能为空";
private static final String MSG_ROLE_PARAM_REQUIRED = "角色参数不能为空";
private static final String MSG_DEPT_ID_REQUIRED = "部门ID不能为空";
private static final String MSG_ROLE_ID_REQUIRED = "角色ID不能为空";
private static final String MSG_DEPT_ROLE_ID_REQUIRED = "部门ID和角色ID不能为空";
private static final String MSG_QUERY_PARAM_REQUIRED = "查询条件不能为空";
private static final String MSG_PAGE_PARAM_REQUIRED = "分页参数不能为空";
@Resource
private TbSysDeptMapper deptMapper;
@Resource
private TbSysRoleMapper roleMapper;
@Resource
private TbSysDeptRoleMapper deptRoleMapper;
@Resource
private TbSysUserRoleMapper userRoleMapper;
@Resource
private TbSysRolePermissionMapper rolePermissionMapper;
@Override
public ResultDomain<TbSysDeptDTO> insertDept(TbSysDeptDTO deptDTO) {
if (deptDTO == null) {
return ResultDomain.failure(MSG_DEPT_PARAM_REQUIRED);
}
if (StringUtils.isBlank(deptDTO.getDeptId())) {
deptDTO.setDeptId(IDUtils.generateID());
}
if (deptDTO.getCreateTime() == null) {
deptDTO.setCreateTime(new Date());
}
if (deptDTO.getDeleted() == null) {
deptDTO.setDeleted(false);
}
int rows = deptMapper.insertDept(deptDTO);
if (rows > 0) {
logger.info("新增部门成功, deptId={}", deptDTO.getDeptId());
return ResultDomain.success("新增部门成功", deptDTO);
}
logger.warn("新增部门失败, deptId={}", deptDTO.getDeptId());
return ResultDomain.failure("新增部门失败");
}
@Override
public ResultDomain<TbSysDeptDTO> updateDept(TbSysDeptDTO deptDTO) {
if (deptDTO == null || StringUtils.isBlank(deptDTO.getDeptId())) {
return ResultDomain.failure(MSG_DEPT_ID_REQUIRED);
}
deptDTO.setUpdateTime(new Date());
int rows = deptMapper.updateDept(deptDTO);
if (rows > 0) {
logger.info("更新部门成功, deptId={}", deptDTO.getDeptId());
return ResultDomain.success("更新部门成功", deptDTO);
}
logger.warn("更新部门失败, deptId={}", deptDTO.getDeptId());
return ResultDomain.failure("更新部门失败");
}
@Override
public ResultDomain<Boolean> deleteDept(TbSysDeptDTO deptDTO) {
if (deptDTO == null || StringUtils.isBlank(deptDTO.getDeptId())) {
return ResultDomain.failure(MSG_DEPT_ID_REQUIRED);
}
int rows = deptMapper.deleteDept(deptDTO);
if (rows > 0) {
logger.info("删除部门成功, deptId={}", deptDTO.getDeptId());
return ResultDomain.success("删除部门成功", Boolean.TRUE);
}
logger.warn("删除部门失败, deptId={}", deptDTO.getDeptId());
return ResultDomain.failure("删除部门失败");
}
@Override
public ResultDomain<UserDeptRoleVO> getDept(UserDeptRoleVO filter) {
TbSysDeptDTO dto = UserDeptRoleVO.toDeptDTO(filter);
if (dto == null) {
return ResultDomain.failure(MSG_QUERY_PARAM_REQUIRED);
}
List<PermissionVO> permissionList = deptMapper.getDeptByFilter(dto);
if (permissionList == null || permissionList.isEmpty()) {
return ResultDomain.failure("未找到部门");
}
UserDeptRoleVO dept = UserDeptRoleVO.fromPermission(permissionList.get(0));
return ResultDomain.success("获取部门成功", dept);
}
@Override
public ResultDomain<UserDeptRoleVO> getDeptList(UserDeptRoleVO filter) {
TbSysDeptDTO dto = UserDeptRoleVO.toDeptDTO(filter);
List<PermissionVO> permissionList = deptMapper.getDeptByFilter(dto);
List<UserDeptRoleVO> result = (permissionList == null || permissionList.isEmpty()) ?
java.util.Collections.emptyList() :
permissionList.stream().map(UserDeptRoleVO::fromPermission).filter(java.util.Objects::nonNull).toList();
return ResultDomain.success("获取部门列表成功", result);
}
@Override
public ResultDomain<UserDeptRoleVO> getDeptPage(PageRequest<UserDeptRoleVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysDeptDTO filter = UserDeptRoleVO.toDeptDTO(pageRequest.getFilter());
int total = deptMapper.getDeptCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<PermissionVO> permissionList = deptMapper.getDeptPageByFilter(filter, pageParam);
List<UserDeptRoleVO> data = (permissionList == null || permissionList.isEmpty()) ?
java.util.Collections.emptyList() :
permissionList.stream().map(UserDeptRoleVO::fromPermission).filter(java.util.Objects::nonNull).toList();
PageDomain<UserDeptRoleVO> pageDomain = new PageDomain<>(pageParam, data);
return ResultDomain.success("分页查询部门成功", pageDomain);
}
@Override
public ResultDomain<UserDeptRoleVO> getDeptTree(UserDeptRoleVO filter) {
return getDeptList(filter);
}
@Override
public ResultDomain<TbSysRoleDTO> insertRole(TbSysRoleDTO roleDTO) {
if (roleDTO == null) {
return ResultDomain.failure(MSG_ROLE_PARAM_REQUIRED);
}
if (StringUtils.isBlank(roleDTO.getRoleId())) {
roleDTO.setRoleId(IDUtils.generateID());
}
if (roleDTO.getCreateTime() == null) {
roleDTO.setCreateTime(new Date());
}
if (roleDTO.getDeleted() == null) {
roleDTO.setDeleted(false);
}
int rows = roleMapper.insertRole(roleDTO);
if (rows > 0) {
logger.info("新增角色成功, roleId={}", roleDTO.getRoleId());
return ResultDomain.success("新增角色成功", roleDTO);
}
logger.warn("新增角色失败, roleId={}", roleDTO.getRoleId());
return ResultDomain.failure("新增角色失败");
}
@Override
public ResultDomain<TbSysRoleDTO> updateRole(TbSysRoleDTO roleDTO) {
if (roleDTO == null || StringUtils.isBlank(roleDTO.getRoleId())) {
return ResultDomain.failure(MSG_ROLE_ID_REQUIRED);
}
roleDTO.setUpdateTime(new Date());
int rows = roleMapper.updateRole(roleDTO);
if (rows > 0) {
logger.info("更新角色成功, roleId={}", roleDTO.getRoleId());
return ResultDomain.success("更新角色成功", roleDTO);
}
logger.warn("更新角色失败, roleId={}", roleDTO.getRoleId());
return ResultDomain.failure("更新角色失败");
}
@Override
public ResultDomain<Boolean> deleteRole(TbSysRoleDTO roleDTO) {
if (roleDTO == null || StringUtils.isBlank(roleDTO.getRoleId())) {
return ResultDomain.failure(MSG_ROLE_ID_REQUIRED);
}
int rows = roleMapper.deleteRole(roleDTO);
if (rows > 0) {
logger.info("删除角色成功, roleId={}", roleDTO.getRoleId());
return ResultDomain.success("删除角色成功", Boolean.TRUE);
}
logger.warn("删除角色失败, roleId={}", roleDTO.getRoleId());
return ResultDomain.failure("删除角色失败");
}
@Override
public ResultDomain<UserDeptRoleVO> getRole(UserDeptRoleVO filter) {
TbSysRoleDTO dto = UserDeptRoleVO.toRoleDTO(filter);
if (dto == null) {
return ResultDomain.failure(MSG_QUERY_PARAM_REQUIRED);
}
List<PermissionVO> permissionList = roleMapper.getRoleByFilter(dto);
if (permissionList == null || permissionList.isEmpty()) {
return ResultDomain.failure("未找到角色");
}
UserDeptRoleVO role = UserDeptRoleVO.fromPermission(permissionList.get(0));
return ResultDomain.success("获取角色成功", role);
}
@Override
public ResultDomain<UserDeptRoleVO> getRoleList(UserDeptRoleVO filter) {
TbSysRoleDTO dto = UserDeptRoleVO.toRoleDTO(filter);
List<PermissionVO> permissionList = roleMapper.getRoleByFilter(dto);
List<UserDeptRoleVO> result = (permissionList == null || permissionList.isEmpty()) ?
java.util.Collections.emptyList() :
permissionList.stream().map(UserDeptRoleVO::fromPermission).filter(java.util.Objects::nonNull).toList();
return ResultDomain.success("获取角色列表成功", result);
}
@Override
public ResultDomain<UserDeptRoleVO> getRolePage(PageRequest<UserDeptRoleVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysRoleDTO filter = UserDeptRoleVO.toRoleDTO(pageRequest.getFilter());
int total = roleMapper.getRoleCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<PermissionVO> permissionList = roleMapper.getRolePageByFilter(filter, pageParam);
List<UserDeptRoleVO> data = (permissionList == null || permissionList.isEmpty()) ?
java.util.Collections.emptyList() :
permissionList.stream().map(UserDeptRoleVO::fromPermission).filter(java.util.Objects::nonNull).toList();
PageDomain<UserDeptRoleVO> pageDomain = new PageDomain<>(pageParam, data);
return ResultDomain.success("分页查询角色成功", pageDomain);
}
@Override
public ResultDomain<UserDeptRoleVO> getRoleListByDeptId(String deptId) {
if (StringUtils.isBlank(deptId)) {
return ResultDomain.failure(MSG_DEPT_ID_REQUIRED);
}
TbSysRoleDTO filter = new TbSysRoleDTO();
filter.setOwnerDeptId(deptId);
List<PermissionVO> permissionList = roleMapper.getRoleByFilter(filter);
List<UserDeptRoleVO> result = (permissionList == null || permissionList.isEmpty()) ?
java.util.Collections.emptyList() :
permissionList.stream().map(UserDeptRoleVO::fromPermission).filter(java.util.Objects::nonNull).toList();
return ResultDomain.success("根据部门获取角色成功", result);
}
@Override
public ResultDomain<UserDeptRoleVO> getRoleListByUserId(String userId) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure("用户ID不能为空");
}
TbSysUserRoleDTO filter = new TbSysUserRoleDTO();
filter.setUserId(userId);
List<UserDeptRoleVO> roleList = userRoleMapper.getUserRoleByFilter(filter);
if (roleList == null) {
roleList = Collections.emptyList();
}
return ResultDomain.success("根据用户获取角色成功", roleList);
}
@Override
public ResultDomain<TbSysDeptRoleDTO> insertDeptRole(TbSysDeptRoleDTO deptRoleDTO) {
if (deptRoleDTO == null || StringUtils.isBlank(deptRoleDTO.getDeptId()) || StringUtils.isBlank(deptRoleDTO.getRoleId())) {
return ResultDomain.failure(MSG_DEPT_ROLE_ID_REQUIRED);
}
if (deptRoleDTO.getCreateTime() == null) {
deptRoleDTO.setCreateTime(new Date());
}
if (deptRoleDTO.getDeleted() == null) {
deptRoleDTO.setDeleted(false);
}
int rows = deptRoleMapper.insertDeptRole(deptRoleDTO);
if (rows > 0) {
logger.info("新增部门角色关联成功, deptId={}, roleId={}", deptRoleDTO.getDeptId(), deptRoleDTO.getRoleId());
return ResultDomain.success("新增部门角色关联成功", deptRoleDTO);
}
logger.warn("新增部门角色关联失败, deptId={}, roleId={}", deptRoleDTO.getDeptId(), deptRoleDTO.getRoleId());
return ResultDomain.failure("新增部门角色关联失败");
}
@Override
public ResultDomain<TbSysDeptRoleDTO> updateDeptRole(TbSysDeptRoleDTO deptRoleDTO) {
if (deptRoleDTO == null || StringUtils.isBlank(deptRoleDTO.getDeptId()) || StringUtils.isBlank(deptRoleDTO.getRoleId())) {
return ResultDomain.failure(MSG_DEPT_ROLE_ID_REQUIRED);
}
deptRoleDTO.setUpdateTime(new Date());
int rows = deptRoleMapper.updateDeptRole(deptRoleDTO);
if (rows > 0) {
logger.info("更新部门角色关联成功, deptId={}, roleId={}", deptRoleDTO.getDeptId(), deptRoleDTO.getRoleId());
return ResultDomain.success("更新部门角色关联成功", deptRoleDTO);
}
logger.warn("更新部门角色关联失败, deptId={}, roleId={}", deptRoleDTO.getDeptId(), deptRoleDTO.getRoleId());
return ResultDomain.failure("更新部门角色关联失败");
}
@Override
public ResultDomain<Boolean> deleteDeptRole(TbSysDeptRoleDTO deptRoleDTO) {
if (deptRoleDTO == null || StringUtils.isBlank(deptRoleDTO.getDeptId()) || StringUtils.isBlank(deptRoleDTO.getRoleId())) {
return ResultDomain.failure(MSG_DEPT_ROLE_ID_REQUIRED);
}
int rows = deptRoleMapper.deleteDeptRole(deptRoleDTO);
if (rows > 0) {
logger.info("删除部门角色关联成功, deptId={}, roleId={}", deptRoleDTO.getDeptId(), deptRoleDTO.getRoleId());
return ResultDomain.success("删除部门角色关联成功", Boolean.TRUE);
}
logger.warn("删除部门角色关联失败, deptId={}, roleId={}", deptRoleDTO.getDeptId(), deptRoleDTO.getRoleId());
return ResultDomain.failure("删除部门角色关联失败");
}
@Override
public ResultDomain<UserDeptRoleVO> getDeptRole(UserDeptRoleVO filter) {
TbSysDeptRoleDTO dto = UserDeptRoleVO.toDeptRoleDTO(filter);
if (dto == null) {
return ResultDomain.failure(MSG_QUERY_PARAM_REQUIRED);
}
List<PermissionVO> permissionList = deptRoleMapper.getDeptRoleByFilter(dto);
if (permissionList == null || permissionList.isEmpty()) {
return ResultDomain.failure("未找到部门角色关联");
}
UserDeptRoleVO result = UserDeptRoleVO.fromPermission(permissionList.get(0));
return ResultDomain.success("获取部门角色关联成功", result);
}
@Override
public ResultDomain<UserDeptRoleVO> getDeptRoleList(UserDeptRoleVO filter) {
TbSysDeptRoleDTO dto = UserDeptRoleVO.toDeptRoleDTO(filter);
List<PermissionVO> permissionList = deptRoleMapper.getDeptRoleByFilter(dto);
List<UserDeptRoleVO> result = (permissionList == null || permissionList.isEmpty()) ?
java.util.Collections.emptyList() :
permissionList.stream().map(UserDeptRoleVO::fromPermission).filter(java.util.Objects::nonNull).toList();
return ResultDomain.success("获取部门角色关联列表成功", result);
}
@Override
public ResultDomain<UserDeptRoleVO> getDeptRolePage(PageRequest<UserDeptRoleVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysDeptRoleDTO filter = UserDeptRoleVO.toDeptRoleDTO(pageRequest.getFilter());
int total = deptRoleMapper.getDeptRoleCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<PermissionVO> permissionList = deptRoleMapper.getDeptRolePageByFilter(filter, pageParam);
List<UserDeptRoleVO> data = (permissionList == null || permissionList.isEmpty()) ?
java.util.Collections.emptyList() :
permissionList.stream().map(UserDeptRoleVO::fromPermission).filter(java.util.Objects::nonNull).toList();
PageDomain<UserDeptRoleVO> pageDomain = new PageDomain<>(pageParam, data);
return ResultDomain.success("分页查询部门角色关联成功", pageDomain);
}
@Override
public ResultDomain<PermissionVO> setRolePermission(PermissionVO permissionVO) {
if (permissionVO == null || StringUtils.isBlank(permissionVO.getRoleId())) {
return ResultDomain.failure(MSG_ROLE_ID_REQUIRED);
}
rolePermissionMapper.delete(new QueryWrapper<TbSysRolePermissionDTO>()
.eq("role_id", permissionVO.getRoleId()));
List<String> permissionIds = permissionVO.getPermissionIdList();
if (permissionIds != null && !permissionIds.isEmpty()) {
Date now = new Date();
for (String permissionId : permissionIds) {
if (StringUtils.isBlank(permissionId)) {
continue;
}
TbSysRolePermissionDTO dto = new TbSysRolePermissionDTO();
dto.setRoleId(permissionVO.getRoleId());
dto.setPermissionId(permissionId);
dto.setCreateTime(now);
dto.setDeleted(false);
rolePermissionMapper.insertRolePermission(dto);
}
}
logger.info("角色权限设置成功, roleId={}, count={}",
permissionVO.getRoleId(),
permissionIds == null ? 0 : permissionIds.size());
return ResultDomain.success("设置角色权限成功", permissionVO);
}
@Override
public ResultDomain<PermissionVO> getRolePermissionList(PermissionVO permissionVO) {
TbSysRolePermissionDTO dto = new TbSysRolePermissionDTO();
if (permissionVO != null) {
dto.setRoleId(permissionVO.getRoleId());
if (permissionVO.getPermissionIdList() != null && !permissionVO.getPermissionIdList().isEmpty()) {
dto.setPermissionId(permissionVO.getPermissionIdList().get(0));
} else {
dto.setPermissionId(permissionVO.getPermissionId());
}
dto.setDeptPath(permissionVO.getDeptPath());
dto.setDeleted(permissionVO.getDeleted());
}
List<PermissionVO> list = rolePermissionMapper.getRolePermissionByFilter(dto);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取角色权限列表成功", list);
}
}

View File

@@ -0,0 +1,264 @@
package org.xyzh.system.service.impl;
import org.apache.dubbo.config.annotation.DubboService;
import org.xyzh.api.system.service.ModulePermissionService;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysModuleDTO;
import org.xyzh.common.dto.sys.TbSysPermissionDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.annotation.Resource;
import java.util.Date;
import java.util.Collections;
import java.util.List;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.core.page.PageDomain;
import org.xyzh.common.utils.IDUtils;
import org.xyzh.common.utils.StringUtils;
import org.xyzh.system.mapper.module.TbSysModuleMapper;
import org.xyzh.system.mapper.permission.TbSysPermissionMapper;
import org.xyzh.system.mapper.role.TbSysRolePermissionMapper;
import org.xyzh.system.mapper.user.TbSysUserRoleMapper;
/**
* @description 模块权限服务实现类
* @filename ModulePermissionServiceImpl.java
*/
@DubboService(
version = "1.0.0",
group = "system",
timeout = 3000,
retries = 0
)
public class ModulePermissionServiceImpl implements ModulePermissionService {
private static final Logger logger = LoggerFactory.getLogger(ModulePermissionServiceImpl.class);
private static final String MSG_MODULE_PARAM_REQUIRED = "模块参数不能为空";
private static final String MSG_PERMISSION_PARAM_REQUIRED = "权限参数不能为空";
private static final String MSG_MODULE_ID_REQUIRED = "模块ID不能为空";
private static final String MSG_PERMISSION_ID_REQUIRED = "权限ID不能为空";
private static final String MSG_QUERY_PARAM_REQUIRED = "查询条件不能为空";
private static final String MSG_PAGE_PARAM_REQUIRED = "分页参数不能为空";
@Resource
private TbSysModuleMapper moduleMapper;
@Resource
private TbSysPermissionMapper permissionMapper;
@Resource
private TbSysRolePermissionMapper rolePermissionMapper;
@Resource
private TbSysUserRoleMapper userRoleMapper;
@Override
public ResultDomain<TbSysModuleDTO> insertModule(TbSysModuleDTO moduleDTO) {
if (moduleDTO == null) {
return ResultDomain.failure(MSG_MODULE_PARAM_REQUIRED);
}
if (StringUtils.isBlank(moduleDTO.getModuleId())) {
moduleDTO.setModuleId(IDUtils.generateID());
}
if (moduleDTO.getCreateTime() == null) {
moduleDTO.setCreateTime(new Date());
}
if (moduleDTO.getDeleted() == null) {
moduleDTO.setDeleted(false);
}
int rows = moduleMapper.insertModule(moduleDTO);
if (rows > 0) {
logger.info("新增模块成功, moduleId={}", moduleDTO.getModuleId());
return ResultDomain.success("新增模块成功", moduleDTO);
}
logger.warn("新增模块失败, moduleId={}", moduleDTO.getModuleId());
return ResultDomain.failure("新增模块失败");
}
@Override
public ResultDomain<TbSysModuleDTO> updateModule(TbSysModuleDTO moduleDTO) {
if (moduleDTO == null || StringUtils.isBlank(moduleDTO.getModuleId())) {
return ResultDomain.failure(MSG_MODULE_ID_REQUIRED);
}
moduleDTO.setUpdateTime(new Date());
int rows = moduleMapper.updateModule(moduleDTO);
if (rows > 0) {
logger.info("更新模块成功, moduleId={}", moduleDTO.getModuleId());
return ResultDomain.success("更新模块成功", moduleDTO);
}
logger.warn("更新模块失败, moduleId={}", moduleDTO.getModuleId());
return ResultDomain.failure("更新模块失败");
}
@Override
public ResultDomain<Boolean> deleteModule(TbSysModuleDTO moduleDTO) {
if (moduleDTO == null || StringUtils.isBlank(moduleDTO.getModuleId())) {
return ResultDomain.failure(MSG_MODULE_ID_REQUIRED);
}
int rows = moduleMapper.deleteModule(moduleDTO);
if (rows > 0) {
logger.info("删除模块成功, moduleId={}", moduleDTO.getModuleId());
return ResultDomain.success("删除模块成功", Boolean.TRUE);
}
logger.warn("删除模块失败, moduleId={}", moduleDTO.getModuleId());
return ResultDomain.failure("删除模块失败");
}
@Override
public ResultDomain<PermissionVO> getModulePage(PageRequest<PermissionVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysModuleDTO filter = org.xyzh.api.system.vo.PermissionVO.toModuleDTO(pageRequest.getFilter());
int total = moduleMapper.getModuleCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<PermissionVO> list = moduleMapper.getModulePageByFilter(filter, pageParam);
PageDomain<PermissionVO> pageDomain = new PageDomain<>(pageParam, list == null ? Collections.emptyList() : list);
return ResultDomain.success("分页查询模块成功", pageDomain);
}
@Override
public ResultDomain<PermissionVO> getModuleList(PermissionVO filter) {
TbSysModuleDTO dto = org.xyzh.api.system.vo.PermissionVO.toModuleDTO(filter);
List<PermissionVO> list = moduleMapper.getModuleByFilter(dto);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取模块列表成功", list);
}
@Override
public ResultDomain<TbSysPermissionDTO> insertPermission(TbSysPermissionDTO permissionDTO) {
if (permissionDTO == null) {
return ResultDomain.failure(MSG_PERMISSION_PARAM_REQUIRED);
}
if (StringUtils.isBlank(permissionDTO.getPermissionId())) {
permissionDTO.setPermissionId(IDUtils.generateID());
}
if (permissionDTO.getCreateTime() == null) {
permissionDTO.setCreateTime(new Date());
}
if (permissionDTO.getDeleted() == null) {
permissionDTO.setDeleted(false);
}
int rows = permissionMapper.insertPermission(permissionDTO);
if (rows > 0) {
logger.info("新增权限成功, permissionId={}", permissionDTO.getPermissionId());
return ResultDomain.success("新增权限成功", permissionDTO);
}
logger.warn("新增权限失败, permissionId={}", permissionDTO.getPermissionId());
return ResultDomain.failure("新增权限失败");
}
@Override
public ResultDomain<TbSysPermissionDTO> updatePermission(TbSysPermissionDTO permissionDTO) {
if (permissionDTO == null || StringUtils.isBlank(permissionDTO.getPermissionId())) {
return ResultDomain.failure(MSG_PERMISSION_ID_REQUIRED);
}
permissionDTO.setUpdateTime(new Date());
int rows = permissionMapper.updatePermission(permissionDTO);
if (rows > 0) {
logger.info("更新权限成功, permissionId={}", permissionDTO.getPermissionId());
return ResultDomain.success("更新权限成功", permissionDTO);
}
logger.warn("更新权限失败, permissionId={}", permissionDTO.getPermissionId());
return ResultDomain.failure("更新权限失败");
}
@Override
public ResultDomain<Boolean> deletePermission(TbSysPermissionDTO permissionDTO) {
if (permissionDTO == null || StringUtils.isBlank(permissionDTO.getPermissionId())) {
return ResultDomain.failure(MSG_PERMISSION_ID_REQUIRED);
}
int rows = permissionMapper.deletePermission(permissionDTO);
if (rows > 0) {
logger.info("删除权限成功, permissionId={}", permissionDTO.getPermissionId());
return ResultDomain.success("删除权限成功", Boolean.TRUE);
}
logger.warn("删除权限失败, permissionId={}", permissionDTO.getPermissionId());
return ResultDomain.failure("删除权限失败");
}
@Override
public ResultDomain<PermissionVO> getPermissionListByModuleId(String moduleId) {
if (StringUtils.isBlank(moduleId)) {
return ResultDomain.failure(MSG_MODULE_ID_REQUIRED);
}
TbSysPermissionDTO filter = new TbSysPermissionDTO();
filter.setModuleId(moduleId);
List<PermissionVO> list = permissionMapper.getPermissionByFilter(filter);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("根据模块获取权限列表成功", list);
}
@Override
public ResultDomain<PermissionVO> getModulePermission(PermissionVO filter) {
TbSysPermissionDTO dto = org.xyzh.api.system.vo.PermissionVO.toPermissionDTO(filter);
if (dto == null) {
return ResultDomain.failure(MSG_QUERY_PARAM_REQUIRED);
}
List<PermissionVO> list = permissionMapper.getPermissionByFilter(dto);
if (list == null || list.isEmpty()) {
return ResultDomain.failure("未找到模块权限");
}
return ResultDomain.success("获取模块权限成功", list.get(0));
}
@Override
public ResultDomain<PermissionVO> getModulePermissionList(PermissionVO filter) {
TbSysPermissionDTO dto = org.xyzh.api.system.vo.PermissionVO.toPermissionDTO(filter);
List<PermissionVO> list = permissionMapper.getPermissionByFilter(dto);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取模块权限列表成功", list);
}
@Override
public ResultDomain<PermissionVO> getModulePermissionPage(PageRequest<PermissionVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysPermissionDTO filter = org.xyzh.api.system.vo.PermissionVO.toPermissionDTO(pageRequest.getFilter());
int total = permissionMapper.getPermissionCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<PermissionVO> list = permissionMapper.getPermissionPageByFilter(filter, pageParam);
PageDomain<PermissionVO> pageDomain = new PageDomain<>(pageParam, list == null ? Collections.emptyList() : list);
return ResultDomain.success("分页查询模块权限成功", pageDomain);
}
@Override
public ResultDomain<PermissionVO> getModulePermissionListByRoleId(String roleId) {
if (StringUtils.isBlank(roleId)) {
return ResultDomain.failure("角色ID不能为空");
}
List<PermissionVO> list = rolePermissionMapper.getRolePermissionByRoleId(roleId);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("根据角色获取权限列表成功", list);
}
@Override
public ResultDomain<PermissionVO> getUserPermissions(String userId) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure("用户ID不能为空");
}
List<PermissionVO> list = rolePermissionMapper.getPermissionsByUserId(userId);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取用户权限成功", list);
}
}

View File

@@ -0,0 +1,168 @@
package org.xyzh.system.service.impl;
import org.apache.dubbo.config.annotation.DubboService;
import org.xyzh.api.system.service.SysConfigService;
import org.xyzh.api.system.vo.SysConfigVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysConfigDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.annotation.Resource;
import java.util.Date;
import java.util.Collections;
import java.util.List;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.core.page.PageDomain;
import org.xyzh.common.utils.IDUtils;
import org.xyzh.common.utils.StringUtils;
import org.xyzh.system.mapper.config.TbSysConfigMapper;
/**
* @description 系统配置服务实现类
* @filename SysConfigServiceImpl.java
*/
@DubboService(
version = "1.0.0",
group = "system",
timeout = 3000,
retries = 0
)
public class SysConfigServiceImpl implements SysConfigService {
private static final Logger logger = LoggerFactory.getLogger(SysConfigServiceImpl.class);
private static final String MSG_CONFIG_PARAM_REQUIRED = "配置参数不能为空";
private static final String MSG_CONFIG_ID_REQUIRED = "配置ID不能为空";
private static final String MSG_QUERY_PARAM_REQUIRED = "查询条件不能为空";
private static final String MSG_PAGE_PARAM_REQUIRED = "分页参数不能为空";
@Resource
private TbSysConfigMapper configMapper;
@Override
public ResultDomain<TbSysConfigDTO> insertConfig(TbSysConfigDTO configDTO) {
if (configDTO == null) {
return ResultDomain.failure(MSG_CONFIG_PARAM_REQUIRED);
}
if (StringUtils.isBlank(configDTO.getConfigId())) {
configDTO.setConfigId(IDUtils.generateID());
}
if (configDTO.getCreateTime() == null) {
configDTO.setCreateTime(new Date());
}
if (configDTO.getDeleted() == null) {
configDTO.setDeleted(false);
}
int rows = configMapper.insertConfig(configDTO);
if (rows > 0) {
logger.info("新增配置成功, configId={}", configDTO.getConfigId());
return ResultDomain.success("新增配置成功", configDTO);
}
logger.warn("新增配置失败, configId={}", configDTO.getConfigId());
return ResultDomain.failure("新增配置失败");
}
@Override
public ResultDomain<TbSysConfigDTO> updateConfig(TbSysConfigDTO configDTO) {
if (configDTO == null || StringUtils.isBlank(configDTO.getConfigId())) {
return ResultDomain.failure(MSG_CONFIG_ID_REQUIRED);
}
configDTO.setUpdateTime(new Date());
int rows = configMapper.updateConfig(configDTO);
if (rows > 0) {
logger.info("更新配置成功, configId={}", configDTO.getConfigId());
return ResultDomain.success("更新配置成功", configDTO);
}
logger.warn("更新配置失败, configId={}", configDTO.getConfigId());
return ResultDomain.failure("更新配置失败");
}
@Override
public ResultDomain<Boolean> deleteConfig(TbSysConfigDTO configDTO) {
if (configDTO == null || StringUtils.isBlank(configDTO.getConfigId())) {
return ResultDomain.failure(MSG_CONFIG_ID_REQUIRED);
}
int rows = configMapper.deleteConfig(configDTO);
if (rows > 0) {
logger.info("删除配置成功, configId={}", configDTO.getConfigId());
return ResultDomain.success("删除配置成功", Boolean.TRUE);
}
logger.warn("删除配置失败, configId={}", configDTO.getConfigId());
return ResultDomain.failure("删除配置失败");
}
@Override
public ResultDomain<SysConfigVO> getConfig(SysConfigVO filter) {
TbSysConfigDTO dto = SysConfigVO.toDTO(filter);
if (dto == null) {
return ResultDomain.failure(MSG_QUERY_PARAM_REQUIRED);
}
List<SysConfigVO> list = configMapper.getConfigByFilter(dto);
if (list == null || list.isEmpty()) {
return ResultDomain.failure("未找到配置");
}
return ResultDomain.success("获取配置成功", list.get(0));
}
@Override
public ResultDomain<SysConfigVO> getConfigList(SysConfigVO filter) {
TbSysConfigDTO dto = SysConfigVO.toDTO(filter);
List<SysConfigVO> list = configMapper.getConfigByFilter(dto);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取配置列表成功", list);
}
@Override
public ResultDomain<SysConfigVO> getConfigPage(PageRequest<SysConfigVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysConfigDTO filter = SysConfigVO.toDTO(pageRequest.getFilter());
int total = configMapper.getConfigCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<SysConfigVO> data = configMapper.getConfigPageByFilter(filter, pageParam);
if (data == null) {
data = Collections.emptyList();
}
PageDomain<SysConfigVO> pageDomain = new PageDomain<>(pageParam, data);
return ResultDomain.success("分页查询配置成功", pageDomain);
}
@Override
public ResultDomain<String> getConfigValueByKey(String key) {
if (StringUtils.isBlank(key)) {
return ResultDomain.failure("配置键不能为空");
}
TbSysConfigDTO filter = new TbSysConfigDTO();
filter.setKey(key);
List<SysConfigVO> list = configMapper.getConfigByFilter(filter);
if (list == null || list.isEmpty()) {
return ResultDomain.failure("未找到配置");
}
String value = list.get(0).getValue();
return ResultDomain.success("获取配置值成功", value);
}
@Override
public ResultDomain<SysConfigVO> getConfigListByModuleId(String moduleId) {
if (StringUtils.isBlank(moduleId)) {
return ResultDomain.failure("模块ID不能为空");
}
TbSysConfigDTO filter = new TbSysConfigDTO();
filter.setModuleId(moduleId);
List<SysConfigVO> list = configMapper.getConfigByFilter(filter);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("根据模块ID获取配置列表成功", list);
}
}

View File

@@ -0,0 +1,356 @@
package org.xyzh.system.service.impl;
import org.apache.dubbo.config.annotation.DubboService;
import org.xyzh.api.system.service.SysUserService;
import org.xyzh.api.system.vo.SysUserVO;
import org.xyzh.api.system.vo.UserDeptRoleVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysUserDTO;
import org.xyzh.common.dto.sys.TbSysUserInfoDTO;
import org.xyzh.common.dto.sys.TbSysUserRoleDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.core.page.PageDomain;
import org.xyzh.common.utils.IDUtils;
import org.xyzh.common.utils.StringUtils;
import org.xyzh.system.mapper.user.TbSysUserMapper;
import org.xyzh.system.mapper.user.TbSysUserInfoMapper;
import org.xyzh.system.mapper.user.TbSysUserRoleMapper;
/**
* @description 用户服务实现类
* @filename SysUserServiceImpl.java
*/
@DubboService(
version = "1.0.0",
group = "system",
timeout = 3000,
retries = 0
)
public class SysUserServiceImpl implements SysUserService {
private static final Logger logger = LoggerFactory.getLogger(SysUserServiceImpl.class);
private static final String MSG_USER_PARAM_REQUIRED = "用户参数不能为空";
private static final String MSG_USER_ID_REQUIRED = "用户ID不能为空";
private static final String MSG_QUERY_PARAM_REQUIRED = "查询条件不能为空";
private static final String MSG_PAGE_PARAM_REQUIRED = "分页参数不能为空";
@Resource
private TbSysUserMapper userMapper;
@Resource
private TbSysUserInfoMapper userInfoMapper;
@Resource
private TbSysUserRoleMapper userRoleMapper;
@Override
public ResultDomain<TbSysUserDTO> insertUser(SysUserVO userVO) {
if (userVO == null) {
return ResultDomain.failure(MSG_USER_PARAM_REQUIRED);
}
TbSysUserDTO dto = SysUserVO.toDTO(userVO);
if (StringUtils.isBlank(dto.getUserId())) {
dto.setUserId(IDUtils.generateID());
}
if (dto.getCreateTime() == null) {
dto.setCreateTime(new Date());
}
if (dto.getDeleted() == null) {
dto.setDeleted(false);
}
int rows = userMapper.insertUser(dto);
if (rows > 0) {
logger.info("新增用户成功, userId={}", dto.getUserId());
return ResultDomain.success("新增用户成功", dto);
}
logger.warn("新增用户失败, userId={}", dto.getUserId());
return ResultDomain.failure("新增用户失败");
}
@Override
public ResultDomain<TbSysUserDTO> updateUser(SysUserVO userVO) {
if (userVO == null || StringUtils.isBlank(userVO.getUserId())) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
TbSysUserDTO dto = SysUserVO.toDTO(userVO);
dto.setUpdateTime(new Date());
int rows = userMapper.updateUser(dto);
if (rows > 0) {
logger.info("更新用户成功, userId={}", dto.getUserId());
return ResultDomain.success("更新用户成功", dto);
}
logger.warn("更新用户失败, userId={}", dto.getUserId());
return ResultDomain.failure("更新用户失败");
}
@Override
public ResultDomain<Boolean> deleteUser(TbSysUserDTO userDTO) {
if (userDTO == null || StringUtils.isBlank(userDTO.getUserId())) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
int rows = userMapper.deleteUser(userDTO);
if (rows > 0) {
logger.info("删除用户成功, userId={}", userDTO.getUserId());
return ResultDomain.success("删除用户成功", Boolean.TRUE);
}
logger.warn("删除用户失败, userId={}", userDTO.getUserId());
return ResultDomain.failure("删除用户失败");
}
@Override
public ResultDomain<SysUserVO> getUser(SysUserVO filter) {
TbSysUserDTO dto = SysUserVO.toFilter(filter);
if (dto == null) {
return ResultDomain.failure(MSG_QUERY_PARAM_REQUIRED);
}
List<SysUserVO> list = userMapper.getUserByFilter(dto);
if (list == null || list.isEmpty()) {
return ResultDomain.failure("未找到用户");
}
return ResultDomain.success("获取用户成功", list.get(0));
}
@Override
public ResultDomain<SysUserVO> getLoginUser(SysUserVO filter) {
// 登录查询语义与 getUser 相同(可根据用户名/手机号/邮箱查询)
return getUser(filter);
}
@Override
public ResultDomain<SysUserVO> getUserList(SysUserVO filter) {
TbSysUserDTO dto = SysUserVO.toFilter(filter);
List<SysUserVO> list = userMapper.getUserByFilter(dto);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取用户列表成功", list);
}
@Override
public ResultDomain<SysUserVO> getUserPage(PageRequest<SysUserVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysUserDTO filter = SysUserVO.toFilter(pageRequest.getFilter());
int total = userMapper.getUserCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<SysUserVO> data = userMapper.getUserPageByFilter(filter, pageParam);
if (data == null) {
data = Collections.emptyList();
}
PageDomain<SysUserVO> pageDomain = new PageDomain<>(pageParam, data);
return ResultDomain.success("分页查询用户成功", pageDomain);
}
@Override
public ResultDomain<SysUserVO> getUserByUsername(String username) {
if (StringUtils.isBlank(username)) {
return ResultDomain.failure("用户名不能为空");
}
TbSysUserDTO filter = new TbSysUserDTO();
filter.setUsername(username);
List<SysUserVO> list = userMapper.getUserByFilter(filter);
if (list == null || list.isEmpty()) {
return ResultDomain.failure("未找到用户");
}
return ResultDomain.success("根据用户名获取用户成功", list.get(0));
}
@Override
public ResultDomain<Boolean> updateUserPassword(String userId, String oldPassword, String newPassword) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
if (StringUtils.isBlank(newPassword)) {
return ResultDomain.failure("新密码不能为空");
}
TbSysUserDTO dto = new TbSysUserDTO();
dto.setUserId(userId);
dto.setPassword(newPassword);
dto.setUpdateTime(new Date());
int rows = userMapper.updateUser(dto);
if (rows > 0) {
logger.info("更新用户密码成功, userId={}", userId);
return ResultDomain.success("更新用户密码成功", Boolean.TRUE);
}
logger.warn("更新用户密码失败, userId={}", userId);
return ResultDomain.failure("更新用户密码失败");
}
@Override
public ResultDomain<String> resetUserPassword(String userId) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
String newPwd = IDUtils.generateID();
if (newPwd.length() > 12) {
newPwd = newPwd.substring(0, 12);
}
TbSysUserDTO dto = new TbSysUserDTO();
dto.setUserId(userId);
dto.setPassword(newPwd);
dto.setUpdateTime(new Date());
int rows = userMapper.updateUser(dto);
if (rows > 0) {
logger.info("重置用户密码成功, userId={}", userId);
return ResultDomain.success("重置用户密码成功", newPwd);
}
logger.warn("重置用户密码失败, userId={}", userId);
return ResultDomain.failure("重置用户密码失败");
}
@Override
public ResultDomain<Boolean> updateUserStatus(String userId, String status) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
TbSysUserDTO dto = new TbSysUserDTO();
dto.setUserId(userId);
dto.setStatus(status);
dto.setUpdateTime(new Date());
int rows = userMapper.updateUser(dto);
if (rows > 0) {
logger.info("更新用户状态成功, userId={}", userId);
return ResultDomain.success("更新用户状态成功", Boolean.TRUE);
}
logger.warn("更新用户状态失败, userId={}", userId);
return ResultDomain.failure("更新用户状态失败");
}
@Override
public ResultDomain<TbSysUserInfoDTO> updateUserInfo(TbSysUserInfoDTO userInfoDTO) {
if (userInfoDTO == null || StringUtils.isBlank(userInfoDTO.getUserId())) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
userInfoDTO.setUpdateTime(new Date());
int rows = userInfoMapper.updateUserInfo(userInfoDTO);
if (rows > 0) {
logger.info("更新用户信息成功, userId={}", userInfoDTO.getUserId());
return ResultDomain.success("更新用户信息成功", userInfoDTO);
}
logger.warn("更新用户信息失败, userId={}", userInfoDTO.getUserId());
return ResultDomain.failure("更新用户信息失败");
}
@Override
public ResultDomain<SysUserVO> getUserInfo(String userId) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
TbSysUserInfoDTO info = userInfoMapper.getUserInfoById(userId);
if (info == null) {
return ResultDomain.failure("未找到用户信息");
}
SysUserVO vo = new SysUserVO();
vo.setUserId(userId);
vo.setAvatar(info.getAvatar());
vo.setGender(info.getGender());
vo.setFamilyName(info.getFamilyName());
vo.setGivenName(info.getGivenName());
vo.setFullName(info.getFullName());
vo.setLevel(info.getLevel());
vo.setIdCard(info.getIdCard());
vo.setAddress(info.getAddress());
vo.setCreateTime(info.getCreateTime());
vo.setUpdateTime(info.getUpdateTime());
vo.setDeleteTime(info.getDeleteTime());
vo.setDeleted(info.getDeleted());
return ResultDomain.success("获取用户信息成功", vo);
}
@Override
public ResultDomain<TbSysUserRoleDTO> addUserRole(TbSysUserRoleDTO userRoleDTO) {
if (userRoleDTO == null || StringUtils.isBlank(userRoleDTO.getUserId()) || StringUtils.isBlank(userRoleDTO.getRoleId())) {
return ResultDomain.failure("用户ID和角色ID不能为空");
}
if (userRoleDTO.getCreateTime() == null) {
userRoleDTO.setCreateTime(new Date());
}
if (userRoleDTO.getDeleted() == null) {
userRoleDTO.setDeleted(false);
}
int rows = userRoleMapper.insertUserRole(userRoleDTO);
if (rows > 0) {
logger.info("新增用户角色关联成功, userId={}, roleId={}", userRoleDTO.getUserId(), userRoleDTO.getRoleId());
return ResultDomain.success("新增用户角色关联成功", userRoleDTO);
}
logger.warn("新增用户角色关联失败, userId={}, roleId={}", userRoleDTO.getUserId(), userRoleDTO.getRoleId());
return ResultDomain.failure("新增用户角色关联失败");
}
@Override
public ResultDomain<Boolean> removeUserRole(TbSysUserRoleDTO userRoleDTO) {
if (userRoleDTO == null || StringUtils.isBlank(userRoleDTO.getUserId()) || StringUtils.isBlank(userRoleDTO.getRoleId())) {
return ResultDomain.failure("用户ID和角色ID不能为空");
}
int rows = userRoleMapper.deleteUserRole(userRoleDTO);
if (rows > 0) {
logger.info("删除用户角色关联成功, userId={}, roleId={}", userRoleDTO.getUserId(), userRoleDTO.getRoleId());
return ResultDomain.success("删除用户角色关联成功", Boolean.TRUE);
}
logger.warn("删除用户角色关联失败, userId={}, roleId={}", userRoleDTO.getUserId(), userRoleDTO.getRoleId());
return ResultDomain.failure("删除用户角色关联失败");
}
@Override
public ResultDomain<Boolean> setUserRoles(String userId, String[] roleIds) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
// 先删除现有的用户角色关系
List<UserDeptRoleVO> exists = userRoleMapper.getUserRoleByUserId(userId);
if (exists != null) {
for (UserDeptRoleVO vo : exists) {
if (vo == null || StringUtils.isBlank(vo.getRoleId())) {
continue;
}
TbSysUserRoleDTO del = new TbSysUserRoleDTO();
del.setUserId(userId);
del.setRoleId(vo.getRoleId());
userRoleMapper.deleteUserRole(del);
}
}
// 批量插入新角色
if (roleIds != null) {
Date now = new Date();
for (String rid : roleIds) {
if (StringUtils.isBlank(rid)) {
continue;
}
TbSysUserRoleDTO add = new TbSysUserRoleDTO();
add.setUserId(userId);
add.setRoleId(rid);
add.setCreateTime(now);
add.setDeleted(false);
userRoleMapper.insertUserRole(add);
}
}
logger.info("设置用户角色成功, userId={}, count={}", userId, roleIds == null ? 0 : roleIds.length);
return ResultDomain.success("设置用户角色成功", Boolean.TRUE);
}
@Override
public ResultDomain<UserDeptRoleVO> getUserWithDeptRole(String userId) {
if (StringUtils.isBlank(userId)) {
return ResultDomain.failure(MSG_USER_ID_REQUIRED);
}
List<UserDeptRoleVO> list = userRoleMapper.getUserRoleByUserId(userId);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取用户部门角色成功", list);
}
}

View File

@@ -0,0 +1,190 @@
package org.xyzh.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import java.util.Date;
import java.util.Collections;
import java.util.List;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xyzh.api.system.service.ViewService;
import org.xyzh.api.system.vo.PermissionVO;
import org.xyzh.common.core.domain.ResultDomain;
import org.xyzh.common.core.page.PageDomain;
import org.xyzh.common.core.page.PageParam;
import org.xyzh.common.core.page.PageRequest;
import org.xyzh.common.dto.sys.TbSysViewDTO;
import org.xyzh.common.dto.sys.TbSysViewPermissionDTO;
import org.xyzh.common.utils.IDUtils;
import org.xyzh.common.utils.StringUtils;
import org.xyzh.system.mapper.permission.TbSysViewPermissionMapper;
import org.xyzh.system.mapper.view.TbSysViewMapper;
/**
* @description 视图服务实现类
* @filename ViewServiceImpl.java
*/
@DubboService(
version = "1.0.0",
group = "system",
timeout = 3000,
retries = 0
)
public class ViewServiceImpl implements ViewService {
private static final Logger logger = LoggerFactory.getLogger(ViewServiceImpl.class);
private static final String MSG_VIEW_ID_REQUIRED = "视图ID不能为空";
private static final String MSG_QUERY_PARAM_REQUIRED = "查询条件不能为空";
private static final String MSG_PAGE_PARAM_REQUIRED = "分页参数不能为空";
@Resource
private TbSysViewMapper viewMapper;
@Resource
private TbSysViewPermissionMapper viewPermissionMapper;
@Override
public ResultDomain<TbSysViewDTO> insertView(TbSysViewDTO viewDTO) {
if (viewDTO == null) {
return ResultDomain.failure("视图参数不能为空");
}
if (StringUtils.isBlank(viewDTO.getViewId())) {
viewDTO.setViewId(IDUtils.generateID());
}
if (viewDTO.getCreateTime() == null) {
viewDTO.setCreateTime(new Date());
}
if (viewDTO.getDeleted() == null) {
viewDTO.setDeleted(false);
}
int rows = viewMapper.insertView(viewDTO);
if (rows > 0) {
logger.info("新增视图成功, viewId={}", viewDTO.getViewId());
return ResultDomain.success("新增视图成功", viewDTO);
}
logger.warn("新增视图失败, viewId={}", viewDTO.getViewId());
return ResultDomain.failure("新增视图失败");
}
@Override
public ResultDomain<TbSysViewDTO> updateView(TbSysViewDTO viewDTO) {
if (viewDTO == null || StringUtils.isBlank(viewDTO.getViewId())) {
return ResultDomain.failure(MSG_VIEW_ID_REQUIRED);
}
viewDTO.setUpdateTime(new Date());
int rows = viewMapper.updateView(viewDTO);
if (rows > 0) {
logger.info("更新视图成功, viewId={}", viewDTO.getViewId());
return ResultDomain.success("更新视图成功", viewDTO);
}
logger.warn("更新视图失败, viewId={}", viewDTO.getViewId());
return ResultDomain.failure("更新视图失败");
}
@Override
public ResultDomain<Boolean> deleteView(TbSysViewDTO viewDTO) {
if (viewDTO == null || StringUtils.isBlank(viewDTO.getViewId())) {
return ResultDomain.failure(MSG_VIEW_ID_REQUIRED);
}
int rows = viewMapper.deleteView(viewDTO);
if (rows > 0) {
logger.info("删除视图成功, viewId={}", viewDTO.getViewId());
return ResultDomain.success("删除视图成功", Boolean.TRUE);
}
logger.warn("删除视图失败, viewId={}", viewDTO.getViewId());
return ResultDomain.failure("删除视图失败");
}
@Override
public ResultDomain<PermissionVO> getView(PermissionVO filter) {
TbSysViewDTO dto = PermissionVO.toViewDTO(filter);
if (dto == null) {
return ResultDomain.failure(MSG_QUERY_PARAM_REQUIRED);
}
List<TbSysViewDTO> list = viewMapper.getViewByFilter(dto);
if (list == null || list.isEmpty()) {
return ResultDomain.failure("未找到视图");
}
PermissionVO result = PermissionVO.fromViewDTO(list.get(0));
return ResultDomain.success("获取视图成功", result);
}
@Override
public ResultDomain<PermissionVO> getViewList(PermissionVO filter) {
TbSysViewDTO dto = PermissionVO.toViewDTO(filter);
List<TbSysViewDTO> list = viewMapper.getViewByFilter(dto);
List<PermissionVO> result = PermissionVO.fromViewDTOList(list);
return ResultDomain.success("获取视图列表成功", result);
}
@Override
public ResultDomain<PermissionVO> getViewPage(PageRequest<PermissionVO> pageRequest) {
if (pageRequest == null) {
return ResultDomain.failure(MSG_PAGE_PARAM_REQUIRED);
}
PageParam pageParam = pageRequest.getPageParam();
TbSysViewDTO filter = PermissionVO.toViewDTO(pageRequest.getFilter());
int total = viewMapper.getViewCount(filter);
pageParam.setTotal(total);
pageParam.setTotalPages(pageParam.getPageSize() == 0 ? 0 : (int) Math.ceil((double) total / pageParam.getPageSize()));
List<TbSysViewDTO> list = viewMapper.getViewPageByFilter(filter, pageParam);
List<PermissionVO> data = PermissionVO.fromViewDTOList(list);
PageDomain<PermissionVO> pageDomain = new PageDomain<>(pageParam, data);
return ResultDomain.success("分页查询视图成功", pageDomain);
}
@Override
public ResultDomain<PermissionVO> getViewTree(PermissionVO filter) {
return getViewList(filter);
}
@Override
public ResultDomain<PermissionVO> setViewPermissions(PermissionVO permissionVO) {
if (permissionVO == null || StringUtils.isBlank(permissionVO.getViewId())) {
return ResultDomain.failure(MSG_VIEW_ID_REQUIRED);
}
viewPermissionMapper.delete(new QueryWrapper<TbSysViewPermissionDTO>()
.eq("view_id", permissionVO.getViewId()));
List<String> permissionIds = permissionVO.getPermissionIdList();
if (permissionIds != null && !permissionIds.isEmpty()) {
Date now = new Date();
for (String permissionId : permissionIds) {
if (StringUtils.isBlank(permissionId)) {
continue;
}
TbSysViewPermissionDTO dto = new TbSysViewPermissionDTO();
dto.setViewId(permissionVO.getViewId());
dto.setPermissionId(permissionId);
dto.setCreateTime(now);
dto.setDeleted(false);
viewPermissionMapper.insertViewPermission(dto);
}
}
logger.info("视图权限设置成功, viewId={}, count={}",
permissionVO.getViewId(),
permissionIds == null ? 0 : permissionIds.size());
return ResultDomain.success("设置视图权限成功", permissionVO);
}
@Override
public ResultDomain<PermissionVO> getViewPermissionList(PermissionVO permissionVO) {
TbSysViewPermissionDTO dto = new TbSysViewPermissionDTO();
if (permissionVO != null) {
dto.setViewId(permissionVO.getViewId());
if (permissionVO.getPermissionIdList() != null && !permissionVO.getPermissionIdList().isEmpty()) {
dto.setPermissionId(permissionVO.getPermissionIdList().get(0));
} else {
dto.setPermissionId(permissionVO.getPermissionId());
}
dto.setDeptPath(permissionVO.getDeptPath());
dto.setDeleted(permissionVO.getDeleted());
}
List<PermissionVO> list = viewPermissionMapper.getViewPermissionByFilter(dto);
if (list == null) {
list = Collections.emptyList();
}
return ResultDomain.success("获取视图权限列表成功", list);
}
}

View File

@@ -0,0 +1,99 @@
# ================== Server ==================
server:
port: 8082
servlet:
context-path: /urban-lifeline/system
# ================== Auth ====================
urban-lifeline:
auth:
enabled: true
# 认证接口:可以按服务自定义
login-path: /urban-lifeline/auth/login
logout-path: /urban-lifeline/auth/logout
captcha-path: /urban-lifeline/auth/captcha
refresh-path: /urban-lifeline/auth/refresh
# 通用白名单(非认证接口)
whitelist:
# Swagger/OpenAPI 文档相关(建议不带 context-path
- /swagger-ui/**
- /swagger-ui.html
- /v3/api-docs/**
- /webjars/**
# 静态资源
- /favicon.ico
- /error
# 健康检查
- /actuator/health
- /actuator/info
# 其他需要放行的路径
# - /public/**
# - /api/public/**
# ================== Spring ==================
spring:
# ================== DataSource ==================
datasource:
# 按你的实际库名改一下,比如 urban-lifeline_system
url: jdbc:postgresql://127.0.0.1:5432/urban-lifeline # 换成你的 PG 库名
username: postgres # PG 用户
password: "123456" # PG 密码
driver-class-name: org.postgresql.Driver
# ================== Redis ==================
data:
redis:
host: 127.0.0.1 # 如果是 docker 跑的 redis按实际 host / 端口改
port: 6379
database: 0
# password: "" # 如果有密码就填上,没密码可以去掉这一行
# ================== SpringDoc ==================
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
path: /swagger-ui.html
try-it-out-enabled: true
show-common-extensions: true
show-extensions: true
show-request-duration: true
filter: true
tags-sorter: alpha
operations-sorter: alpha
group-configs:
- group: 'default'
display-name: '系统服务 API'
paths-to-match: '/**'
# ================== Dubbo + Nacos 注册中心 ==================
dubbo:
application:
name: urban-lifeline-system
qos-enable: false
protocol:
name: dubbo
port: -1 # -1 表示随机端口,避免端口冲突;也可以写死一个端口
registry:
# Nacos 注册中心地址:使用 docker-compose 中映射到宿主机的 8848 端口
address: nacos://127.0.0.1:8848
# 如果 Nacos 有用户名密码,可以加上:
# username: nacos
# password: nacos
# Dubbo 服务扫描包(你 @DubboService 标注的位置)
scan:
base-packages: org.xyzh.system.service.impl
# ================== MyBatis ==================
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: org.xyzh.common.dto, org.xyzh.api

View File

@@ -0,0 +1,99 @@
# ================== Server ==================
server:
port: 8082
servlet:
context-path: /urban-lifeline/system
# ================== Auth ====================
urban-lifeline:
auth:
enabled: true
# 认证接口:可以按服务自定义
login-path: /urban-lifeline/auth/login
logout-path: /urban-lifeline/auth/logout
captcha-path: /urban-lifeline/auth/captcha
refresh-path: /urban-lifeline/auth/refresh
# 通用白名单(非认证接口)
whitelist:
# Swagger/OpenAPI 文档相关(建议不带 context-path
- /swagger-ui/**
- /swagger-ui.html
- /v3/api-docs/**
- /webjars/**
# 静态资源
- /favicon.ico
- /error
# 健康检查
- /actuator/health
- /actuator/info
# 其他需要放行的路径
# - /public/**
# - /api/public/**
# ================== Spring ==================
spring:
# ================== DataSource ==================
datasource:
# 按你的实际库名改一下,比如 urban-lifeline_system
url: jdbc:postgresql://127.0.0.1:5432/urban-lifeline # 换成你的 PG 库名
username: postgres # PG 用户
password: "123456" # PG 密码
driver-class-name: org.postgresql.Driver
# ================== Redis ==================
data:
redis:
host: 127.0.0.1 # 如果是 docker 跑的 redis按实际 host / 端口改
port: 6379
database: 0
# password: "" # 如果有密码就填上,没密码可以去掉这一行
# ================== SpringDoc ==================
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
path: /swagger-ui.html
try-it-out-enabled: true
show-common-extensions: true
show-extensions: true
show-request-duration: true
filter: true
tags-sorter: alpha
operations-sorter: alpha
group-configs:
- group: 'default'
display-name: '系统服务 API'
paths-to-match: '/**'
# ================== Dubbo + Nacos 注册中心 ==================
dubbo:
application:
name: urban-lifeline-system
qos-enable: false
protocol:
name: dubbo
port: -1 # -1 表示随机端口,避免端口冲突;也可以写死一个端口
registry:
# Nacos 注册中心地址:使用 docker-compose 中映射到宿主机的 8848 端口
address: nacos://127.0.0.1:8848
# 如果 Nacos 有用户名密码,可以加上:
# username: nacos
# password: nacos
# Dubbo 服务扫描包(你 @DubboService 标注的位置)
scan:
base-packages: org.xyzh.system.service.impl
# ================== MyBatis ==================
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: org.xyzh.common.dto, org.xyzh.api

View File

@@ -0,0 +1,285 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.acl.TbSysAclMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysAclDTO">
<!-- ACL 字段 -->
<id column="acl_id" property="aclId" jdbcType="VARCHAR"/>
<result column="object_type" property="objectType" jdbcType="VARCHAR"/>
<result column="object_id" property="objectId" jdbcType="VARCHAR"/>
<result column="principal_type" property="principalType" jdbcType="VARCHAR"/>
<result column="principal_id" property="principalId" jdbcType="VARCHAR"/>
<result column="principal_dept_id" property="principalDeptId" jdbcType="VARCHAR"/>
<result column="permission" property="permission" jdbcType="VARCHAR"/>
<result column="allow" property="allow" jdbcType="BOOLEAN"/>
<result column="include_descendants" property="includeDescendants" jdbcType="BOOLEAN"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="AclVOResultMap" type="org.xyzh.api.system.vo.AclVO">
<!-- ACL 字段 -->
<id column="acl_id" property="aclId" jdbcType="VARCHAR"/>
<result column="object_type" property="objectType" jdbcType="VARCHAR"/>
<result column="object_id" property="objectId" jdbcType="VARCHAR"/>
<result column="principal_type" property="principalType" jdbcType="VARCHAR"/>
<result column="principal_id" property="principalId" jdbcType="VARCHAR"/>
<result column="principal_dept_id" property="principalDeptId" jdbcType="VARCHAR"/>
<result column="permission" property="permission" jdbcType="INTEGER"/>
<result column="allow" property="allow" jdbcType="BOOLEAN"/>
<result column="include_descendants" property="includeDescendants" jdbcType="BOOLEAN"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
acl_id, object_type, object_id, principal_type, principal_id, principal_dept_id, permission, allow, include_descendants,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统访问控制列表(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertAcl" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
INSERT INTO sys.tb_sys_acl
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段ACL 主字段 + optsn -->
acl_id,
object_type,
object_id,
principal_type,
principal_id,
principal_dept_id,
permission,
allow,
include_descendants,
optsn,
<!-- 可选字段:根据是否有值动态拼接 -->
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{aclId},
#{objectType},
#{objectId},
#{principalType},
#{principalId},
#{principalDeptId},
#{permission},
#{allow},
#{includeDescendants},
#{optsn},
<!-- 可选字段值 -->
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统访问控制列表 -->
<update id="updateAcl" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
UPDATE sys.tb_sys_acl
<set>
<if test="objectType != null and objectType != ''">
object_type = #{objectType},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="principalId != null and principalId != ''">
principal_id = #{principalId},
</if>
<if test="principalDeptId != null and principalDeptId != ''">
principal_dept_id = #{principalDeptId},
</if>
<if test="permission != null and permission != ''">
permission = #{permission},
</if>
<if test="allow != null">
allow = #{allow},
</if>
<if test="includeDescendants != null">
include_descendants = #{includeDescendants},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE acl_id = #{aclId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统访问控制列表 -->
<update id="deleteAcl" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
DELETE FROM sys.tb_sys_acl
WHERE acl_id = #{aclId}
</update>
<!-- 根据ID查询系统访问控制列表 -->
<select id="getAclById" resultMap="AclVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
WHERE acl_id = #{aclId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据对象ID查询系统访问控制列表 -->
<select id="getAclByObjectId" resultMap="AclVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
WHERE object_id = #{objectId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统访问控制列表列表 -->
<select id="getAclByFilter" resultMap="AclVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
<where>
<if test="filter.aclId != null and filter.aclId != ''">
AND acl_id = #{filter.aclId}
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type LIKE CONCAT('%', #{filter.objectType}, '%')
</if>
<if test="filter.objectId != null and filter.objectId != ''">
AND object_id LIKE CONCAT('%', #{filter.objectId}, '%')
</if>
<if test="filter.principalType != null and filter.principalType != ''">
AND principal_type LIKE CONCAT('%', #{filter.principalType}, '%')
</if>
<if test="filter.principalId != null and filter.principalId != ''">
AND principal_id LIKE CONCAT('%', #{filter.principalId}, '%')
</if>
<if test="filter.principalDeptId != null and filter.principalDeptId != ''">
AND principal_dept_id LIKE CONCAT('%', #{filter.principalDeptId}, '%')
</if>
<if test="filter.permission != null and filter.permission != ''">
AND permission LIKE CONCAT('%', #{filter.permission}, '%')
</if>
<if test="filter.allow != null">
AND allow = #{filter.allow}
</if>
<if test="filter.includeDescendants != null">
AND include_descendants = #{filter.includeDescendants}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统访问控制列表分页列表 -->
<select id="getAclPageByFilter" resultMap="AclVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
<where>
<if test="filter.aclId != null and filter.aclId != ''">
AND acl_id = #{filter.aclId}
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type LIKE CONCAT('%', #{filter.objectType}, '%')
</if>
<if test="filter.objectId != null and filter.objectId != ''">
AND object_id LIKE CONCAT('%', #{filter.objectId}, '%')
</if>
<if test="filter.principalType != null and filter.principalType != ''">
AND principal_type LIKE CONCAT('%', #{filter.principalType}, '%')
</if>
<if test="filter.principalId != null and filter.principalId != ''">
AND principal_id LIKE CONCAT('%', #{filter.principalId}, '%')
</if>
<if test="filter.principalDeptId != null and filter.principalDeptId != ''">
AND principal_dept_id LIKE CONCAT('%', #{filter.principalDeptId}, '%')
</if>
<if test="filter.permission != null and filter.permission != ''">
AND permission LIKE CONCAT('%', #{filter.permission}, '%')
</if>
<if test="filter.allow != null">
AND allow = #{filter.allow}
</if>
<if test="filter.includeDescendants != null">
AND include_descendants = #{filter.includeDescendants}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统访问控制列表数量 -->
<select id="getAclCountByFilter" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
SELECT COUNT(1)
FROM sys.tb_sys_acl
<where>
<if test="filter.aclId != null and filter.aclId != ''">
AND acl_id = #{filter.aclId}
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type LIKE CONCAT('%', #{filter.objectType}, '%')
</if>
<if test="filter.objectId != null and filter.objectId != ''">
AND object_id LIKE CONCAT('%', #{filter.objectId}, '%')
</if>
<if test="filter.principalType != null and filter.principalType != ''">
AND principal_type LIKE CONCAT('%', #{filter.principalType}, '%')
</if>
<if test="filter.principalId != null and filter.principalId != ''">
AND principal_id LIKE CONCAT('%', #{filter.principalId}, '%')
</if>
<if test="filter.principalDeptId != null and filter.principalDeptId != ''">
AND principal_dept_id LIKE CONCAT('%', #{filter.principalDeptId}, '%')
</if>
<if test="filter.permission != null and filter.permission != ''">
AND permission LIKE CONCAT('%', #{filter.permission}, '%')
</if>
<if test="filter.allow != null">
AND allow = #{filter.allow}
</if>
<if test="filter.includeDescendants != null">
AND include_descendants = #{filter.includeDescendants}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,239 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.acl.TbSysAclPolicyMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
<!-- ACL 策略字段 -->
<id column="policy_id" property="policyId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="object_type" property="objectType" jdbcType="VARCHAR"/>
<result column="edit_hierarchy_rule" property="editHierarchyRule" jdbcType="VARCHAR"/>
<result column="view_hierarchy_rule" property="viewHierarchyRule" jdbcType="VARCHAR"/>
<result column="default_permission" property="defaultPermission" jdbcType="INTEGER"/>
<result column="default_allow" property="defaultAllow" jdbcType="BOOLEAN"/>
<result column="apply_to_children" property="applyToChildren" jdbcType="BOOLEAN"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="AclPolicyVOResultMap" type="org.xyzh.api.system.vo.AclVO">
<!-- ACL 策略字段 -->
<id column="policy_id" property="policyId" jdbcType="VARCHAR"/>
<result column="name" property="policyName" jdbcType="VARCHAR"/>
<result column="object_type" property="policyObjectType" jdbcType="VARCHAR"/>
<result column="edit_hierarchy_rule" property="editHierarchyRule" jdbcType="VARCHAR"/>
<result column="view_hierarchy_rule" property="viewHierarchyRule" jdbcType="VARCHAR"/>
<result column="default_permission" property="defaultPermission" jdbcType="INTEGER"/>
<result column="default_allow" property="defaultAllow" jdbcType="BOOLEAN"/>
<result column="apply_to_children" property="applyToChildren" jdbcType="BOOLEAN"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
policy_id, name, object_type, edit_hierarchy_rule, view_hierarchy_rule, default_permission, default_allow, apply_to_children,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统访问控制策略(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertAclPolicy" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
INSERT INTO sys.tb_sys_acl_policy
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段:策略主字段 + optsn -->
policy_id,
name,
object_type,
edit_hierarchy_rule,
view_hierarchy_rule,
default_permission,
default_allow,
apply_to_children,
optsn,
<!-- 可选字段:根据是否有值动态拼接 -->
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{policyId},
#{name},
#{objectType},
#{editHierarchyRule},
#{viewHierarchyRule},
#{defaultPermission},
#{defaultAllow},
#{applyToChildren},
#{optsn},
<!-- 可选字段值 -->
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统访问控制策略 -->
<update id="updateAclPolicy" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
UPDATE sys.tb_sys_acl_policy
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="objectType != null and objectType != ''">
object_type = #{objectType},
</if>
<if test="editHierarchyRule != null and editHierarchyRule != ''">
edit_hierarchy_rule = #{editHierarchyRule},
</if>
<if test="viewHierarchyRule != null and viewHierarchyRule != ''">
view_hierarchy_rule = #{viewHierarchyRule},
</if>
<if test="defaultPermission != null">
default_permission = #{defaultPermission},
</if>
<if test="defaultAllow != null">
default_allow = #{defaultAllow},
</if>
<if test="applyToChildren != null">
apply_to_children = #{applyToChildren},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE policy_id = #{policyId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统访问控制策略 -->
<update id="deleteAclPolicy" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
DELETE FROM sys.tb_sys_acl_policy
WHERE policy_id = #{policyId}
</update>
<!-- 根据ID查询系统访问控制策略 -->
<select id="getAclPolicyById" resultMap="AclPolicyVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl_policy
WHERE policy_id = #{policyId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统访问控制策略列表 -->
<select id="getAclPolicyByFilter" resultMap="AclPolicyVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl_policy
<where>
<if test="filter.policyId != null and filter.policyId != ''">
AND policy_id = #{filter.policyId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type = #{filter.objectType}
</if>
<if test="filter.editHierarchyRule != null and filter.editHierarchyRule != ''">
AND edit_hierarchy_rule = #{filter.editHierarchyRule}
</if>
<if test="filter.viewHierarchyRule != null and filter.viewHierarchyRule != ''">
AND view_hierarchy_rule = #{filter.viewHierarchyRule}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统访问控制策略分页列表 -->
<select id="getAclPolicyPageByFilter" resultMap="AclPolicyVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl_policy
<where>
<if test="filter.policyId != null and filter.policyId != ''">
AND policy_id = #{filter.policyId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type = #{filter.objectType}
</if>
<if test="filter.editHierarchyRule != null and filter.editHierarchyRule != ''">
AND edit_hierarchy_rule = #{filter.editHierarchyRule}
</if>
<if test="filter.viewHierarchyRule != null and filter.viewHierarchyRule != ''">
AND view_hierarchy_rule = #{filter.viewHierarchyRule}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统访问控制策略数量 -->
<select id="getAclPolicyCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
SELECT COUNT(1)
FROM sys.tb_sys_acl_policy
<where>
<if test="filter.policyId != null and filter.policyId != ''">
AND policy_id = #{filter.policyId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type = #{filter.objectType}
</if>
<if test="filter.editHierarchyRule != null and filter.editHierarchyRule != ''">
AND edit_hierarchy_rule = #{filter.editHierarchyRule}
</if>
<if test="filter.viewHierarchyRule != null and filter.viewHierarchyRule != ''">
AND view_hierarchy_rule = #{filter.viewHierarchyRule}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,258 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.config.TbSysConfigMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysConfigDTO">
<!-- 配置字段 -->
<id column="config_id" property="configId" jdbcType="VARCHAR"/>
<result column="key" property="key" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="value" property="value" jdbcType="VARCHAR"/>
<result column="config_type" property="configType" jdbcType="VARCHAR"/>
<result column="render_type" property="renderType" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="re" property="re" jdbcType="OTHER"/>
<result column="options" property="options" jdbcType="OTHER"/>
<result column="group" property="group" jdbcType="VARCHAR"/>
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="ConfigVOResultMap" type="org.xyzh.api.system.vo.SysConfigVO">
<!-- 配置字段 -->
<id column="config_id" property="configId" jdbcType="VARCHAR"/>
<result column="key" property="key" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="value" property="value" jdbcType="VARCHAR"/>
<result column="config_type" property="configType" jdbcType="VARCHAR"/>
<result column="render_type" property="renderType" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="re" property="re" jdbcType="OTHER"/>
<result column="options" property="options" jdbcType="OTHER"/>
<result column="group" property="group" jdbcType="VARCHAR"/>
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- 模块关联字段 -->
<result column="module_name" property="moduleName" jdbcType="VARCHAR"/>
<result column="module_description" property="moduleDescription" jdbcType="VARCHAR"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
config_id, key, name, value, config_type, render_type, description, re, options, "group", module_id, order_num, status,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统配置 -->
<insert id="insertConfig" parameterType="TbSysConfigDTO">
INSERT INTO config.tb_sys_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 无默认值字段:必填固定列 -->
config_id,
key,
name,
value,
config_type,
render_type,
description,
"group",
module_id,
order_num,
optsn,
remark,
<!-- 有默认值/可空字段:根据是否传值动态拼接 -->
<if test="re != null">re,</if>
<if test="options != null">options,</if>
<if test="status != null">status,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="updater != null and updater != ''">updater,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 无默认值字段:必填固定值 -->
#{configId},
#{key},
#{name},
#{value},
#{configType},
#{renderType},
#{description},
#{group},
#{moduleId},
#{orderNum},
#{optsn},
#{remark},
<!-- 有默认值/可空字段:根据是否传值动态拼接 -->
<if test="re != null">#{re},</if>
<if test="options != null">#{options},</if>
<if test="status != null">#{status},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="updater != null and updater != ''">#{updater},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统配置 -->
<update id="updateConfig" parameterType="TbSysConfigDTO">
UPDATE config.tb_sys_config
<set>
<if test="key != null and key != ''">key = #{key},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="value != null and value != ''">value = #{value},</if>
<if test="configType != null and configType != ''">config_type = #{configType},</if>
<if test="renderType != null and renderType != ''">render_type = #{renderType},</if>
<if test="description != null and description != ''">description = #{description},</if>
<if test="re != null">re = #{re},</if>
<if test="options != null">options = #{options},</if>
<if test="group != null and group != ''">"group" = #{group},</if>
<if test="moduleId != null and moduleId != ''">module_id = #{moduleId},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="status != null">status = #{status},</if>
<if test="updater != null and updater != ''">updater = #{updater},</if>
<if test="deptPath != null and deptPath != ''">dept_path = #{deptPath},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="deleteTime != null">delete_time = #{deleteTime},</if>
<if test="deleted != null">deleted = #{deleted},</if>
</set>
WHERE config_id = #{configId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统配置 -->
<update id="deleteConfig" parameterType="TbSysConfigDTO">
UPDATE config.tb_sys_config
SET deleted = true,
delete_time = NOW()
WHERE config_id = #{configId}
</update>
<!-- 根据条件查询系统配置列表 -->
<select id="getConfigByFilter" resultMap="ConfigVOResultMap" parameterType="TbSysConfigDTO">
SELECT
c.config_id, c.key, c.name, c.value, c.config_type, c.render_type, c.description, c.re, c.options, c."group", c.module_id, c.order_num, c.status,
c.optsn, c.creator, c.updater, c.dept_path, c.remark, c.create_time, c.update_time, c.delete_time, c.deleted,
m.name AS module_name, m.description AS module_description
FROM config.tb_sys_config c
LEFT JOIN sys.tb_sys_module m ON c.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.configId != null and filter.configId != ''">
AND c.config_id = #{filter.configId}
</if>
<if test="filter.key != null and filter.key != ''">
AND c.key LIKE CONCAT('%', #{filter.key}, '%')
</if>
<if test="filter.configType != null and filter.configType != ''">
AND c.config_type = #{filter.configType}
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND c.module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND c.status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND c.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (c.deleted IS NULL OR c.deleted = false)
</where>
ORDER BY c.order_num ASC, c.create_time DESC
</select>
<!-- 根据条件查询系统配置分页列表 -->
<select id="getConfigPageByFilter" resultMap="ConfigVOResultMap">
SELECT
c.config_id, c.key, c.name, c.value, c.config_type, c.render_type, c.description, c.re, c.options, c."group", c.module_id, c.order_num, c.status,
c.optsn, c.creator, c.updater, c.dept_path, c.remark, c.create_time, c.update_time, c.delete_time, c.deleted,
m.name AS module_name, m.description AS module_description
FROM config.tb_sys_config c
LEFT JOIN sys.tb_sys_module m ON c.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.configId != null and filter.configId != ''">
AND c.config_id = #{filter.configId}
</if>
<if test="filter.key != null and filter.key != ''">
AND c.key LIKE CONCAT('%', #{filter.key}, '%')
</if>
<if test="filter.configType != null and filter.configType != ''">
AND c.config_type = #{filter.configType}
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND c.module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND c.status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND c.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (c.deleted IS NULL OR c.deleted = false)
</where>
ORDER BY c.order_num ASC, c.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统配置数量 -->
<select id="getConfigCount" resultType="java.lang.Integer" parameterType="TbSysConfigDTO">
SELECT COUNT(1)
FROM config.tb_sys_config
<where>
<if test="filter.configId != null and filter.configId != ''">
AND config_id = #{filter.configId}
</if>
<if test="filter.key != null and filter.key != ''">
AND key LIKE CONCAT('%', #{filter.key}, '%')
</if>
<if test="filter.configType != null and filter.configType != ''">
AND config_type = #{filter.configType}
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.dept.TbSysDeptMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysDeptDTO">
<!-- 部门字段 -->
<id column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 部门字段 -->
<id column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="name" property="deptName" jdbcType="VARCHAR"/>
<result column="parent_id" property="deptParentId" jdbcType="VARCHAR"/>
<result column="description" property="deptDescription" jdbcType="VARCHAR"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
dept_id, name, parent_id, description,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统部门(按表字段 + 默认值动态列,仅修改 insert -->
<insert id="insertDept" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
INSERT INTO sys.tb_sys_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段NOT NULL 且无默认值):根据建表约束,这里视 dept_id, name, optsn 为必填 -->
dept_id,
name,
optsn,
<!-- 其他字段(可空或有默认值):动态拼接 -->
<if test="parentId != null and parentId != ''">parent_id,</if>
<if test="description != null and description != ''">description,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段对应的值 -->
#{deptId},
#{name},
#{optsn},
<!-- 其他字段对应的值 -->
<if test="parentId != null and parentId != ''">#{parentId},</if>
<if test="description != null and description != ''">#{description},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统部门 -->
<update id="updateDept" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
UPDATE sys.tb_sys_dept
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="parentId != null">
parent_id = #{parentId},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE dept_id = #{deptId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统部门 -->
<update id="deleteDept" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
UPDATE sys.tb_sys_dept
SET deleted = true,
delete_time = NOW()
WHERE dept_id = #{deptId}
</update>
<!-- 根据条件查询系统部门列表 -->
<select id="getDeptByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_dept
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统部门分页列表 -->
<select id="getDeptPageByFilter" resultMap="PermissionVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_dept
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统部门数量 -->
<select id="getDeptCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
SELECT COUNT(1)
FROM sys.tb_sys_dept
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.dept.TbSysDeptRoleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
<!-- 部门角色关系字段 -->
<id column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 部门字段 -->
<result column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
<result column="parent_id" property="deptParentId" jdbcType="VARCHAR"/>
<result column="dept_description" property="deptDescription" jdbcType="VARCHAR"/>
<!-- 角色字段 -->
<result column="role_id" property="roleId" jdbcType="VARCHAR"/>
<result column="role_name" property="roleName" jdbcType="VARCHAR"/>
<result column="role_description" property="roleDescription" jdbcType="VARCHAR"/>
<result column="scope" property="roleScope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="roleOwnerDeptId" jdbcType="VARCHAR"/>
<result column="role_status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
dept_id, role_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统部门角色关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertDeptRole" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
INSERT INTO sys.tb_sys_dept_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段dept_id, role_id, optsn -->
dept_id,
role_id,
optsn,
<!-- 可选字段:根据是否有值动态拼接 -->
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{deptId},
#{roleId},
#{optsn},
<!-- 可选字段值 -->
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统部门角色关系 -->
<update id="updateDeptRole" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
UPDATE sys.tb_sys_dept_role
<set>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE dept_id = #{deptId} AND role_id = #{roleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统部门角色关系 -->
<update id="deleteDeptRole" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
UPDATE sys.tb_sys_dept_role
SET deleted = true,
delete_time = NOW()
WHERE dept_id = #{deptId} AND role_id = #{roleId}
</update>
<!-- 根据部门ID和角色ID查询系统部门角色关系 -->
<select id="getDeptRoleByDeptId" resultMap="PermissionVOResultMap">
SELECT
dr.dept_id, dr.role_id,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
dr.optsn, dr.creator, dr.updater, dr.dept_path, dr.remark, dr.create_time, dr.update_time, dr.delete_time, dr.deleted
FROM sys.tb_sys_dept_role dr
LEFT JOIN sys.tb_sys_dept d ON dr.dept_id = d.dept_id AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON dr.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
WHERE dr.dept_id = #{deptId} AND dr.role_id = #{roleId}
AND (dr.deleted IS NULL OR dr.deleted = false)
</select>
<!-- 根据条件查询系统部门角色关系列表 -->
<select id="getDeptRoleByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
SELECT DISTINCT
dr.dept_id, dr.role_id,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
dr.optsn, dr.creator, dr.updater, dr.dept_path, dr.remark, dr.create_time, dr.update_time, dr.delete_time, dr.deleted
FROM sys.tb_sys_dept_role dr
LEFT JOIN sys.tb_sys_dept d ON dr.dept_id = d.dept_id AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON dr.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dr.dept_id = #{filter.deptId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND dr.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dr.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (dr.deleted IS NULL OR dr.deleted = false)
</where>
ORDER BY dr.create_time DESC
</select>
<!-- 根据条件查询系统部门角色关系分页列表 -->
<select id="getDeptRolePageByFilter" resultMap="PermissionVOResultMap">
SELECT DISTINCT
dr.dept_id, dr.role_id,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
dr.optsn, dr.creator, dr.updater, dr.dept_path, dr.remark, dr.create_time, dr.update_time, dr.delete_time, dr.deleted
FROM sys.tb_sys_dept_role dr
LEFT JOIN sys.tb_sys_dept d ON dr.dept_id = d.dept_id AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON dr.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dr.dept_id = #{filter.deptId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND dr.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dr.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (dr.deleted IS NULL OR dr.deleted = false)
</where>
ORDER BY dr.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统部门角色关系数量 -->
<select id="getDeptRoleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_dept_role
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.module.TbSysModuleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysModuleDTO">
<!-- 模块字段 -->
<id column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 模块字段 -->
<id column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="name" property="moduleName" jdbcType="VARCHAR"/>
<result column="description" property="moduleDescription" jdbcType="VARCHAR"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
module_id, name, description,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统模块(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertModule" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
INSERT INTO sys.tb_sys_module
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段module_id, name, optsn -->
module_id,
name,
optsn,
<!-- 可选字段description 及基础字段 -->
<if test="description != null and description != ''">description,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段对应的值 -->
#{moduleId},
#{name},
#{optsn},
<!-- 可选字段对应的值 -->
<if test="description != null and description != ''">#{description},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统模块 -->
<update id="updateModule" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
UPDATE sys.tb_sys_module
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE module_id = #{moduleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统模块 -->
<update id="deleteModule" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
UPDATE sys.tb_sys_module
SET deleted = true,
delete_time = NOW()
WHERE module_id = #{moduleId}
</update>
<!-- 根据模块ID查询系统模块 -->
<select id="getModuleById" resultMap="PermissionVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_module
WHERE module_id = #{moduleId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统模块列表 -->
<select id="getModuleByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_module
<where>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统模块分页列表 -->
<select id="getModulePageByFilter" resultMap="PermissionVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_module
<where>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统模块数量 -->
<select id="getModuleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_module
<where>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,249 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.permission.TbSysPermissionMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysPermissionDTO">
<!-- 权限字段 -->
<id column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 权限字段 -->
<id column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
<result column="permission_name" property="permissionName" jdbcType="VARCHAR"/>
<result column="permission_code" property="permissionCode" jdbcType="VARCHAR"/>
<result column="permission_description" property="permissionDescription" jdbcType="VARCHAR"/>
<result column="permission_status" property="permissionStatus" jdbcType="VARCHAR"/>
<!-- 模块关联字段 -->
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="module_name" property="moduleName" jdbcType="VARCHAR"/>
<result column="module_description" property="moduleDescription" jdbcType="VARCHAR"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
permission_id, name, code, description, module_id, status,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统权限(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertPermission" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
INSERT INTO sys.tb_sys_permission
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段permission_id, name, code, module_id, optsn -->
permission_id,
name,
code,
module_id,
optsn,
<!-- 可选字段description, status 及基础字段 -->
<if test="description != null and description != ''">description,</if>
<if test="status != null">status,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段对应的值 -->
#{permissionId},
#{name},
#{code},
#{moduleId},
#{optsn},
<!-- 可选字段对应的值 -->
<if test="description != null and description != ''">#{description},</if>
<if test="status != null">#{status},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统权限 -->
<update id="updatePermission" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
UPDATE sys.tb_sys_permission
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="code != null and code != ''">
code = #{code},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="moduleId != null">
module_id = #{moduleId},
</if>
<if test="status != null and status != ''">
status = #{status},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE permission_id = #{permissionId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统权限 -->
<update id="deletePermission" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
UPDATE sys.tb_sys_permission
SET deleted = true,
delete_time = NOW()
WHERE permission_id = #{permissionId}
</update>
<!-- 根据权限ID查询系统权限 -->
<select id="getPermissionById" resultMap="PermissionVOResultMap" parameterType="java.lang.String">
SELECT
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
p.optsn, p.creator, p.updater, p.dept_path, p.remark, p.create_time, p.update_time, p.delete_time, p.deleted
FROM sys.tb_sys_permission p
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE p.permission_id = #{permissionId}
AND (p.deleted IS NULL OR p.deleted = false)
</select>
<!-- 根据条件查询系统权限列表 -->
<select id="getPermissionByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
SELECT
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
p.optsn, p.creator, p.updater, p.dept_path, p.remark, p.create_time, p.update_time, p.delete_time, p.deleted
FROM sys.tb_sys_permission p
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND p.permission_id = #{filter.permissionId}
</if>
<if test="filter.name != null and filter.name != ''">
AND p.name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.code != null and filter.code != ''">
AND p.code LIKE CONCAT('%', #{filter.code}, '%')
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND p.module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND p.status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND p.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (p.deleted IS NULL OR p.deleted = false)
</where>
ORDER BY p.create_time DESC
</select>
<!-- 根据条件查询系统权限分页列表 -->
<select id="getPermissionPageByFilter" resultMap="PermissionVOResultMap">
SELECT
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
p.optsn, p.creator, p.updater, p.dept_path, p.remark, p.create_time, p.update_time, p.delete_time, p.deleted
FROM sys.tb_sys_permission p
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND p.permission_id = #{filter.permissionId}
</if>
<if test="filter.name != null and filter.name != ''">
AND p.name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.code != null and filter.code != ''">
AND p.code LIKE CONCAT('%', #{filter.code}, '%')
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND p.module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND p.status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND p.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (p.deleted IS NULL OR p.deleted = false)
</where>
ORDER BY p.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统权限数量 -->
<select id="getPermissionCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
SELECT COUNT(1)
FROM sys.tb_sys_permission
<where>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND permission_id = #{filter.permissionId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.code != null and filter.code != ''">
AND code LIKE CONCAT('%', #{filter.code}, '%')
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.permission.TbSysViewPermissionMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
<!-- 视图权限关系字段 -->
<id column="view_id" property="viewId" jdbcType="VARCHAR"/>
<id column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 视图字段 -->
<result column="view_id" property="viewId" jdbcType="VARCHAR"/>
<result column="view_name" property="viewName" jdbcType="VARCHAR"/>
<result column="view_parent_id" property="viewParentId" jdbcType="VARCHAR"/>
<result column="view_url" property="viewUrl" jdbcType="VARCHAR"/>
<result column="view_component" property="viewComponent" jdbcType="VARCHAR"/>
<result column="view_icon" property="viewIcon" jdbcType="VARCHAR"/>
<result column="view_type" property="viewType" jdbcType="INTEGER"/>
<result column="view_layout" property="viewLayout" jdbcType="VARCHAR"/>
<result column="view_order_num" property="viewOrderNum" jdbcType="INTEGER"/>
<result column="view_description" property="viewDescription" jdbcType="VARCHAR"/>
<!-- 权限字段 -->
<result column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
<result column="permission_name" property="permissionName" jdbcType="VARCHAR"/>
<result column="permission_code" property="permissionCode" jdbcType="VARCHAR"/>
<result column="permission_description" property="permissionDescription" jdbcType="VARCHAR"/>
<result column="permission_status" property="permissionStatus" jdbcType="VARCHAR"/>
<!-- 模块关联字段 -->
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="module_name" property="moduleName" jdbcType="VARCHAR"/>
<result column="module_description" property="moduleDescription" jdbcType="VARCHAR"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
view_id, permission_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统视图权限关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertViewPermission" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
INSERT INTO sys.tb_sys_view_permission
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段view_id, permission_id, optsn -->
view_id,
permission_id,
optsn,
<!-- 可选字段:基础审计字段 -->
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{viewId},
#{permissionId},
#{optsn},
<!-- 可选字段值 -->
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统视图权限关系 -->
<update id="updateViewPermission" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
UPDATE sys.tb_sys_view_permission
<set>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE view_id = #{viewId} AND permission_id = #{permissionId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统视图权限关系 -->
<update id="deleteViewPermission" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
UPDATE sys.tb_sys_view_permission
SET deleted = true,
delete_time = NOW()
WHERE view_id = #{viewId} AND permission_id = #{permissionId}
</update>
<!-- 根据视图ID和权限ID查询系统视图权限关系 -->
<select id="getViewPermissionByViewId" resultMap="PermissionVOResultMap">
SELECT
vp.view_id, vp.permission_id,
v.view_id, v.name AS view_name, v.parent_id AS view_parent_id, v.url AS view_url, v.component AS view_component,
v.icon AS view_icon, v.type AS view_type, v.layout AS view_layout, v.order_num AS view_order_num, v.description AS view_description,
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
vp.optsn, vp.creator, vp.updater, vp.dept_path, vp.remark, vp.create_time, vp.update_time, vp.delete_time, vp.deleted
FROM sys.tb_sys_view_permission vp
LEFT JOIN sys.tb_sys_view v ON vp.view_id = v.view_id AND (v.deleted IS NULL OR v.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON vp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE vp.view_id = #{viewId} AND vp.permission_id = #{permissionId}
AND (vp.deleted IS NULL OR vp.deleted = false)
</select>
<!-- 根据条件查询系统视图权限关系列表 -->
<select id="getViewPermissionByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
SELECT
vp.view_id, vp.permission_id,
v.view_id, v.name AS view_name, v.parent_id AS view_parent_id, v.url AS view_url, v.component AS view_component,
v.icon AS view_icon, v.type AS view_type, v.layout AS view_layout, v.order_num AS view_order_num, v.description AS view_description,
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
vp.optsn, vp.creator, vp.updater, vp.dept_path, vp.remark, vp.create_time, vp.update_time, vp.delete_time, vp.deleted
FROM sys.tb_sys_view_permission vp
LEFT JOIN sys.tb_sys_view v ON vp.view_id = v.view_id AND (v.deleted IS NULL OR v.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON vp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND vp.view_id = #{filter.viewId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND vp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND vp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (vp.deleted IS NULL OR vp.deleted = false)
</where>
ORDER BY vp.create_time DESC
</select>
<!-- 根据条件查询系统视图权限关系分页列表 -->
<select id="getViewPermissionPageByFilter" resultMap="PermissionVOResultMap">
SELECT
vp.view_id, vp.permission_id,
v.view_id, v.name AS view_name, v.parent_id AS view_parent_id, v.url AS view_url, v.component AS view_component,
v.icon AS view_icon, v.type AS view_type, v.layout AS view_layout, v.order_num AS view_order_num, v.description AS view_description,
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
vp.optsn, vp.creator, vp.updater, vp.dept_path, vp.remark, vp.create_time, vp.update_time, vp.delete_time, vp.deleted
FROM sys.tb_sys_view_permission vp
LEFT JOIN sys.tb_sys_view v ON vp.view_id = v.view_id AND (v.deleted IS NULL OR v.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON vp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND vp.view_id = #{filter.viewId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND vp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND vp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (vp.deleted IS NULL OR vp.deleted = false)
</where>
ORDER BY vp.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统视图权限关系数量 -->
<select id="getViewPermissionCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
SELECT COUNT(1)
FROM sys.tb_sys_view_permission
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,228 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.role.TbSysRoleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysRoleDTO">
<!-- 角色字段 -->
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="scope" property="scope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="ownerDeptId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="BOOLEAN"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 角色字段 -->
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<result column="name" property="roleName" jdbcType="VARCHAR"/>
<result column="description" property="roleDescription" jdbcType="VARCHAR"/>
<result column="scope" property="roleScope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="roleOwnerDeptId" jdbcType="VARCHAR"/>
<result column="status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
role_id, name, description, scope, owner_dept_id, status,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统角色(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertRole" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
INSERT INTO sys.tb_sys_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 假定必填字段role_id, name, optsn -->
role_id,
name,
optsn,
<!-- 其他字段视为可选/有默认:动态拼接 -->
<if test="description != null and description != ''">description,</if>
<if test="scope != null and scope != ''">scope,</if>
<if test="ownerDeptId != null and ownerDeptId != ''">owner_dept_id,</if>
<if test="status != null">status,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{roleId},
#{name},
#{optsn},
<!-- 可选字段值 -->
<if test="description != null and description != ''">#{description},</if>
<if test="scope != null and scope != ''">#{scope},</if>
<if test="ownerDeptId != null and ownerDeptId != ''">#{ownerDeptId},</if>
<if test="status != null">#{status},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统角色 -->
<update id="updateRole" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
UPDATE sys.tb_sys_role
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="scope != null and scope != ''">
scope = #{scope},
</if>
<if test="ownerDeptId != null">
owner_dept_id = #{ownerDeptId},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE role_id = #{roleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统角色 -->
<update id="deleteRole" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
UPDATE sys.tb_sys_role
SET deleted = true,
delete_time = NOW()
WHERE role_id = #{roleId}
</update>
<!-- 根据条件查询系统角色列表 -->
<select id="getRoleByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_role
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.scope != null and filter.scope != ''">
AND scope = #{filter.scope}
</if>
<if test="filter.ownerDeptId != null and filter.ownerDeptId != ''">
AND owner_dept_id = #{filter.ownerDeptId}
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统角色分页列表 -->
<select id="getRolePageByFilter" resultMap="PermissionVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_role
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.scope != null and filter.scope != ''">
AND scope = #{filter.scope}
</if>
<if test="filter.ownerDeptId != null and filter.ownerDeptId != ''">
AND owner_dept_id = #{filter.ownerDeptId}
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统角色数量 -->
<select id="getRoleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_role
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.scope != null and filter.scope != ''">
AND scope = #{filter.scope}
</if>
<if test="filter.ownerDeptId != null and filter.ownerDeptId != ''">
AND owner_dept_id = #{filter.ownerDeptId}
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,245 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.role.TbSysRolePermissionMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
<!-- 角色权限关系字段 -->
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<id column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 角色字段 -->
<result column="role_id" property="roleId" jdbcType="VARCHAR"/>
<result column="role_name" property="roleName" jdbcType="VARCHAR"/>
<result column="role_description" property="roleDescription" jdbcType="VARCHAR"/>
<result column="role_scope" property="roleScope" jdbcType="VARCHAR"/>
<result column="role_owner_dept_id" property="roleOwnerDeptId" jdbcType="VARCHAR"/>
<result column="role_status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- 权限字段 -->
<result column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
<result column="permission_name" property="permissionName" jdbcType="VARCHAR"/>
<result column="permission_code" property="permissionCode" jdbcType="VARCHAR"/>
<result column="permission_description" property="permissionDescription" jdbcType="VARCHAR"/>
<result column="permission_status" property="permissionStatus" jdbcType="VARCHAR"/>
<!-- 模块关联字段 -->
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="module_name" property="moduleName" jdbcType="VARCHAR"/>
<result column="module_description" property="moduleDescription" jdbcType="VARCHAR"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
role_id, permission_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 批量插入系统角色权限关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertRolePermissionBatch" parameterType="java.util.List">
INSERT INTO sys.tb_sys_role_permission
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段role_id, permission_id, optsn -->
role_id,
permission_id,
optsn,
<!-- 可选字段:统一列定义,值侧按 item 是否有值动态拼接 -->
<if test="list[0].creator != null">creator,</if>
<if test="list[0].deptPath != null">dept_path,</if>
<if test="list[0].remark != null">remark,</if>
<if test="list[0].createTime != null">create_time,</if>
<if test="list[0].updateTime != null">update_time,</if>
<if test="list[0].deleteTime != null">delete_time,</if>
<if test="list[0].deleted != null">deleted</if>
</trim>
VALUES
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{item.roleId},
#{item.permissionId},
#{item.optsn},
<!-- 可选字段值:允许为 null走数据库默认值或 NULL -->
<if test="item.creator != null">#{item.creator},</if>
<if test="item.deptPath != null">#{item.deptPath},</if>
<if test="item.remark != null">#{item.remark},</if>
<if test="item.createTime != null">#{item.createTime},</if>
<if test="item.updateTime != null">#{item.updateTime},</if>
<if test="item.deleteTime != null">#{item.deleteTime},</if>
<if test="item.deleted != null">#{item.deleted}</if>
</trim>
</foreach>
</insert>
<!-- 插入系统角色权限关系 -->
<insert id="insertRolePermission" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
INSERT INTO sys.tb_sys_role_permission (
role_id, permission_id,
optsn, creator, dept_path, remark, create_time
) VALUES (
#{roleId}, #{permissionId},
#{optsn}, #{creator}, #{deptPath}, #{remark}, #{createTime}
)
</insert>
<!-- 更新系统角色权限关系 -->
<update id="updateRolePermission" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
UPDATE sys.tb_sys_role_permission
<set>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE role_id = #{roleId} AND permission_id = #{permissionId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统角色权限关系 -->
<update id="deleteRolePermission" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
UPDATE sys.tb_sys_role_permission
SET deleted = true,
delete_time = NOW()
WHERE role_id = #{roleId} AND permission_id = #{permissionId}
</update>
<!-- 根据角色ID查询系统角色权限关系 -->
<select id="getRolePermissionByRoleId" resultMap="PermissionVOResultMap" parameterType="java.lang.String">
SELECT
rp.role_id, rp.permission_id,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope AS role_scope, r.owner_dept_id AS role_owner_dept_id, r.status AS role_status,
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
rp.optsn, rp.creator, rp.updater, rp.dept_path, rp.remark, rp.create_time, rp.update_time, rp.delete_time, rp.deleted
FROM sys.tb_sys_role_permission rp
LEFT JOIN sys.tb_sys_role r ON rp.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp.role_id = #{roleId}
AND (rp.deleted IS NULL OR rp.deleted = false)
ORDER BY rp.create_time DESC
</select>
<!-- 根据条件查询系统角色权限关系列表 -->
<select id="getRolePermissionByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
SELECT
rp.role_id, rp.permission_id,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope AS role_scope, r.owner_dept_id AS role_owner_dept_id, r.status AS role_status,
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
rp.optsn, rp.creator, rp.updater, rp.dept_path, rp.remark, rp.create_time, rp.update_time, rp.delete_time, rp.deleted
FROM sys.tb_sys_role_permission rp
LEFT JOIN sys.tb_sys_role r ON rp.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND rp.role_id = #{filter.roleId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND rp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND rp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (rp.deleted IS NULL OR rp.deleted = false)
</where>
ORDER BY rp.create_time DESC
</select>
<!-- 根据条件查询系统角色权限关系分页列表 -->
<select id="getRolePermissionPageByFilter" resultMap="PermissionVOResultMap">
SELECT
rp.role_id, rp.permission_id,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope AS role_scope, r.owner_dept_id AS role_owner_dept_id, r.status AS role_status,
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
p.module_id, m.name AS module_name, m.description AS module_description,
rp.optsn, rp.creator, rp.updater, rp.dept_path, rp.remark, rp.create_time, rp.update_time, rp.delete_time, rp.deleted
FROM sys.tb_sys_role_permission rp
LEFT JOIN sys.tb_sys_role r ON rp.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND rp.role_id = #{filter.roleId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND rp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND rp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (rp.deleted IS NULL OR rp.deleted = false)
</where>
ORDER BY rp.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统角色权限关系数量 -->
<select id="getRolePermissionCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
SELECT COUNT(1)
FROM sys.tb_sys_role_permission
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
<!-- getPermissionsByUserId -->
<select id="getPermissionsByUserId" resultMap="PermissionVOResultMap">
SELECT p.permission_id AS permissionId,
p.name AS permissionName,
p.code AS permissionCode,
p.description AS permissionDescription,
p.dept_path AS deptPath,
p.deleted AS deleted,
p.module_id AS moduleId
FROM sys.tb_sys_user_role ur
JOIN sys.tb_sys_role_permission rp ON ur.role_id = rp.role_id
JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id
WHERE ur.user_id = #{userId}
AND (p.deleted IS NULL OR p.deleted = false)
AND (rp.deleted IS NULL OR rp.deleted = false)
</select>
</mapper>

View File

@@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.user.TbSysUserInfoMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
<!-- 用户信息字段 -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="avatar" property="avatar" jdbcType="VARCHAR"/>
<result column="gender" property="gender" jdbcType="INTEGER"/>
<result column="family_name" property="familyName" jdbcType="VARCHAR"/>
<result column="given_name" property="givenName" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
user_id, avatar, gender, family_name, given_name, full_name, level, id_card, address,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统用户信息(按表字段 + 默认值动态列,仅修改 insert -->
<insert id="insertUserInfo" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
INSERT INTO sys.tb_sys_user_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段NOT NULL 且无默认值optsn, user_id -->
optsn,
user_id,
<!-- 可空/有默认值字段:按是否有入参动态拼接 -->
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="gender != null">gender,</if>
<if test="familyName != null and familyName != ''">family_name,</if>
<if test="givenName != null and givenName != ''">given_name,</if>
<if test="fullName != null and fullName != ''">full_name,</if>
<if test="level != null">level,</if>
<if test="idCard != null and idCard != ''">id_card,</if>
<if test="address != null and address != ''">address,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段对应的值 -->
#{optsn},
#{userId},
<!-- 可空/有默认值字段对应的值 -->
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="gender != null">#{gender},</if>
<if test="familyName != null and familyName != ''">#{familyName},</if>
<if test="givenName != null and givenName != ''">#{givenName},</if>
<if test="fullName != null and fullName != ''">#{fullName},</if>
<if test="level != null">#{level},</if>
<if test="idCard != null and idCard != ''">#{idCard},</if>
<if test="address != null and address != ''">#{address},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统用户信息 -->
<update id="updateUserInfo" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
UPDATE sys.tb_sys_user_info
<set>
<if test="avatar != null">
avatar = #{avatar},
</if>
<if test="gender != null">
gender = #{gender},
</if>
<if test="familyName != null">
family_name = #{familyName},
</if>
<if test="givenName != null">
given_name = #{givenName},
</if>
<if test="fullName != null">
full_name = #{fullName},
</if>
<if test="level != null">
level = #{level},
</if>
<if test="idCard != null">
id_card = #{idCard},
</if>
<if test="address != null">
address = #{address},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE user_id = #{userId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统用户信息 -->
<update id="deleteUserInfo" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
UPDATE sys.tb_sys_user_info
SET deleted = true,
delete_time = NOW()
WHERE user_id = #{userId}
</update>
<!-- 根据用户ID查询系统用户信息 -->
<select id="getUserInfoById" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_user_info
WHERE user_id = #{userId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统用户信息列表 -->
<select id="getUserInfoByFilter" resultMap="BaseResultMap" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_user_info
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.fullName != null and filter.fullName != ''">
AND full_name LIKE CONCAT('%', #{filter.fullName}, '%')
</if>
<if test="filter.familyName != null and filter.familyName != ''">
AND family_name LIKE CONCAT('%', #{filter.familyName}, '%')
</if>
<if test="filter.givenName != null and filter.givenName != ''">
AND given_name LIKE CONCAT('%', #{filter.givenName}, '%')
</if>
<if test="filter.idCard != null and filter.idCard != ''">
AND id_card = #{filter.idCard}
</if>
<if test="filter.gender != null">
AND gender = #{filter.gender}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统用户信息分页列表 -->
<select id="getUserInfoPageByFilter" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_user_info
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.fullName != null and filter.fullName != ''">
AND full_name LIKE CONCAT('%', #{filter.fullName}, '%')
</if>
<if test="filter.familyName != null and filter.familyName != ''">
AND family_name LIKE CONCAT('%', #{filter.familyName}, '%')
</if>
<if test="filter.givenName != null and filter.givenName != ''">
AND given_name LIKE CONCAT('%', #{filter.givenName}, '%')
</if>
<if test="filter.idCard != null and filter.idCard != ''">
AND id_card = #{filter.idCard}
</if>
<if test="filter.gender != null">
AND gender = #{filter.gender}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统用户信息数量 -->
<select id="getUserInfoCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
SELECT COUNT(1)
FROM sys.tb_sys_user_info
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.fullName != null and filter.fullName != ''">
AND full_name LIKE CONCAT('%', #{filter.fullName}, '%')
</if>
<if test="filter.familyName != null and filter.familyName != ''">
AND family_name LIKE CONCAT('%', #{filter.familyName}, '%')
</if>
<if test="filter.givenName != null and filter.givenName != ''">
AND given_name LIKE CONCAT('%', #{filter.givenName}, '%')
</if>
<if test="filter.idCard != null and filter.idCard != ''">
AND id_card = #{filter.idCard}
</if>
<if test="filter.gender != null">
AND gender = #{filter.gender}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.user.TbSysUserMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysUserDTO">
<!-- 用户表字段(按 createTableUser.sql -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="wechat_id" property="wechatId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- BaseDTO 中在该表实际存在的字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="UserVOResultMap" type="org.xyzh.api.system.vo.SysUserVO">
<!-- 用户字段(按表结构对齐) -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="wechat_id" property="wechatId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- 用户信息关联字段 -->
<result column="avatar" property="avatar" jdbcType="VARCHAR"/>
<result column="gender" property="gender" jdbcType="INTEGER"/>
<result column="family_name" property="familyName" jdbcType="VARCHAR"/>
<result column="given_name" property="givenName" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<!-- BaseVO 中在该表实际存在的字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列(完全按表结构) -->
<sql id="Base_Column_List">
user_id, password, email, phone, wechat_id, status,
optsn, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入用户(按表字段 + 默认值动态列) -->
<insert id="insertUser" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
INSERT INTO sys.tb_sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段NOT NULL 且无默认值optsn, user_id, password -->
optsn,
user_id,
password,
<!-- 可空/有默认值字段:按是否有入参动态拼接 -->
<if test="email != null and email != ''">email,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="wechatId != null and wechatId != ''">wechat_id,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
<if test="status != null">status,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段对应的值 -->
#{optsn},
#{userId},
#{password},
<!-- 可空/有默认值字段对应的值 -->
<if test="email != null and email != ''">#{email},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="wechatId != null and wechatId != ''">#{wechatId},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
<!-- 更新用户 -->
<update id="updateUser" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
UPDATE sys.tb_sys_user
<set>
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="wechatId != null and wechatId != ''">
wechat_id = #{wechatId},
</if>
<if test="status != null and status != ''">
status = #{status},
</if>
<if test="userType != null and userType != ''">
user_type = #{userType},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE user_id = #{userId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除用户(逻辑删除) -->
<update id="deleteUser" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
UPDATE sys.tb_sys_user
SET deleted = true,
delete_time = NOW()
WHERE user_id = #{userId}
</update>
<!-- 根据ID查询用户 -->
<select id="getUserById" resultMap="UserVOResultMap" parameterType="java.lang.String">
SELECT
u.user_id, u.password, u.email, u.phone, u.wechat_id, u.status,
u.optsn, u.create_time, u.update_time, u.delete_time, u.deleted,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address
FROM sys.tb_sys_user u
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
WHERE u.user_id = #{userId}
AND (u.deleted IS NULL OR u.deleted = false)
</select>
<!-- 根据条件查询用户列表 -->
<select id="getUserByFilter" resultMap="UserVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
SELECT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
u.optsn, u.creator, u.updater, u.dept_path, u.remark, u.create_time, u.update_time, u.delete_time, u.deleted,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address
FROM sys.tb_sys_user u
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND u.user_id = #{filter.userId}
</if>
<if test="filter.email != null and filter.email != ''">
AND u.email = #{filter.email}
</if>
<if test="filter.phone != null and filter.phone != ''">
AND u.phone = #{filter.phone}
</if>
<if test="filter.status != null and filter.status != ''">
AND u.status = #{filter.status}
</if>
<!-- username / userType / deptPath 在表中不存在,按 SQL 为准移除相关条件 -->
AND (u.deleted IS NULL OR u.deleted = false)
</where>
ORDER BY u.create_time DESC
</select>
<!-- 根据条件查询用户分页列表 -->
<select id="getUserPageByFilter" resultMap="UserVOResultMap">
SELECT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
u.optsn, u.creator, u.updater, u.dept_path, u.remark, u.create_time, u.update_time, u.delete_time, u.deleted,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address
FROM sys.tb_sys_user u
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND u.user_id = #{filter.userId}
</if>
<if test="filter.username != null and filter.username != ''">
AND u.username LIKE CONCAT('%', #{filter.username}, '%')
</if>
<if test="filter.email != null and filter.email != ''">
AND u.email = #{filter.email}
</if>
<if test="filter.phone != null and filter.phone != ''">
AND u.phone = #{filter.phone}
</if>
<if test="filter.status != null and filter.status != ''">
AND u.status = #{filter.status}
</if>
<if test="filter.userType != null and filter.userType != ''">
AND u.user_type = #{filter.userType}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND u.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (u.deleted IS NULL OR u.deleted = false)
</where>
ORDER BY u.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询用户数量 -->
<select id="getUserCountByFilter" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
SELECT COUNT(1)
FROM sys.tb_sys_user
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.email != null and filter.email != ''">
AND email = #{filter.email}
</if>
<if test="filter.phone != null and filter.phone != ''">
AND phone = #{filter.phone}
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,247 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.user.TbSysUserRoleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
<!-- 用户角色关系字段 -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="UserDeptRoleVOResultMap" type="org.xyzh.api.system.vo.UserDeptRoleVO">
<!-- 用户字段 -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="wechat_id" property="wechatId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="VARCHAR"/>
<result column="user_type" property="userType" jdbcType="VARCHAR"/>
<!-- 用户信息字段 -->
<result column="avatar" property="avatar" jdbcType="VARCHAR"/>
<result column="gender" property="gender" jdbcType="INTEGER"/>
<result column="family_name" property="familyName" jdbcType="VARCHAR"/>
<result column="given_name" property="givenName" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<!-- 部门字段 -->
<result column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="dept_description" property="deptDescription" jdbcType="VARCHAR"/>
<!-- 角色字段 -->
<result column="role_id" property="roleId" jdbcType="VARCHAR"/>
<result column="role_name" property="roleName" jdbcType="VARCHAR"/>
<result column="role_description" property="roleDescription" jdbcType="VARCHAR"/>
<result column="scope" property="scope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="ownerDeptId" jdbcType="VARCHAR"/>
<result column="role_status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- BaseVO 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
user_id, role_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统用户角色关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertUserRole" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
INSERT INTO sys.tb_sys_user_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段user_id, role_id, optsn -->
user_id,
role_id,
optsn,
<!-- 可选字段:基础字段按是否有值动态拼接 -->
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{userId},
#{roleId},
#{optsn},
<!-- 可选字段值 -->
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统用户角色关系 -->
<update id="updateUserRole" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
UPDATE sys.tb_sys_user_role
<set>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE user_id = #{userId} AND role_id = #{roleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统用户角色关系 -->
<update id="deleteUserRole" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
UPDATE sys.tb_sys_user_role
SET deleted = true,
delete_time = NOW()
WHERE user_id = #{userId} AND role_id = #{roleId}
</update>
<!-- 根据用户ID查询系统用户角色关系 -->
<select id="getUserRoleByUserId" resultMap="UserDeptRoleVOResultMap" parameterType="java.lang.String">
SELECT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
ur.optsn, ur.creator, ur.updater, ur.dept_path, ur.remark, ur.create_time, ur.update_time, ur.delete_time, ur.deleted
FROM sys.tb_sys_user_role ur
LEFT JOIN sys.tb_sys_user u ON ur.user_id = u.user_id AND (u.deleted IS NULL OR u.deleted = false)
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
LEFT JOIN sys.tb_sys_dept d ON u.dept_path LIKE CONCAT('%/', d.dept_id, '/%') AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON ur.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
WHERE ur.user_id = #{userId}
AND (ur.deleted IS NULL OR ur.deleted = false)
ORDER BY ur.create_time DESC
</select>
<!-- 根据条件查询系统用户角色关系列表 -->
<select id="getUserRoleByFilter" resultMap="UserDeptRoleVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
SELECT DISTINCT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
ur.optsn, ur.creator, ur.updater, ur.dept_path, ur.remark, ur.create_time, ur.update_time, ur.delete_time, ur.deleted
FROM sys.tb_sys_user_role ur
LEFT JOIN sys.tb_sys_user u ON ur.user_id = u.user_id AND (u.deleted IS NULL OR u.deleted = false)
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
LEFT JOIN sys.tb_sys_dept d ON u.dept_path LIKE CONCAT('%/', d.dept_id, '/%') AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON ur.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND ur.user_id = #{filter.userId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND ur.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND ur.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (ur.deleted IS NULL OR ur.deleted = false)
</where>
ORDER BY ur.create_time DESC
</select>
<!-- 根据条件查询系统用户角色关系分页列表 -->
<select id="getUserRolePageByFilter" resultMap="UserDeptRoleVOResultMap">
SELECT DISTINCT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
(SELECT m.module_id FROM sys.tb_sys_role_permission rp2
LEFT JOIN sys.tb_sys_permission p2 ON rp2.permission_id = p2.permission_id AND (p2.deleted IS NULL OR p2.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p2.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp2.role_id = r.role_id AND (rp2.deleted IS NULL OR rp2.deleted = false)
ORDER BY rp2.create_time ASC LIMIT 1) AS module_id,
(SELECT m.name FROM sys.tb_sys_role_permission rp2
LEFT JOIN sys.tb_sys_permission p2 ON rp2.permission_id = p2.permission_id AND (p2.deleted IS NULL OR p2.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p2.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp2.role_id = r.role_id AND (rp2.deleted IS NULL OR rp2.deleted = false)
ORDER BY rp2.create_time ASC LIMIT 1) AS module_name,
(SELECT m.description FROM sys.tb_sys_role_permission rp2
LEFT JOIN sys.tb_sys_permission p2 ON rp2.permission_id = p2.permission_id AND (p2.deleted IS NULL OR p2.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p2.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp2.role_id = r.role_id AND (rp2.deleted IS NULL OR rp2.deleted = false)
ORDER BY rp2.create_time ASC LIMIT 1) AS module_description,
ur.optsn, ur.creator, ur.updater, ur.dept_path, ur.remark, ur.create_time, ur.update_time, ur.delete_time, ur.deleted
FROM sys.tb_sys_user_role ur
LEFT JOIN sys.tb_sys_user u ON ur.user_id = u.user_id AND (u.deleted IS NULL OR u.deleted = false)
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
LEFT JOIN sys.tb_sys_dept d ON u.dept_path LIKE CONCAT('%/', d.dept_id, '/%') AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON ur.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND ur.user_id = #{filter.userId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND ur.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND ur.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (ur.deleted IS NULL OR ur.deleted = false)
</where>
ORDER BY ur.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统用户角色关系数量 -->
<select id="getUserRoleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_user_role
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,231 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.xyzh.system.mapper.view.TbSysViewMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysViewDTO">
<!-- 视图字段 -->
<id column="view_id" property="viewId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="url" property="url" jdbcType="VARCHAR"/>
<result column="component" property="component" jdbcType="VARCHAR"/>
<result column="icon" property="icon" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="layout" property="layout" jdbcType="VARCHAR"/>
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<!-- 基础字段 -->
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="DATE"/>
<result column="update_time" property="updateTime" jdbcType="DATE"/>
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
view_id, name, parent_id, url, component, icon, type, layout, order_num, description,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统视图(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertView" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
INSERT INTO sys.tb_sys_view
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段view_id, name, type, layout, order_num, optsn -->
view_id,
name,
type,
layout,
order_num,
optsn,
<!-- 可选字段parent_id, url, component, icon, description 及基础字段 -->
<if test="parentId != null and parentId != ''">parent_id,</if>
<if test="url != null and url != ''">url,</if>
<if test="component != null and component != ''">component,</if>
<if test="icon != null and icon != ''">icon,</if>
<if test="description != null and description != ''">description,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteTime != null">delete_time,</if>
<if test="deleted != null">deleted,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段对应的值 -->
#{viewId},
#{name},
#{type},
#{layout},
#{orderNum},
#{optsn},
<!-- 可选字段对应的值 -->
<if test="parentId != null and parentId != ''">#{parentId},</if>
<if test="url != null and url != ''">#{url},</if>
<if test="component != null and component != ''">#{component},</if>
<if test="icon != null and icon != ''">#{icon},</if>
<if test="description != null and description != ''">#{description},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteTime != null">#{deleteTime},</if>
<if test="deleted != null">#{deleted},</if>
</trim>
</insert>
<!-- 更新系统视图 -->
<update id="updateView" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
UPDATE sys.tb_sys_view
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="parentId != null">
parent_id = #{parentId},
</if>
<if test="url != null">
url = #{url},
</if>
<if test="component != null">
component = #{component},
</if>
<if test="icon != null">
icon = #{icon},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="layout != null">
layout = #{layout},
</if>
<if test="orderNum != null">
order_num = #{orderNum},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="deptPath != null and deptPath != ''">
dept_path = #{deptPath},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
WHERE view_id = #{viewId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统视图 -->
<update id="deleteView" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
UPDATE sys.tb_sys_view
SET deleted = true,
delete_time = NOW()
WHERE view_id = #{viewId}
</update>
<!-- 根据ID查询系统视图 -->
<select id="getViewById" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_view
WHERE view_id = #{viewId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统视图列表 -->
<select id="getViewByFilter" resultMap="BaseResultMap" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_view
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.type != null">
AND type = #{filter.type}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY order_num ASC, create_time DESC
</select>
<!-- 根据条件查询系统视图分页列表 -->
<select id="getViewPageByFilter" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_view
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.type != null">
AND type = #{filter.type}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY order_num ASC, create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统视图数量 -->
<select id="getViewCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
SELECT COUNT(1)
FROM sys.tb_sys_view
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.type != null">
AND type = #{filter.type}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>