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