✨ 生成权限相关CURD
This commit is contained in:
parent
95cb8bfa86
commit
4765a78468
|
@ -0,0 +1,69 @@
|
|||
package com.spring.step2.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.PermissionDto;
|
||||
import com.spring.step2.domain.entity.PermissionEntity;
|
||||
import com.spring.step2.domain.vo.PermissionVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.domain.vo.result.Result;
|
||||
import com.spring.step2.domain.vo.result.ResultCodeEnum;
|
||||
import com.spring.step2.service.PermissionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统权限表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Tag(name = "系统权限表", description = "系统权限表相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/coupon/permission")
|
||||
@RequiredArgsConstructor
|
||||
public class PermissionController {
|
||||
|
||||
private final PermissionService permissionService;
|
||||
|
||||
@Operation(summary = "分页查询系统权限表", description = "分页系统权限表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<PermissionVo>> getPermissionPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
PermissionDto dto) {
|
||||
Page<PermissionEntity> pageParams = new Page<>(page, limit);
|
||||
PageResult<PermissionVo> pageResult = permissionService.getPermissionPage(pageParams, dto);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加系统权限表", description = "添加系统权限表")
|
||||
@PostMapping()
|
||||
public Result<String> addPermission(@Valid @RequestBody PermissionDto dto) {
|
||||
permissionService.addPermission(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新系统权限表", description = "更新系统权限表")
|
||||
@PutMapping()
|
||||
public Result<String> updatePermission(@Valid @RequestBody PermissionDto dto) {
|
||||
permissionService.updatePermission(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除系统权限表", description = "删除系统权限表")
|
||||
@DeleteMapping()
|
||||
public Result<String> deletePermission(@RequestBody List<Long> ids) {
|
||||
permissionService.deletePermission(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.spring.step2.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.RoleDto;
|
||||
import com.spring.step2.domain.entity.RoleEntity;
|
||||
import com.spring.step2.domain.vo.RoleVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.domain.vo.result.Result;
|
||||
import com.spring.step2.domain.vo.result.ResultCodeEnum;
|
||||
import com.spring.step2.service.RoleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Tag(name = "系统角色表", description = "系统角色表相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/coupon/role")
|
||||
@RequiredArgsConstructor
|
||||
public class RoleController {
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
@Operation(summary = "分页查询系统角色表", description = "分页系统角色表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<RoleVo>> getRolePage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
RoleDto dto) {
|
||||
Page<RoleEntity> pageParams = new Page<>(page, limit);
|
||||
PageResult<RoleVo> pageResult = roleService.getRolePage(pageParams, dto);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加系统角色表", description = "添加系统角色表")
|
||||
@PostMapping()
|
||||
public Result<String> addRole(@Valid @RequestBody RoleDto dto) {
|
||||
roleService.addRole(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新系统角色表", description = "更新系统角色表")
|
||||
@PutMapping()
|
||||
public Result<String> updateRole(@Valid @RequestBody RoleDto dto) {
|
||||
roleService.updateRole(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除系统角色表", description = "删除系统角色表")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteRole(@RequestBody List<Long> ids) {
|
||||
roleService.deleteRole(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.spring.step2.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.RolePermissionDto;
|
||||
import com.spring.step2.domain.entity.RolePermissionEntity;
|
||||
import com.spring.step2.domain.vo.RolePermissionVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.domain.vo.result.Result;
|
||||
import com.spring.step2.domain.vo.result.ResultCodeEnum;
|
||||
import com.spring.step2.service.RolePermissionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色权限关联表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Tag(name = "角色权限关联表", description = "角色权限关联表相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/coupon/role-permission")
|
||||
@RequiredArgsConstructor
|
||||
public class RolePermissionController {
|
||||
|
||||
private final RolePermissionService rolePermissionService;
|
||||
|
||||
@Operation(summary = "分页查询角色权限关联表", description = "分页角色权限关联表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<RolePermissionVo>> getRolePermissionPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
RolePermissionDto dto) {
|
||||
Page<RolePermissionEntity> pageParams = new Page<>(page, limit);
|
||||
PageResult<RolePermissionVo> pageResult = rolePermissionService.getRolePermissionPage(pageParams, dto);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加角色权限关联表", description = "添加角色权限关联表")
|
||||
@PostMapping()
|
||||
public Result<String> addRolePermission(@Valid @RequestBody RolePermissionDto dto) {
|
||||
rolePermissionService.addRolePermission(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新角色权限关联表", description = "更新角色权限关联表")
|
||||
@PutMapping()
|
||||
public Result<String> updateRolePermission(@Valid @RequestBody RolePermissionDto dto) {
|
||||
rolePermissionService.updateRolePermission(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除角色权限关联表", description = "删除角色权限关联表")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteRolePermission(@RequestBody List<Long> ids) {
|
||||
rolePermissionService.deleteRolePermission(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.spring.step2.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.UserDto;
|
||||
import com.spring.step2.domain.entity.UserEntity;
|
||||
|
@ -19,21 +20,21 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* 用户 前端控制器
|
||||
* 用户基本信息表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Tag(name = "用户", description = "用户相关接口")
|
||||
@Tag(name = "用户基本信息表", description = "用户基本信息表相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/user/user")
|
||||
@RequestMapping("/api/coupon/user")
|
||||
@RequiredArgsConstructor
|
||||
public class UserController {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@Operation(summary = "分页查询用户", description = "分页用户")
|
||||
@Operation(summary = "分页查询用户基本信息表", description = "分页用户基本信息表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<UserVo>> getUserPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
|
@ -46,21 +47,21 @@ public class UserController {
|
|||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加用户", description = "添加用户")
|
||||
@Operation(summary = "添加用户基本信息表", description = "添加用户基本信息表")
|
||||
@PostMapping()
|
||||
public Result<String> addUser(@Valid @RequestBody UserDto dto) {
|
||||
userService.addUser(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新用户", description = "更新用户")
|
||||
@Operation(summary = "更新用户基本信息表", description = "更新用户基本信息表")
|
||||
@PutMapping()
|
||||
public Result<String> updateUser(@Valid @RequestBody UserDto dto) {
|
||||
userService.updateUser(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除用户", description = "删除用户")
|
||||
@Operation(summary = "删除用户基本信息表", description = "删除用户基本信息表")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteUser(@RequestBody List<Long> ids) {
|
||||
userService.deleteUser(ids);
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package com.spring.step2.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.UserRoleDto;
|
||||
import com.spring.step2.domain.entity.UserRoleEntity;
|
||||
import com.spring.step2.domain.vo.UserRoleVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.domain.vo.result.Result;
|
||||
import com.spring.step2.domain.vo.result.ResultCodeEnum;
|
||||
import com.spring.step2.service.UserRoleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Tag(name = "用户角色关联表", description = "用户角色关联表相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/coupon/user-role")
|
||||
@RequiredArgsConstructor
|
||||
public class UserRoleController {
|
||||
|
||||
private final UserRoleService userRoleService;
|
||||
|
||||
@Operation(summary = "分页查询用户角色关联表", description = "分页用户角色关联表")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<UserRoleVo>> getUserRolePage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
UserRoleDto dto) {
|
||||
Page<UserRoleEntity> pageParams = new Page<>(page, limit);
|
||||
PageResult<UserRoleVo> pageResult = userRoleService.getUserRolePage(pageParams, dto);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加用户角色关联表", description = "添加用户角色关联表")
|
||||
@PostMapping()
|
||||
public Result<String> addUserRole(@Valid @RequestBody UserRoleDto dto) {
|
||||
userRoleService.addUserRole(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新用户角色关联表", description = "更新用户角色关联表")
|
||||
@PutMapping()
|
||||
public Result<String> updateUserRole(@Valid @RequestBody UserRoleDto dto) {
|
||||
userRoleService.updateUserRole(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除用户角色关联表", description = "删除用户角色关联表")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteUserRole(@RequestBody List<Long> ids) {
|
||||
userRoleService.deleteUserRole(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.spring.step2.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.UsersDto;
|
||||
import com.spring.step2.domain.entity.UsersEntity;
|
||||
import com.spring.step2.domain.vo.UsersVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.domain.vo.result.Result;
|
||||
import com.spring.step2.domain.vo.result.ResultCodeEnum;
|
||||
import com.spring.step2.service.UsersService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
*/
|
||||
@Tag(name = "Csharp用户接口查询", description = "用户接口查询相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/user/users")
|
||||
@RequiredArgsConstructor
|
||||
public class UsersController {
|
||||
|
||||
private final UsersService usersService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页")
|
||||
@GetMapping("{page}/{limit}")
|
||||
public Result<PageResult<UsersVo>> getUsersPage(
|
||||
@Parameter(name = "page", description = "当前页", required = true)
|
||||
@PathVariable("page") Integer page,
|
||||
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||
@PathVariable("limit") Integer limit,
|
||||
UsersDto dto) {
|
||||
Page<UsersEntity> pageParams = new Page<>(page, limit);
|
||||
PageResult<UsersVo> pageResult = usersService.getUsersPage(pageParams, dto);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "添加", description = "添加")
|
||||
@PostMapping()
|
||||
public Result<String> addUsers(@Valid @RequestBody UsersDto dto) {
|
||||
usersService.addUsers(dto);
|
||||
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新", description = "更新")
|
||||
@PutMapping()
|
||||
public Result<String> updateUsers(@Valid @RequestBody UsersDto dto) {
|
||||
usersService.updateUsers(dto);
|
||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除", description = "删除")
|
||||
@DeleteMapping()
|
||||
public Result<String> deleteUsers(@RequestBody List<Long> ids) {
|
||||
usersService.deleteUsers(ids);
|
||||
return Result.success(ResultCodeEnum.DELETE_SUCCESS);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.spring.step2.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "PermissionDTO对象", title = "系统权限表", description = "系统权限表的DTO对象")
|
||||
public class PermissionDto {
|
||||
|
||||
@Schema(name = "id", title = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "permissionCode", title = "权限编码")
|
||||
private String permissionCode;
|
||||
|
||||
@Schema(name = "description", title = "权限描述")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "remark", title = "备注信息")
|
||||
private String remark;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.spring.step2.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "RoleDTO对象", title = "系统角色表", description = "系统角色表的DTO对象")
|
||||
public class RoleDto {
|
||||
|
||||
@Schema(name = "id", title = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "roleName", title = "角色名称")
|
||||
private String roleName;
|
||||
|
||||
@Schema(name = "description", title = "角色描述")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "remark", title = "备注信息")
|
||||
private String remark;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.spring.step2.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "RolePermissionDTO对象", title = "角色权限关联表", description = "角色权限关联表的DTO对象")
|
||||
public class RolePermissionDto {
|
||||
|
||||
@Schema(name = "id", title = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "roleId", title = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(name = "permissionId", title = "权限ID")
|
||||
private Long permissionId;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.spring.step2.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "UserRoleDTO对象", title = "用户角色关联表", description = "用户角色关联表的DTO对象")
|
||||
public class UserRoleDto {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "roleId", title = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(name = "userId", title = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package com.spring.step2.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Schema(name = "UsersDTO对象", title = "", description = "的DTO对象")
|
||||
public class UsersDto {
|
||||
|
||||
@Schema(name = "username", title = "username")
|
||||
private String username;
|
||||
|
||||
@Schema(name = "password", title = "password")
|
||||
private String password;
|
||||
|
||||
@Schema(name = "enabled", title = "enabled")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(name = "email", title = "邮箱")
|
||||
private String email;
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.spring.step2.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_permission")
|
||||
@Schema(name = "Permission对象", title = "系统权限表", description = "系统权限表的实体类对象")
|
||||
public class PermissionEntity extends BaseEntity {
|
||||
|
||||
@Schema(name = "permissionCode", title = "权限编码")
|
||||
private String permissionCode;
|
||||
|
||||
@Schema(name = "description", title = "权限描述")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "remark", title = "备注信息")
|
||||
private String remark;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.spring.step2.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_role")
|
||||
@Schema(name = "Role对象", title = "系统角色表", description = "系统角色表的实体类对象")
|
||||
public class RoleEntity extends BaseEntity {
|
||||
|
||||
@Schema(name = "roleName", title = "角色名称")
|
||||
private String roleName;
|
||||
|
||||
@Schema(name = "description", title = "角色描述")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "remark", title = "备注信息")
|
||||
private String remark;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.spring.step2.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_role_permission")
|
||||
@Schema(name = "RolePermission对象", title = "角色权限关联表", description = "角色权限关联表的实体类对象")
|
||||
public class RolePermissionEntity extends BaseEntity {
|
||||
|
||||
@Schema(name = "roleId", title = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(name = "permissionId", title = "权限ID")
|
||||
private Long permissionId;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.spring.step2.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("t_user_role")
|
||||
@Schema(name = "UserRole对象", title = "用户角色关联表", description = "用户角色关联表的实体类对象")
|
||||
public class UserRoleEntity extends BaseEntity {
|
||||
|
||||
@Schema(name = "roleId", title = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(name = "userId", title = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package com.spring.step2.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
@TableName("users")
|
||||
@Schema(name = "Users对象", title = "", description = "的实体类对象")
|
||||
public class UsersEntity {
|
||||
|
||||
@Schema(name = "username", title = "username")
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String username;
|
||||
|
||||
@Schema(name = "password", title = "password")
|
||||
private String password;
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(name = "email", title = "邮箱")
|
||||
private String email;
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.spring.step2.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "PermissionVO对象", title = "系统权限表", description = "系统权限表的VO对象")
|
||||
public class PermissionVo {
|
||||
|
||||
@Schema(name = "id", title = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "permissionCode", title = "权限编码")
|
||||
private String permissionCode;
|
||||
|
||||
@Schema(name = "description", title = "权限描述")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "remark", title = "备注信息")
|
||||
private String remark;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.spring.step2.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "RolePermissionVO对象", title = "角色权限关联表", description = "角色权限关联表的VO对象")
|
||||
public class RolePermissionVo {
|
||||
|
||||
@Schema(name = "id", title = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "roleId", title = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(name = "permissionId", title = "权限ID")
|
||||
private Long permissionId;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.spring.step2.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "RoleVO对象", title = "系统角色表", description = "系统角色表的VO对象")
|
||||
public class RoleVo {
|
||||
|
||||
@Schema(name = "id", title = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "roleName", title = "角色名称")
|
||||
private String roleName;
|
||||
|
||||
@Schema(name = "description", title = "角色描述")
|
||||
private String description;
|
||||
|
||||
@Schema(name = "remark", title = "备注信息")
|
||||
private String remark;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.spring.step2.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "UserRoleVO对象", title = "用户角色关联表", description = "用户角色关联表的VO对象")
|
||||
public class UserRoleVo {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "roleId", title = "角色ID")
|
||||
private Long roleId;
|
||||
|
||||
@Schema(name = "userId", title = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(name = "createTime", title = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否删除:0-未删除,1-已删除")
|
||||
private Boolean isDeleted;
|
||||
|
||||
}
|
||||
|
|
@ -10,11 +10,11 @@ import java.time.LocalDateTime;
|
|||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "UserVO对象", title = "用户", description = "用户的VO对象")
|
||||
@Schema(name = "UserVO对象", title = "用户基本信息表", description = "用户基本信息表的VO对象")
|
||||
public class UserVo {
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
private String id;
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "username", title = "用户名")
|
||||
private String username;
|
||||
|
@ -31,10 +31,10 @@ public class UserVo {
|
|||
@Schema(name = "updateTime", title = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(name = "createUser", title = "创建用户")
|
||||
@Schema(name = "createUser", title = "创建用户ID")
|
||||
private Long createUser;
|
||||
|
||||
@Schema(name = "updateUser", title = "更新用户")
|
||||
@Schema(name = "updateUser", title = "更新用户ID")
|
||||
private Long updateUser;
|
||||
|
||||
@Schema(name = "isDeleted", title = "是否被删除")
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package com.spring.step2.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Schema(name = "UsersVO对象", title = "", description = "的VO对象")
|
||||
public class UsersVo {
|
||||
|
||||
@Schema(name = "username", title = "username")
|
||||
private String username;
|
||||
|
||||
@Schema(name = "password", title = "password")
|
||||
private String password;
|
||||
|
||||
@Schema(name = "enabled", title = "enabled")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(name = "id", title = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(name = "email", title = "邮箱")
|
||||
private String email;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.spring.step2.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.PermissionDto;
|
||||
import com.spring.step2.domain.entity.PermissionEntity;
|
||||
import com.spring.step2.domain.vo.PermissionVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统权限表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Mapper
|
||||
public interface PermissionMapper extends BaseMapper<PermissionEntity> {
|
||||
|
||||
/**
|
||||
* * 分页查询系统权限表内容
|
||||
*
|
||||
* @param pageParams 系统权限表分页参数
|
||||
* @param dto 系统权限表查询表单
|
||||
* @return 系统权限表分页结果
|
||||
*/
|
||||
IPage<PermissionVo> selectListByPage(@Param("page") Page<PermissionEntity> pageParams, @Param("dto") PermissionDto dto);
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.spring.step2.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.RoleDto;
|
||||
import com.spring.step2.domain.entity.RoleEntity;
|
||||
import com.spring.step2.domain.vo.RoleVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapper<RoleEntity> {
|
||||
|
||||
/**
|
||||
* * 分页查询系统角色表内容
|
||||
*
|
||||
* @param pageParams 系统角色表分页参数
|
||||
* @param dto 系统角色表查询表单
|
||||
* @return 系统角色表分页结果
|
||||
*/
|
||||
IPage<RoleVo> selectListByPage(@Param("page") Page<RoleEntity> pageParams, @Param("dto") RoleDto dto);
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.spring.step2.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.RolePermissionDto;
|
||||
import com.spring.step2.domain.entity.RolePermissionEntity;
|
||||
import com.spring.step2.domain.vo.RolePermissionVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色权限关联表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Mapper
|
||||
public interface RolePermissionMapper extends BaseMapper<RolePermissionEntity> {
|
||||
|
||||
/**
|
||||
* * 分页查询角色权限关联表内容
|
||||
*
|
||||
* @param pageParams 角色权限关联表分页参数
|
||||
* @param dto 角色权限关联表查询表单
|
||||
* @return 角色权限关联表分页结果
|
||||
*/
|
||||
IPage<RolePermissionVo> selectListByPage(@Param("page") Page<RolePermissionEntity> pageParams, @Param("dto") RolePermissionDto dto);
|
||||
|
||||
}
|
|
@ -1,34 +1,50 @@
|
|||
package com.spring.step2.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.UserDto;
|
||||
import com.spring.step2.domain.entity.PermissionEntity;
|
||||
import com.spring.step2.domain.entity.UserEntity;
|
||||
import com.spring.step2.domain.vo.UserVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户 Mapper 接口
|
||||
* 用户基本信息表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<UserEntity> {
|
||||
|
||||
/**
|
||||
* * 分页查询用户内容
|
||||
* * 分页查询用户基本信息表内容
|
||||
*
|
||||
* @param pageParams 用户分页参数
|
||||
* @param dto 用户查询表单
|
||||
* @return 用户分页结果
|
||||
* @param pageParams 用户基本信息表分页参数
|
||||
* @param dto 用户基本信息表查询表单
|
||||
* @return 用户基本信息表分页结果
|
||||
*/
|
||||
IPage<UserVo> selectListByPage(@Param("page") Page<UserEntity> pageParams, @Param("dto") UserDto dto);
|
||||
|
||||
/**
|
||||
* 根据用户id查找当前用户的权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<PermissionEntity> selectPermissionByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户名查询当前用户
|
||||
*
|
||||
* @param username 用户名
|
||||
* @return 用户 {@link UserEntity}
|
||||
*/
|
||||
UserEntity selectByUsername(String username);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.spring.step2.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.UserRoleDto;
|
||||
import com.spring.step2.domain.entity.UserRoleEntity;
|
||||
import com.spring.step2.domain.vo.UserRoleVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserRoleMapper extends BaseMapper<UserRoleEntity> {
|
||||
|
||||
/**
|
||||
* * 分页查询用户角色关联表内容
|
||||
*
|
||||
* @param pageParams 用户角色关联表分页参数
|
||||
* @param dto 用户角色关联表查询表单
|
||||
* @return 用户角色关联表分页结果
|
||||
*/
|
||||
IPage<UserRoleVo> selectListByPage(@Param("page") Page<UserRoleEntity> pageParams, @Param("dto") UserRoleDto dto);
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package com.spring.step2.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.spring.step2.domain.dto.UsersDto;
|
||||
import com.spring.step2.domain.entity.UsersEntity;
|
||||
import com.spring.step2.domain.vo.UsersVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Mapper
|
||||
public interface UsersMapper extends BaseMapper<UsersEntity> {
|
||||
|
||||
/**
|
||||
* * 分页查询内容
|
||||
*
|
||||
* @param pageParams 分页参数
|
||||
* @param dto 查询表单
|
||||
* @return 分页结果
|
||||
*/
|
||||
IPage<UsersVo> selectListByPage(@Param("page") Page<UsersEntity> pageParams, @Param("dto") UsersDto dto);
|
||||
|
||||
}
|
|
@ -1,15 +1,18 @@
|
|||
package com.spring.step2.security.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.spring.step2.domain.entity.PermissionEntity;
|
||||
import com.spring.step2.domain.entity.UserEntity;
|
||||
import com.spring.step2.mapper.UserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DbUserDetailService implements UserDetailsService {
|
||||
|
@ -19,17 +22,27 @@ public class DbUserDetailService implements UserDetailsService {
|
|||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
// 查询当前用户
|
||||
QueryWrapper<UserEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(UserEntity::getUsername, username);
|
||||
UserEntity userEntity = userMapper.selectOne(wrapper);
|
||||
UserEntity userEntity = userMapper.selectByUsername(username);
|
||||
|
||||
// 判断当前用户是否存在
|
||||
if (userEntity == null) {
|
||||
throw new UsernameNotFoundException("用户不存在");
|
||||
}
|
||||
|
||||
return User.builder().username(userEntity.getUsername())
|
||||
// 设置用户权限
|
||||
List<SimpleGrantedAuthority> authorities = findPermissionByUserId(userEntity.getId()).stream()
|
||||
.map(SimpleGrantedAuthority::new)
|
||||
.toList();
|
||||
|
||||
return User.builder()
|
||||
.username(userEntity.getUsername())
|
||||
.password(userEntity.getPassword())
|
||||
.authorities(authorities)
|
||||
.build();
|
||||
}
|
||||
|
||||
public List<String> findPermissionByUserId(Long userId) {
|
||||
List<PermissionEntity> permissionList = userMapper.selectPermissionByUserId(userId);
|
||||
return permissionList.stream().map(PermissionEntity::getPermissionCode).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.spring.step2.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.spring.step2.domain.dto.PermissionDto;
|
||||
import com.spring.step2.domain.entity.PermissionEntity;
|
||||
import com.spring.step2.domain.vo.PermissionVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统权限表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
public interface PermissionService extends IService<PermissionEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询系统权限表
|
||||
*
|
||||
* @return {@link PermissionVo}
|
||||
*/
|
||||
PageResult<PermissionVo> getPermissionPage(Page<PermissionEntity> pageParams, PermissionDto dto);
|
||||
|
||||
/**
|
||||
* 添加系统权限表
|
||||
*
|
||||
* @param dto {@link PermissionDto} 添加表单
|
||||
*/
|
||||
void addPermission(PermissionDto dto);
|
||||
|
||||
/**
|
||||
* 更新系统权限表
|
||||
*
|
||||
* @param dto {@link PermissionDto} 更新表单
|
||||
*/
|
||||
void updatePermission(PermissionDto dto);
|
||||
|
||||
/**
|
||||
* 删除|批量删除系统权限表类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deletePermission(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.spring.step2.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.spring.step2.domain.dto.RolePermissionDto;
|
||||
import com.spring.step2.domain.entity.RolePermissionEntity;
|
||||
import com.spring.step2.domain.vo.RolePermissionVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色权限关联表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
public interface RolePermissionService extends IService<RolePermissionEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询角色权限关联表
|
||||
*
|
||||
* @return {@link RolePermissionVo}
|
||||
*/
|
||||
PageResult<RolePermissionVo> getRolePermissionPage(Page<RolePermissionEntity> pageParams, RolePermissionDto dto);
|
||||
|
||||
/**
|
||||
* 添加角色权限关联表
|
||||
*
|
||||
* @param dto {@link RolePermissionDto} 添加表单
|
||||
*/
|
||||
void addRolePermission(RolePermissionDto dto);
|
||||
|
||||
/**
|
||||
* 更新角色权限关联表
|
||||
*
|
||||
* @param dto {@link RolePermissionDto} 更新表单
|
||||
*/
|
||||
void updateRolePermission(RolePermissionDto dto);
|
||||
|
||||
/**
|
||||
* 删除|批量删除角色权限关联表类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteRolePermission(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.spring.step2.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.spring.step2.domain.dto.RoleDto;
|
||||
import com.spring.step2.domain.entity.RoleEntity;
|
||||
import com.spring.step2.domain.vo.RoleVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
public interface RoleService extends IService<RoleEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询系统角色表
|
||||
*
|
||||
* @return {@link RoleVo}
|
||||
*/
|
||||
PageResult<RoleVo> getRolePage(Page<RoleEntity> pageParams, RoleDto dto);
|
||||
|
||||
/**
|
||||
* 添加系统角色表
|
||||
*
|
||||
* @param dto {@link RoleDto} 添加表单
|
||||
*/
|
||||
void addRole(RoleDto dto);
|
||||
|
||||
/**
|
||||
* 更新系统角色表
|
||||
*
|
||||
* @param dto {@link RoleDto} 更新表单
|
||||
*/
|
||||
void updateRole(RoleDto dto);
|
||||
|
||||
/**
|
||||
* 删除|批量删除系统角色表类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteRole(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.spring.step2.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.spring.step2.domain.dto.UserRoleDto;
|
||||
import com.spring.step2.domain.entity.UserRoleEntity;
|
||||
import com.spring.step2.domain.vo.UserRoleVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
public interface UserRoleService extends IService<UserRoleEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询用户角色关联表
|
||||
*
|
||||
* @return {@link UserRoleVo}
|
||||
*/
|
||||
PageResult<UserRoleVo> getUserRolePage(Page<UserRoleEntity> pageParams, UserRoleDto dto);
|
||||
|
||||
/**
|
||||
* 添加用户角色关联表
|
||||
*
|
||||
* @param dto {@link UserRoleDto} 添加表单
|
||||
*/
|
||||
void addUserRole(UserRoleDto dto);
|
||||
|
||||
/**
|
||||
* 更新用户角色关联表
|
||||
*
|
||||
* @param dto {@link UserRoleDto} 更新表单
|
||||
*/
|
||||
void updateUserRole(UserRoleDto dto);
|
||||
|
||||
/**
|
||||
* 删除|批量删除用户角色关联表类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteUserRole(List<Long> ids);
|
||||
}
|
|
@ -11,37 +11,37 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* 用户 服务类
|
||||
* 用户基本信息表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
public interface UserService extends IService<UserEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询用户
|
||||
* 分页查询用户基本信息表
|
||||
*
|
||||
* @return {@link UserVo}
|
||||
*/
|
||||
PageResult<UserVo> getUserPage(Page<UserEntity> pageParams, UserDto dto);
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
* 添加用户基本信息表
|
||||
*
|
||||
* @param dto {@link UserDto} 添加表单
|
||||
*/
|
||||
void addUser(UserDto dto);
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
* 更新用户基本信息表
|
||||
*
|
||||
* @param dto {@link UserDto} 更新表单
|
||||
*/
|
||||
void updateUser(UserDto dto);
|
||||
|
||||
/**
|
||||
* 删除|批量删除用户类型
|
||||
* 删除|批量删除用户基本信息表类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package com.spring.step2.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.spring.step2.domain.dto.UsersDto;
|
||||
import com.spring.step2.domain.entity.UsersEntity;
|
||||
import com.spring.step2.domain.vo.UsersVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
*/
|
||||
public interface UsersService extends IService<UsersEntity> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @return {@link UsersVo}
|
||||
*/
|
||||
PageResult<UsersVo> getUsersPage(Page<UsersEntity> pageParams, UsersDto dto);
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param dto {@link UsersDto} 添加表单
|
||||
*/
|
||||
void addUsers(UsersDto dto);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param dto {@link UsersDto} 更新表单
|
||||
*/
|
||||
void updateUsers(UsersDto dto);
|
||||
|
||||
/**
|
||||
* 删除|批量删除类型
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
void deleteUsers(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.spring.step2.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.spring.step2.domain.dto.PermissionDto;
|
||||
import com.spring.step2.domain.entity.PermissionEntity;
|
||||
import com.spring.step2.domain.vo.PermissionVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.mapper.PermissionMapper;
|
||||
import com.spring.step2.service.PermissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统权限表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, PermissionEntity> implements PermissionService {
|
||||
|
||||
/**
|
||||
* * 系统权限表 服务实现类
|
||||
*
|
||||
* @param pageParams 系统权限表分页查询page对象
|
||||
* @param dto 系统权限表分页查询对象
|
||||
* @return 查询分页系统权限表返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<PermissionVo> getPermissionPage(Page<PermissionEntity> pageParams, PermissionDto dto) {
|
||||
IPage<PermissionVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
return PageResult.<PermissionVo>builder()
|
||||
.list(page.getRecords())
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加系统权限表
|
||||
*
|
||||
* @param dto 系统权限表添加
|
||||
*/
|
||||
@Override
|
||||
public void addPermission(PermissionDto dto) {
|
||||
PermissionEntity permission = new PermissionEntity();
|
||||
BeanUtils.copyProperties(dto, permission);
|
||||
save(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新系统权限表
|
||||
*
|
||||
* @param dto 系统权限表更新
|
||||
*/
|
||||
@Override
|
||||
public void updatePermission(PermissionDto dto) {
|
||||
PermissionEntity permission = new PermissionEntity();
|
||||
BeanUtils.copyProperties(dto, permission);
|
||||
updateById(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除系统权限表
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deletePermission(List<Long> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.spring.step2.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.spring.step2.domain.dto.RolePermissionDto;
|
||||
import com.spring.step2.domain.entity.RolePermissionEntity;
|
||||
import com.spring.step2.domain.vo.RolePermissionVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.mapper.RolePermissionMapper;
|
||||
import com.spring.step2.service.RolePermissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 角色权限关联表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermissionEntity> implements RolePermissionService {
|
||||
|
||||
/**
|
||||
* * 角色权限关联表 服务实现类
|
||||
*
|
||||
* @param pageParams 角色权限关联表分页查询page对象
|
||||
* @param dto 角色权限关联表分页查询对象
|
||||
* @return 查询分页角色权限关联表返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<RolePermissionVo> getRolePermissionPage(Page<RolePermissionEntity> pageParams, RolePermissionDto dto) {
|
||||
IPage<RolePermissionVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
return PageResult.<RolePermissionVo>builder()
|
||||
.list(page.getRecords())
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加角色权限关联表
|
||||
*
|
||||
* @param dto 角色权限关联表添加
|
||||
*/
|
||||
@Override
|
||||
public void addRolePermission(RolePermissionDto dto) {
|
||||
RolePermissionEntity rolePermission = new RolePermissionEntity();
|
||||
BeanUtils.copyProperties(dto, rolePermission);
|
||||
save(rolePermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新角色权限关联表
|
||||
*
|
||||
* @param dto 角色权限关联表更新
|
||||
*/
|
||||
@Override
|
||||
public void updateRolePermission(RolePermissionDto dto) {
|
||||
RolePermissionEntity rolePermission = new RolePermissionEntity();
|
||||
BeanUtils.copyProperties(dto, rolePermission);
|
||||
updateById(rolePermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除角色权限关联表
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteRolePermission(List<Long> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.spring.step2.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.spring.step2.domain.dto.RoleDto;
|
||||
import com.spring.step2.domain.entity.RoleEntity;
|
||||
import com.spring.step2.domain.vo.RoleVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.mapper.RoleMapper;
|
||||
import com.spring.step2.service.RoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统角色表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RoleEntity> implements RoleService {
|
||||
|
||||
/**
|
||||
* * 系统角色表 服务实现类
|
||||
*
|
||||
* @param pageParams 系统角色表分页查询page对象
|
||||
* @param dto 系统角色表分页查询对象
|
||||
* @return 查询分页系统角色表返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<RoleVo> getRolePage(Page<RoleEntity> pageParams, RoleDto dto) {
|
||||
IPage<RoleVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
return PageResult.<RoleVo>builder()
|
||||
.list(page.getRecords())
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加系统角色表
|
||||
*
|
||||
* @param dto 系统角色表添加
|
||||
*/
|
||||
@Override
|
||||
public void addRole(RoleDto dto) {
|
||||
RoleEntity role = new RoleEntity();
|
||||
BeanUtils.copyProperties(dto, role);
|
||||
save(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新系统角色表
|
||||
*
|
||||
* @param dto 系统角色表更新
|
||||
*/
|
||||
@Override
|
||||
public void updateRole(RoleDto dto) {
|
||||
RoleEntity role = new RoleEntity();
|
||||
BeanUtils.copyProperties(dto, role);
|
||||
updateById(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除系统角色表
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteRole(List<Long> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.spring.step2.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.spring.step2.domain.dto.UserRoleDto;
|
||||
import com.spring.step2.domain.entity.UserRoleEntity;
|
||||
import com.spring.step2.domain.vo.UserRoleVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.mapper.UserRoleMapper;
|
||||
import com.spring.step2.service.UserRoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户角色关联表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRoleEntity> implements UserRoleService {
|
||||
|
||||
/**
|
||||
* * 用户角色关联表 服务实现类
|
||||
*
|
||||
* @param pageParams 用户角色关联表分页查询page对象
|
||||
* @param dto 用户角色关联表分页查询对象
|
||||
* @return 查询分页用户角色关联表返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<UserRoleVo> getUserRolePage(Page<UserRoleEntity> pageParams, UserRoleDto dto) {
|
||||
IPage<UserRoleVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
return PageResult.<UserRoleVo>builder()
|
||||
.list(page.getRecords())
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户角色关联表
|
||||
*
|
||||
* @param dto 用户角色关联表添加
|
||||
*/
|
||||
@Override
|
||||
public void addUserRole(UserRoleDto dto) {
|
||||
UserRoleEntity userRole = new UserRoleEntity();
|
||||
BeanUtils.copyProperties(dto, userRole);
|
||||
save(userRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户角色关联表
|
||||
*
|
||||
* @param dto 用户角色关联表更新
|
||||
*/
|
||||
@Override
|
||||
public void updateUserRole(UserRoleDto dto) {
|
||||
UserRoleEntity userRole = new UserRoleEntity();
|
||||
BeanUtils.copyProperties(dto, userRole);
|
||||
updateById(userRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除用户角色关联表
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteUserRole(List<Long> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
}
|
|
@ -20,11 +20,11 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* <p>
|
||||
* 用户 服务实现类
|
||||
* 用户基本信息表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
* @since 2025-07-11 22:36:53
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Service
|
||||
|
@ -35,11 +35,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
|||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
* * 用户 服务实现类
|
||||
* * 用户基本信息表 服务实现类
|
||||
*
|
||||
* @param pageParams 用户分页查询page对象
|
||||
* @param dto 用户分页查询对象
|
||||
* @return 查询分页用户返回对象
|
||||
* @param pageParams 用户基本信息表分页查询page对象
|
||||
* @param dto 用户基本信息表分页查询对象
|
||||
* @return 查询分页用户基本信息表返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<UserVo> getUserPage(Page<UserEntity> pageParams, UserDto dto) {
|
||||
|
@ -54,9 +54,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
|||
}
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
* 添加用户基本信息表
|
||||
*
|
||||
* @param dto 用户添加
|
||||
* @param dto 用户基本信息表添加
|
||||
*/
|
||||
@Override
|
||||
public void addUser(UserDto dto) {
|
||||
|
@ -72,9 +72,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
|||
}
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
* 更新用户基本信息表
|
||||
*
|
||||
* @param dto 用户更新
|
||||
* @param dto 用户基本信息表更新
|
||||
*/
|
||||
@Override
|
||||
public void updateUser(UserDto dto) {
|
||||
|
@ -84,7 +84,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
|
|||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除用户
|
||||
* 删除|批量删除用户基本信息表
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
package com.spring.step2.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.spring.step2.domain.dto.UsersDto;
|
||||
import com.spring.step2.domain.entity.UsersEntity;
|
||||
import com.spring.step2.domain.vo.UsersVo;
|
||||
import com.spring.step2.domain.vo.result.PageResult;
|
||||
import com.spring.step2.mapper.UsersMapper;
|
||||
import com.spring.step2.service.UsersService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2025-07-11 14:49:46
|
||||
*/
|
||||
@DS("testJwt")
|
||||
@Service
|
||||
@Transactional
|
||||
@RequiredArgsConstructor
|
||||
public class UsersServiceImpl extends ServiceImpl<UsersMapper, UsersEntity> implements UsersService {
|
||||
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
* * 服务实现类
|
||||
*
|
||||
* @param pageParams 分页查询page对象
|
||||
* @param dto 分页查询对象
|
||||
* @return 查询分页返回对象
|
||||
*/
|
||||
@Override
|
||||
public PageResult<UsersVo> getUsersPage(Page<UsersEntity> pageParams, UsersDto dto) {
|
||||
IPage<UsersVo> page = baseMapper.selectListByPage(pageParams, dto);
|
||||
|
||||
return PageResult.<UsersVo>builder()
|
||||
.list(page.getRecords())
|
||||
.pageNo(page.getCurrent())
|
||||
.pageSize(page.getSize())
|
||||
.total(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param dto 添加
|
||||
*/
|
||||
@Override
|
||||
public void addUsers(UsersDto dto) {
|
||||
UsersEntity user = new UsersEntity();
|
||||
BeanUtils.copyProperties(dto, user);
|
||||
|
||||
// 设置用户密码
|
||||
String password = user.getPassword();
|
||||
String encodePassword = passwordEncoder.encode(password);
|
||||
user.setPassword(encodePassword);
|
||||
|
||||
save(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param dto 更新
|
||||
*/
|
||||
@Override
|
||||
public void updateUsers(UsersDto dto) {
|
||||
UsersEntity users = new UsersEntity();
|
||||
BeanUtils.copyProperties(dto, users);
|
||||
updateById(users);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除|批量删除
|
||||
*
|
||||
* @param ids 删除id列表
|
||||
*/
|
||||
@Override
|
||||
public void deleteUsers(List<Long> ids) {
|
||||
removeByIds(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.spring.step2.mapper.PermissionMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.spring.step2.domain.entity.PermissionEntity">
|
||||
<id column="id" property="id"/>
|
||||
<id column="permission_code" property="permissionCode"/>
|
||||
<id column="description" property="description"/>
|
||||
<id column="remark" property="remark"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,permission_code,description,remark,create_time,update_time,create_user,update_user,is_deleted
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询系统权限表内容 -->
|
||||
<select id="selectListByPage" resultType="com.spring.step2.domain.vo.PermissionVo">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from t_permission
|
||||
<where>
|
||||
is_deleted = 0
|
||||
<if test="dto.permissionCode != null and dto.permissionCode != ''">
|
||||
and permission_code like CONCAT('%',#{dto.permissionCode},'%')
|
||||
</if>
|
||||
<if test="dto.description != null and dto.description != ''">
|
||||
and description like CONCAT('%',#{dto.description},'%')
|
||||
</if>
|
||||
<if test="dto.remark != null and dto.remark != ''">
|
||||
and remark like CONCAT('%',#{dto.remark},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.spring.step2.mapper.RoleMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.spring.step2.domain.entity.RoleEntity">
|
||||
<id column="id" property="id"/>
|
||||
<id column="role_name" property="roleName"/>
|
||||
<id column="description" property="description"/>
|
||||
<id column="remark" property="remark"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,role_name,description,remark,create_time,update_time,create_user,update_user,is_deleted
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询系统角色表内容 -->
|
||||
<select id="selectListByPage" resultType="com.spring.step2.domain.vo.RoleVo">
|
||||
select
|
||||
*
|
||||
from t_role
|
||||
<where>
|
||||
is_deleted = 0
|
||||
<if test="dto.id != null and dto.id != ''">
|
||||
and id like CONCAT('%',#{dto.id},'%')
|
||||
</if>
|
||||
<if test="dto.roleName != null and dto.roleName != ''">
|
||||
and role_name like CONCAT('%',#{dto.roleName},'%')
|
||||
</if>
|
||||
<if test="dto.description != null and dto.description != ''">
|
||||
and description like CONCAT('%',#{dto.description},'%')
|
||||
</if>
|
||||
<if test="dto.remark != null and dto.remark != ''">
|
||||
and remark like CONCAT('%',#{dto.remark},'%')
|
||||
</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.spring.step2.mapper.RolePermissionMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.spring.step2.domain.entity.RolePermissionEntity">
|
||||
<id column="id" property="id"/>
|
||||
<id column="role_id" property="roleId"/>
|
||||
<id column="permission_id" property="permissionId"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,role_id,permission_id,create_time,update_time,create_user,update_user,is_deleted
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询角色权限关联表内容 -->
|
||||
<select id="selectListByPage" resultType="com.spring.step2.domain.vo.RolePermissionVo">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from t_role_permission
|
||||
<where>
|
||||
base.is_deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -36,4 +36,25 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 根据用户id查找当前用户的权限 -->
|
||||
<select id="selectPermissionByUserId" resultType="com.spring.step2.domain.entity.PermissionEntity">
|
||||
SELECT DISTINCT p.*
|
||||
FROM t_permission p
|
||||
JOIN t_role_permission rp ON p.id = rp.permission_id
|
||||
JOIN t_user_role ur ON rp.role_id = ur.role_id
|
||||
WHERE ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 根据用户名查询当前用户 -->
|
||||
<select id="selectByUsername" resultType="com.spring.step2.domain.entity.UserEntity">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from t_user
|
||||
<where>
|
||||
<if test="username != null and username != ;;">
|
||||
username=#{username}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.spring.step2.mapper.UserRoleMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.spring.step2.domain.entity.UserRoleEntity">
|
||||
<id column="id" property="id"/>
|
||||
<id column="role_id" property="roleId"/>
|
||||
<id column="user_id" property="userId"/>
|
||||
<id column="create_time" property="createTime"/>
|
||||
<id column="update_time" property="updateTime"/>
|
||||
<id column="create_user" property="createUser"/>
|
||||
<id column="update_user" property="updateUser"/>
|
||||
<id column="is_deleted" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id,role_id,user_id,create_time,update_time,create_user,update_user,is_deleted
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询用户角色关联表内容 -->
|
||||
<select id="selectListByPage" resultType="com.spring.step2.domain.vo.UserRoleVo">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from t_user_role
|
||||
<where>
|
||||
base.is_deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.spring.step2.mapper.UsersMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.spring.step2.domain.entity.UsersEntity">
|
||||
<id column="username" property="username"/>
|
||||
<id column="password" property="password"/>
|
||||
<id column="Id" property="id"/>
|
||||
<id column="email" property="email"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
username,password,Id,email
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询内容 -->
|
||||
<select id="selectListByPage" resultType="com.spring.step2.domain.vo.UsersVo">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from users
|
||||
<where>
|
||||
<if test="dto.username != null and dto.username != ''">
|
||||
and username like CONCAT('%',#{dto.username},'%')
|
||||
</if>
|
||||
<if test="dto.email != null and dto.email != ''">
|
||||
and email like CONCAT('%',#{dto.email},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue