日志修改

This commit is contained in:
GYJ
2024-12-04 17:28:19 +08:00
parent 149eec4363
commit e8a2e9bee1
5 changed files with 139 additions and 124 deletions

View File

@@ -7,15 +7,17 @@ import org.slf4j.LoggerFactory;
import org.springframework.dao.DuplicateKeyException; import org.springframework.dao.DuplicateKeyException;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.NoHandlerFoundException; import org.springframework.web.servlet.NoHandlerFoundException;
/** /**
* 异常处理器 * 异常处理器
* *
* @author GYJ
*/ */
@RestControllerAdvice @RestControllerAdvice
public class SqxExceptionHandler { public class SqxExceptionHandler {
private Logger logger = LoggerFactory.getLogger(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
/** /**
* 处理自定义异常 * 处理自定义异常
@@ -30,25 +32,33 @@ public class SqxExceptionHandler {
} }
@ExceptionHandler(NoHandlerFoundException.class) @ExceptionHandler(NoHandlerFoundException.class)
public Result handlerNoFoundException(Exception e) { public Result handlerNoFoundException(Exception e, WebRequest webRequest) {
String requestUrl = webRequest.getDescription(false).split(" ")[1];
logger.error("请求路径不存在:{}", requestUrl);
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
return Result.error(404, "路径不存在,请检查路径是否正确"); return Result.error(404, "路径不存在,请检查路径是否正确");
} }
@ExceptionHandler(DuplicateKeyException.class) @ExceptionHandler(DuplicateKeyException.class)
public Result handleDuplicateKeyException(DuplicateKeyException e){ public Result handleDuplicateKeyException(DuplicateKeyException e, WebRequest webRequest) {
String requestUrl = webRequest.getDescription(false).split(" ")[1];
logger.error("请求路径:{},数据库中已存在该记录", requestUrl);
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
return Result.error("数据库中已存在该记录"); return Result.error("数据库中已存在该记录");
} }
@ExceptionHandler(AuthorizationException.class) @ExceptionHandler(AuthorizationException.class)
public Result handleAuthorizationException(AuthorizationException e){ public Result handleAuthorizationException(AuthorizationException e, WebRequest webRequest) {
String requestUrl = webRequest.getDescription(false).split(" ")[1];
logger.error("请求路径:{},没有权限", requestUrl);
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
return Result.error("没有权限,请联系管理员授权"); return Result.error("没有权限,请联系管理员授权");
} }
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
public Result handleException(Exception e){ public Result handleException(Exception e, WebRequest webRequest) {
String requestUrl = webRequest.getDescription(false).split(" ")[1];
logger.error("请求路径:{},发生异常", requestUrl);
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
return Result.error(); return Result.error();
} }

View File

@@ -875,7 +875,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
return getResult(userInfo); return getResult(userInfo);
} else { } else {
if(StringUtils.isEmpty(msg)){ if(StringUtils.isEmpty(msg)){
return Result.error("手机号未注册"); return Result.error("验证码不能为空");
} }
Msg msg1 = msgDao.findByPhoneAndCode(phone, msg); Msg msg1 = msgDao.findByPhoneAndCode(phone, msg);
if(msg1==null){ if(msg1==null){

View File

@@ -148,18 +148,24 @@ public class InviteServiceImpl extends ServiceImpl<InviteDao, Invite> implements
user.setInviterCode(userEntity.getInvitationCode()); user.setInviterCode(userEntity.getInvitationCode());
userService.updateById(user); userService.updateById(user);
String value = commonInfoService.findOne(813).getValue(); String value = commonInfoService.findOne(813).getValue();
if("".equals(value)){ if (!"".equals(value)) {
return 0;
}
//获取邀请人的邀请数量 //获取邀请人的邀请数量
int inviterCount = userService.queryInviterCount(userEntity.getInvitationCode()); int inviterCount = userService.queryInviterCount(userEntity.getInvitationCode());
InviteAward inviteAward = inviteAwardService.getOne(new QueryWrapper<InviteAward>().eq("invite_count", inviterCount)); InviteAward inviteAward = inviteAwardService.getOne(new QueryWrapper<InviteAward>().eq("invite_count", inviterCount));
if(inviteAward!=null){ if (inviteAward == null) {
return 0;
}
if (inviteAward.getInviteMonth() == 0) { if (inviteAward.getInviteMonth() == 0) {
userVipService.update(null, Wrappers.<UserVip>lambdaUpdate() userVipService.update(null, Wrappers.<UserVip>lambdaUpdate()
.set(UserVip::getIsVip, 2) .set(UserVip::getIsVip, 2)
.set(UserVip::getEndTime, null) .set(UserVip::getEndTime, null)
.set(UserVip::getVipType, 1) .set(UserVip::getVipType, 1)
.eq(UserVip::getUserId, userEntity.getUserId())); .eq(UserVip::getUserId, userEntity.getUserId()));
}else{
return 1;
}
UserVip userVip = userVipService.selectUserVipByUserId(userEntity.getUserId()); UserVip userVip = userVipService.selectUserVipByUserId(userEntity.getUserId());
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
if (userVip != null && userVip.getIsVip() == 2) { if (userVip != null && userVip.getIsVip() == 2) {
@@ -179,9 +185,6 @@ public class InviteServiceImpl extends ServiceImpl<InviteDao, Invite> implements
} else { } else {
userVipService.save(userVip); userVipService.save(userVip);
} }
}
}
}
return 1; return 1;
} }

View File

@@ -16,5 +16,6 @@ public class Constants {
final static String EXTRACT_QUERY_URL = BASE_URL + "/api/querySalary"; final static String EXTRACT_QUERY_URL = BASE_URL + "/api/querySalary";
final static String NOTIFY_URL = "https://video.hnsiyao.cn/sqx_fast/app/wuyou/notify"; final static String NOTIFY_URL = "https://video.hnsiyao.cn/sqx_fast/app/wuyou/notify";
final static String EXTRACT_NOTIFY_URL = "https://video.hnsiyao.cn/sqx_fast/app/wuyou/notify";
} }

View File

@@ -2,6 +2,7 @@ package com.sqx.modules.pay.wuyou;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -53,7 +54,7 @@ public class WuyouPay {
params.put("bank_branch", "1"); params.put("bank_branch", "1");
params.put("province", "1"); params.put("province", "1");
params.put("city", "1"); params.put("city", "1");
params.put("notify_url", "1"); params.put("notify_url", Constants.EXTRACT_NOTIFY_URL);
String sign = Encrypt.getParamsSign(params); String sign = Encrypt.getParamsSign(params);
params.put("sign", sign); params.put("sign", sign);
@@ -93,7 +94,7 @@ public class WuyouPay {
.execute() .execute()
.body(); .body();
logger.info("request url: {}, params: {}, response: {}", url, params, body); logger.info("无忧支付 request url: {}, params: {}, response: {}", url, params, body);
return body; return body;
} }