1.修改用户模块返回,配置功能返回
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,3 +25,4 @@ hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
!/target/
|
||||
!/.idea/
|
||||
|
||||
BIN
.idea/.cache/.Apifox_Helper/.toolWindow.db
generated
BIN
.idea/.cache/.Apifox_Helper/.toolWindow.db
generated
Binary file not shown.
6
.idea/ApifoxUploaderProjectSetting.xml
generated
6
.idea/ApifoxUploaderProjectSetting.xml
generated
File diff suppressed because one or more lines are too long
@@ -5,7 +5,9 @@ import vvpkassistant.Data.ResponseData;
|
||||
import vvpkassistant.Data.ResponseInfo;
|
||||
import vvpkassistant.FunctionConfig.mapper.FunctionConfigMapper;
|
||||
import vvpkassistant.FunctionConfig.model.FunctionConfigModel;
|
||||
import vvpkassistant.common.ErrorCode;
|
||||
import vvpkassistant.config.FunctionConfigHolder;
|
||||
import vvpkassistant.exception.BusinessException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("config")
|
||||
@@ -37,7 +39,7 @@ public class FunctionConfigController {
|
||||
boolean isDuplicate = FunctionConfigHolder.CONFIGS.stream()
|
||||
.anyMatch(config -> name.equals(config.getFunctionName()));
|
||||
if (isDuplicate) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),"配置名称重复");
|
||||
throw new BusinessException(ErrorCode.CONFIG_NAME_DUPLICATE);
|
||||
}else {
|
||||
configMapper.insert(newModel);
|
||||
FunctionConfigHolder.CONFIGS.add(newModel);
|
||||
@@ -52,7 +54,7 @@ public class FunctionConfigController {
|
||||
FunctionConfigHolder.CONFIGS.removeIf(c -> model.getId().equals(c.getId()));
|
||||
return ResponseData.success("");
|
||||
}else {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),null);
|
||||
throw new BusinessException(ErrorCode.DELETE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ import vvpkassistant.Data.ResponseInfo;
|
||||
import vvpkassistant.Data.WxChatParam;
|
||||
import vvpkassistant.User.mapper.UserDao;
|
||||
import vvpkassistant.User.model.UserModel;
|
||||
import vvpkassistant.common.ErrorCode;
|
||||
import vvpkassistant.config.FunctionConfigHolder;
|
||||
import vvpkassistant.Tools.VVRequester;
|
||||
import vvpkassistant.Tools.VVTools;
|
||||
import vvpkassistant.exception.BusinessException;
|
||||
import vvpkassistant.pk.mapper.PkInfoDao;
|
||||
import vvpkassistant.pk.model.PkInfoModel;
|
||||
import vvpkassistant.pk.model.PkRecordDetail;
|
||||
@@ -46,11 +48,11 @@ public class UserController {
|
||||
public ResponseData<Object> inputUserInfo(@RequestBody Map<String,Object> param) {
|
||||
|
||||
if (!param.containsKey("code")) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(), "code不能为空");
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR,"code不能为空");
|
||||
}
|
||||
|
||||
if (!param.containsKey("id")) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(), "id不能为空");
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR,"id不能为空");
|
||||
}
|
||||
|
||||
//获取前端传递过来的code
|
||||
@@ -64,23 +66,23 @@ public class UserController {
|
||||
Integer errcode = Integer.valueOf(wx_result.get("errcode").toString());
|
||||
|
||||
if (errcode == 45011) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(), "API 调用太频繁,请稍候再试。");
|
||||
throw new BusinessException(ErrorCode.WX_API_CALL_TOO_FREQUENT);
|
||||
}
|
||||
|
||||
if (errcode == 40029) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(), "js_code 无效");
|
||||
throw new BusinessException(ErrorCode.WX_INVALID_JSCODE);
|
||||
}
|
||||
|
||||
if (errcode == 40226) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(), "该账号为风险用户。禁止登录小程序");
|
||||
throw new BusinessException(ErrorCode.WX_RISK_ACCOUNT);
|
||||
}
|
||||
|
||||
if (errcode == -1) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(), "系统繁忙");
|
||||
throw new BusinessException(ErrorCode.WX_SYSTEM_BUSY);
|
||||
}
|
||||
|
||||
if (!wx_result.containsKey("openid")) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(), "获取用户信息失败,请稍后再试。");
|
||||
throw new BusinessException(ErrorCode.WX_GET_USER_INFO_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +113,7 @@ public class UserController {
|
||||
return ResponseData.success(result);
|
||||
}
|
||||
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),"未知错误");
|
||||
return ResponseData.error(ErrorCode.SYSTEM_ERROR.getCode(),"未知错误");
|
||||
}
|
||||
|
||||
// 手机号登录 / 注册
|
||||
@@ -119,14 +121,13 @@ public class UserController {
|
||||
public ResponseData<Object> loginWithPhoneNumber(@RequestBody Map<String,Object> param) {
|
||||
|
||||
if (!param.containsKey("code")) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),"code不能为空");
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR,"code不能为空");
|
||||
}
|
||||
|
||||
String code = param.get("code").toString();
|
||||
String phoneNumber = vvRequester.queryPhoneNumber(code);
|
||||
|
||||
if (phoneNumber.isEmpty()) {
|
||||
return ResponseData.error(ResponseInfo.ERROR.getCode(),"手机号码无法查询");
|
||||
throw new BusinessException(ErrorCode.PARAMS_ERROR,"手机号码无法查询");
|
||||
}
|
||||
|
||||
// 查询是否存在用户。如果用户存在直接返回 如果用户不存在则新建用户
|
||||
@@ -165,6 +166,8 @@ public class UserController {
|
||||
|
||||
}
|
||||
|
||||
//todo 修改用户返回结果
|
||||
|
||||
// 修改用户信息
|
||||
@PostMapping("updateUserInfo")
|
||||
public ResponseData<Object> updateUserInfo(@RequestBody Map<String,Object> map) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import vvpkassistant.Data.ResponseData;
|
||||
import vvpkassistant.Data.ResponseInfo;
|
||||
import vvpkassistant.chat.mapper.ChatDao;
|
||||
import vvpkassistant.chat.model.ChatModel;
|
||||
import vvpkassistant.common.ErrorCode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -22,7 +23,7 @@ public class ChatController {
|
||||
@PostMapping("add")
|
||||
public ResponseData<Object> add(@RequestBody ChatModel model) {
|
||||
int insert = chatDao.insert(model);
|
||||
return insert == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
|
||||
return insert == 1 ? ResponseData.success("") : ResponseData.error(ErrorCode.ADD_FAILED);
|
||||
}
|
||||
|
||||
//根据ip查询数据
|
||||
|
||||
@@ -4,16 +4,29 @@ import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ErrorCode {
|
||||
|
||||
/* =============== 全局通用 =============== */
|
||||
SUCCESS(0, "ok"),
|
||||
ADD_FAILED(1, "添加失败"),
|
||||
DELETE_FAILED(2, "删除失败"),
|
||||
UPDATE_FAILED(2, "删除失败"),
|
||||
ANCHOR_ALREADY_EXISTS(101,"主播已存在"),
|
||||
ANCHOR_HAS_PKRECORD(102,"主播存在PK记录"),
|
||||
PARAMS_ERROR(40000, "请求参数错误"),
|
||||
SYSTEM_ERROR(50000, "系统错误"),
|
||||
PARAMS_ERROR(40000, "请求参数错误")
|
||||
;
|
||||
|
||||
/* =============== 业务失败 =============== */
|
||||
ADD_FAILED(1001, "添加失败"),
|
||||
DELETE_FAILED(1002, "删除失败"),
|
||||
UPDATE_FAILED(1003, "更新失败"),
|
||||
CONFIG_NAME_DUPLICATE(1004, "配置名称重复"),
|
||||
|
||||
/* =============== 主播相关 =============== */
|
||||
ANCHOR_ALREADY_EXISTS(2001, "主播已存在"),
|
||||
ANCHOR_HAS_PKRECORD(2002, "主播存在PK记录"),
|
||||
|
||||
/* =============== 微信小程序 =============== */
|
||||
WX_API_CALL_TOO_FREQUENT(45011, "API 调用太频繁,请稍候再试"),
|
||||
WX_INVALID_JSCODE(40029, "js_code 无效"),
|
||||
WX_RISK_ACCOUNT(40226, "该账号为风险用户,禁止登录小程序"),
|
||||
WX_SYSTEM_BUSY(-1, "系统繁忙"),
|
||||
|
||||
/* =============== 登录/用户信息 =============== */
|
||||
WX_GET_USER_INFO_FAILED(50001, "获取用户信息失败,请稍后再试");
|
||||
|
||||
/**
|
||||
* 状态码
|
||||
|
||||
Reference in New Issue
Block a user