feat: 升级SpringBoot3
This commit is contained in:
@@ -14,17 +14,18 @@ import com.youlai.system.pojo.vo.user.UserExportVO;
|
||||
import com.youlai.system.pojo.vo.user.UserLoginVO;
|
||||
import com.youlai.system.pojo.vo.user.UserVO;
|
||||
import com.youlai.system.service.SysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -37,7 +38,7 @@ import java.util.List;
|
||||
* @author haoxr
|
||||
* @date 2022/10/16
|
||||
*/
|
||||
@Api(tags = "用户接口")
|
||||
@Tag(name = "用户接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/users")
|
||||
@RequiredArgsConstructor
|
||||
@@ -45,23 +46,23 @@ public class SysUserController {
|
||||
|
||||
private final SysUserService userService;
|
||||
|
||||
@ApiOperation(value = "用户分页列表")
|
||||
@Operation(summary = "用户分页列表")
|
||||
@GetMapping("/pages")
|
||||
public PageResult<UserVO> listUserPages(UserPageQuery queryParams) {
|
||||
IPage<UserVO> result = userService.listUserPages(queryParams);
|
||||
return PageResult.success(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户表单数据")
|
||||
@Operation(summary = "用户表单数据")
|
||||
@GetMapping("/{userId}/form")
|
||||
public Result<UserForm> getUserDetail(
|
||||
@ApiParam(value = "用户ID") @PathVariable Long userId
|
||||
@Parameter(name = "用户ID") @PathVariable Long userId
|
||||
) {
|
||||
UserForm formData = userService.getUserFormData(userId);
|
||||
return Result.success(formData);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增用户")
|
||||
@Operation(summary = "新增用户")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys:user:add')")
|
||||
public Result saveUser(
|
||||
@@ -71,41 +72,41 @@ public class SysUserController {
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户")
|
||||
@Operation(summary = "修改用户")
|
||||
@PutMapping(value = "/{userId}")
|
||||
@PreAuthorize("@pms.hasPermission('sys:user:edit')")
|
||||
public Result updateUser(
|
||||
@ApiParam("用户ID") @PathVariable Long userId,
|
||||
@Parameter(name ="用户ID") @PathVariable Long userId,
|
||||
@RequestBody @Validated UserForm userForm) {
|
||||
boolean result = userService.updateUser(userId, userForm);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除用户")
|
||||
@Operation(summary = "删除用户")
|
||||
@DeleteMapping("/{ids}")
|
||||
@PreAuthorize("@pms.hasPermission('sys:user:delete')")
|
||||
public Result deleteUsers(
|
||||
@ApiParam("用户ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
@Parameter(name ="用户ID,多个以英文逗号(,)分割") @PathVariable String ids
|
||||
) {
|
||||
boolean result = userService.deleteUsers(ids);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户密码")
|
||||
@Operation(summary = "修改用户密码")
|
||||
@PatchMapping(value = "/{userId}/password")
|
||||
public Result updatePassword(
|
||||
@ApiParam("用户ID") @PathVariable Long userId,
|
||||
@Parameter(name ="用户ID") @PathVariable Long userId,
|
||||
@RequestParam String password
|
||||
) {
|
||||
boolean result = userService.updatePassword(userId, password);
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改用户状态")
|
||||
@Operation(summary = "修改用户状态")
|
||||
@PatchMapping(value = "/{userId}/status")
|
||||
public Result updatePassword(
|
||||
@ApiParam("用户ID") @PathVariable Long userId,
|
||||
@ApiParam("用户状态(1:启用;0:禁用)") @RequestParam Integer status
|
||||
@Parameter(name ="用户ID") @PathVariable Long userId,
|
||||
@Parameter(name ="用户状态(1:启用;0:禁用)") @RequestParam Integer status
|
||||
) {
|
||||
boolean result = userService.update(new LambdaUpdateWrapper<SysUser>()
|
||||
.eq(SysUser::getId, userId)
|
||||
@@ -114,14 +115,14 @@ public class SysUserController {
|
||||
return Result.judge(result);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取登录用户信息")
|
||||
@Operation(summary = "获取登录用户信息")
|
||||
@GetMapping("/me")
|
||||
public Result<UserLoginVO> getUserLoginInfo() {
|
||||
UserLoginVO userLoginVO = userService.getUserLoginInfo();
|
||||
return Result.success(userLoginVO);
|
||||
}
|
||||
|
||||
@ApiOperation("用户导入模板下载")
|
||||
@Operation(summary ="用户导入模板下载")
|
||||
@GetMapping("/template")
|
||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||
String fileName = "用户导入模板.xlsx";
|
||||
@@ -137,14 +138,14 @@ public class SysUserController {
|
||||
excelWriter.finish();
|
||||
}
|
||||
|
||||
@ApiOperation("导入用户")
|
||||
@Operation(summary ="导入用户")
|
||||
@PostMapping("/_import")
|
||||
public Result importUsers(UserImportDTO userImportDTO) throws IOException {
|
||||
String msg = userService.importUsers(userImportDTO);
|
||||
return Result.success(msg);
|
||||
}
|
||||
|
||||
@ApiOperation("导出用户")
|
||||
@Operation(summary ="导出用户")
|
||||
@GetMapping("/_export")
|
||||
public void exportUsers(UserPageQuery queryParams, HttpServletResponse response) throws IOException {
|
||||
String fileName = "用户列表.xlsx";
|
||||
|
||||
Reference in New Issue
Block a user