重新设计失败错误码。
This commit is contained in:
@@ -53,7 +53,7 @@ public class AdminAddressController {
|
||||
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
|
||||
String sort, String order){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
List<LitemallAddress> addressList = addressService.querySelective(userId, name, page, limit, sort, order);
|
||||
@@ -75,7 +75,7 @@ public class AdminAddressController {
|
||||
@PostMapping("/create")
|
||||
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallAddress address){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
String mobile = address.getMobile();
|
||||
@@ -92,7 +92,7 @@ public class AdminAddressController {
|
||||
@GetMapping("/read")
|
||||
public Object read(@LoginAdmin Integer adminId, Integer addressId){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
LitemallAddress address = addressService.findById(addressId);
|
||||
@@ -103,7 +103,7 @@ public class AdminAddressController {
|
||||
@PostMapping("/update")
|
||||
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallAddress address){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
addressService.updateById(address);
|
||||
Map<String, Object> addressVo = toVo(address);
|
||||
@@ -113,7 +113,7 @@ public class AdminAddressController {
|
||||
@PostMapping("/delete")
|
||||
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallAddress address){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
addressService.delete(address.getId());
|
||||
return ResponseUtil.ok();
|
||||
|
||||
@@ -43,9 +43,9 @@ public class AdminHistoryController {
|
||||
@PostMapping("/create")
|
||||
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallSearchHistory history){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
return ResponseUtil.fail501();
|
||||
return ResponseUtil.unsupport();
|
||||
}
|
||||
|
||||
@GetMapping("/read")
|
||||
|
||||
@@ -48,7 +48,7 @@ public class AdminOrderController {
|
||||
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
|
||||
String sort, String order){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
List<LitemallOrder> orderList = orderService.querySelective(userId, orderSn, page, limit, sort, order);
|
||||
int total = orderService.countSelective(userId, orderSn, page, limit, sort, order);
|
||||
@@ -74,7 +74,7 @@ public class AdminOrderController {
|
||||
@GetMapping("/read")
|
||||
public Object read(@LoginAdmin Integer adminId, Integer id){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
|
||||
LitemallOrder order = orderService.findById(id);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AdminUserController {
|
||||
@RequestParam(value = "limit", defaultValue = "10") Integer limit,
|
||||
String sort, String order){
|
||||
if(adminId == null){
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
List<LitemallUser> userList = userService.querySelective(username, mobile, page, limit, sort, order);
|
||||
int total = userService.countSeletive(username, mobile, page, limit, sort, order);
|
||||
@@ -43,7 +43,7 @@ public class AdminUserController {
|
||||
@GetMapping("/username")
|
||||
public Object username(String username){
|
||||
if(StringUtil.isEmpty(username)){
|
||||
return ResponseUtil.fail402();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
int total = userService.countSeletive(username, null, null, null, null, null);
|
||||
|
||||
@@ -33,7 +33,7 @@ router.beforeEach((to, from, next) => {
|
||||
})
|
||||
}).catch(() => {
|
||||
store.dispatch('FedLogOut').then(() => {
|
||||
Message.error('Verification failed, please login again')
|
||||
Message.error('验证失败,请输入正确的用户名和密码')
|
||||
next({ path: '/login' })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -26,22 +26,29 @@ service.interceptors.request.use(config => {
|
||||
service.interceptors.response.use(
|
||||
response => {
|
||||
const res = response.data
|
||||
if (res.errno === 502) {
|
||||
MessageBox.alert('系统内部错误,请联系管理员维护', '错误', {
|
||||
|
||||
if (res.errno === 501) {
|
||||
MessageBox.alert('系统未登录,请重新登录', '未登录', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
return Promise.reject('error')
|
||||
} else if (res.errno !== 0) {
|
||||
MessageBox.alert('超时自动退出系统,请重新登录', '已退出', {
|
||||
confirmButtonText: '重新登录',
|
||||
type: 'error'
|
||||
}).then(() => {
|
||||
store.dispatch('FedLogOut').then(() => {
|
||||
location.reload()
|
||||
})
|
||||
})
|
||||
return Promise.reject('error')
|
||||
} else if (res.errno === 502) {
|
||||
MessageBox.alert('系统内部错误,请联系管理员维护', '错误', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
return Promise.reject('error')
|
||||
} else if (res.errno === 503) {
|
||||
MessageBox.alert('请求业务目前未支持', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
return Promise.reject('error')
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -41,46 +41,27 @@ public class ResponseUtil {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static Object fail401() {
|
||||
return fail(401, "请登录");
|
||||
|
||||
|
||||
public static Object badArgument(){
|
||||
return fail(401, "参数不对");
|
||||
}
|
||||
|
||||
|
||||
public static Object badArgumentValue(){
|
||||
return fail(402, "参数值不对");
|
||||
}
|
||||
|
||||
public static Object unlogin(){
|
||||
return fail401();
|
||||
}
|
||||
|
||||
public static Object fail402() {
|
||||
return fail(402, "参数不对");
|
||||
}
|
||||
|
||||
public static Object badArgument(){
|
||||
return fail402();
|
||||
}
|
||||
|
||||
public static Object fail403() {
|
||||
return fail(403, "参数值不对");
|
||||
}
|
||||
|
||||
public static Object badArgumentValue(){
|
||||
return fail403();
|
||||
}
|
||||
|
||||
public static Object fail501() {
|
||||
return fail(501, "业务不支持");
|
||||
}
|
||||
|
||||
public static Object unsupport(){
|
||||
return fail501();
|
||||
}
|
||||
|
||||
public static Object fail502() {
|
||||
return fail(502, "系统内部错误");
|
||||
return fail(501, "请登录");
|
||||
}
|
||||
|
||||
public static Object serious(){
|
||||
return fail502();
|
||||
return fail(502, "系统内部错误");
|
||||
}
|
||||
|
||||
|
||||
public static Object unsupport(){
|
||||
return fail(503, "业务不支持");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class WxAuthController {
|
||||
List<LitemallUser> userList =userService.queryByUsername(username);
|
||||
LitemallUser user = null;
|
||||
if(userList.size() > 1){
|
||||
return ResponseUtil.fail502();
|
||||
return ResponseUtil.serious();
|
||||
}
|
||||
else if(userList.size() == 0){
|
||||
return ResponseUtil.badArgumentValue();
|
||||
|
||||
@@ -125,7 +125,7 @@ public class WxOrderController {
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "size", defaultValue = "10") Integer size) {
|
||||
if (userId == null) {
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if (showType == null) {
|
||||
showType = 0;
|
||||
@@ -186,10 +186,10 @@ public class WxOrderController {
|
||||
@GetMapping("detail")
|
||||
public Object detail(@LoginUser Integer userId, Integer orderId) {
|
||||
if (userId == null) {
|
||||
return ResponseUtil.fail401();
|
||||
return ResponseUtil.unlogin();
|
||||
}
|
||||
if (orderId == null) {
|
||||
return ResponseUtil.fail402();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
// 订单信息
|
||||
|
||||
@@ -87,7 +87,7 @@ public class WxTopicController {
|
||||
@GetMapping("related")
|
||||
public Object related(Integer id) {
|
||||
if(id == null){
|
||||
return ResponseUtil.fail402();
|
||||
return ResponseUtil.badArgument();
|
||||
}
|
||||
|
||||
List<LitemallTopic> topicRelatedList = topicService.queryRelatedList(id, 0, 4);
|
||||
|
||||
@@ -36,7 +36,7 @@ function request(url, data = {}, method = "GET") {
|
||||
|
||||
if (res.statusCode == 200) {
|
||||
|
||||
if (res.data.errno == 401) {
|
||||
if (res.data.errno == 501) {
|
||||
// 清除登录相关内容
|
||||
try {
|
||||
wx.removeStorageSync('userInfo');
|
||||
|
||||
Reference in New Issue
Block a user