2025-12-30 03:14:25 +00:00
|
|
|
package com.tacit.admin.controller;
|
|
|
|
|
|
|
|
|
|
import com.tacit.admin.entity.User;
|
|
|
|
|
import com.tacit.admin.service.UserService;
|
|
|
|
|
import com.tacit.common.entity.ResponseResult;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
2026-01-06 05:55:06 +00:00
|
|
|
import jakarta.annotation.Resource;
|
2025-12-30 03:14:25 +00:00
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/user")
|
2026-01-06 03:08:46 +00:00
|
|
|
@Tag(name = "用户管理", description = "用户管理相关接口")
|
2025-12-30 03:14:25 +00:00
|
|
|
public class UserController {
|
|
|
|
|
|
2026-01-06 05:55:06 +00:00
|
|
|
@Resource
|
2025-12-30 03:14:25 +00:00
|
|
|
private UserService userService;
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "获取所有用户", description = "获取系统中所有用户列表")
|
|
|
|
|
@GetMapping("/list")
|
|
|
|
|
public ResponseResult<List<User>> getAllUsers() {
|
|
|
|
|
List<User> users = userService.getAllUsers();
|
|
|
|
|
return ResponseResult.success(users);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "根据ID获取用户", description = "根据用户ID获取用户详情")
|
|
|
|
|
@GetMapping("/info/{id}")
|
|
|
|
|
public ResponseResult<User> getUserById(@PathVariable Long id) {
|
|
|
|
|
User user = userService.getUserById(id);
|
|
|
|
|
return ResponseResult.success(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "创建用户", description = "创建新用户")
|
|
|
|
|
@PostMapping("/create")
|
|
|
|
|
public ResponseResult<Boolean> createUser(@RequestBody User user) {
|
|
|
|
|
boolean result = userService.createUser(user);
|
|
|
|
|
return ResponseResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "更新用户", description = "更新用户信息")
|
|
|
|
|
@PutMapping("/update")
|
|
|
|
|
public ResponseResult<Boolean> updateUser(@RequestBody User user) {
|
|
|
|
|
boolean result = userService.updateUser(user);
|
|
|
|
|
return ResponseResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除用户", description = "根据用户ID删除用户")
|
|
|
|
|
@DeleteMapping("/delete/{id}")
|
|
|
|
|
public ResponseResult<Boolean> deleteUser(@PathVariable Long id) {
|
|
|
|
|
boolean result = userService.deleteUser(id);
|
|
|
|
|
return ResponseResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
}
|