Commit 98a57a82 by 林永健

fix(controller): 修正MerchantStaffController中的错误处理和日志信息

1 parent 22eab51e
...@@ -3,6 +3,7 @@ package cn.com.glsx.dj.strategy.controller; ...@@ -3,6 +3,7 @@ package cn.com.glsx.dj.strategy.controller;
import cn.com.glsx.dj.smartcarlife.dto.StaffInfoDTO; import cn.com.glsx.dj.smartcarlife.dto.StaffInfoDTO;
import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote; import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote;
import cn.com.glsx.dj.strategy.request.StrategyStaffRequest; import cn.com.glsx.dj.strategy.request.StrategyStaffRequest;
import cn.com.glsx.dj.strategy.uitl.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
...@@ -60,11 +61,11 @@ public class MerchantStaffController { ...@@ -60,11 +61,11 @@ public class MerchantStaffController {
} }
return RopResponse.success(res.getResult()); return RopResponse.success(res.getResult());
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.info("addMerchantStaff occur error!", e); log.info("addMerchantStaff occur exception!", e);
return RopResponse.error(e); return RopResponse.error(e);
} catch (Exception e) { } catch (Exception e) {
log.info("addMerchantStaff occur error!", e); log.info("addMerchantStaff occur error!", e);
return RopResponse.result(DefaultErrorEnum.SERVICE_ERROR); return RopResponse.result(DefaultErrorEnum.SERVER_ERROR);
} }
} }
...@@ -82,11 +83,11 @@ public class MerchantStaffController { ...@@ -82,11 +83,11 @@ public class MerchantStaffController {
RpcResponse<List<MerchantStaffResponse>> staffListRes = merchantStaffRemote.selectStaffListByMerchantIdsAndPhone(staffQuery); RpcResponse<List<MerchantStaffResponse>> staffListRes = merchantStaffRemote.selectStaffListByMerchantIdsAndPhone(staffQuery);
if (staffListRes.isFailed()) { if (staffListRes.isFailed()) {
log.error("查询员工列表失败,response:{}", staffListRes); log.error("查询员工列表失败,response:{}", staffListRes);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, staffListRes.getMessage()); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, staffListRes.getMessage());
} }
if (CollectionUtils.isNotEmpty(staffListRes.getResult())) { if (CollectionUtils.isNotEmpty(staffListRes.getResult())) {
log.info("员工已存在, staffIds:{}", staffListRes.getResult().stream().map(MerchantStaffResponse::getUuid).collect(Collectors.toList())); log.info("员工已存在, staffIds:{}", staffListRes.getResult().stream().map(MerchantStaffResponse::getUuid).collect(Collectors.toList()));
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "已存在员工账号"); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "已存在员工账号");
} }
} }
...@@ -99,15 +100,15 @@ public class MerchantStaffController { ...@@ -99,15 +100,15 @@ public class MerchantStaffController {
staffRequest.setStaffPhone(request.getStaffPhone()); staffRequest.setStaffPhone(request.getStaffPhone());
staffRequest.setPassword("Gl123456"); staffRequest.setPassword("Gl123456");
staffRequest.setVisibleInferiorMer(request.getMerchantId().toString()); staffRequest.setVisibleInferiorMer(request.getMerchantId().toString());
staffRequest.setCreatedAccount("lyj-test"); staffRequest.setCreatedAccount(CommonUtil.getUserName());
staffRequest.setCreatedName("lyj-test1"); staffRequest.setCreatedName(CommonUtil.getUserName());
staffRequest.setStaffLabel(request.getStaffLabel()); staffRequest.setStaffLabel(request.getStaffLabel());
staffRequest.setStaffBusinessType(0); staffRequest.setStaffBusinessType(0);
// 查询商户主键 // 查询商户主键
RpcResponse<MerchantBaseInfoResponse> merchantRes = merchantRemote.findMerchantBaseInfo(request.getMerchantId()); RpcResponse<MerchantBaseInfoResponse> merchantRes = merchantRemote.findMerchantBaseInfo(request.getMerchantId());
if (merchantRes.isFailed() || merchantRes.getResult() == null) { if (merchantRes.isFailed() || merchantRes.getResult() == null) {
log.error("查询商户信息失败,merchantId:{}, response:{}", request.getMerchantId(), merchantRes); log.error("查询商户信息失败,merchantId:{}, response:{}", request.getMerchantId(), merchantRes);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "查询商户信息失败"); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "查询商户信息失败");
} }
staffRequest.setMerchantId(merchantRes.getResult().getId()); staffRequest.setMerchantId(merchantRes.getResult().getId());
...@@ -119,7 +120,7 @@ public class MerchantStaffController { ...@@ -119,7 +120,7 @@ public class MerchantStaffController {
RpcResponse<List<MerchantRoleResponse>> roleListRes = merchantRoleRemote.getRoleListRemote(roleQuery); RpcResponse<List<MerchantRoleResponse>> roleListRes = merchantRoleRemote.getRoleListRemote(roleQuery);
if (!roleListRes.hasResult() || CollectionUtils.isEmpty(roleListRes.getResult())) { if (!roleListRes.hasResult() || CollectionUtils.isEmpty(roleListRes.getResult())) {
log.error("查询角色列表失败,response:{}", roleListRes); log.error("查询角色列表失败,response:{}", roleListRes);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "门店驻店人员角色不存在"); throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "门店驻店人员角色不存在");
} }
Integer roleId = roleListRes.getResult().get(0).getId(); Integer roleId = roleListRes.getResult().get(0).getId();
staffRequest.setRoleIds(Lists.newArrayList(roleId)); staffRequest.setRoleIds(Lists.newArrayList(roleId));
...@@ -137,11 +138,11 @@ public class MerchantStaffController { ...@@ -137,11 +138,11 @@ public class MerchantStaffController {
} }
return RopResponse.success(res.getResult()); return RopResponse.success(res.getResult());
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.info("disableMerchantStaff occur error!", e); log.info("disableMerchantStaff occur exception!", e);
return RopResponse.error(e); return RopResponse.error(e);
} catch (Exception e) { } catch (Exception e) {
log.info("disableMerchantStaff occur error!", e); log.info("disableMerchantStaff occur error!", e);
return RopResponse.result(DefaultErrorEnum.SERVICE_ERROR); return RopResponse.result(DefaultErrorEnum.SERVER_ERROR);
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!