1.优化主播代码模块代码,添加统一异常处理

This commit is contained in:
2025-08-01 21:15:16 +08:00
parent 93c10482d0
commit e9ee9d6b90
22 changed files with 365 additions and 98 deletions

BIN
.idea/.cache/.Apifox_Helper/.toolWindow.db generated Normal file

Binary file not shown.

6
.idea/ApifoxUploaderProjectSetting.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ApifoxUploaderProjectSetting">
<option name="apiAccessToken" value="APS-bCiUm0GlQrVfnvxUtLKidqmrUwG2Uqx6" />
</component>
</project>

10
.idea/dataSources.xml generated
View File

@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="vv_assistant@120.26.251.180" uuid="825abb89-80f2-475c-9ee4-5b0afe788f5b">
<data-source source="LOCAL" name="vv_assistant@localhost" uuid="a97b176f-f814-4c14-b11c-1945b687d99f">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://120.26.251.180:3326/vv_assistant</jdbc-url>
<jdbc-url>jdbc:mysql://localhost:3306/vv_assistant?allowMultiQueries=true</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>

View File

@@ -0,0 +1,23 @@
autoDetectedPackages:
- vvpkassistant
enableAutoDetect: true
entryDisplayConfig:
excludedPathPatterns: []
skipJsCss: true
funcDisplayConfig:
skipConstructors: false
skipFieldAccess: true
skipFieldChange: true
skipGetters: false
skipNonProjectPackages: false
skipPrivateMethods: false
skipSetters: false
ignoreSameClassCall: null
ignoreSamePackageCall: null
includedPackagePrefixes: null
includedParentClasses: null
name: xcodemap-filter
recordMode: all
sourceDisplayConfig:
color: blue
startOnDebug: false

View File

@@ -1,80 +1,51 @@
package vvpkassistant.Anchors.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vvpkassistant.Anchors.mapper.AnchorDao;
import vvpkassistant.Anchors.model.AnchorModel;
import vvpkassistant.Anchors.service.AnchorsService;
import vvpkassistant.Data.ResponseData;
import vvpkassistant.Data.ResponseInfo;
import vvpkassistant.pk.mapper.PkRecordDao;
import vvpkassistant.common.ErrorCode;
import java.util.List;
import javax.annotation.Resource;
import java.util.Map;
@RestController
@RequestMapping("anchor")
public class AnchorsController {
@Autowired
private AnchorDao anchorDao;
@Resource
private AnchorsService anchorsService;
@Autowired
private PkRecordDao recordDao;
// 添加新主播
@PostMapping("add")
public ResponseData<Object> addNewAnchor(@RequestBody AnchorModel model) {
//查询是否存在重复主播
int r = anchorDao.selectAnchorWithAnchorIdAndUserId(model.getAnchorId(), model.getCreateUserId());
if (r != 0) {
return ResponseData.error(ResponseInfo.ERROR,"该主播已存在");
}
int insert = anchorDao.insert(model);
return insert == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,"添加失败");
return anchorsService.addNewAnchor(model) == 1 ? ResponseData.success("") : ResponseData.error(ErrorCode.ADD_FAILED);
}
// 查询我的主播列表
@PostMapping("list")
public ResponseData<Object> myAnchorList(@RequestBody Map<String,Integer> map) {
Integer userId = map.get("id");
List<AnchorModel> anchorModels = anchorDao.selectMyAnchor(userId);
return ResponseData.success(anchorModels);
return ResponseData.success(anchorsService.selectMyAnchor(userId));
}
// 删除我的主播
@PostMapping("deleteMyAnchor")
public ResponseData<Object> deleteMyAnchor(@RequestBody Map<String,Integer> map) {
Integer id = map.get("id");
AnchorModel anchorModel = anchorDao.selectById(id);
try {
String anchorId = anchorModel.getAnchorId();
// 根据主播id查询该主播是否存在pk记录
int i = recordDao.existsPkRecordByAnchor(anchorId);
if (i > 0) {
return ResponseData.error(ResponseInfo.ERROR,"该主播已有pk记录。无法删除");
}
int r = anchorDao.deleteById(id);
return r == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,null);
} catch (Exception e) {
return ResponseData.error(ResponseInfo.ERROR,"非法数据,操作失败");
}
return anchorsService.deleteMyAnchor(id) == 1 ? ResponseData.success(""):ResponseData.error(ErrorCode.DELETE_FAILED );
}
// 更新主播信息
@PostMapping("updateAnchorInfo")
public ResponseData<Object> updateAnchorInfo(@RequestBody AnchorModel model) {
// 查询该主播是否存在记录
int i = recordDao.existsPkRecordByAnchor(model.getAnchorId());
if (i > 0) {
return ResponseData.error(ResponseInfo.ERROR,"该主播已有pk记录。无法修改信息");
}
int r = anchorDao.updateById(model);
return r == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,null);
return anchorsService.updateAnchorInfo(model) == 1 ? ResponseData.success(""):ResponseData.error(ErrorCode.UPDATE_FAILED);
}
}

