|
|
|
@ -3,13 +3,13 @@ package jty.expressdistributionsystem.controller;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
import jty.expressdistributionsystem.DTO.SendMessageDTO;
|
|
|
|
|
import jty.expressdistributionsystem.config.MyMetaObjectHandler;
|
|
|
|
|
import jty.expressdistributionsystem.entity.Result;
|
|
|
|
|
import jty.expressdistributionsystem.entity.User;
|
|
|
|
|
import jty.expressdistributionsystem.service.UserService;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import jty.expressdistributionsystem.utils.SendMessage;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/admin")
|
|
|
|
@ -17,9 +17,9 @@ public class AdminController {
|
|
|
|
|
@Resource
|
|
|
|
|
private UserService userService;
|
|
|
|
|
|
|
|
|
|
// 管理员查看用户信息
|
|
|
|
|
// 管理员查看用户或者快递员信息
|
|
|
|
|
@GetMapping("/userList")
|
|
|
|
|
public Result<Page<User>> getUserList(@RequestParam int page, @RequestParam int pageSize){
|
|
|
|
|
public Result<Page<User>> getUserList(@RequestParam int page, @RequestParam int pageSize, @RequestParam int mark) {
|
|
|
|
|
if (page <= 0 || pageSize <= 0) {
|
|
|
|
|
return new Result<>(400, "页码和每页大小必须大于0", null);
|
|
|
|
|
}
|
|
|
|
@ -27,11 +27,41 @@ public class AdminController {
|
|
|
|
|
Page<User> pageInfo = new Page<>(page, pageSize);
|
|
|
|
|
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
// 添加查询条件
|
|
|
|
|
queryWrapper.eq(User::getMark, 0);
|
|
|
|
|
queryWrapper.eq(User::getMark, mark);
|
|
|
|
|
// 排序
|
|
|
|
|
queryWrapper.orderByDesc(User::getLoginTime)
|
|
|
|
|
.orderByDesc(User::getCreateTime);
|
|
|
|
|
userService.page(pageInfo, queryWrapper);
|
|
|
|
|
return new Result<>(200, "", pageInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 拉黑删除快递员或者用户
|
|
|
|
|
@DeleteMapping("/delete/{id}")
|
|
|
|
|
public Result<String> delete(@PathVariable Long id, @RequestParam String operation) {
|
|
|
|
|
User user = userService.getById(id);
|
|
|
|
|
switch(operation){
|
|
|
|
|
// 禁用
|
|
|
|
|
case "0" -> user.setDisabled(1);
|
|
|
|
|
// 解除禁用
|
|
|
|
|
case "1" -> user.setDisabled(0);
|
|
|
|
|
// 直接删除
|
|
|
|
|
case "2" -> {
|
|
|
|
|
userService.removeById(id);
|
|
|
|
|
return new Result<>(200, "删除成功", "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 禁用自动填充
|
|
|
|
|
MyMetaObjectHandler.setSkipUpdateFill(true);
|
|
|
|
|
userService.updateById(user);
|
|
|
|
|
// 开启自动填充
|
|
|
|
|
MyMetaObjectHandler.setSkipUpdateFill(false);
|
|
|
|
|
return new Result<>(200, "操作成功", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 管理员发送消息
|
|
|
|
|
@PostMapping("/sendMessage")
|
|
|
|
|
public Result<String> sendMessage(@RequestBody SendMessageDTO sendMessageDTO) {
|
|
|
|
|
SendMessage.sendMessage(sendMessageDTO);
|
|
|
|
|
return new Result<>(200, "发送成功", "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|