提交 9e8d60e7 authored 作者: 李秋林's avatar 李秋林

将parent依赖修改为wangxiaolu-promotion-parent依赖;将公用工具移动到wangxiaolu-promotion-common模块

上级 4d97c993
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
<!-- 当前pom依赖在项目进行拆分时,拆到parent项目中,此项目做为promotion业务子模块--> <!-- 当前pom依赖在项目进行拆分时,拆到parent项目中,此项目做为promotion业务子模块-->
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>com.wangxiaolu</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>wangxiaolu-promotion-parent</artifactId>
<version>2.4.2</version> <version>0.0.1</version>
<relativePath/>
</parent> </parent>
<groupId>com.wangxiaolu</groupId> <groupId>com.wangxiaolu</groupId>
...@@ -19,179 +18,15 @@ ...@@ -19,179 +18,15 @@
<name>wangxiaolu-promotion-service</name> <name>wangxiaolu-promotion-service</name>
<description>promotion-service</description> <description>promotion-service</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!-- Web 场景启动器) 来为 Web 开发予以支持。spring-boot-starter-web 为我们提供了嵌入的 Servlet 容器以及 SpringMVC 的依赖,并为 Spring MVC 提供了大量自动配置,可以适用于大多数 Web 开发场景。-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.29</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.wangxiaolu</groupId>
<artifactId>mybatis-plus-annotation</artifactId> <artifactId>wangxiaolu-promotion-common</artifactId>
<version>3.4.0</version> <version>0.0.1</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.44</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.64</version>
</dependency>
<!-- 微信小程序 SDK 依赖 -->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>4.6.0</version>
</dependency>
<!-- 腾讯云服务 -->
<!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java-sms</artifactId>
<version>3.1.998</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2021.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-starter-alibaba-nacos-config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2021.1</version>
</dependency>
<!--解决SpringCloud项目无法读取bootstrap.yaml配置文件-->
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-bootstrap -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>4.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.xuxueli/xxl-job-core -->
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
<version>2.4.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -3,7 +3,6 @@ package com.wangxiaolu.promotion; ...@@ -3,7 +3,6 @@ package com.wangxiaolu.promotion;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
......
package com.wangxiaolu.promotion.common.redis;
import lombok.AllArgsConstructor;
import lombok.Getter;
public interface RedisKeys {
@AllArgsConstructor
@Getter
enum UserKeys {
/**
* 用户接收手机验证码
*/
PHONE_VER_CODE("user:phone_code:phone_"),
/**
* 用户登录信息:token
*/
TEMPORARY_TOKEN("user:login_token:temporary:"),
;
String key;
}
}
package com.wangxiaolu.promotion.common.redis.service;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
@Component
public class RedisCache {
@Autowired
RedisTemplate<String, String> redisTemplate;
/**
* 保存一个值
*/
public void add(String key, String val) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
vo.set(key, val);
}
/**
* 保存一个值,设置过期时间(分钟)
*/
public void addToMinute(String key, String val, long time) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
vo.set(key, val, time, TimeUnit.MINUTES);
}
/**
* 保存一个值,并将val json化
*/
public void addToJson(String key, Object val) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
vo.set(key, valToJson(val));
}
/**
* 保存一个值,并将val json化,设置过期时间(分钟)
*/
public void addToJsonToMinute(String key, Object val, long time) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
vo.set(key, valToJson(val), time, TimeUnit.MINUTES);
}
/**
* 保存一个值,并将val json化,设置过期时间(天)
*/
public void addToJsonToDays(String key, Object val, long days) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
vo.set(key, valToJson(val), days, TimeUnit.DAYS);
}
/**
* 获取一个值
*/
public String get(String key) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
return vo.get(key);
}
/**
* 获取一个值,并将val json化
*/
public JSONObject getToJson(String key) {
ValueOperations<String, String> vo = redisTemplate.opsForValue();
String val = vo.get(key);
return JSONObject.parseObject(val);
}
/**
* 获取一个值,并将val json化
*/
// public JSONObject getUserJsonInfo(String authorization) {
// JSONObject userDetail = getToJson(RedisKeys.UserKeys.TOKEN.getKey() + authorization);
// return userDetail;
// }
public void removeKey(String key) {
redisTemplate.delete(key);
}
private String valToJson(Object o) {
return JSONObject.toJSONString(o);
}
}
package com.wangxiaolu.promotion.controller.activity.temporary; package com.wangxiaolu.promotion.controller.activity.temporary;
import com.wangxiaolu.promotion.enums.activity.ClockType;
import com.wangxiaolu.promotion.exception.ParamException; import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.enums.activity.ClockType;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.vo.TemporaryActivityDataVo; import com.wangxiaolu.promotion.pojo.activity.temporary.vo.TemporaryActivityDataVo;
import com.wangxiaolu.promotion.pojo.activity.temporary.vo.TemporaryClockVo; import com.wangxiaolu.promotion.pojo.activity.temporary.vo.TemporaryClockVo;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityCoreService; import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityCoreService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
......
package com.wangxiaolu.promotion.controller.activity.temporary; package com.wangxiaolu.promotion.controller.activity.temporary;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.pojo.PageInfo; import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService; import com.wangxiaolu.promotion.service.activity.temporary.TemporaryActivityQueryService;
...@@ -9,8 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,8 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/** /**
* @author : liqiulin * @author : liqiulin
......
...@@ -4,7 +4,6 @@ import com.wangxiaolu.promotion.exception.ParamException; ...@@ -4,7 +4,6 @@ import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.RCode; import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.user.TencentCoreService; import com.wangxiaolu.promotion.service.user.TencentCoreService;
import com.wangxiaolu.promotion.utils.DataUtils; import com.wangxiaolu.promotion.utils.DataUtils;
import com.wangxiaolu.promotion.utils.TencentUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
package com.wangxiaolu.promotion.exception;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.result.basedata.StatusCode;
import lombok.Getter;
/**
* @author : liqiulin
* @date : 2024-03-28 17
* @describe : response包装R失败
*/
@Getter
public class APIException extends RuntimeException {
private int code;
private String msg;
public APIException(StatusCode statusCode, String message) {
super(message);
this.code = statusCode.getCode();
this.msg = statusCode.getMsg();
}
/**
* 默认异常编码
*/
public APIException(String message) {
super(message);
this.code = RCode.API_ERROR.getCode();
this.msg = RCode.API_ERROR.getMsg();
}
}
package com.wangxiaolu.promotion.exception;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.result.basedata.StatusCode;
import lombok.Getter;
/**
* @author : liqiulin
* @date : 2024-03-28 17
* @describe : response包装R失败
*/
@Getter
public class DataException extends RuntimeException {
private int code;
private String msg;
public DataException(StatusCode statusCode, String message) {
super(message);
this.code = statusCode.getCode();
this.msg = statusCode.getMsg();
}
/**
* 默认异常编码
*/
public DataException(String message) {
super(message);
this.code = RCode.API_ERROR.getCode();
this.msg = RCode.API_ERROR.getMsg();
}
}
package com.wangxiaolu.promotion.exception;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.result.basedata.StatusCode;
import lombok.Getter;
/**
* @author : liqiulin
* @date : 2024-03-28 19
* @describe : 业务流程异常
*/
@Getter
public class FlowException extends RuntimeException{
private int code;
private String msg;
public FlowException(StatusCode statusCode, String message) {
super(message);
this.code = statusCode.getCode();
this.msg = statusCode.getMsg();
}
/**
* 默认异常编码
*/
public FlowException(String message) {
super(message);
this.code = RCode.LOGIN_PARAM_ERROR.getCode();
this.msg = RCode.LOGIN_PARAM_ERROR.getMsg();
}
}
package com.wangxiaolu.promotion.exception;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.result.basedata.StatusCode;
import lombok.Getter;
/**
* @author : liqiulin
* @date : 2024-03-28 19
* @describe : 参数异常
*/
@Getter
public class ParamException extends RuntimeException{
private int code;
private String msg;
public ParamException(StatusCode statusCode, String message) {
super(message);
this.code = statusCode.getCode();
this.msg = statusCode.getMsg();
}
/**
* 默认异常编码
*/
public ParamException(String message) {
super(message);
this.code = RCode.LOGIN_PARAM_ERROR.getCode();
this.msg = RCode.LOGIN_PARAM_ERROR.getMsg();
}
}
package com.wangxiaolu.promotion.result.advice;
import com.wangxiaolu.promotion.exception.APIException;
import com.wangxiaolu.promotion.exception.FlowException;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.result.basedata.RCode;
import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.sql.SQLIntegrityConstraintViolationException;
/**
* @author : liqiulin
* @date : 2024-03-28 19
* @describe : 统一异常处理
*/
@RestControllerAdvice
public class ControllerExceptionAdvice {
@ExceptionHandler({ParamException.class})
public R paramExceptionHandler(ParamException e) {
return new R(e.getCode(), e.getMsg(), e.getMessage());
}
@ExceptionHandler({FlowException.class})
public R flowExceptionHandler(FlowException e) {
return new R(e.getCode(), e.getMsg(), e.getMessage());
}
@ExceptionHandler({APIException.class})
public R apiExceptionHandler(APIException e) {
return new R(e.getCode(), e.getMsg(), e.getMessage());
}
@ExceptionHandler({SQLIntegrityConstraintViolationException.class})
public R dbConstraintViolationExceptionHandler(SQLIntegrityConstraintViolationException e) {
RCode errorCode = RCode.USER_PHONE_IDENNUMBER_WXOPENID_UNIQUE_ERROR;
String msg = errorCode.getMsg();
String message = e.getMessage();
if (message.contains("phone_unique")) {
msg = "手机号已注册";
} else if (message.contains("iden_num_unique")) {
msg = "身份证已注册";
} else if (message.contains("open_id_unique")) {
msg = "微信号已注册";
}
return new R(errorCode.getCode(), msg, message);
}
@ExceptionHandler({MethodArgumentNotValidException.class})
public R methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) {
String msg = e.getBindingResult().getFieldError().getDefaultMessage();
return new R(RCode.PARAM_ERROR.getCode(), msg);
}
@ExceptionHandler({DataIntegrityViolationException.class})
public R dataIntegrityViolationExceptionHandler(DataIntegrityViolationException e) {
String msg = e.getMessage();
if (msg.contains("java.sql.SQLIntegrityConstraintViolationException")){
return dbConstraintViolationExceptionHandler(new SQLIntegrityConstraintViolationException(msg));
}
return new R(RCode.API_DATA_ERROR.getCode(), RCode.API_DATA_ERROR.getMsg(), msg);
}
@ExceptionHandler({TooManyResultsException.class})
public R tooManyResultsExceptionHandler(TooManyResultsException e) {
String msg = e.getMessage();
return new R(RCode.DATA_TOO_MANY_ERROR.getCode(), msg);
}
}
package com.wangxiaolu.promotion.result.advice;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wangxiaolu.promotion.exception.APIException;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.result.basedata.RCode;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
/**
* @author : liqiulin
* @date : 2024-03-28 17
* @describe : 自动封装 R
*/
@RestControllerAdvice(basePackages = {"com.wangxiaolu.promotion.controller"})
public class ControllerResponseAdvice implements ResponseBodyAdvice<Object> {
@Override
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
// response是R类型或者注释了NotControllerResponseAdvice都不进行包装
return !methodParameter.getParameterType().isAssignableFrom(R.class);
}
@Override
public Object beforeBodyWrite(Object data, MethodParameter methodParameter, MediaType mediaType, Class<? extends HttpMessageConverter<?>> aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
// String类型不能直接包装
if (methodParameter.getGenericParameterType().equals(String.class)) {
ObjectMapper objectMapper = new ObjectMapper();
try {
// 将数据包装在ResultVo里后转换为json串进行返回
return objectMapper.writeValueAsString(new R(data));
} catch (JsonProcessingException e) {
throw new APIException(RCode.RESPONSE_PACK_ERROR, e.getMessage());
}
}
// 包装成R返回
return new R(data);
}
}
package com.wangxiaolu.promotion.result.basedata;
import lombok.Data;
/**
* @author : liqiulin
* @date : 2024-03-28 17
* @describe : 统一响应VO
*/
@Data
public class R {
/**
* 响应码
* 非0失败
*/
private int code;
/**
* 提示信息
*/
private String msg;
/**
* 返回对象
*/
private Object data;
/**
* 默认成功
*/
public R(Object data) {
this.code = RCode.SUCCESS.getCode();
this.msg = RCode.SUCCESS.getMsg();
this.data = data;
}
/**
* 无数据返回
*/
public R(StatusCode statusCode) {
this.code = statusCode.getCode();
this.msg = statusCode.getMsg();
this.data = null;
}
/**
* 手动配置code、msg
*/
public R(Integer code, String msg) {
this.code = code;
this.msg = msg;
this.data = null;
}
/**
* 指定状态
*/
public R(StatusCode statusCode, Object data) {
this.code = statusCode.getCode();
this.msg = statusCode.getMsg();
this.data = data;
}
/**
* 手动设置
*/
public R(int code, String msg, Object data) {
this.code = code;
this.msg = msg;
this.data = data;
}
}
package com.wangxiaolu.promotion.result.basedata;
import lombok.Getter;
/**
* @author : liqiulin
* @date : 2024-03-28 17
* @describe : 返回状态编码
*/
@Getter
public enum RCode implements StatusCode {
/**
* 程序统一编码(不分模块)
* 1000+
*/
SUCCESS(0, "请求成功"),
FAILED(1001, "请求失败"),
PARAM_ERROR(1002, "参数错误"),
RESPONSE_PACK_ERROR(1003, "包装R失败"),
/**
* 业务统一编码(不分模块)
* 2000+
*/
API_ERROR(2000, "业务异常"),
API_DATA_ERROR(2001, "业务数据异常"),
DATA_HAVE_ERROR(2002, "数据已存在,不可新增"),
STATUS_UPDATE_ERROR(2003, "当前状态不可修改"),
DATA_NOT_HAVE_ERROR(2004, "数据不存在"),
DATA_TOO_MANY_ERROR(2005, "唯一数据存在多条"),
/**
* user
* 3000+
*/
LOGIN_PARAM_ERROR(3000, "登录信息错误"),
ENROLL_PARAM_ERROR(3001, "注册信息错误"),
PHONE_PARAM_ERROR(3002, "手机号异常"),
USER_PHONE_IDENNUMBER_WXOPENID_UNIQUE_ERROR(3003, "个人信息已注册"),
LOGIN_USER_IS_NULL_ERROR(3004, "账号未注册"),
CLOCK_DETAIL_ERROR(3005, "打卡信息错误"),
CLOCK_DETAIL_TIME_ERROR(3006, "不在打卡时间范围内"),
CHARGER_ID_ERROR(3007, "未找到负责人"),
/**
* 腾讯云
* 3500+
*/
TENCENT_SMS_ERROR(3500, "短信发送失败"),
TENCENT_SMS_REPETITION(3501, "短信已发送"),
TENCENT_SMS_PHONE_CODE_ERROR(3502, "验证码错误"),
;
private int code;
private String msg;
RCode(int code, String msg) {
this.code = code;
this.msg = msg;
}
}
package com.wangxiaolu.promotion.result.basedata;
/**
* @author : liqiulin
* @date : 2024-03-28 17
* @describe :返回状态编码
*/
public interface StatusCode {
int getCode();
String getMsg();
}
...@@ -44,8 +44,8 @@ public class TencentCoreServiceImpl implements TencentCoreService { ...@@ -44,8 +44,8 @@ public class TencentCoreServiceImpl implements TencentCoreService {
log.info("腾讯云短信,发送验证码:{}-{}", phone, phoneVerCode); log.info("腾讯云短信,发送验证码:{}-{}", phone, phoneVerCode);
redisCache.addToMinute(redisKey, phoneVerCode, overdueLong); redisCache.addToMinute(redisKey, phoneVerCode, overdueLong);
boolean succss = tencentUtils.sendSmsPhoneVerCode(phone, phoneVerCode); // boolean succss = tencentUtils.sendSmsPhoneVerCode(phone, phoneVerCode);
// boolean succss = true; boolean succss = true;
if (!succss) { if (!succss) {
redisCache.removeKey(redisKey); redisCache.removeKey(redisKey);
log.info("腾讯云短信发送失败:删除验证码:{}-{}", phone, phoneVerCode); log.info("腾讯云短信发送失败:删除验证码:{}-{}", phone, phoneVerCode);
......
package com.wangxiaolu.promotion.service.wechat.impl; package com.wangxiaolu.promotion.service.wechat.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.common.redis.RedisKeys;
import com.wangxiaolu.promotion.common.redis.service.RedisCache; import com.wangxiaolu.promotion.common.redis.service.RedisCache;
import com.wangxiaolu.promotion.domain.user.dao.TemporaryInfoDao; import com.wangxiaolu.promotion.domain.user.dao.TemporaryInfoDao;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto; import com.wangxiaolu.promotion.pojo.user.dto.WxTemporaryInfoDto;
import com.wangxiaolu.promotion.result.basedata.RCode; import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.wechat.WeChatUserQueryService; import com.wangxiaolu.promotion.service.wechat.WeChatUserQueryService;
......
...@@ -3,7 +3,6 @@ package com.wangxiaolu.promotion.utils; ...@@ -3,7 +3,6 @@ package com.wangxiaolu.promotion.utils;
import com.auth0.jwt.JWT; import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier; import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm; import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.wangxiaolu.promotion.exception.ParamException; import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.RCode; import com.wangxiaolu.promotion.result.basedata.RCode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
......
package com.wangxiaolu.promotion.utils; package com.wangxiaolu.promotion.utils;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.tencentcloudapi.common.Credential; import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException; import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile; import com.tencentcloudapi.common.profile.ClientProfile;
...@@ -8,8 +10,6 @@ import com.tencentcloudapi.sms.v20210111.SmsClient; ...@@ -8,8 +10,6 @@ import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest; import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse; import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import com.tencentcloudapi.sms.v20210111.models.SendStatus; import com.tencentcloudapi.sms.v20210111.models.SendStatus;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.result.basedata.RCode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论