1.用户模块返回统一包装返回
This commit is contained in:
@@ -184,7 +184,11 @@ public class UserController {
|
|||||||
Map<String,Object> result = new HashMap<>();
|
Map<String,Object> result = new HashMap<>();
|
||||||
result.put("info", userDao.selectById(map.get("id").toString()));
|
result.put("info", userDao.selectById(map.get("id").toString()));
|
||||||
result.put("newAccount", false);
|
result.put("newAccount", false);
|
||||||
return i == 1 ? ResponseData.success(result) : ResponseData.error(ResponseInfo.ERROR.getCode(), "");
|
if (i == 1){
|
||||||
|
return ResponseData.success(result);
|
||||||
|
}else {
|
||||||
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
@@ -224,7 +228,7 @@ public class UserController {
|
|||||||
// 别人邀请我的pk数据
|
// 别人邀请我的pk数据
|
||||||
return ResponseData.success(userDao.getMyGuestPkList(id, page * size, size));
|
return ResponseData.success(userDao.getMyGuestPkList(id, page * size, size));
|
||||||
}
|
}
|
||||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),"未知错误");
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -242,7 +246,7 @@ public class UserController {
|
|||||||
Integer userId = map.get("userId");
|
Integer userId = map.get("userId");
|
||||||
int i = userDao.checkSignStatus(userId);
|
int i = userDao.checkSignStatus(userId);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),"当天已签到");
|
throw new BusinessException(ErrorCode.SIGN_IN_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = userDao.signIn(userId);
|
int result = userDao.signIn(userId);
|
||||||
@@ -261,7 +265,7 @@ public class UserController {
|
|||||||
coinRecordsDao.insert(coinRecords);
|
coinRecordsDao.insert(coinRecords);
|
||||||
return ResponseData.success(null);
|
return ResponseData.success(null);
|
||||||
}else {
|
}else {
|
||||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),null);
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR,"签到失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,13 +312,13 @@ public class UserController {
|
|||||||
// 返回给前端数据
|
// 返回给前端数据
|
||||||
return ResponseData.success(info);
|
return ResponseData.success(info);
|
||||||
}else {
|
}else {
|
||||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),null);
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),String.format("积分不足,需要%d积分",totalCoin));
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR,String.format("积分不足,需要%d积分",totalCoin));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),"用户不存在");
|
throw new BusinessException(ErrorCode.SYSTEM_ERROR,"用户不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public enum ErrorCode {
|
|||||||
DELETE_FAILED(1002, "删除失败"),
|
DELETE_FAILED(1002, "删除失败"),
|
||||||
UPDATE_FAILED(1003, "更新失败"),
|
UPDATE_FAILED(1003, "更新失败"),
|
||||||
CONFIG_NAME_DUPLICATE(1004, "配置名称重复"),
|
CONFIG_NAME_DUPLICATE(1004, "配置名称重复"),
|
||||||
|
SIGN_IN_FAIL(1004, "当天已签到"),
|
||||||
|
|
||||||
/* =============== 主播相关 =============== */
|
/* =============== 主播相关 =============== */
|
||||||
ANCHOR_ALREADY_EXISTS(2001, "主播已存在"),
|
ANCHOR_ALREADY_EXISTS(2001, "主播已存在"),
|
||||||
|
|||||||
Reference in New Issue
Block a user