View File

@@ -0,0 +1,20 @@
package vvpkassistant.Anchors.service;
import vvpkassistant.Anchors.model.AnchorModel;
import vvpkassistant.Data.ResponseData;
import java.util.List;
/*
* @author: ziin
* @date: 2025/8/1 19:59
*/
public interface AnchorsService {
Integer addNewAnchor(AnchorModel model);
List<AnchorModel> selectMyAnchor(Integer userId);
Integer deleteMyAnchor(Integer id);
Integer updateAnchorInfo(AnchorModel model);
}

View File

@@ -0,0 +1,69 @@
package vvpkassistant.Anchors.service;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import vvpkassistant.Anchors.mapper.AnchorDao;
import vvpkassistant.Anchors.model.AnchorModel;
import vvpkassistant.Data.ResponseData;
import vvpkassistant.Data.ResponseInfo;
import vvpkassistant.common.ErrorCode;
import vvpkassistant.exception.BusinessException;
import vvpkassistant.pk.mapper.PkRecordDao;
import javax.annotation.Resource;
import java.util.List;
/*
* @author: ziin
* @date: 2025/8/1 19:59
*/
@Service
public class AnchorsServiceImpl implements AnchorsService {
@Resource
private AnchorDao anchorDao;
@Resource
private PkRecordDao recordDao;
@Override
public Integer addNewAnchor(AnchorModel model) {
//查询是否存在重复主播
int r = anchorDao.selectAnchorWithAnchorIdAndUserId(model.getAnchorId(), model.getCreateUserId());
if (r != 0) {
throw new BusinessException(ErrorCode.ANCHOR_ALREADY_EXISTS);
}
return anchorDao.insert(model);
}
@Override
public List<AnchorModel> selectMyAnchor(Integer userId) {
return anchorDao.selectMyAnchor(userId);
}
@Override
public Integer deleteMyAnchor(Integer id) {
AnchorModel anchorModel = anchorDao.selectById(id);
if (anchorModel == null) {
throw new BusinessException(ErrorCode.PARAMS_ERROR,"主播不存在");
}
String anchorId = anchorModel.getAnchorId();
// 根据主播id查询该主播是否存在pk记录
int i = recordDao.existsPkRecordByAnchor(anchorId);
if (i > 0) {
throw new BusinessException(ErrorCode.ANCHOR_HAS_PKRECORD,"该主播已有pk记录。无法删除");
}
return anchorDao.deleteById(id);
}
@Override
public Integer updateAnchorInfo(AnchorModel model) {
// 查询该主播是否存在记录
int i = recordDao.existsPkRecordByAnchor(model.getAnchorId());
if (i > 0) {
throw new BusinessException(ErrorCode.ANCHOR_HAS_PKRECORD,"该主播已有pk记录。无法修改信息");
}
return anchorDao.updateById(model);
}
}

View File

