更新
This commit is contained in:
		@ -72,6 +72,6 @@ public class AuthGenerator {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
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.yj.earth.annotation.CheckAuth;
 | 
			
		||||
import com.yj.earth.business.domain.Role;
 | 
			
		||||
@ -14,6 +16,7 @@ import org.springframework.beans.BeanUtils;
 | 
			
		||||
import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@Tag(name = "角色数据管理")
 | 
			
		||||
@CheckAuth
 | 
			
		||||
@ -33,9 +36,9 @@ public class RoleController {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "删除角色")
 | 
			
		||||
    @PostMapping("/delete")
 | 
			
		||||
    public ApiResponse delete(@Parameter(description = "角色ID") String id) {
 | 
			
		||||
        roleService.removeById(id);
 | 
			
		||||
    @PostMapping("/deletes")
 | 
			
		||||
    public ApiResponse deletes(@Parameter(description = "用户ID列表") @RequestBody List<String> ids) {
 | 
			
		||||
        roleService.removeByIds(ids);
 | 
			
		||||
        return ApiResponse.success(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -57,8 +60,30 @@ public class RoleController {
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "角色列表")
 | 
			
		||||
    @GetMapping("/list")
 | 
			
		||||
    public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum, @Parameter(description = "分页大小") Integer pageSize) {
 | 
			
		||||
        Page<Role> rolePage = roleService.page(new Page<>(pageNum, pageSize));
 | 
			
		||||
    public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum,
 | 
			
		||||
                            @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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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 = "工程导出")
 | 
			
		||||
    @GetMapping("/export")
 | 
			
		||||
    public void exportProject(HttpServletResponse response) {
 | 
			
		||||
        // 获取SQLite文件绝对路径
 | 
			
		||||
        // 获取 SQLite 文件绝对路径
 | 
			
		||||
        String sqliteFilePath = DatabaseManager.getSqliteDbFilePath();
 | 
			
		||||
        // 校验路径与文件有效性
 | 
			
		||||
        if (sqliteFilePath == null || sqliteFilePath.isEmpty()) {
 | 
			
		||||
 | 
			
		||||
@ -47,10 +47,6 @@ public class UserController {
 | 
			
		||||
        }
 | 
			
		||||
        String password = user.getPassword();
 | 
			
		||||
        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);
 | 
			
		||||
        return ApiResponse.success(null);
 | 
			
		||||
    }
 | 
			
		||||
@ -91,16 +87,21 @@ public class UserController {
 | 
			
		||||
    public ApiResponse list(@Parameter(description = "分页数量") Integer pageNum,
 | 
			
		||||
                            @Parameter(description = "分页大小") Integer pageSize,
 | 
			
		||||
                            @Parameter(description = "搜索字段") String searchKey,
 | 
			
		||||
                            @Parameter(description = "角色ID") String roleId) {
 | 
			
		||||
                            @Parameter(description = "角色ID") String roleId,
 | 
			
		||||
                            @Parameter(description = "用户状态") Integer status) {
 | 
			
		||||
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
 | 
			
		||||
        // 根据用户名或者昵称进行模糊搜索
 | 
			
		||||
        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等值搜索
 | 
			
		||||
        if (StringUtils.isNotBlank(roleId)) {
 | 
			
		||||
            wrapper.eq(User::getRoleId, roleId);
 | 
			
		||||
        }
 | 
			
		||||
        // 角色状态处理
 | 
			
		||||
        if (status != null) {
 | 
			
		||||
            wrapper.eq(User::getStatus, status);
 | 
			
		||||
        }
 | 
			
		||||
        Page<User> userPage = userService.page(new Page<>(pageNum, pageSize), wrapper);
 | 
			
		||||
        return ApiResponse.success(userPage);
 | 
			
		||||
    }
 | 
			
		||||
@ -154,7 +155,7 @@ public class UserController {
 | 
			
		||||
    @Operation(summary = "删除用户")
 | 
			
		||||
    @PostMapping("/deletes")
 | 
			
		||||
    @RoleAccess(roleNames = "管理员")
 | 
			
		||||
    public ApiResponse deletes(@RequestBody List<String> ids) {
 | 
			
		||||
    public ApiResponse deletes(@Parameter(description = "用户ID列表") @RequestBody List<String> ids) {
 | 
			
		||||
        userService.removeByIds(ids);
 | 
			
		||||
        return ApiResponse.success(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -7,10 +7,10 @@ import lombok.Data;
 | 
			
		||||
public class AddRoleDto {
 | 
			
		||||
    @Schema(description = "角色名称")
 | 
			
		||||
    private String roleName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "角色描述")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "是否超级管理员")
 | 
			
		||||
    private Integer isSuper;
 | 
			
		||||
    @Schema(description = "状态")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -7,10 +7,10 @@ import lombok.Data;
 | 
			
		||||
public class UpdateRoleDto {
 | 
			
		||||
    @Schema(description = "主键")
 | 
			
		||||
    private String id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "角色描述")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "是否超级管理员")
 | 
			
		||||
    private Integer isSuper;
 | 
			
		||||
    @Schema(description = "角色状态")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -23,4 +23,7 @@ public class AddUserDto {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "所属角色")
 | 
			
		||||
    private String roleId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "状态")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,8 @@ import lombok.Data;
 | 
			
		||||
public class UpdateUserDto {
 | 
			
		||||
    @Schema(description = "主键")
 | 
			
		||||
    private String id;
 | 
			
		||||
    @Schema(description = "用户名")
 | 
			
		||||
    private String username;
 | 
			
		||||
    @Schema(description = "头像")
 | 
			
		||||
    private String avatar;
 | 
			
		||||
    @Schema(description = "昵称")
 | 
			
		||||
@ -16,4 +18,6 @@ public class UpdateUserDto {
 | 
			
		||||
    private String phone;
 | 
			
		||||
    @Schema(description = "用户状态")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
    @Schema(description = "角色ID")
 | 
			
		||||
    private String roleId;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user