mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-29 00:42:50 +08:00
json返回信息
This commit is contained in:
parent
f4909257ae
commit
ebd77f97d4
@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import xyz.playedu.api.domain.AdminUser;
|
||||
import xyz.playedu.api.service.impl.AdminUserServiceImpl;
|
||||
import xyz.playedu.api.types.PaginationResult;
|
||||
import xyz.playedu.api.types.ResponseBody;
|
||||
|
||||
@RestController
|
||||
public class AdminUserController {
|
||||
@ -15,9 +16,9 @@ public class AdminUserController {
|
||||
private AdminUserServiceImpl adminUserService;
|
||||
|
||||
@GetMapping("/admin/user/index")
|
||||
public PaginationResult<AdminUser> List(@RequestParam("page") Integer page, @RequestParam("size") Integer size) {
|
||||
public ResponseBody<Object> List(@RequestParam("page") Integer page, @RequestParam("size") Integer size) {
|
||||
PaginationResult<AdminUser> result = adminUserService.paginate(page, size, null);
|
||||
return result;
|
||||
return ResponseBody.data(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
50
src/main/java/xyz/playedu/api/types/ResponseBody.java
Normal file
50
src/main/java/xyz/playedu/api/types/ResponseBody.java
Normal file
@ -0,0 +1,50 @@
|
||||
package xyz.playedu.api.types;
|
||||
|
||||
public class ResponseBody<T> {
|
||||
|
||||
private Integer code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResponseBody(Integer code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static ResponseBody<String> success(String msg) {
|
||||
return new ResponseBody<>(0, msg, null);
|
||||
}
|
||||
|
||||
public static ResponseBody<Object> data(Object data) {
|
||||
return new ResponseBody<>(0, "", data);
|
||||
}
|
||||
|
||||
public static ResponseBody<String> error(String msg, Integer code) {
|
||||
return new ResponseBody<>(code, msg, null);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user