grs
yjxx 3 weeks ago
parent de12494bbd
commit 8e1250df12

@ -10,11 +10,13 @@ import jty.expressdistributionsystem.entity.User;
import jty.expressdistributionsystem.service.MessageService; import jty.expressdistributionsystem.service.MessageService;
import jty.expressdistributionsystem.service.UserService; import jty.expressdistributionsystem.service.UserService;
import jty.expressdistributionsystem.utils.SendMessageUtil; import jty.expressdistributionsystem.utils.SendMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("/admin") @RequestMapping("/admin")
@Slf4j
public class AdminController { public class AdminController {
@Resource @Resource
private UserService userService; private UserService userService;
@ -42,8 +44,11 @@ public class AdminController {
// 拉黑删除快递员或者用户 // 拉黑删除快递员或者用户
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public Result<String> delete(@PathVariable Long id, @RequestParam String operation) { public Result<String> delete(@PathVariable Long id, @RequestParam @NotNull String operation) {
User user = userService.getById(id); User user = userService.getById(id);
if(user == null) {
return new Result<>(401, "账号不存在", "");
}
switch (operation) { switch (operation) {
// 禁用 // 禁用
case "0" -> user.setDisabled(1); case "0" -> user.setDisabled(1);
@ -51,7 +56,7 @@ public class AdminController {
case "1" -> user.setDisabled(0); case "1" -> user.setDisabled(0);
// 直接删除 // 直接删除
case "2" -> { case "2" -> {
userService.removeById(id); userService.removeById(user.getId());
return new Result<>(200, "删除成功", ""); return new Result<>(200, "删除成功", "");
} }
} }

Loading…
Cancel
Save