通用返回结果,数据统一放到putData里
This commit is contained in:
@@ -35,7 +35,7 @@ public class AuthController {
|
||||
}else {
|
||||
if (MD5Utils.getSaltverifyMD5(user.getPassword(),userEntity.getPassword())){
|
||||
UserToken userToken = userTokenService.createToken(userEntity.getId());
|
||||
return R.ok("登录成功").put("userToken",userToken);
|
||||
return R.ok("登录成功").putData("userToken",userToken);
|
||||
}else {
|
||||
return R.error(500,"密码不正确,请重试");
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class UserController {
|
||||
public R getUserList(@RequestBody Map<String,Object> params){
|
||||
Page<User> userList = userService.page(new Page<>(Long.parseLong(params.get("page").toString()),
|
||||
Long.parseLong(params.get("limit").toString())));
|
||||
return R.ok().put("userList",userList);
|
||||
return R.ok().putData("userList",userList);
|
||||
}
|
||||
|
||||
//新增用户
|
||||
@@ -56,7 +56,7 @@ public class UserController {
|
||||
WumenUser wumenUser = wumenUserService.getById("12301");
|
||||
Customer customer = customerService.getOne(new LambdaQueryWrapper<Customer>()
|
||||
.eq(Customer::getCellPhone,"15674886255"));
|
||||
return R.ok().put("wumenUser",wumenUser).put("customer",customer);
|
||||
return R.ok().putData("customer",customer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.zmzm.finance.util;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -66,5 +68,17 @@ public class R extends HashMap<String, Object> {
|
||||
super.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public R putData(String key, Object value) {
|
||||
if (!super.containsKey("data")) {
|
||||
super.put("data", new HashMap<>());
|
||||
}
|
||||
Map<String,Object> oldData = (Map<String, Object>) super.get("data");
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(key,value);
|
||||
oldData.putAll(map);
|
||||
super.put("data", oldData);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user