@@ -1,36 +1,45 @@
package vvpkassistant.Data;
import lombok.Data;
import org.springframework.lang.Nullable;
import vvpkassistant.common.ErrorCode;
import java.io.Serializable;
@Data
public class ResponseData<T> {
public class ResponseData<T> implements Serializable {
// 状态码
T data = null;
private T data ;
public String msg;
public Integer code;
ResponseData() {}
public ResponseData(int code, T data,String message) {
this.code = code;
this.data = data;
this.msg = message;
}
public ResponseData(int code, T data) {
this(code,data,"");
}
public ResponseData(ErrorCode errorCode) {
this(errorCode.getCode(), null, errorCode.getMessage());
}
// 成功的返回方法
public static <T> ResponseData<T> success(@Nullable T param) {
ResponseInfo info = ResponseInfo.SUCCESS;
ResponseData<T> data = new ResponseData<>();
data.setData(param);
data.setCode(info.getCode());
data.setMsg(info.getDesc());
return data;
public static <T> ResponseData<T> success(T data) {
return new ResponseData<>(ResponseInfo.SUCCESS.getCode(),data,"ok");
}
// 返回错误的方法
public static ResponseData<Object> error(ResponseInfo info, @Nullable String msg) {
ResponseData<Object> data = new ResponseData<>();
data.msg = msg != null ? msg : info.getDesc();
data.code = info.getCode();
data.data = null;
return data;
public static ResponseData<Object> error(int code,String message) {
return new ResponseData<>(code, message);
}
public static ResponseData<Object> error(ErrorCode errorCode) {
return new ResponseData<>(errorCode);
}
}

View File

@@ -37,7 +37,7 @@ public class FunctionConfigController {
boolean isDuplicate = FunctionConfigHolder.CONFIGS.stream()
.anyMatch(config -> name.equals(config.getFunctionName()));
if (isDuplicate) {
return ResponseData.error(ResponseInfo.ERROR,"配置名称重复");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"配置名称重复");
}else {
configMapper.insert(newModel);
FunctionConfigHolder.CONFIGS.add(newModel);
@@ -52,7 +52,7 @@ public class FunctionConfigController {
FunctionConfigHolder.CONFIGS.removeIf(c -> model.getId().equals(c.getId()));
return ResponseData.success("");
}else {
return ResponseData.error(ResponseInfo.ERROR,null);
return ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
}

View File

@@ -1,4 +1,4 @@
package vvpkassistant.SystemMessage;
package vvpkassistant.SystemMessage.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@@ -6,6 +6,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vvpkassistant.Data.ResponseData;
import vvpkassistant.SystemMessage.mapper.SystemMessageDao;
import vvpkassistant.SystemMessage.model.SystemMessage;
import vvpkassistant.Tools.VVTools;
import java.util.List;

View File

@@ -1,9 +1,10 @@
package vvpkassistant.SystemMessage;
package vvpkassistant.SystemMessage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import vvpkassistant.SystemMessage.model.SystemMessage;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package vvpkassistant.SystemMessage;
package vvpkassistant.SystemMessage.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;

View File

@@ -46,11 +46,11 @@ public class UserController {
public ResponseData<Object> inputUserInfo(@RequestBody Map<String,Object> param) {
if (!param.containsKey("code")) {
return ResponseData.error(ResponseInfo.ERROR, "code不能为空");
return ResponseData.error(ResponseInfo.ERROR.getCode(), "code不能为空");
}
if (!param.containsKey("id")) {
return ResponseData.error(ResponseInfo.ERROR, "id不能为空");
return ResponseData.error(ResponseInfo.ERROR.getCode(), "id不能为空");
}
//获取前端传递过来的code
@@ -64,23 +64,23 @@ public class UserController {
Integer errcode = Integer.valueOf(wx_result.get("errcode").toString());
if (errcode == 45011) {
return ResponseData.error(ResponseInfo.ERROR, "API 调用太频繁,请稍候再试。");
return ResponseData.error(ResponseInfo.ERROR.getCode(), "API 调用太频繁,请稍候再试。");
}
if (errcode == 40029) {
return ResponseData.error(ResponseInfo.ERROR, "js_code 无效");
return ResponseData.error(ResponseInfo.ERROR.getCode(), "js_code 无效");
}
if (errcode == 40226) {
return ResponseData.error(ResponseInfo.ERROR, "该账号为风险用户。禁止登录小程序");
return ResponseData.error(ResponseInfo.ERROR.getCode(), "该账号为风险用户。禁止登录小程序");
}
if (errcode == -1) {
return ResponseData.error(ResponseInfo.ERROR, "系统繁忙");
return ResponseData.error(ResponseInfo.ERROR.getCode(), "系统繁忙");
}
if (!wx_result.containsKey("openid")) {
return ResponseData.error(ResponseInfo.ERROR, "获取用户信息失败,请稍后再试。");
return ResponseData.error(ResponseInfo.ERROR.getCode(), "获取用户信息失败,请稍后再试。");
}
}
@@ -111,7 +111,7 @@ public class UserController {
return ResponseData.success(result);
}
return ResponseData.error(ResponseInfo.ERROR,"未知错误");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"未知错误");
}
// 手机号登录 / 注册
@@ -119,14 +119,14 @@ public class UserController {
public ResponseData<Object> loginWithPhoneNumber(@RequestBody Map<String,Object> param) {
if (!param.containsKey("code")) {
return ResponseData.error(ResponseInfo.ERROR,"code不能为空");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"code不能为空");
}
String code = param.get("code").toString();
String phoneNumber = vvRequester.queryPhoneNumber(code);
if (phoneNumber.isEmpty()) {
return ResponseData.error(ResponseInfo.ERROR,"手机号码无法查询");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"手机号码无法查询");
}
// 查询是否存在用户。如果用户存在直接返回 如果用户不存在则新建用户
@@ -181,7 +181,7 @@ public class UserController {
Map<String,Object> result = new HashMap<>();
result.put("info", userDao.selectById(map.get("id").toString()));
result.put("newAccount", false);
return i == 1 ? ResponseData.success(result) : ResponseData.error(ResponseInfo.ERROR, "");
return i == 1 ? ResponseData.success(result) : ResponseData.error(ResponseInfo.ERROR.getCode(), "");
}
// 获取用户信息
@@ -221,7 +221,7 @@ public class UserController {
// 别人邀请我的pk数据
return ResponseData.success(userDao.getMyGuestPkList(id, page * size, size));
}
return ResponseData.error(ResponseInfo.ERROR,"未知错误");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"未知错误");
}
@@ -239,7 +239,7 @@ public class UserController {
Integer userId = map.get("userId");
int i = userDao.checkSignStatus(userId);
if (i != 0) {
return ResponseData.error(ResponseInfo.ERROR,"当天已签到");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"当天已签到");
}
int result = userDao.signIn(userId);
@@ -258,7 +258,7 @@ public class UserController {
coinRecordsDao.insert(coinRecords);
return ResponseData.success(null);
}else {
return ResponseData.error(ResponseInfo.ERROR,null);
return ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
}
@@ -305,13 +305,13 @@ public class UserController {
// 返回给前端数据
return ResponseData.success(info);
}else {
return ResponseData.error(ResponseInfo.ERROR,null);
return ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
}else {
return ResponseData.error(ResponseInfo.ERROR,String.format("积分不足,需要%d积分",totalCoin));
return ResponseData.error(ResponseInfo.ERROR.getCode(),String.format("积分不足,需要%d积分",totalCoin));
}
}else {
return ResponseData.error(ResponseInfo.ERROR,"用户不存在");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"用户不存在");
}
}
@@ -345,7 +345,7 @@ public class UserController {
coinRecordsDao.insert(coinRecords);
return ResponseData.success(String.format("操作成功,返还%d积分",totalCoin));
}else {
return ResponseData.error(ResponseInfo.ERROR,null);
return ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
}

