Commit 1089fb95 by huluobin

错误状态码

parent f874c39c
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gogirl.application.common.xcx.CustomerMessageService; import com.gogirl.application.common.xcx.CustomerMessageService;
import com.gogirl.domain.user.customer.CustomerMessage; import com.gogirl.domain.user.customer.CustomerMessage;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.SessionUtils; import com.gogirl.infrastructure.common.util.SessionUtils;
import com.gogirl.infrastructure.mapper.user.customer.CustomerMessageMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerMessageMapper;
...@@ -30,7 +31,7 @@ public class CustomerMessageServiceImpl extends ServiceImpl<CustomerMessageMappe ...@@ -30,7 +31,7 @@ public class CustomerMessageServiceImpl extends ServiceImpl<CustomerMessageMappe
public Page<CustomerMessage> queryPageMessage(CustomerMessagePageQuery qry) { public Page<CustomerMessage> queryPageMessage(CustomerMessagePageQuery qry) {
//线程变量当前当前用户id //线程变量当前当前用户id
if (SessionUtils.getCustomerToken() == null) { if (SessionUtils.getCustomerToken() == null) {
throw new RRException(2000, "token失效"); throw new RRException(ErrorCode.CS_2000);
} }
qry.setCustomerId(SessionUtils.getCustomerToken().getCustomerId()); qry.setCustomerId(SessionUtils.getCustomerToken().getCustomerId());
......
...@@ -23,6 +23,7 @@ import com.gogirl.domain.store.store.StoreManage; ...@@ -23,6 +23,7 @@ import com.gogirl.domain.store.store.StoreManage;
import com.gogirl.domain.store.store.StoreTechnician; import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.domain.user.customer.Customer; import com.gogirl.domain.user.customer.Customer;
import com.gogirl.infrastructure.common.config.property.GogirlProperties; import com.gogirl.infrastructure.common.config.property.GogirlProperties;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.*; import com.gogirl.infrastructure.common.util.*;
import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigLabelMapper; import com.gogirl.infrastructure.mapper.market.discount.LeisureDiscountConfigLabelMapper;
...@@ -621,7 +622,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper, ...@@ -621,7 +622,7 @@ public class ScheduleManageServiceImpl extends ServiceImpl<ScheduleManageMapper,
technicianId, technicianId,
scheduleId); scheduleId);
if (ListUtil.isNotEmpty(conflictScheduleServeList)) { if (ListUtil.isNotEmpty(conflictScheduleServeList)) {
throw new RRException(2003, "冲突"); throw new RRException(ErrorCode.OR_2003);
} }
}); });
} }
......
...@@ -8,6 +8,7 @@ import com.gogirl.application.store.store.StoreManageService; ...@@ -8,6 +8,7 @@ import com.gogirl.application.store.store.StoreManageService;
import com.gogirl.domain.common.xcx.GogirlToken; import com.gogirl.domain.common.xcx.GogirlToken;
import com.gogirl.domain.store.store.StoreGuide; import com.gogirl.domain.store.store.StoreGuide;
import com.gogirl.domain.store.store.StoreManage; import com.gogirl.domain.store.store.StoreManage;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.MapDistanceUtils; import com.gogirl.infrastructure.common.util.MapDistanceUtils;
import com.gogirl.infrastructure.common.util.SessionUtils; import com.gogirl.infrastructure.common.util.SessionUtils;
...@@ -37,7 +38,7 @@ public class StoreManageServiceImpl extends ServiceImpl<StoreManageMapper, Store ...@@ -37,7 +38,7 @@ public class StoreManageServiceImpl extends ServiceImpl<StoreManageMapper, Store
public List<StoreManage> getTechnicianShopList() { public List<StoreManage> getTechnicianShopList() {
GogirlToken gogirlToken = SessionUtils.getTechnicianToken(); GogirlToken gogirlToken = SessionUtils.getTechnicianToken();
if (gogirlToken == null) { if (gogirlToken == null) {
throw new RRException(2000, "token失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} }
return storeManageMapper.getTechnicianShopList(SessionUtils.getTechnicianId()); return storeManageMapper.getTechnicianShopList(SessionUtils.getTechnicianId());
} }
......
...@@ -9,6 +9,7 @@ import com.gogirl.application.store.store.StoreTechnicianService; ...@@ -9,6 +9,7 @@ import com.gogirl.application.store.store.StoreTechnicianService;
import com.gogirl.domain.common.xcx.GogirlToken; import com.gogirl.domain.common.xcx.GogirlToken;
import com.gogirl.domain.store.store.StoreManage; import com.gogirl.domain.store.store.StoreManage;
import com.gogirl.domain.store.store.StoreTechnician; import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.SessionUtils; import com.gogirl.infrastructure.common.util.SessionUtils;
import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper; import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper;
...@@ -58,7 +59,7 @@ public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMappe ...@@ -58,7 +59,7 @@ public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMappe
StoreTechnician storeTechnician = this.getOne(new LambdaQueryWrapper<StoreTechnician>().eq(StoreTechnician::getOpenid, openid)); StoreTechnician storeTechnician = this.getOne(new LambdaQueryWrapper<StoreTechnician>().eq(StoreTechnician::getOpenid, openid));
if (storeTechnician == null) { if (storeTechnician == null) {
throw new RRException(2006, "请绑定手机号"); throw new RRException(ErrorCode.TC_2006);
} }
//美甲师token //美甲师token
...@@ -82,7 +83,7 @@ public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMappe ...@@ -82,7 +83,7 @@ public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMappe
public void choseStore(Integer departmentId) { public void choseStore(Integer departmentId) {
GogirlToken gogirlToken = SessionUtils.getTechnicianToken(); GogirlToken gogirlToken = SessionUtils.getTechnicianToken();
if (gogirlToken == null) { if (gogirlToken == null) {
throw new RRException(2000, "token已经失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} }
StoreManage storeManage = storeManageMapper.selectById(departmentId); StoreManage storeManage = storeManageMapper.selectById(departmentId);
...@@ -95,7 +96,7 @@ public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMappe ...@@ -95,7 +96,7 @@ public class StoreTechnicianServiceImpl extends ServiceImpl<StoreTechnicianMappe
public StoreTechnician getTechnician() { public StoreTechnician getTechnician() {
Integer technicianId = SessionUtils.getTechnicianId(); Integer technicianId = SessionUtils.getTechnicianId();
if (technicianId == null) { if (technicianId == null) {
throw new RRException(2000, "token已经失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} }
StoreTechnician storeTechnician = this.getById(technicianId); StoreTechnician storeTechnician = this.getById(technicianId);
GogirlToken gogirlToken = SessionUtils.getTechnicianToken(); GogirlToken gogirlToken = SessionUtils.getTechnicianToken();
......
...@@ -12,6 +12,7 @@ import com.gogirl.domain.order.serve.OrderManage; ...@@ -12,6 +12,7 @@ import com.gogirl.domain.order.serve.OrderManage;
import com.gogirl.domain.store.store.StoreUser; import com.gogirl.domain.store.store.StoreUser;
import com.gogirl.domain.user.customer.CustomerBalance; import com.gogirl.domain.user.customer.CustomerBalance;
import com.gogirl.domain.user.customer.CustomerBalanceRecord; import com.gogirl.domain.user.customer.CustomerBalanceRecord;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.mapper.store.store.UserManageMapper; import com.gogirl.infrastructure.mapper.store.store.UserManageMapper;
import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerBalanceMapper;
...@@ -72,7 +73,7 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe ...@@ -72,7 +73,7 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
} }
if (customerBalance.getBalance() < cmd.getAmount()) { if (customerBalance.getBalance() < cmd.getAmount()) {
throw new RRException(2002, "余额不足"); throw new RRException(ErrorCode.CS_2002);
} }
//余额支付 //余额支付
......
package com.gogirl.infrastructure.common.exception;
/**
* <p>
* 错误码
* </p>
*
* @author robbendev
* @since 2020/7/23 2:17 下午
*/
public enum ErrorCode {
CS_1001(1001, "请授权手机号"),
CS_1002(1002, "会员才能享受服务"),
CS_2000(2000, "token失效,请重新登陆"),
CS_2002(2002, "余额不足"),
OR_2003(2003, "预约冲突"),
ST_2005(2005, "请选择店铺"),
TC_2006(2006, "请绑定手机号"),
;
private Integer code;
private String message;
ErrorCode(Integer code, String message) {
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
...@@ -46,6 +46,11 @@ public class RRException extends RuntimeException implements Serializable { ...@@ -46,6 +46,11 @@ public class RRException extends RuntimeException implements Serializable {
} }
public RRException(ErrorCode errorCode) {
this.code = errorCode.getCode();
this.message = errorCode.getMessage();
}
public RRException(String message) { public RRException(String message) {
this.code = 500; this.code = 500;
this.message = message; this.message = message;
......
...@@ -4,6 +4,7 @@ import com.gogirl.application.common.xcx.GogirlTokenService; ...@@ -4,6 +4,7 @@ import com.gogirl.application.common.xcx.GogirlTokenService;
import com.gogirl.domain.common.xcx.GogirlToken; import com.gogirl.domain.common.xcx.GogirlToken;
import com.gogirl.domain.user.customer.Customer; import com.gogirl.domain.user.customer.Customer;
import com.gogirl.infrastructure.common.annotation.AuthIgnore; import com.gogirl.infrastructure.common.annotation.AuthIgnore;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.StringUtils; import com.gogirl.infrastructure.common.util.StringUtils;
import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper; import com.gogirl.infrastructure.mapper.user.customer.CustomerMapper;
...@@ -54,11 +55,11 @@ public class AuthHandlerInterceptor implements HandlerInterceptor { ...@@ -54,11 +55,11 @@ public class AuthHandlerInterceptor implements HandlerInterceptor {
if (sourceFrom.equals("customer")) { if (sourceFrom.equals("customer")) {
GogirlToken gogirlToken = gogirlTokenService.getByToken(token); GogirlToken gogirlToken = gogirlTokenService.getByToken(token);
if (gogirlToken == null) { if (gogirlToken == null) {
throw new RRException(2000, "token失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} else { } else {
Customer customer = customerMapper.selectById(gogirlToken.getCustomerId()); Customer customer = customerMapper.selectById(gogirlToken.getCustomerId());
if (customer != null && StringUtils.isEmpty(customer.getPhone())) { if (customer != null && StringUtils.isEmpty(customer.getPhone())) {
throw new RRException(1001, "请授权手机号码"); throw new RRException(ErrorCode.CS_1001);
} }
} }
} }
......
...@@ -4,6 +4,7 @@ import com.gogirl.application.common.xcx.GogirlTokenService; ...@@ -4,6 +4,7 @@ import com.gogirl.application.common.xcx.GogirlTokenService;
import com.gogirl.domain.common.xcx.GogirlToken; import com.gogirl.domain.common.xcx.GogirlToken;
import com.gogirl.domain.store.store.StoreManage; import com.gogirl.domain.store.store.StoreManage;
import com.gogirl.infrastructure.common.annotation.LoginIgnore; import com.gogirl.infrastructure.common.annotation.LoginIgnore;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.ListUtil; import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper; import com.gogirl.infrastructure.mapper.store.store.StoreManageMapper;
...@@ -53,14 +54,14 @@ public class LoginHandlerInterceptor implements HandlerInterceptor { ...@@ -53,14 +54,14 @@ public class LoginHandlerInterceptor implements HandlerInterceptor {
if (sourceFrom.equals("customer")) { if (sourceFrom.equals("customer")) {
GogirlToken gogirlToken = gogirlTokenService.getByToken(token); GogirlToken gogirlToken = gogirlTokenService.getByToken(token);
if (gogirlToken == null) { if (gogirlToken == null) {
throw new RRException(2000, "token失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} }
} }
if (sourceFrom.equals("technician")) { if (sourceFrom.equals("technician")) {
GogirlToken gogirlToken = gogirlTokenService.getByToken(token); GogirlToken gogirlToken = gogirlTokenService.getByToken(token);
if (gogirlToken == null) { if (gogirlToken == null) {
throw new RRException(2000, "token失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} else { } else {
if (gogirlToken.getDepartmentId() == null || gogirlToken.getDepartmentId() == 0) { if (gogirlToken.getDepartmentId() == null || gogirlToken.getDepartmentId() == 0) {
List<StoreManage> storeManageList = storeManageMapper.getTechnicianShopList(gogirlToken.getTechnicianId()); List<StoreManage> storeManageList = storeManageMapper.getTechnicianShopList(gogirlToken.getTechnicianId());
...@@ -70,7 +71,7 @@ public class LoginHandlerInterceptor implements HandlerInterceptor { ...@@ -70,7 +71,7 @@ public class LoginHandlerInterceptor implements HandlerInterceptor {
gogirlToken.setDepartmentName(storeManage.getName()); gogirlToken.setDepartmentName(storeManage.getName());
gogirlTokenService.updateByToken(gogirlToken); gogirlTokenService.updateByToken(gogirlToken);
} else { } else {
throw new RRException(2005, "请选择店铺"); throw new RRException(ErrorCode.ST_2005);
} }
} }
} }
......
package com.gogirl.infrastructure.common.util; package com.gogirl.infrastructure.common.util;
import com.gogirl.domain.common.xcx.GogirlToken; import com.gogirl.domain.common.xcx.GogirlToken;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
/** /**
...@@ -77,7 +78,7 @@ public class SessionUtils { ...@@ -77,7 +78,7 @@ public class SessionUtils {
public static Integer getTechnicianId() { public static Integer getTechnicianId() {
GogirlToken gogirlToken = technicianTokenThreadLocal.get(); GogirlToken gogirlToken = technicianTokenThreadLocal.get();
if (gogirlToken == null) { if (gogirlToken == null) {
throw new RRException(2000, "token已经失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} }
return gogirlToken.getTechnicianId(); return gogirlToken.getTechnicianId();
} }
...@@ -90,7 +91,7 @@ public class SessionUtils { ...@@ -90,7 +91,7 @@ public class SessionUtils {
public static Integer getCustomerId() { public static Integer getCustomerId() {
GogirlToken gogirlToken = customerTokenThreadLocal.get(); GogirlToken gogirlToken = customerTokenThreadLocal.get();
if (gogirlToken == null) { if (gogirlToken == null) {
throw new RRException(2000, "token已经失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} }
return gogirlToken.getCustomerId(); return gogirlToken.getCustomerId();
} }
......
package com.gogirl.infrastructure.common.util; package com.gogirl.infrastructure.common.util;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
...@@ -34,7 +35,7 @@ public class WxUtils { ...@@ -34,7 +35,7 @@ public class WxUtils {
result = new String(WxPKCS7Encoder.decode(resultByte)); result = new String(WxPKCS7Encoder.decode(resultByte));
return JSONObject.fromObject(result); return JSONObject.fromObject(result);
} }
throw new RRException(2000, "token失效,请重新登陆"); throw new RRException(ErrorCode.CS_2000);
} }
/** /**
......
...@@ -17,6 +17,7 @@ import com.gogirl.domain.order.serve.ScheduleServe; ...@@ -17,6 +17,7 @@ import com.gogirl.domain.order.serve.ScheduleServe;
import com.gogirl.domain.product.serve.BaseProduce; import com.gogirl.domain.product.serve.BaseProduce;
import com.gogirl.domain.store.store.StoreTechnician; import com.gogirl.domain.store.store.StoreTechnician;
import com.gogirl.infrastructure.common.base.JsonResult; import com.gogirl.infrastructure.common.base.JsonResult;
import com.gogirl.infrastructure.common.exception.ErrorCode;
import com.gogirl.infrastructure.common.exception.RRException; import com.gogirl.infrastructure.common.exception.RRException;
import com.gogirl.infrastructure.common.util.ListUtil; import com.gogirl.infrastructure.common.util.ListUtil;
import com.gogirl.infrastructure.common.util.SessionUtils; import com.gogirl.infrastructure.common.util.SessionUtils;
...@@ -153,7 +154,7 @@ public class ScheduleManageController { ...@@ -153,7 +154,7 @@ public class ScheduleManageController {
.eq(VipServe::getVipLevel, customerBalanceService.getCustomerBalance(currentCustomerId).getLevel())); .eq(VipServe::getVipLevel, customerBalanceService.getCustomerBalance(currentCustomerId).getLevel()));
if (ListUtil.isEmpty(vipServeList)) { if (ListUtil.isEmpty(vipServeList)) {
throw new RRException(1002, "会员才能享受服务"); throw new RRException(ErrorCode.CS_1002);
} }
return JsonResult.success(); return JsonResult.success();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment