grs
yjxx 4 weeks ago
parent de12494bbd
commit 8e1250df12

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

Loading…
Cancel
Save