View File

@@ -22,7 +22,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,null);
return insert == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
//根据ip查询数据

View File

@@ -0,0 +1,44 @@
package vvpkassistant.common;
/**
* 自定义错误码
*
* @author <a href="https://github.com/liyupi">程序员鱼皮</a>
* @from <a href="https://yupi.icu">编程导航知识星球</a>
*/
public enum ErrorCode {
SUCCESS(0, "ok"),
ADD_FAILED(1, "添加失败"),
DELETE_FAILED(2, "删除失败"),
UPDATE_FAILED(2, "删除失败"),
ANCHOR_ALREADY_EXISTS(101,"主播已存在"),
ANCHOR_HAS_PKRECORD(102,"主播存在PK记录"),
SYSTEM_ERROR(50000, "系统错误"),
PARAMS_ERROR(40000, "请求参数错误")
;
/**
* 状态码
*/
private final int code;
/**
* 信息
*/
private final String message;
ErrorCode(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}

View File

@@ -13,7 +13,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
@RequiredArgsConstructor
public class FunctionConfigHolder {
// 线程安全的全局配置容器
static public final List<FunctionConfigModel> CONFIGS = new CopyOnWriteArrayList<>();
public static final List<FunctionConfigModel> CONFIGS = new CopyOnWriteArrayList<>();
@Autowired
private FunctionConfigMapper configMapper;

View File

@@ -0,0 +1,37 @@
package vvpkassistant.exception;
import vvpkassistant.common.ErrorCode;
/**
* 自定义异常类
*
* @author <a href="https://github.com/liyupi">程序员鱼皮</a>
* @from <a href="https://yupi.icu">编程导航知识星球</a>
*/
public class BusinessException extends RuntimeException {
/**
* 错误码
*/
private final int code;
public BusinessException(int code, String message) {
super(message);
this.code = code;
}
public BusinessException(ErrorCode errorCode) {
super(errorCode.getMessage());
this.code = errorCode.getCode();
}
public BusinessException(ErrorCode errorCode, String message) {
super(message);
this.code = errorCode.getCode();
}
public int getCode() {
return code;
}
}

View File

@@ -0,0 +1,33 @@
package vvpkassistant.exception;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import vvpkassistant.Data.ResponseData;
import vvpkassistant.Data.ResponseInfo;
import vvpkassistant.common.ErrorCode;
/**
* 全局异常处理器
*
* @author <a href="https://github.com/liyupi">程序员鱼皮</a>
* @from <a href="https://yupi.icu">编程导航知识星球</a>
*/
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
@ExceptionHandler(BusinessException.class)
public ResponseData<?> businessExceptionHandler(BusinessException e) {
log.error("BusinessException", e);
return ResponseData.error(e.getCode(), e.getMessage());
}
@ExceptionHandler(RuntimeException.class)
public ResponseData<?> runtimeExceptionHandler(RuntimeException e) {
log.error("RuntimeException", e);
return ResponseData.error(ErrorCode.SYSTEM_ERROR);
}
}

View File

@@ -0,0 +1,46 @@
package vvpkassistant.exception;
import vvpkassistant.common.ErrorCode;
/**
* 抛异常工具类
*
* @author <a href="https://github.com/liyupi">程序员鱼皮</a>
* @from <a href="https://yupi.icu">编程导航知识星球</a>
*/
public class ThrowUtils {
/**
* 条件成立则抛异常
*
* @param condition
* @param runtimeException
*/
public static void throwIf(boolean condition, RuntimeException runtimeException) {
if (condition) {
throw runtimeException;
}
}
/**
* 条件成立则抛异常
*
* @param condition
* @param errorCode
*/
public static void throwIf(boolean condition, ErrorCode errorCode) {
throwIf(condition, new BusinessException(errorCode));
}
/**
* 条件成立则抛异常
*
* @param condition
* @param errorCode
* @param message
*/
public static void throwIf(boolean condition, ErrorCode errorCode, String message) {
throwIf(condition, new BusinessException(errorCode, message));
}
}

View File

@@ -63,11 +63,11 @@ public class PkController {
// 判断该主播在当日是否已发布过pk信息
if (pkInfoModels.size() > 0) {
return ResponseData.error(ResponseInfo.ERROR,"该主播当日已有pk信息");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"该主播当日已有pk信息");
}
int insert = pkDao.insert(pkModel);
return insert == 1 ? ResponseData.success(pkModel) : ResponseData.error(ResponseInfo.ERROR,null);
return insert == 1 ? ResponseData.success(pkModel) : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
// 更新pk信息
@@ -124,7 +124,7 @@ public class PkController {
// 更新pk邀请记录
int update = recordDao.updateById(recordModel);
return update == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,null);
return update == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
// 创建PK记录
@@ -137,12 +137,12 @@ public class PkController {
Integer dataCount = recordDao.getPendingInvitations(anchorIdA, anchorIdB);
if (dataCount > 0) {
return ResponseData.error(ResponseInfo.ERROR,"已存在一条未处理的pk申请不能重复发送");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"已存在一条未处理的pk申请不能重复发送");
}
record.setPkStatus(0);
int insert = recordDao.insert(record);
return insert == 1 ? ResponseData.success(record) : ResponseData.error(ResponseInfo.ERROR,null);
return insert == 1 ? ResponseData.success(record) : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
// pk列表
@@ -220,7 +220,7 @@ public class PkController {
PkInfoModel pkInfoModel = pkDao.selectById(id);
if (pkInfoModel == null) {
return ResponseData.error(ResponseInfo.ERROR,"该信息不存在");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"该信息不存在");
}
if (from == 1) {
@@ -239,7 +239,7 @@ public class PkController {
}
return ResponseData.success(pkInfoModel);
}else {
return ResponseData.error(ResponseInfo.ERROR,"当前信息已无效");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"当前信息已无效");
}
}else{
Integer isHave = pkDao.checkIfUnfinishedPKExistsWithAnchor(userId, pkInfoModel.getAnchorId());
@@ -259,18 +259,18 @@ public class PkController {
PkInfoModel pkInfoModel = pkDao.selectById(id);
if (pkInfoModel.getPinExpireTime() > VVTools.currentTimeStamp()) {
return ResponseData.error(ResponseInfo.ERROR,"该信息在置顶中。如要删除清先取消置顶");
return ResponseData.error(ResponseInfo.ERROR.getCode(),"该信息在置顶中。如要删除清先取消置顶");
}
Integer result = pkDao.deletePkDataWithId(id);
return result == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,"删除数据失败");
return result == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR.getCode(),"删除数据失败");
}
//修改pk信息内容
@PostMapping("updatePkInfoById")
public ResponseData<Object> updatePkInfoById(@RequestBody PkInfoModel infoModel) {
int result = pkDao.updateById(infoModel);
return result == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,null);
return result == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
// 根据id查询pk记录
@@ -318,7 +318,7 @@ public class PkController {
@PostMapping("updatePkRecordInfo")
public ResponseData<Object> updatePkRecordInfo(@RequestBody PkRecord record) {
int i = recordDao.updateById(record);
return i == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,null);
return i == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
// 插入pk明细表数据
@@ -326,7 +326,7 @@ public class PkController {
public ResponseData<Object> insert(@RequestBody PkRecordDetail detail) {
detail.setCreateTime(VVTools.currentTimeStamp());
int insert = detailDao.insert(detail);
return insert == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR,null);
return insert == 1 ? ResponseData.success("") : ResponseData.error(ResponseInfo.ERROR.getCode(),null);
}
}

View File

@@ -3,7 +3,7 @@ server:
spring:
profiles:
active: prd
active: local

View File

@@ -3,7 +3,7 @@ server:
spring:
profiles:
active: prd
active: local