多语言-BusiResult返回包装类,适配BusiStatus常量名作i18n key
This commit is contained in:
@@ -539,7 +539,7 @@ public class GiftAdminService extends AbstractCoreService<Gift, GiftExample> {
|
||||
if (failCell.size() > 0) {
|
||||
retMap.put("row", failCell.toString());
|
||||
retMap.put("reason", failReason.toString());
|
||||
return new BusiResult(300, "部分导入成功", retMap);
|
||||
return new BusiResult(BusiStatus.SERVERERROR, "部分导入成功", retMap);
|
||||
} else {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
@@ -604,7 +604,7 @@ public class GiftAdminService extends AbstractCoreService<Gift, GiftExample> {
|
||||
if (failErbanNos.size() > 0) {
|
||||
retMap.put("row", failErbanNos.toString());
|
||||
retMap.put("reason", failReason.toString());
|
||||
return new BusiResult(300, "部分添加成功", retMap);
|
||||
return new BusiResult(BusiStatus.SERVERERROR, "部分添加成功", retMap);
|
||||
} else {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}
|
||||
|
@@ -361,7 +361,7 @@ public class VoiceAdminService extends BaseService {
|
||||
if (failCell.size() > 0) {
|
||||
retMap.put("row", failCell.toString());
|
||||
retMap.put("reason", failReason.toString());
|
||||
return new BusiResult(300,"部分导入成功",retMap);
|
||||
return new BusiResult(BusiStatus.SERVERERROR,"部分导入成功",retMap);
|
||||
} else {
|
||||
return new BusiResult(BusiStatus.SUCCESS,retMap);
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.dto.ChannelDistributeSearchDto;
|
||||
@@ -67,7 +68,7 @@ public class ChannelDistributeAdminController extends BaseController {
|
||||
ChannelDistribute record = channelDistributeAdminService.getById(id);
|
||||
return new BusiResult(BusiStatus.SUCCESS, record);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -5,10 +5,12 @@ import com.accompany.business.service.api.QinniuService;
|
||||
import com.accompany.common.config.QiNiuConfig;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import springfox.documentation.swagger.readers.operation.OperationAuthReader;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
@@ -24,9 +26,6 @@ public class QiniuUploadController extends BaseController {
|
||||
@Autowired
|
||||
private QinniuService qinniuService;
|
||||
|
||||
@Autowired
|
||||
private QiNiuConfig qiNiuConfig;
|
||||
|
||||
@RequestMapping(value = "uploadPatch", method = RequestMethod.POST)
|
||||
public BusiResult<List<String>> uploadPatch(HttpServletRequest request) throws Exception {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
@@ -43,7 +42,7 @@ public class QiniuUploadController extends BaseController {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("uploadPatch failed", e);
|
||||
return new BusiResult<>(500, e.getMessage(), null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
busiResult.setData(filePathList);
|
||||
return busiResult;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.activity;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.activity.ActivityAwardAdminService;
|
||||
@@ -50,7 +51,7 @@ public class ActivityAwardAdminController extends BaseController {
|
||||
busiResult.setData(list);
|
||||
return busiResult;
|
||||
}catch (Exception e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.activity;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
@@ -48,7 +49,7 @@ public class ActivityPackAdminController extends BaseController {
|
||||
"saveOrUpdate pack","params===>>name:"+name+",sellingPrice="+sellingPrice+",stock="+stock+",allowBuyNum="+allowBuyNum);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -62,7 +63,7 @@ public class ActivityPackAdminController extends BaseController {
|
||||
adminLogService.insertLog(getAdminId(),getClass().getCanonicalName(),"close pack","params===>>id:"+packId);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -86,7 +87,7 @@ public class ActivityPackAdminController extends BaseController {
|
||||
"params===>>packId:"+packId+",awardId:"+awardId+",num:"+num);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -100,7 +101,7 @@ public class ActivityPackAdminController extends BaseController {
|
||||
adminLogService.insertLog(getAdminId(),getClass().getCanonicalName(),"delPackItem","params===>>itemId:"+itemId);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -65,7 +65,7 @@ public class ChargeActivityAdminController extends BaseController {
|
||||
record.getActId(), record.getRoomRule(), record.getUserRule()));
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -81,7 +81,7 @@ public class ChargeActivityAdminController extends BaseController {
|
||||
chargeActivityService2.deleteById(id);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -94,7 +94,7 @@ public class ChargeActivityAdminController extends BaseController {
|
||||
ChargeActivityWithBLOBs record = chargeActivityService2.getById(id);
|
||||
return new BusiResult(BusiStatus.SUCCESS, record);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.anchor;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
@@ -46,11 +47,9 @@ public class AnchorAdminController extends BaseController {
|
||||
} else {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "添加失败!",null);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +63,7 @@ public class AnchorAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "操作失败!",null);
|
||||
}
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -4,6 +4,7 @@ import com.accompany.admin.params.app.AppBottomBarParam;
|
||||
import com.accompany.admin.service.app.AppBottomBarAdminService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -49,7 +50,7 @@ public class AppBottomBarAdminController {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}catch(Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ public class AppBottomBarAdminController {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}catch(Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,7 @@ import com.accompany.admin.service.channel.ChannelContentPartitionAdminService;
|
||||
import com.accompany.admin.util.ExcelUtils;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.channel.ChannelContentPartition;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -57,7 +58,7 @@ public class ChannelContentPartitionAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}catch(Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ public class ChannelContentPartitionAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}catch(Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ public class FirstPageBannerAdminController extends BaseController {
|
||||
firstPageBanner.setOperator(adminName);
|
||||
List<Integer> partitionIds = firstPageBanner.getPartitionIds();
|
||||
if (CollectionUtils.isEmpty(partitionIds)) {
|
||||
return new BusiResult(BusiStatus.ALERT_SIGN_FAIL.value(),"展示分区不能为空");
|
||||
return new BusiResult(BusiStatus.ALERT_SIGN_FAIL,"展示分区不能为空");
|
||||
}
|
||||
Boolean result = firstPageBannerAdminService.saveOrUpdateFirstPageBanner(firstPageBanner,startTimeString,endTimeString);
|
||||
if(result) {
|
||||
@@ -97,7 +97,7 @@ public class FirstPageBannerAdminController extends BaseController {
|
||||
@PostMapping(value="/upload")
|
||||
public BusiResult<String> uploadImage(@RequestParam("uploadFile") MultipartFile uploadFile) throws Exception{
|
||||
if(uploadFile.isEmpty()){
|
||||
return new BusiResult<>(400,"上传失败,表单类型不正确!");
|
||||
return new BusiResult<>(BusiStatus.PARAMETERILLEGAL,"上传失败,表单类型不正确!");
|
||||
}
|
||||
String fileName = uploadFile.getOriginalFilename();
|
||||
if (StrUtil.isNotEmpty(fileName)) {
|
||||
|
@@ -5,6 +5,7 @@ import com.accompany.admin.params.home.HomeRecommenResourceParam;
|
||||
import com.accompany.admin.service.home.HomeResourceAdminService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -45,7 +46,7 @@ public class HomeResourceAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}catch(Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ public class HomeResourceAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}catch(Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -58,7 +58,7 @@ public class DeviateRangeAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR.value(), e.getMessage(), null);
|
||||
return new BusiResult(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -7,6 +7,7 @@ import com.accompany.admin.service.system.AdminLogService;
|
||||
import com.accompany.business.model.PrizePoolItem;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,7 +43,7 @@ public class PrizePoolItemAdminController extends BaseController {
|
||||
"params===>>poolType:" + poolType + ", id:" + id + ", prizeId:" + prizeId);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
}catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error("save prizepoolitem failed",e);
|
||||
return new BusiResult(BusiStatus.BUSIERROR);
|
||||
|
@@ -86,11 +86,9 @@ public class UserCardsAdminController extends BaseController {
|
||||
adminLogService.insertLog(getAdminId(),getClass().getCanonicalName(),"exchangeCard",
|
||||
"params===>>uid:"+uid+",exchangeType:"+exchangeType+",exchangeRefId:"+exchangeRefId+",exchangeNum:"+exchangeNum+",eliminateCards:"+eliminateCards);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
} catch (ApiException e){
|
||||
return new BusiResult(e.getResponseCode(), e.getMessage(), null);
|
||||
}catch (ServiceException s){
|
||||
} catch (BusinessException | ApiException e){
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (ServiceException s){
|
||||
return new BusiResult(s.getBusiStatus());
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
@@ -108,9 +106,9 @@ public class UserCardsAdminController extends BaseController {
|
||||
"params===>>uid"+uid+",eliminateCards:"+eliminateCards);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (ApiException e){
|
||||
return new BusiResult(e.getResponseCode(), e.getMessage(), null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.BUSIERROR);
|
||||
@@ -174,11 +172,9 @@ public class UserCardsAdminController extends BaseController {
|
||||
OpenBoxKeyTypeEnum.DIAMOND.getValue() + ",exchangeNum:" + userBackpack.getCount() + ",eliminateCards:"+eliminateCards);
|
||||
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
} catch (ApiException e){
|
||||
return new BusiResult(e.getResponseCode(), e.getMessage(), null);
|
||||
}catch (ServiceException s){
|
||||
} catch (BusinessException | ApiException e){
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (ServiceException s){
|
||||
return new BusiResult(s.getBusiStatus());
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.user;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
@@ -47,7 +48,7 @@ public class FrozenAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "添加失败!",null);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -64,7 +65,7 @@ public class FrozenAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "解除失败!",null);
|
||||
}
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -57,7 +57,7 @@ public class TopicBoxItemAdminController extends BaseController {
|
||||
topicBoxItemAdminService.save(record);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -74,7 +74,7 @@ public class TopicBoxItemAdminController extends BaseController {
|
||||
topicBoxItemAdminService.deleteById(id);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -88,7 +88,7 @@ public class TopicBoxItemAdminController extends BaseController {
|
||||
TopicBoxItem record = topicBoxItemAdminService.getById(id);
|
||||
return new BusiResult(BusiStatus.SUCCESS, record);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.user;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
import com.accompany.admin.service.user.UserBankAccountAdminService;
|
||||
@@ -43,7 +44,7 @@ public class UserBankAccountAdminController extends BaseController {
|
||||
return busiResult;
|
||||
}catch (Exception e){
|
||||
logger.error("save or update failed,UserBankAccount={}",JSONObject.toJSON(userBankAccountVo),e);
|
||||
return new BusiResult(500,e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ public class UserBankAccountAdminController extends BaseController {
|
||||
return busiResult;
|
||||
}catch (Exception e){
|
||||
logger.error("delete failed, recordId={}",JSONObject.toJSON(recordId),e);
|
||||
return new BusiResult(500,e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.accompany.admin.controller.user;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.accompany.business.service.user.UsersService;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
@@ -75,7 +76,7 @@ public class UserCertifyRecordAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "删除失败!", null);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(), null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -97,7 +98,7 @@ public class UserCertifyRecordAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "删除失败!", null);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(), null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.user;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
@@ -49,7 +50,7 @@ public class UserMuteAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "添加失败!",null);
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -69,7 +70,7 @@ public class UserMuteAdminController extends BaseController {
|
||||
return new BusiResult(BusiStatus.UNKNOWN, "添加失败!",null);
|
||||
}
|
||||
} catch (BusinessException e){
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
@@ -85,7 +86,7 @@ public class UserMuteAdminController extends BaseController {
|
||||
UserMuteAdmin record = userMuteAdminService.getById(id);
|
||||
return new BusiResult(BusiStatus.SUCCESS, record);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.user;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.BusinessException;
|
||||
import com.accompany.admin.controller.BaseController;
|
||||
@@ -52,7 +53,7 @@ public class UserMuteRecordAdminController extends BaseController {
|
||||
userMuteRecordAdminService.release(id, reason);
|
||||
return new BusiResult(BusiStatus.SUCCESS);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult(500, e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.admin.controller.withdraw;
|
||||
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.accompany.admin.common.AdminConstants;
|
||||
@@ -64,7 +65,7 @@ public class WithdrawBlockAdminController extends BaseController {
|
||||
return busiResult;
|
||||
}catch (Exception e){
|
||||
logger.error("modify failed,param is uids:{}",uids,e);
|
||||
return new BusiResult(500,e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ public class WithdrawBlockAdminController extends BaseController {
|
||||
return busiResult;
|
||||
}catch (Exception e){
|
||||
logger.error("add withdraw block failed,erbanNo = {}",JSON.toJSONString(erbanNoList),e);
|
||||
return new BusiResult(500,e.getMessage(),null);
|
||||
throw new ServiceException(BusiStatus.SERVERERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,11 +26,6 @@ public class ApiException extends RuntimeException {
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public ApiException(int responseCode, String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public int getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
|
@@ -685,6 +685,11 @@ public enum BusiStatus implements BusiStatusInterface {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCode() {
|
||||
return value();
|
||||
|
@@ -2,6 +2,8 @@ package com.accompany.common.status;
|
||||
|
||||
public interface BusiStatusInterface {
|
||||
|
||||
String getName();
|
||||
|
||||
int getCode();
|
||||
|
||||
String getMessage();
|
||||
|
@@ -3,6 +3,7 @@ package com.accompany.common.result;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.status.BusiStatusInterface;
|
||||
import com.accompany.core.annotation.I18nPartition;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -19,7 +20,10 @@ public class BusiResult<T> {
|
||||
@ApiModelProperty("响应状态码")
|
||||
private int code;
|
||||
|
||||
@I18nPartition(className = "BusiStatus")
|
||||
@JsonIgnore
|
||||
private String codeName;
|
||||
|
||||
@I18nPartition(className = "BusiStatus", fieldName = "codeName")
|
||||
@ApiModelProperty("响应消息")
|
||||
private String message;
|
||||
|
||||
@@ -38,27 +42,28 @@ public class BusiResult<T> {
|
||||
status = BusiStatus.SERVER_BUSY;
|
||||
}
|
||||
this.code = status.getCode();
|
||||
this.codeName = status.getName();
|
||||
this.message = status.getMessage();
|
||||
this.data = data;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public BusiResult(BusiStatusInterface status, String message) {
|
||||
if (status == null) {
|
||||
status = BusiStatus.SERVER_BUSY;
|
||||
}
|
||||
this.code = status.getCode();
|
||||
this.codeName = status.getName();
|
||||
this.message = message;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public BusiResult(BusiStatusInterface status, String message, T data) {
|
||||
if (status == null) {
|
||||
status = BusiStatus.SERVER_BUSY;
|
||||
}
|
||||
this.code = status.getCode();
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public BusiResult(Integer code, String message) {
|
||||
this(code, message, null);
|
||||
}
|
||||
|
||||
public BusiResult(int code, String message, T data) {
|
||||
this.code = code;
|
||||
this.codeName = status.getName();
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
@@ -76,38 +81,6 @@ public class BusiResult<T> {
|
||||
this.message = status.getReasonPhrase();
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public static <T> BusiResult<T> success() {
|
||||
return success(null);
|
||||
}
|
||||
@@ -125,7 +98,7 @@ public class BusiResult<T> {
|
||||
}
|
||||
|
||||
public static <T> BusiResult<T> fail(String message) {
|
||||
return fail(500, message, null);
|
||||
return fail(BusiStatus.SERVERERROR, message, null);
|
||||
}
|
||||
|
||||
public static <T> BusiResult<T> fail(BusiStatusInterface status, String message) {
|
||||
@@ -143,10 +116,6 @@ public class BusiResult<T> {
|
||||
return new BusiResult<>(status, message, data);
|
||||
}
|
||||
|
||||
public static <T> BusiResult<T> fail(int code, String message, T data) {
|
||||
return new BusiResult<>(code, message, data);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public boolean isSuccess() {
|
||||
return this.code == BusiStatus.SUCCESS.value();
|
||||
|
@@ -45,7 +45,7 @@ public class GlobalExceptionHandler {
|
||||
public BusiResult<Void> handle(HttpServletRequest request, ServiceException exception) {
|
||||
logErrorMessage(request, exception);
|
||||
return new BusiResult<>(exception.getBusiStatus() == null ?
|
||||
BusiStatus.SERVER_BUSY.value() : exception.getBusiStatus().getCode(), exception.getMessage());
|
||||
BusiStatus.SERVER_BUSY : exception.getBusiStatus(), exception.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ public class GlobalExceptionHandler {
|
||||
})
|
||||
public BusiResult<Void> handle(HttpServletRequest request, ValidationException exception) {
|
||||
logErrorMessage(request, exception);
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR.value(), "請求參數錯誤:" + exception.getMessage());
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR, "請求參數錯誤:" + exception.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public class GlobalExceptionHandler {
|
||||
HttpServletRequest request, MethodArgumentNotValidException exception) {
|
||||
logErrorMessage(request, exception);
|
||||
FieldError fieldError = exception.getBindingResult().getFieldError();
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR.value(), Objects.requireNonNull(fieldError).getDefaultMessage());
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR, Objects.requireNonNull(fieldError).getDefaultMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ public class GlobalExceptionHandler {
|
||||
@ExceptionHandler({IllegalStateException.class})
|
||||
public BusiResult<Void> handle(HttpServletRequest request, IllegalStateException exception) {
|
||||
logErrorMessage(request, exception);
|
||||
return new BusiResult<>(BusiStatus.SERVER_BUSY.value(), exception.getMessage());
|
||||
return new BusiResult<>(BusiStatus.SERVER_BUSY, exception.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public class GlobalExceptionHandler {
|
||||
public BusiResult<Void> handle(
|
||||
HttpServletRequest request, HttpMessageNotReadableException exception) {
|
||||
logErrorMessage(request, exception);
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR.value(), "請求體錯誤");
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR, "請求體錯誤");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(BindException.class)
|
||||
public BusiResult<Void> handle(HttpServletRequest request, BindException exception) {
|
||||
logErrorMessage(request, exception);
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR.value(), Objects.requireNonNull(exception.getFieldError()).getDefaultMessage());
|
||||
return new BusiResult<>(BusiStatus.PARAMERROR, Objects.requireNonNull(exception.getFieldError()).getDefaultMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -205,7 +205,7 @@ public class PayCenterService {
|
||||
PayContext payContext = buildPayContext(null, null, successUrlSb.toString(), chargeProd, chargeRecord, realName, idCardNum, deviceInfo);
|
||||
PayStrategy strategy = payStrategyFactory.getStrategy(channel);
|
||||
if (strategy == null) {
|
||||
throw new ApiException(500, "支付失败.未找到正确的支付渠道");
|
||||
throw new ApiException("支付失败.未找到正确的支付渠道");
|
||||
}
|
||||
TarotChargeRetVo retVo = new TarotChargeRetVo();
|
||||
Object ret = strategy.pay(payContext);
|
||||
|
@@ -1170,7 +1170,7 @@ public class UsersService extends BaseService {
|
||||
} else {
|
||||
String message = String.format(BusiStatus.PAY_PASSWORD_ERROR.getReasonPhrase(),
|
||||
Constant.GrantError.PAY_PASSWORD - Long.parseLong(value));
|
||||
return new BusiResult(BusiStatus.PAY_PASSWORD_ERROR.value(), message, null);
|
||||
return new BusiResult(BusiStatus.PAY_PASSWORD_ERROR, message);
|
||||
}
|
||||
} else {
|
||||
jedisService.hdel(RedisKey.error_pay_password_times.getKey(), uid.toString());
|
||||
|
@@ -16,28 +16,6 @@ import java.util.List;
|
||||
@Configuration
|
||||
public class WebInterceptorConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public MappingJackson2HttpMessageConverter customJackson2HttpMessageConverter() {
|
||||
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
jsonConverter.setObjectMapper(objectMapper);
|
||||
return jsonConverter;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public StringHttpMessageConverter stringHttpMessageConverter() {
|
||||
return new StringHttpMessageConverter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
converters.add(customJackson2HttpMessageConverter());
|
||||
converters.add(stringHttpMessageConverter());
|
||||
}
|
||||
|
||||
/**
|
||||
* 自己定义的拦截器类
|
||||
* @return
|
||||
|
@@ -52,7 +52,7 @@ public class ExceptionController {
|
||||
}
|
||||
} else if (exception instanceof ApiException) {
|
||||
ApiException apiException = (ApiException) exception;
|
||||
return new BusiResult<>(apiException.getResponseCode(), apiException.getMessage(), null);
|
||||
return new BusiResult<>(BusiStatus.SERVERERROR, apiException.getMessage(), null);
|
||||
} else if (exception instanceof MethodArgumentNotValidException) {
|
||||
MethodArgumentNotValidException ex = (MethodArgumentNotValidException) exception;
|
||||
List<ObjectError> errors = ex.getBindingResult().getAllErrors();
|
||||
|
@@ -35,8 +35,6 @@ public class AnchorFansTeamController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private AnchorFansTeamService anchorFansTeamService;
|
||||
@Autowired
|
||||
private AnchorFansTeamAudioRecordService anchorFansTeamAudioRecordService;
|
||||
|
||||
private RateLimiter sendAllLimiter = RateLimiter.create(1500.0); // 1秒1500并发
|
||||
|
||||
@@ -175,8 +173,6 @@ public class AnchorFansTeamController extends BaseController {
|
||||
return new BusiResult(anchorFansTeamService.sendJoinTeamGift(sendUid, targetUids, roomUid, giftId, giftNum, msg, giftSource, sendType));
|
||||
} catch (ServiceException s){
|
||||
return new BusiResult(s.getBusiStatus(), s.getMessage(), null);
|
||||
}catch (ApiException a){
|
||||
return new BusiResult(a.getResponseCode(),a.getMessage(),null);
|
||||
}catch (Exception e){
|
||||
log.error("sendV4 error param==>>> uid:{},targetUids:{},roomUid:{},giftId:{},giftNum:{},sendType:{},giftSource:{}",
|
||||
sendUid, targetUids, roomUid, giftId, giftNum, sendType, giftSource,e);
|
||||
|
@@ -92,7 +92,7 @@ public class GiftV2Controller extends BaseController {
|
||||
} catch (ServiceException s) {
|
||||
return new BusiResult(s.getBusiStatus(), s.getMessage(), null);
|
||||
} catch (ApiException a) {
|
||||
return new BusiResult(a.getResponseCode(), a.getMessage(), null);
|
||||
return new BusiResult(a.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("sendV4 error param==>>> uid:{},targetUids:{},roomUid:{},giftId:{},giftNum:{},sendType:{},giftSource:{}",
|
||||
uid, targetUids, roomUid, giftId, giftNum, sendType, giftSource, e);
|
||||
|
@@ -180,6 +180,11 @@ public enum OAuthStatus implements BusiStatusInterface {
|
||||
return Integer.toString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCode() {
|
||||
return value();
|
||||
|
@@ -84,11 +84,11 @@ public class H5LoginController extends BaseController {
|
||||
try {
|
||||
String token = this.accountH5LoginService.checkCodeIsUsed(code);
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
return new BusiResult<>(1001, "no used", null);
|
||||
return new BusiResult<>(BusiStatus.SERVERERROR);
|
||||
}
|
||||
return new BusiResult<>(BusiStatus.SUCCESS, token);
|
||||
} catch (BusinessException e) {
|
||||
return new BusiResult<>(500, e.getMessage(), null);
|
||||
return new BusiResult<>(BusiStatus.SERVERERROR, e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return new BusiResult<>(BusiStatus.BUSIERROR);
|
||||
}
|
||||
@@ -104,8 +104,6 @@ public class H5LoginController extends BaseController {
|
||||
Map<String, String> map = this.accountH5LoginService.h5Login(token);
|
||||
log.info("h5 login ...... token={},result={}", token, JSONObject.toJSON(map));
|
||||
return new BusiResult<>(BusiStatus.SUCCESS, map);
|
||||
} catch (ApiException e) {
|
||||
return new BusiResult<>(e.getResponseCode(), e.getMessage(), null);
|
||||
} catch (CustomOAuth2Exception e) {
|
||||
return new BusiResult<>(BusiStatus.ACCOUNT_ERROR);
|
||||
} catch (Exception e) {
|
||||
@@ -140,7 +138,7 @@ public class H5LoginController extends BaseController {
|
||||
try {
|
||||
return BusiResult.success(accountH5LoginService.token(new ServletWebRequest(request, response)));
|
||||
} catch (Exception e) {
|
||||
return BusiResult.fail(HttpStatus.UNAUTHORIZED.value(), e.getMessage(), null);
|
||||
return BusiResult.fail(BusiStatus.NOAUTHORITY, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user