diff --git a/ad-platform-common/ad-platform-common-core/pom.xml b/ad-platform-common/ad-platform-common-core/pom.xml
index 492e8ff4..55c8f9ab 100644
--- a/ad-platform-common/ad-platform-common-core/pom.xml
+++ b/ad-platform-common/ad-platform-common-core/pom.xml
@@ -107,8 +107,15 @@
com.alibaba
easyexcel
+
+
+ com.auth0
+ java-jwt
+
+
+
diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java
index fc1861d9..eab27a4f 100644
--- a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java
+++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/constant/DefaultNumberConstants.java
@@ -75,6 +75,10 @@ public class DefaultNumberConstants {
*/
public static final int TEN_NUMBER = 10;
+ /**
+ * 11
+ */
+ public static final int ELEVEN_NUMBER = 11;
/**
* 15
@@ -131,6 +135,16 @@ public class DefaultNumberConstants {
*/
public static final int FIVE_THOUSAND = 5000;
+ /**
+ * 十万
+ */
+ public static final int ONE_HUNDRED_THOUSAND = 100000;
+
+
+ /**
+ * 999999
+ */
+ public static final int LESS_THAN_ONE_MILLION = 999999;
/**
* 一百万
@@ -139,7 +153,7 @@ public class DefaultNumberConstants {
/**
- * 一千万
+ * 9999999
*/
public static final int TEN_MILLION = 9999999;
diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/manager/UserTokenManager.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/manager/UserTokenManager.java
new file mode 100644
index 00000000..10ec0929
--- /dev/null
+++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/manager/UserTokenManager.java
@@ -0,0 +1,31 @@
+package com.baiye.manager;
+
+
+import com.baiye.util.JwtHelper;
+
+/**
+ * @author Enzo
+ * 维护用户token
+ */
+public class UserTokenManager {
+
+ public static String generateToken(Long id) {
+ JwtHelper jwtHelper = new JwtHelper();
+ return jwtHelper.createToken(id);
+ }
+
+
+ public static Long getUserId(String token) {
+ JwtHelper jwtHelper = new JwtHelper();
+
+ Long userId = jwtHelper.verifyTokenAndGetUserId(token);
+ if(userId == null || userId == 0){
+ return null;
+ }
+ return userId;
+ }
+
+
+
+
+}
diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/JwtHelper.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/JwtHelper.java
new file mode 100644
index 00000000..3d9aca89
--- /dev/null
+++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/JwtHelper.java
@@ -0,0 +1,112 @@
+package com.baiye.util;
+
+import com.auth0.jwt.JWT;
+import com.auth0.jwt.JWTVerifier;
+import com.auth0.jwt.algorithms.Algorithm;
+import com.auth0.jwt.exceptions.JWTCreationException;
+import com.auth0.jwt.exceptions.JWTVerificationException;
+import com.auth0.jwt.interfaces.Claim;
+import com.auth0.jwt.interfaces.DecodedJWT;
+import com.baiye.constant.DefaultNumberConstants;
+import com.baiye.exception.BadRequestException;
+
+import java.util.*;
+
+/**
+ * @author Enz
+ */
+public class JwtHelper {
+
+ /**
+ * 秘钥
+ */
+ static final String SECRET = "WX-MALL-TOKEN";
+
+ /**
+ * 签名是有谁生成
+ */
+ static final String USER = "ENZO";
+
+ /**
+ * 签名的主题
+ */
+ static final String SUBJECT = "USER-FORM-TOKEN";
+
+ /**
+ * 签名的观众
+ */
+ static final String AUDIENCE = "USER-FORM-USER";
+
+
+ public String createToken(Long userId) {
+ try {
+ Algorithm algorithm = Algorithm.HMAC256(SECRET);
+ Map map = new HashMap<>(DefaultNumberConstants.SIXTEEN_NUMBER);
+ Date nowDate = new Date();
+ map.put("alg", "HS256");
+ map.put("typ", "JWT");
+ return JWT.create()
+ // 设置头部信息 Header
+ .withHeader(map)
+ // 设置 载荷 Payload
+ .withClaim("userId", userId)
+ .withIssuer(USER)
+ .withSubject(SUBJECT)
+ .withAudience(AUDIENCE)
+ // 生成签名的时间
+ .withIssuedAt(nowDate)
+ // 签名过期的时间
+ //.withExpiresAt(expireDate)
+ // 签名 Signature
+ .sign(algorithm);
+ } catch (JWTCreationException exception) {
+ throw new BadRequestException("生成token失败");
+ }
+ }
+
+ public Long verifyTokenAndGetUserId(String token) {
+ try {
+ Algorithm algorithm = Algorithm.HMAC256(SECRET);
+ JWTVerifier verifier = JWT.require(algorithm)
+ .withIssuer(USER)
+ .build();
+ DecodedJWT jwt = verifier.verify(token);
+ Map claims = jwt.getClaims();
+ Claim claim = claims.get("userId");
+ return claim.asLong();
+ } catch (JWTVerificationException exception) {
+ throw new BadRequestException("校验失败");
+ }
+ }
+
+
+ public Date getAfterDate(Date date, int year, int month, int day, int hour, int minute, int second) {
+ if (date == null) {
+ date = new Date();
+ }
+
+ Calendar cal = new GregorianCalendar();
+
+ cal.setTime(date);
+ if (year != 0) {
+ cal.add(Calendar.YEAR, year);
+ }
+ if (month != 0) {
+ cal.add(Calendar.MONTH, month);
+ }
+ if (day != 0) {
+ cal.add(Calendar.DATE, day);
+ }
+ if (hour != 0) {
+ cal.add(Calendar.HOUR_OF_DAY, hour);
+ }
+ if (minute != 0) {
+ cal.add(Calendar.MINUTE, minute);
+ }
+ if (second != 0) {
+ cal.add(Calendar.SECOND, second);
+ }
+ return cal.getTime();
+ }
+
+}
diff --git a/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/MobileUtil.java b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/MobileUtil.java
new file mode 100644
index 00000000..031a5420
--- /dev/null
+++ b/ad-platform-common/ad-platform-common-core/src/main/java/com/baiye/util/MobileUtil.java
@@ -0,0 +1,112 @@
+package com.baiye.util;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author Enzo
+ * @date : 2022/4/18
+ */
+public class MobileUtil {
+
+ /**
+ * 中国电信号码格式验证 手机段: 133,149,153,173,177,180,181,189,199,1349,1410,1700,1701,1702
+ **/
+ private static final String CHINA_TELECOM_PATTERN = "(?:^(?:\\+86)?1(?:33|49|53|7[37]|8[019]|99)\\d{8}$)|(?:^(?:\\+86)?1349\\d{7}$)|(?:^(?:\\+86)?1410\\d{7}$)|(?:^(?:\\+86)?170[0-2]\\d{7}$)";
+
+ /**
+ * 中国联通号码格式验证 手机段:130,131,132,145,146,155,156,166,171,175,176,185,186,1704,1707,1708,1709
+ **/
+ private static final String CHINA_UNICOM_PATTERN = "(?:^(?:\\+86)?1(?:3[0-2]|4[56]|5[56]|66|7[156]|8[56])\\d{8}$)|(?:^(?:\\+86)?170[47-9]\\d{7}$)";
+
+ /**
+ * 中国移动号码格式验证
+ * 手机段:134,135,136,137,138,139,147,148,150,151,152,157,158,159,178,182,183,184,187,188,198,1440,1703,1705,1706
+ **/
+ private static final String CHINA_MOBILE_PATTERN = "(?:^(?:\\+86)?1(?:3[4-9]|4[78]|5[0-27-9]|78|8[2-478]|98)\\d{8}$)|(?:^(?:\\+86)?1440\\d{7}$)|(?:^(?:\\+86)?170[356]\\d{7}$)";
+
+ /**
+ * 中国大陆手机号码校验
+ *
+ * @param phone
+ *
+ * @return
+ */
+ public static boolean checkPhone(String phone) {
+ if (StringUtils.isNotBlank(phone)) {
+ if (checkChinaMobile(phone) || checkChinaUnicom(phone) || checkChinaTelecom(phone)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 中国移动手机号码校验
+ *
+ * @param phone
+ *
+ * @return
+ */
+ public static boolean checkChinaMobile(String phone) {
+ if (StringUtils.isNotBlank(phone)) {
+ Pattern regexp = Pattern.compile(CHINA_MOBILE_PATTERN);
+ if (regexp.matcher(phone).matches()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 中国联通手机号码校验
+ *
+ * @param phone
+ *
+ * @return
+ */
+ public static boolean checkChinaUnicom(String phone) {
+ if (StringUtils.isNotBlank(phone)) {
+ Pattern regexp = Pattern.compile(CHINA_UNICOM_PATTERN);
+ if (regexp.matcher(phone).matches()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 中国电信手机号码校验
+ *
+ * @param phone
+ *
+ * @return
+ */
+ public static boolean checkChinaTelecom(String phone) {
+ if (StringUtils.isNotBlank(phone)) {
+ Pattern regexp = Pattern.compile(CHINA_TELECOM_PATTERN);
+ if (regexp.matcher(phone).matches()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 隐藏手机号中间四位
+ *
+ * @param phone
+ *
+ * @return java.lang.String
+ */
+ public static String hideMiddleMobile(String phone) {
+ if (StringUtils.isNotBlank(phone)) {
+ phone = phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
+ }
+ return phone;
+ }
+
+
+
+}
diff --git a/ad-platform-pojo/src/main/java/com/baiye/model/enums/ResponseCode.java b/ad-platform-pojo/src/main/java/com/baiye/model/enums/ResponseCode.java
index 0c220213..530b2150 100644
--- a/ad-platform-pojo/src/main/java/com/baiye/model/enums/ResponseCode.java
+++ b/ad-platform-pojo/src/main/java/com/baiye/model/enums/ResponseCode.java
@@ -23,6 +23,21 @@ public enum ResponseCode {
*/
RECHARGE_SUCCESS("1020","充值成功"),
+ /**
+ * 手机号码不正确
+ */
+ PHONE_NUMBER_IS_INCORRECT("1022","手机号码不正确"),
+
+ /**
+ * 验证码错误
+ */
+ VERIFICATION_CODE_PARAMETER_ERROR("1023","验证码错误"),
+
+ /**
+ * 验证码不存在或已过期
+ */
+ VERIFICATION_NOT_EXIST_HAS_EXPIRED("1024","验证码不存在或已过期"),
+
/**
* 读取文件失败
*/
@@ -35,7 +50,7 @@ public enum ResponseCode {
/**
* 用户信息错误
*/
- USER_INFORMATION_ERROR("1002", "用户信息错误,不能通过审核"),
+ USER_INFORMATION_ERROR("1002", "用户信息错误"),
/**
* 支付宝支付失败
diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/security/config/SpringSecurityConfig.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/security/config/SpringSecurityConfig.java
index 805c1904..7545a773 100644
--- a/manage/ad-platform-management/src/main/java/com/baiye/modules/security/config/SpringSecurityConfig.java
+++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/security/config/SpringSecurityConfig.java
@@ -134,6 +134,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/api/users/info/findByName").permitAll()
.antMatchers("/api/users/info/deptIds").permitAll()
.antMatchers("/api/roles/user/authority").permitAll()
+ .antMatchers( "/api/form/user/**").permitAll()
.antMatchers( "/api/report/organize").permitAll()
.antMatchers( "/api/download/task").permitAll()
diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/domain/Debt.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/domain/Debt.java
index 87648c4e..03ab5303 100644
--- a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/domain/Debt.java
+++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/domain/Debt.java
@@ -27,6 +27,10 @@ public class Debt {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
+ @ApiModelProperty(value = "邀请用户id")
+ @Column(name = "user_id")
+ private Long userId;
+
@ApiModelProperty(value = "姓名")
@NotBlank(message = "姓名不能为空")
@Column(name = "name")
diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/domain/FormUser.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/domain/FormUser.java
new file mode 100644
index 00000000..cc74a572
--- /dev/null
+++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/domain/FormUser.java
@@ -0,0 +1,48 @@
+package com.baiye.modules.system.domain;
+
+import com.baiye.model.base.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author Enzo
+ * @date : 2022/4/18
+ */
+@Entity
+@Getter
+@Setter
+@Table(name="tb_user_form")
+public class FormUser extends BaseEntity implements Serializable {
+
+ private static final long serialVersionUID = 7676856944264681235L;
+
+ @Id
+ @Column(name = "id")
+ @NotNull(groups = BaseEntity.Update.class)
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @ApiModelProperty(value = "ID", hidden = true)
+ private Long id;
+
+ @Column(name = "phone")
+ @ApiModelProperty(value = "手机号码")
+ private String phone;
+
+ @Column(name = "qr_code_path")
+ @ApiModelProperty(value = "二维码地址")
+ private String qrCodePath;
+
+ @Column(name = "invitation_nums")
+ @ApiModelProperty(value = "邀请数量")
+ private String invitationNums;
+
+ @Column(name = "last_login_time")
+ @ApiModelProperty(value = "最后登录时间")
+ private Date lastLoginTime;
+
+}
diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/DebtFormRepository.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/DebtFormRepository.java
index c8e4c529..bea1343c 100644
--- a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/DebtFormRepository.java
+++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/DebtFormRepository.java
@@ -3,8 +3,49 @@ package com.baiye.modules.system.repository;
import com.baiye.modules.system.domain.Debt;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
+import java.util.Date;
+import java.util.Map;
+
@Repository
public interface DebtFormRepository extends JpaRepository, JpaSpecificationExecutor {
+
+
+ /**
+ * 时间查询拉取人数
+ * @param dateStr
+ * @param beginDate
+ * @param endDate
+ * @param userId
+ * @return
+ */
+ @Query(value = "SELECT" +
+ " `date`," +
+ " MAX( `sum` ) AS `sum` " +
+ " FROM " +
+ " (" +
+ " SELECT" +
+ " @cdate := DATE_ADD( @cdate, INTERVAL - 1 DAY ) `date`," +
+ " 0 AS `sum` " +
+ " FROM" +
+ " ( SELECT @cdate := DATE_ADD( CURDATE( ), INTERVAL + 1 DAY ) FROM tb_bd_backdata ) t1" +
+ " WHERE" +
+ " @cdate > ?1 UNION ALL" +
+ " SELECT" +
+ " DATE_FORMAT( gmt_create, '%Y-%m-%d' ) AS `date`," +
+ " COUNT( * ) AS 'sum' " +
+ " FROM" +
+ " `tb_bd_backdata`" +
+ " WHERE" +
+ " tb_bd_backdata.`gmt_create` >= ?2" +
+ " AND tb_bd_backdata.`gmt_create` <= ?3" +
+ " AND tb_bd_backdata.`user_id` <= ?4" +
+ " GROUP BY" +
+ " DATE DESC" +
+ " ) _tmpAllTable" +
+ " GROUP BY" +
+ " `date` DESC", nativeQuery = true)
+ Map findByDate(String dateStr, Date beginDate, Date endDate, Long userId);
}
diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/FormUserRepository.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/FormUserRepository.java
new file mode 100644
index 00000000..f7da4a51
--- /dev/null
+++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/repository/FormUserRepository.java
@@ -0,0 +1,21 @@
+
+package com.baiye.modules.system.repository;
+
+import com.baiye.modules.system.domain.FormUser;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+ * @author Enzo
+ * @date 2022-4-18
+ */
+public interface FormUserRepository extends JpaRepository, JpaSpecificationExecutor {
+
+
+ /**
+ * 手机号码查询
+ * @param phoneNumber
+ * @return
+ */
+ FormUser findByPhone(String phoneNumber);
+}
diff --git a/manage/ad-platform-management/src/main/java/com/baiye/modules/system/rest/FormUserController.java b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/rest/FormUserController.java
new file mode 100644
index 00000000..605ea10e
--- /dev/null
+++ b/manage/ad-platform-management/src/main/java/com/baiye/modules/system/rest/FormUserController.java
@@ -0,0 +1,48 @@
+package com.baiye.modules.system.rest;
+
+import com.baiye.http.CommonResponse;
+import com.baiye.modules.system.service.FormUserService;
+import com.baiye.modules.system.service.dto.UserLoginDTO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.constraints.NotNull;
+import java.util.Map;
+
+/**
+ * @author Enzo
+ * @date : 2022/4/18
+ */
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "用户授权")
+@RequestMapping("/api/form/user")
+public class FormUserController {
+
+ private final FormUserService formUserService;
+
+
+ @GetMapping("/verifyCode")
+ @ApiOperation("更改手机号码发送验证码")
+ public CommonResponse getVerifyCode(@NotNull(message = "不能为空") String phone) {
+ return formUserService.createRandomCodeByPhone(phone);
+ }
+
+
+ @PostMapping("/login")
+ @ApiOperation("账号登录")
+ public CommonResponse login(@Validated @RequestBody UserLoginDTO loginDTO) {
+ return formUserService.userLogin(loginDTO);
+ }
+
+ @PostMapping("/userInfo")
+ @ApiOperation("获取用户详情")
+ public CommonResponse