parent
180019adae
commit
c202b4f240
@ -0,0 +1,37 @@
|
||||
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.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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/admin")
|
||||
public class AdminController {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
// 管理员查看用户信息
|
||||
@GetMapping("/userList")
|
||||
public Result<Page<User>> getUserList(@RequestParam int page, @RequestParam int pageSize){
|
||||
if(page <= 0 || pageSize <= 0) {
|
||||
return new Result<>(400, "页码和每页大小必须大于0", null);
|
||||
}
|
||||
// 分页
|
||||
Page<User> pageInfo = new Page<>(page, pageSize);
|
||||
LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// 添加查询条件
|
||||
queryWrapper.eq(User::getMark, 0);
|
||||
// 排序
|
||||
queryWrapper.orderByDesc(User::getLoginTime)
|
||||
.orderByDesc(User::getCreateTime);
|
||||
userService.page(pageInfo, queryWrapper);
|
||||
return new Result<>(200, "", pageInfo);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package jty.expressdistributionsystem.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class Message implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@TableField("content")
|
||||
private String content;
|
||||
|
||||
@TableField("send_user_id")
|
||||
@NotNull
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sendUserId;
|
||||
|
||||
@TableField("get_user_id")
|
||||
@NotNull
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long getUserId;
|
||||
|
||||
@TableField("mark")
|
||||
private Integer mark;
|
||||
}
|
Loading…
Reference in new issue