更新
This commit is contained in:
@ -72,6 +72,6 @@ public class AuthGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(generateAuth("标准版", 1000, 365, "8661A5D7040288C20E17A1D117E20045"));
|
System.out.println(generateAuth("标准版", 1000, 365, "DAC653349FD15F1E6DB2F9322AD628F4"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.yj.earth.business.controller;
|
package com.yj.earth.business.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.yj.earth.annotation.CheckAuth;
|
import com.yj.earth.annotation.CheckAuth;
|
||||||
import com.yj.earth.business.domain.Role;
|
import com.yj.earth.business.domain.Role;
|
||||||
@ -14,6 +16,7 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Tag(name = "角色数据管理")
|
@Tag(name = "角色数据管理")
|
||||||
@CheckAuth
|
@CheckAuth
|
||||||
@ -33,9 +36,9 @@ public class RoleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除角色")
|
@Operation(summary = "删除角色")
|
||||||
@PostMapping("/delete")
|
@PostMapping("/deletes")
|
||||||
public ApiResponse delete(@Parameter(description = "角色ID") String id) {
|
public ApiResponse deletes(@Parameter(description = "用户ID列表") @RequestBody List<String> ids) {
|
||||||
roleService.removeById(id);
|
roleService.removeByIds(ids);
|
||||||
return ApiResponse.success(null);
|
return ApiResponse.success(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +60,30 @@ public class RoleController {
|
|||||||
|
|
||||||
@Operation(summary = "角色列表")
|
@Operation(summary = "角色列表")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum, @Parameter(description = "分页大小") Integer pageSize) {
|
public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum,
|
||||||
Page<Role> rolePage = roleService.page(new Page<>(pageNum, pageSize));
|
@Parameter(description = "分页大小") Integer pageSize,
|
||||||
|
@Parameter(description = "角色名称") String roleName,
|
||||||
|
@Parameter(description = "角色状态") Integer status) {
|
||||||
|
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
// 根据角色名称进行模糊搜索
|
||||||
|
if (StringUtils.isNotBlank(roleName)) {
|
||||||
|
queryWrapper.like(Role::getRoleName, roleName);
|
||||||
|
}
|
||||||
|
// 角色状态
|
||||||
|
if (status != null) {
|
||||||
|
queryWrapper.eq(Role::getStatus, status);
|
||||||
|
}
|
||||||
|
Page<Role> rolePage = roleService.page(new Page<>(pageNum, pageSize), queryWrapper);
|
||||||
return ApiResponse.success(rolePage);
|
return ApiResponse.success(rolePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "管理员数量查询")
|
||||||
|
@GetMapping("/count")
|
||||||
|
public ApiResponse count() {
|
||||||
|
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(Role::getIsSuper, 1);
|
||||||
|
return ApiResponse.success(roleService.count(queryWrapper));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,7 +92,7 @@ public class SystemController {
|
|||||||
@Operation(summary = "工程导出")
|
@Operation(summary = "工程导出")
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public void exportProject(HttpServletResponse response) {
|
public void exportProject(HttpServletResponse response) {
|
||||||
// 获取SQLite文件绝对路径
|
// 获取 SQLite 文件绝对路径
|
||||||
String sqliteFilePath = DatabaseManager.getSqliteDbFilePath();
|
String sqliteFilePath = DatabaseManager.getSqliteDbFilePath();
|
||||||
// 校验路径与文件有效性
|
// 校验路径与文件有效性
|
||||||
if (sqliteFilePath == null || sqliteFilePath.isEmpty()) {
|
if (sqliteFilePath == null || sqliteFilePath.isEmpty()) {
|
||||||
|
|||||||
@ -47,10 +47,6 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
user.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
|
user.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
|
||||||
if (addUserDto.getRoleId() == null) {
|
|
||||||
// 查询系统名字为默认角色的角色ID
|
|
||||||
user.setRoleId(roleService.getOne(new LambdaQueryWrapper<Role>().eq(Role::getRoleName, "默认角色")).getId());
|
|
||||||
}
|
|
||||||
userService.save(user);
|
userService.save(user);
|
||||||
return ApiResponse.success(null);
|
return ApiResponse.success(null);
|
||||||
}
|
}
|
||||||
@ -91,16 +87,21 @@ public class UserController {
|
|||||||
public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum,
|
public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum,
|
||||||
@Parameter(description = "分页大小") Integer pageSize,
|
@Parameter(description = "分页大小") Integer pageSize,
|
||||||
@Parameter(description = "搜索字段") String searchKey,
|
@Parameter(description = "搜索字段") String searchKey,
|
||||||
@Parameter(description = "角色ID") String roleId) {
|
@Parameter(description = "角色ID") String roleId,
|
||||||
|
@Parameter(description = "用户状态") Integer status) {
|
||||||
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
|
||||||
// 根据用户名或者昵称进行模糊搜索
|
// 根据用户名或者昵称进行模糊搜索
|
||||||
if (StringUtils.isNotBlank(searchKey)) {
|
if (StringUtils.isNotBlank(searchKey)) {
|
||||||
wrapper.like(User::getUsername, searchKey).or().like(User::getNickname, searchKey);
|
wrapper.nested(q -> q.like(User::getUsername, searchKey).or().like(User::getNickname, searchKey));
|
||||||
}
|
}
|
||||||
// 根据角色ID等值搜索
|
// 根据角色ID等值搜索
|
||||||
if (StringUtils.isNotBlank(roleId)) {
|
if (StringUtils.isNotBlank(roleId)) {
|
||||||
wrapper.eq(User::getRoleId, roleId);
|
wrapper.eq(User::getRoleId, roleId);
|
||||||
}
|
}
|
||||||
|
// 角色状态处理
|
||||||
|
if (status != null) {
|
||||||
|
wrapper.eq(User::getStatus, status);
|
||||||
|
}
|
||||||
Page<User> userPage = userService.page(new Page<>(pageNum, pageSize), wrapper);
|
Page<User> userPage = userService.page(new Page<>(pageNum, pageSize), wrapper);
|
||||||
return ApiResponse.success(userPage);
|
return ApiResponse.success(userPage);
|
||||||
}
|
}
|
||||||
@ -154,7 +155,7 @@ public class UserController {
|
|||||||
@Operation(summary = "删除用户")
|
@Operation(summary = "删除用户")
|
||||||
@PostMapping("/deletes")
|
@PostMapping("/deletes")
|
||||||
@RoleAccess(roleNames = "管理员")
|
@RoleAccess(roleNames = "管理员")
|
||||||
public ApiResponse deletes(@RequestBody List<String> ids) {
|
public ApiResponse deletes(@Parameter(description = "用户ID列表") @RequestBody List<String> ids) {
|
||||||
userService.removeByIds(ids);
|
userService.removeByIds(ids);
|
||||||
return ApiResponse.success(null);
|
return ApiResponse.success(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,10 @@ import lombok.Data;
|
|||||||
public class AddRoleDto {
|
public class AddRoleDto {
|
||||||
@Schema(description = "角色名称")
|
@Schema(description = "角色名称")
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
|
||||||
@Schema(description = "角色描述")
|
@Schema(description = "角色描述")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Schema(description = "是否超级管理员")
|
@Schema(description = "是否超级管理员")
|
||||||
private Integer isSuper;
|
private Integer isSuper;
|
||||||
|
@Schema(description = "状态")
|
||||||
|
private Integer status;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,10 @@ import lombok.Data;
|
|||||||
public class UpdateRoleDto {
|
public class UpdateRoleDto {
|
||||||
@Schema(description = "主键")
|
@Schema(description = "主键")
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
@Schema(description = "角色描述")
|
@Schema(description = "角色描述")
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
@Schema(description = "是否超级管理员")
|
@Schema(description = "是否超级管理员")
|
||||||
private Integer isSuper;
|
private Integer isSuper;
|
||||||
|
@Schema(description = "角色状态")
|
||||||
|
private Integer status;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,4 +23,7 @@ public class AddUserDto {
|
|||||||
|
|
||||||
@Schema(description = "所属角色")
|
@Schema(description = "所属角色")
|
||||||
private String roleId;
|
private String roleId;
|
||||||
|
|
||||||
|
@Schema(description = "状态")
|
||||||
|
private Integer status;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,8 @@ import lombok.Data;
|
|||||||
public class UpdateUserDto {
|
public class UpdateUserDto {
|
||||||
@Schema(description = "主键")
|
@Schema(description = "主键")
|
||||||
private String id;
|
private String id;
|
||||||
|
@Schema(description = "用户名")
|
||||||
|
private String username;
|
||||||
@Schema(description = "头像")
|
@Schema(description = "头像")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
@Schema(description = "昵称")
|
@Schema(description = "昵称")
|
||||||
@ -16,4 +18,6 @@ public class UpdateUserDto {
|
|||||||
private String phone;
|
private String phone;
|
||||||
@Schema(description = "用户状态")
|
@Schema(description = "用户状态")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
@Schema(description = "角色ID")
|
||||||
|
private String roleId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user