Browse Source

feat:添加登录接口

zhaohaipeng 1 month ago
parent
commit
20f054a673
39 changed files with 2300 additions and 296 deletions
  1. 5 0
      pom.xml
  2. 11 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/common/annotation/UnAuth.java
  3. 5 2
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/common/enums/ExceptionEnum.java
  4. 30 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/common/enums/RedisPrefixEnum.java
  5. 259 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/component/RedisUtils.java
  6. 33 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/CrossOriginConfig.java
  7. 104 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/JwtInterceptor.java
  8. 30 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/LoginUserContext.java
  9. 67 67
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/RedisTemplateConfig.java
  10. 15 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/SecurityConfig.java
  11. 2 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/dao/generator/MybatisGeneratorMain.java
  12. 96 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/dao/mapper/UserMapper.java
  13. 0 39
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/AuthorInfoDTO.java
  14. 0 9
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/ImageUrlDTO.java
  15. 14 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/LoginDTO.java
  16. 0 29
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/VideoBillBoardItemDTO.java
  17. 0 41
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/VideoInfoDTO.java
  18. 0 9
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/VideoUrlDTO.java
  19. 0 8
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/mq/VideoPortraitMessageDTO.java
  20. 14 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/LoginAndRegisterParam.java
  21. 0 11
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/AuthorInfoParam.java
  22. 0 18
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/UserPortraitParam.java
  23. 0 17
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/VideoBillBoardParam.java
  24. 0 13
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/VideoInfoParam.java
  25. 0 18
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/VideoPortraitParam.java
  26. 278 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/po/User.java
  27. 763 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/po/UserExample.java
  28. 10 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/UserService.java
  29. 117 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/impl/UserServiceImpl.java
  30. 19 0
      risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/util/TokenUtil.java
  31. 318 0
      risk-control-core/src/main/resources/mapper/UserMapper.xml
  32. 3 3
      risk-control-core/src/main/resources/mybatis-generator-config.xml
  33. 10 10
      risk-control-server/src/main/java/com/tzld/piaoquan/risk/control/controller/QwLoginController.java
  34. 38 0
      risk-control-server/src/main/java/com/tzld/piaoquan/risk/control/controller/UserController.java
  35. 14 2
      risk-control-server/src/main/resources/application-dev.yml
  36. 11 0
      risk-control-server/src/main/resources/application-pre.yml
  37. 12 0
      risk-control-server/src/main/resources/application-prod.yml
  38. 11 0
      risk-control-server/src/main/resources/application-stress.yml
  39. 11 0
      risk-control-server/src/main/resources/application-test.yml

+ 5 - 0
pom.xml

@@ -128,6 +128,11 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-collections4</artifactId>
+            <version>4.4</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>

+ 11 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/common/annotation/UnAuth.java

@@ -0,0 +1,11 @@
+package com.tzld.piaoquan.risk.control.common.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE})
+public @interface UnAuth {
+}

+ 5 - 2
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/common/enums/ExceptionEnum.java

@@ -15,8 +15,11 @@ public enum ExceptionEnum {
     DATA_ERROR(4, "数据错误"),
     EXIST_RELATED_DATA(5, "存在关联数据"),
     DATA_EXIST(6, "数据已存在"),
-    ILLEGAL_OPERATION (7, "非法操作"),
-    CONFIG_ERROR (8, "配置异常"),
+    ILLEGAL_OPERATION(7, "非法操作"),
+    CONFIG_ERROR(8, "配置异常"),
+    ACCOUNT_EXIST(9, "账号已经存在"),
+    ACCOUNT_NOT_EXIST(10, "账号不存在"),
+    LOGIN_ERROR(11, "登录异常"),
     ;
 
     private int code;

+ 30 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/common/enums/RedisPrefixEnum.java

@@ -0,0 +1,30 @@
+package com.tzld.piaoquan.risk.control.common.enums;
+
+public enum RedisPrefixEnum {
+
+    RISK_CONTROL_TOKEN("risk:control:token:{token}", "Token缓存的Key"),
+    ;
+    private String prefix;
+    private String desc;
+
+    RedisPrefixEnum(String prefix, String desc) {
+        this.prefix = prefix;
+        this.desc = desc;
+    }
+
+    public String getPrefix() {
+        return prefix;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    @Override
+    public String toString() {
+        return "RedisPrefixEnum{" +
+                "prefix='" + prefix + '\'' +
+                ", desc='" + desc + '\'' +
+                '}';
+    }
+}

+ 259 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/component/RedisUtils.java

@@ -0,0 +1,259 @@
+package com.tzld.piaoquan.risk.control.component;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.redis.core.RedisCallback;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+@Service
+public class RedisUtils {
+
+    private final static Logger log = LoggerFactory.getLogger(RedisUtils.class);
+
+    private final static Long AD_FILTER_DEFAULT_EXPIRE_TIME = 30L * 24 * 60 * 60; // 排除人群(广告、计划)默认设置30天,单位秒
+    private final static Long AD_FILTER_DELAY_QUEUE_EXPIRETIME = 5L * 60 * 1000; // 排除人群优化默认设置5分钟,单位毫秒
+    private final static Long AD_FILTER_DEFAULT_USER_BEHAVIOR_EXPIRETIME = 1L * 24 * 60 * 60; // 排除人群优化默认设置1天,单位秒
+    @Resource(name = "redisTemplate")
+    private RedisTemplate<String, String> adOwnRedisTemplate;
+
+
+    public boolean contantinsKey(String key) {
+        if (StringUtils.isBlank(key)) {
+            log.error("contantinsKey is empty key:" + key);
+            return Boolean.FALSE;
+        }
+        return Boolean.TRUE.equals(adOwnRedisTemplate.hasKey(key));
+    }
+
+    public String getString(String key) {
+        Object obj = adOwnRedisTemplate.opsForValue().get(key);
+        return Objects.isNull(obj) ? null : obj.toString();
+    }
+
+    public Long getLong(String key) {
+        long longVal = 0L;
+        Object obj = adOwnRedisTemplate.opsForValue().get(key);
+        if (Objects.nonNull(obj)) {
+            try {
+                longVal = Long.parseLong(obj.toString());
+            } catch (Exception e) {
+                e.printStackTrace();
+                return longVal;
+            }
+
+        }
+        return longVal;
+    }
+
+    public void setValueWithExpire(String key, String value, Date date) {
+        long expireTime;
+        if (date != null) {
+            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
+            if (expireTime < 0) { // 过期时间有问题,或者小于当前时间
+                expireTime = AD_FILTER_DEFAULT_USER_BEHAVIOR_EXPIRETIME;
+            }
+        } else {
+            expireTime = AD_FILTER_DEFAULT_USER_BEHAVIOR_EXPIRETIME;
+        }
+        adOwnRedisTemplate.opsForValue().set(key, value, expireTime, TimeUnit.SECONDS);
+    }
+
+    public void setIncrementValue(String key, long value, Date date) {
+        Long expireTime;
+        if (date != null) {
+            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
+            // 过期时间有问题,或者小于当前时间
+            if (expireTime < 0) {
+                expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
+            }
+        } else { // date为null
+            expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
+        }
+        // 只在第一次进行设置过期时间
+        if (!contantinsKey(key)) {
+            adOwnRedisTemplate.opsForValue().increment(key, value);
+            adOwnRedisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
+        } else {
+            adOwnRedisTemplate.opsForValue().increment(key, value);
+        }
+    }
+
+    public void setDecrementValue(String key, double value) {
+        adOwnRedisTemplate.opsForValue().increment(key, -value);
+    }
+
+    public void setIncrementValue(String key, double value, Date date) {
+        Long expireTime;
+        if (date != null) {
+            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
+            // 过期时间有问题,或者小于当前时间
+            if (expireTime < 0) {
+                expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
+            }
+        } else { // date为null
+            expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
+        }
+        // 只在第一次进行设置过期时间
+        if (!contantinsKey(key)) {
+            adOwnRedisTemplate.opsForValue().increment(key, value);
+            adOwnRedisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
+        } else {
+            adOwnRedisTemplate.opsForValue().increment(key, value);
+        }
+    }
+
+    public int getInteger(String key) {
+        Object obj = adOwnRedisTemplate.opsForValue().get(key);
+        if (Objects.isNull(obj)) {
+            return 0;
+        }
+        return Integer.valueOf(obj.toString());
+    }
+
+    public Integer getIntegerO(String key) {
+        Object obj = adOwnRedisTemplate.opsForValue().get(key);
+        if (Objects.isNull(obj)) {
+            return null;
+        }
+        return Integer.valueOf(obj.toString());
+    }
+
+    public void putDealyQueueMsg(String key, String value) {
+        adOwnRedisTemplate.opsForZSet().add(key, value, System.currentTimeMillis() + AD_FILTER_DELAY_QUEUE_EXPIRETIME);
+    }
+
+    public Set<String> processDelayQueue(String key) {
+        long currentTimeMillis = System.currentTimeMillis();
+        Set<String> values = adOwnRedisTemplate.opsForZSet().rangeByScore(key, 0, currentTimeMillis);
+        if (!CollectionUtils.isEmpty(values)) {
+            adOwnRedisTemplate.opsForZSet().removeRangeByScore(key, 0, currentTimeMillis);
+        }
+        return values;
+    }
+
+    public void addVal(String key, String val) {
+        adOwnRedisTemplate.opsForValue().set(key, val);
+    }
+
+    public Long getKeyExpire(String key) {
+        return adOwnRedisTemplate.getExpire(key, TimeUnit.SECONDS);
+    }
+
+    public void expire(String key, Long time) {
+        adOwnRedisTemplate.expire(key, time, TimeUnit.SECONDS);
+    }
+
+    public Long countExistingKeys(List<String> keys) {
+        return adOwnRedisTemplate.countExistingKeys(keys);
+    }
+
+    public boolean del(String key) {
+        return adOwnRedisTemplate.delete(key);
+    }
+
+    public boolean set(String key, String value, long time) {
+        try {
+            if (time > 0) {
+                adOwnRedisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+            } else {
+                adOwnRedisTemplate.opsForValue().set(key, value);
+            }
+            return true;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * Redis 分布式锁
+     *
+     * @param key        锁键
+     * @param value      锁值,可以为随机数或者 UUID 等唯一标识符
+     * @param expireTime 锁过期时间,单位为秒
+     * @return true:获取锁成功,false:获取锁失败
+     */
+    public boolean tryLock(String key, String value, long expireTime) {
+        Boolean result = adOwnRedisTemplate.opsForValue().setIfAbsent(key, value, expireTime, TimeUnit.SECONDS);
+        if (result != null && result) {
+            // 获取锁成功
+            return true;
+        }
+        return false;
+    }
+
+    public void listLeftPush(String key, String value) {
+        adOwnRedisTemplate.opsForList().leftPush(key, value);
+
+    }
+
+    public String listRightPop(String key) {
+        return adOwnRedisTemplate.opsForList().rightPop(key);
+    }
+
+    public Double getDouble(String key) {
+        try {
+            String val = adOwnRedisTemplate.opsForValue().get(key);
+            if (StringUtils.isNotBlank(val)) {
+                return Double.valueOf(val);
+            }
+        } catch (Exception e) {
+            log.error("getDouble error redis key:" + key + "----" + e);
+        }
+        return null;
+    }
+
+    public String get(String key) {
+        String val = adOwnRedisTemplate.opsForValue().get(key);
+        if (StringUtils.isNotBlank(val)) {
+            return val;
+        }
+        return null;
+    }
+
+    public void sAdd(String key, String val) {
+        adOwnRedisTemplate.opsForSet().add(key, val);
+    }
+
+    public Set<String> sMembers(String key) {
+        return adOwnRedisTemplate.opsForSet().members(key);
+    }
+
+
+    public Boolean sIsMember(String key, String val) {
+        return adOwnRedisTemplate.opsForSet().isMember(key, val);
+    }
+
+    public void setBit(String key, long val, boolean flag) {
+        adOwnRedisTemplate.opsForValue().setBit(key, val, flag);
+    }
+
+    public void setBitList(String key, Set<Long> indexs, boolean flag) {
+        RedisSerializer<String> serializer = adOwnRedisTemplate.getStringSerializer();
+        adOwnRedisTemplate.executePipelined((RedisCallback<Object>) redisConnection -> {
+            indexs.forEach(x -> {
+                redisConnection.setBit(key.getBytes(), x, flag);
+            });
+            return null;
+        }, serializer);
+    }
+
+    public Boolean getBitMap(String key, long offset) {
+        return adOwnRedisTemplate.opsForValue().getBit(key, offset);
+    }
+
+    public List<String> mGet(List<String> keys) {
+        return adOwnRedisTemplate.opsForValue().multiGet(keys);
+    }
+}

+ 33 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/CrossOriginConfig.java

@@ -0,0 +1,33 @@
+package com.tzld.piaoquan.risk.control.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class CrossOriginConfig implements WebMvcConfigurer {
+
+    private final JwtInterceptor jwtInterceptor;
+
+    @Autowired
+    public CrossOriginConfig(JwtInterceptor jwtInterceptor) {
+        this.jwtInterceptor = jwtInterceptor;
+    }
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(this.jwtInterceptor).addPathPatterns("/**");
+    }
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+//        registry.addMapping("/**")
+//                .allowedOrigins("*")
+//                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
+//                .maxAge(3600)
+//                .allowCredentials(false);
+    }
+
+}

+ 104 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/JwtInterceptor.java

@@ -0,0 +1,104 @@
+package com.tzld.piaoquan.risk.control.config;
+
+import com.alibaba.fastjson.JSON;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import com.tzld.piaoquan.risk.control.common.annotation.UnAuth;
+import com.tzld.piaoquan.risk.control.common.enums.ExceptionEnum;
+import com.tzld.piaoquan.risk.control.common.enums.RedisPrefixEnum;
+import com.tzld.piaoquan.risk.control.common.exception.CommonException;
+import com.tzld.piaoquan.risk.control.component.RedisUtils;
+import com.tzld.piaoquan.risk.control.model.po.User;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.stereotype.Component;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Objects;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+@Component
+public class JwtInterceptor implements HandlerInterceptor {
+
+    private final static Logger log = LoggerFactory.getLogger(JwtInterceptor.class);
+
+    ThreadPoolExecutor executor = new ThreadPoolExecutor(128, 128,
+            0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(100000), new ThreadFactoryBuilder().setNameFormat("ad-platform-login-service-pool-%d").build(), new ThreadPoolExecutor.AbortPolicy());
+
+    @Autowired
+    private RedisUtils redisUtils;
+
+    @Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        if ((StringUtils.isNotBlank(request.getRequestURI()) && request.getRequestURI().contains("auth")) ||
+                (Objects.nonNull(request.getRequestURL()) && request.getRequestURL().toString().contains("auth"))
+        ) {
+            return Boolean.TRUE;
+        }
+
+        if (HttpMethod.OPTIONS.name().equals(request.getMethod())) {
+            response.setStatus(HttpServletResponse.SC_OK);
+            return true;
+        }
+
+        // 忽略带UnAuth注解的请求, 不做后续token认证校验
+        if (handler instanceof HandlerMethod) {
+            HandlerMethod handlerMethod = (HandlerMethod) handler;
+            UnAuth jwtIgnore = handlerMethod.getMethodAnnotation(UnAuth.class);
+            if (jwtIgnore != null) {
+                return Boolean.TRUE;
+            }
+        }
+        final String token = request.getHeader("token");
+
+        if (StringUtils.isBlank(token)) {
+            log.info("LOGIN_ERROR, authHeader:{}", token);
+            throw new CommonException(ExceptionEnum.LOGIN_ERROR, "登录失效,请重新登录。");
+        }
+
+        this.validToken(token);
+
+        return Boolean.TRUE;
+    }
+
+    private void validToken(String token) {
+        String loginUserString = redisUtils.getString(RedisPrefixEnum.RISK_CONTROL_TOKEN.getPrefix().replace("{token}", token));
+        if (StringUtils.isBlank(loginUserString)) {
+            log.info("LOGIN_ERROR-1, authHeader:{}", token);
+            throw new CommonException(ExceptionEnum.LOGIN_ERROR, "登录失效,请重新登录。");
+        }
+        User user = null;
+        try {
+            user = JSON.parseObject(loginUserString, User.class);
+        } catch (Exception e) {
+            log.info("LOGIN_ERROR-2, authHeader:{}", token);
+            throw new CommonException(ExceptionEnum.LOGIN_ERROR, "登录失效,请重新登录。");
+        }
+        // token验证完成后获取对应信息,存放在本地线程中
+        LoginUserContext.setLoginUser(user);
+        // 异步处理续期
+        renewalToken(token);
+    }
+
+    @Override
+    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
+        LoginUserContext.remove();
+    }
+
+    private void renewalToken(String token) {
+        executor.execute(() -> {
+            String key = RedisPrefixEnum.RISK_CONTROL_TOKEN.getPrefix().replace("{token}", token);
+            Long seconds = redisUtils.getKeyExpire(key);
+            if (seconds < 600) {
+                redisUtils.expire(key, 7200L);
+            }
+        });
+    }
+}

+ 30 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/LoginUserContext.java

@@ -0,0 +1,30 @@
+package com.tzld.piaoquan.risk.control.config;
+
+import com.tzld.piaoquan.risk.control.common.enums.ExceptionEnum;
+import com.tzld.piaoquan.risk.control.common.exception.CommonException;
+import com.tzld.piaoquan.risk.control.model.po.User;
+
+import java.util.Optional;
+
+public class LoginUserContext {
+    private final static ThreadLocal<Optional<User>> USER_THREAD_LOCAL = new ThreadLocal<>();
+
+    private LoginUserContext() {
+    }
+
+    public static void setLoginUser(User user) {
+        USER_THREAD_LOCAL.set(Optional.ofNullable(user));
+    }
+
+    public static User getUser() {
+        return USER_THREAD_LOCAL.get().orElseThrow(() -> new CommonException(ExceptionEnum.LOGIN_ERROR));
+    }
+
+    private static Long getUserId() {
+        return USER_THREAD_LOCAL.get().map(User::getId).orElseThrow(() -> new CommonException(ExceptionEnum.LOGIN_ERROR));
+    }
+
+    public static void remove() {
+        USER_THREAD_LOCAL.remove();
+    }
+}

+ 67 - 67
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/RedisTemplateConfig.java

@@ -1,67 +1,67 @@
-//package com.tzld.piaoquan.risk.control.config;
-//
-//import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
-//import org.springframework.beans.factory.annotation.Qualifier;
-//import org.springframework.boot.context.properties.ConfigurationProperties;
-//import org.springframework.context.annotation.Bean;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.context.annotation.Primary;
-//import org.springframework.data.redis.connection.RedisConnectionFactory;
-//import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
-//import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
-//import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
-//import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
-//import org.springframework.data.redis.core.RedisTemplate;
-//import org.springframework.data.redis.serializer.StringRedisSerializer;
-//
-///**
-// * redis config
-// *
-// * @author supeng
-// * @date 2020/09/02
-// */
-//@Configuration
-//public class RedisTemplateConfig {
-//
-//    @Bean
-//    @ConfigurationProperties(prefix = "spring.redis.lettuce.pool")
-//    public GenericObjectPoolConfig<LettucePoolingClientConfiguration> redisPool() {
-//        return new GenericObjectPoolConfig<>();
-//    }
-//
-//    @Bean
-//    @ConfigurationProperties(prefix = "spring.redis")
-//    public RedisStandaloneConfiguration redisConfig() {
-//        return new RedisStandaloneConfiguration();
-//    }
-//
-//    @Bean("factory")
-//    @Primary
-//    public LettuceConnectionFactory factory(GenericObjectPoolConfig<LettucePoolingClientConfiguration> config, RedisStandaloneConfiguration redisConfig) {
-//        LettuceClientConfiguration lettuceClientConfiguration = LettucePoolingClientConfiguration.builder().poolConfig(config).build();
-//        return new LettuceConnectionFactory(redisConfig, lettuceClientConfiguration);
-//    }
-//
-//    @Bean(name = "redisTemplate")
-//    public RedisTemplate<String, String> getRedisTemplate(@Qualifier("factory") RedisConnectionFactory factory) {
-//        return buildRedisTemplate(factory);
-//    }
-//
-//    /**
-//     * 构建redisTemplate 使用string序列化
-//     *
-//     * @param factory
-//     * @return
-//     */
-//    public RedisTemplate<String, String> buildRedisTemplate(RedisConnectionFactory factory) {
-//        RedisTemplate<String, String> redisTemplate = new RedisTemplate<>();
-//        redisTemplate.setConnectionFactory(factory);
-//        // key的序列化类型 保证可读性
-//        redisTemplate.setKeySerializer(new StringRedisSerializer());
-//        redisTemplate.setValueSerializer(new StringRedisSerializer());
-//        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
-//        redisTemplate.setHashValueSerializer(new StringRedisSerializer());
-//        return redisTemplate;
-//    }
-//
-//}
+package com.tzld.piaoquan.risk.control.config;
+
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
+import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+* redis config
+*
+* @author supeng
+* @date 2020/09/02
+*/
+@Configuration
+public class RedisTemplateConfig {
+
+   @Bean
+   @ConfigurationProperties(prefix = "spring.redis.lettuce.pool")
+   public GenericObjectPoolConfig<LettucePoolingClientConfiguration> redisPool() {
+       return new GenericObjectPoolConfig<>();
+   }
+
+   @Bean
+   @ConfigurationProperties(prefix = "spring.redis")
+   public RedisStandaloneConfiguration redisConfig() {
+       return new RedisStandaloneConfiguration();
+   }
+
+   @Bean("factory")
+   @Primary
+   public LettuceConnectionFactory factory(GenericObjectPoolConfig<LettucePoolingClientConfiguration> config, RedisStandaloneConfiguration redisConfig) {
+       LettuceClientConfiguration lettuceClientConfiguration = LettucePoolingClientConfiguration.builder().poolConfig(config).build();
+       return new LettuceConnectionFactory(redisConfig, lettuceClientConfiguration);
+   }
+
+   @Bean(name = "redisTemplate")
+   public RedisTemplate<String, String> getRedisTemplate(@Qualifier("factory") RedisConnectionFactory factory) {
+       return buildRedisTemplate(factory);
+   }
+
+   /**
+    * 构建redisTemplate 使用string序列化
+    *
+    * @param factory
+    * @return
+    */
+   public RedisTemplate<String, String> buildRedisTemplate(RedisConnectionFactory factory) {
+       RedisTemplate<String, String> redisTemplate = new RedisTemplate<>();
+       redisTemplate.setConnectionFactory(factory);
+       // key的序列化类型 保证可读性
+       redisTemplate.setKeySerializer(new StringRedisSerializer());
+       redisTemplate.setValueSerializer(new StringRedisSerializer());
+       redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+       redisTemplate.setHashValueSerializer(new StringRedisSerializer());
+       return redisTemplate;
+   }
+
+}

+ 15 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/config/SecurityConfig.java

@@ -0,0 +1,15 @@
+package com.tzld.piaoquan.risk.control.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+
+@Configuration
+public class SecurityConfig {
+
+    @Bean
+    public PasswordEncoder passwordEncoder() {
+        return new BCryptPasswordEncoder();
+    }
+}

+ 2 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/dao/generator/MybatisGeneratorMain.java

@@ -11,6 +11,7 @@ import java.io.File;
 import java.io.IOException;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 public class MybatisGeneratorMain {
@@ -25,6 +26,7 @@ public class MybatisGeneratorMain {
 		DefaultShellCallback callback = new DefaultShellCallback(overwrite);
 		MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
 		myBatisGenerator.generate(null);
+		System.out.println(Arrays.toString(warnings.toArray()));
 		System.out.println("genreate finish");
 	}
 }

+ 96 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/dao/mapper/UserMapper.java

@@ -0,0 +1,96 @@
+package com.tzld.piaoquan.risk.control.dao.mapper;
+
+import com.tzld.piaoquan.risk.control.model.po.User;
+import com.tzld.piaoquan.risk.control.model.po.UserExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+
+public interface UserMapper {
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    long countByExample(UserExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int deleteByExample(UserExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int deleteByPrimaryKey(Long id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int insert(User record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int insertSelective(User record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    List<User> selectByExample(UserExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    User selectByPrimaryKey(Long id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int updateByExample(@Param("record") User record, @Param("example") UserExample example);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int updateByPrimaryKeySelective(User record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    int updateByPrimaryKey(User record);
+}

+ 0 - 39
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/AuthorInfoDTO.java

@@ -1,39 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.dto;
-
-import lombok.Data;
-
-import java.util.List;
-
-@Data
-public class AuthorInfoDTO {
-    private Integer channel;
-    private String channel_account_id;
-    private String xhs_id;
-    /**
-     * 抖音ID
-     */
-    private String dy_id;
-    private String ks_id;
-    private String digit_id;
-    private String account_link;
-    private String account_name;
-    private String avatar_url;
-    private String background_url;
-    private String gender;
-    private String description;
-    private String ip_location;
-    private List<String> tags;
-    private Long follower_count;
-    private Long publish_count;
-    private Long like_count;
-    private Long collect_count;
-    private Long comment_count;
-    private Long looking_count;
-    private String biz_info;
-    private String wx_gh;
-    /**
-     * 毫秒
-     */
-    private Long create_timestamp;
-    private Long update_timestamp;
-}

+ 0 - 9
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/ImageUrlDTO.java

@@ -1,9 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.dto;
-
-import lombok.Data;
-
-@Data
-public class ImageUrlDTO {
-    private Integer image_type;
-    private String image_url;
-}

+ 14 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/LoginDTO.java

@@ -0,0 +1,14 @@
+package com.tzld.piaoquan.risk.control.model.dto;
+
+import lombok.Data;
+import lombok.ToString;
+
+@Data
+@ToString
+public class LoginDTO {
+
+    private String name;
+
+    private String token;
+
+}

+ 0 - 29
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/VideoBillBoardItemDTO.java

@@ -1,29 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.dto;
-
-import lombok.Data;
-
-@Data
-public class VideoBillBoardItemDTO {
-    private String item_id;
-    private String item_title;
-    private String item_cover_url;
-    private Long item_duration;
-    private String nick_name;
-    private String avatar_url;
-    private Long fans_cnt;
-    private Long play_cnt;
-    private Long publish_time;
-    private Long score;
-    private String item_url;
-    private Long like_cnt;
-    private Long follow_cnt;
-    private Double follow_rate;
-    private Double like_rate;
-    private Integer media_type;
-    private Long favorite_id;
-    private Boolean is_favorite;
-    private Integer image_cnt;
-
-    private Integer crawlerType;
-    private String crawlerConfig;
-}

+ 0 - 41
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/VideoInfoDTO.java

@@ -1,41 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.dto;
-
-import lombok.Data;
-
-import java.util.List;
-
-@Data
-public class VideoInfoDTO {
-    private Integer channel;
-    private String channel_content_id;
-    private String content_link;
-    private String wx_sn;
-    private String title;
-    private String content_type;
-    private String body_text;
-    private String location;
-    private String source_url;
-    private String mini_program;
-    private List<String> topic_list;
-    private List<ImageUrlDTO> image_url_list;
-    private List<VideoUrlDTO> video_url_list;
-    private String bgm_data;
-    private String ad_info;
-    private String voice_data;
-    private String channel_account_id;
-    private String channel_account_name;
-    private String avatar;
-    private Long item_index;
-    private Long view_count;
-    private Long like_count;
-    private Long collect_count;
-    private Long comment_count;
-    private Long share_count;
-    private Long looking_count;
-    /**
-     * 毫秒
-     */
-    private Long publish_timestamp;
-    private Long modify_timestamp;
-    private Long update_timestamp;
-}

+ 0 - 9
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/VideoUrlDTO.java

@@ -1,9 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.dto;
-
-import lombok.Data;
-
-@Data
-public class VideoUrlDTO {
-    private Long video_duration;
-    private String video_url;
-}

+ 0 - 8
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/dto/mq/VideoPortraitMessageDTO.java

@@ -1,8 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.dto.mq;
-
-import lombok.Data;
-
-@Data
-public class VideoPortraitMessageDTO {
-    private String vid;
-}

+ 14 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/LoginAndRegisterParam.java

@@ -0,0 +1,14 @@
+package com.tzld.piaoquan.risk.control.model.param;
+
+import lombok.Data;
+
+@Data
+public class LoginAndRegisterParam {
+
+    private String account;
+
+    private String name;
+
+    private String password;
+
+}

+ 0 - 11
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/AuthorInfoParam.java

@@ -1,11 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.param.douhot;
-
-import lombok.Data;
-
-/**
- * @author supeng
- */
-@Data
-public class AuthorInfoParam {
-    private String account_id;
-}

+ 0 - 18
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/UserPortraitParam.java

@@ -1,18 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.param.douhot;
-
-import lombok.Data;
-
-/**
- * @author supeng
- */
-@Data
-public class UserPortraitParam {
-    private String account_id;
-    private Boolean need_province;
-    private Boolean need_city;
-    private Boolean need_city_level;
-    private Boolean need_gender;
-    private Boolean need_age;
-    private Boolean need_phone_brand;
-    private Boolean need_phone_price;
-}

+ 0 - 17
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/VideoBillBoardParam.java

@@ -1,17 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.param.douhot;
-
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * @author supeng
- */
-@Data
-public class VideoBillBoardParam {
-    private String type="视频总榜";
-    private String time="近1天";
-    private String category;
-    private List<String> sub_categories;
-    private String cursor;
-}

+ 0 - 13
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/VideoInfoParam.java

@@ -1,13 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.param.douhot;
-
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * @author supeng
- */
-@Data
-public class VideoInfoParam {
-    private String content_id;
-}

+ 0 - 18
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/param/douhot/VideoPortraitParam.java

@@ -1,18 +0,0 @@
-package com.tzld.piaoquan.risk.control.model.param.douhot;
-
-import lombok.Data;
-
-/**
- * @author supeng
- */
-@Data
-public class VideoPortraitParam {
-    private String content_id;
-    private Boolean need_province;
-    private Boolean need_city;
-    private Boolean need_city_level;
-    private Boolean need_gender;
-    private Boolean need_age;
-    private Boolean need_phone_brand;
-    private Boolean need_phone_price;
-}

+ 278 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/po/User.java

@@ -0,0 +1,278 @@
+package com.tzld.piaoquan.risk.control.model.po;
+
+import java.util.Date;
+
+/**
+ *
+ * This class was generated by MyBatis Generator.
+ * This class corresponds to the database table user
+ */
+public class User {
+    /**
+     * Database Column Remarks:
+     *   主键
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column user.id
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    private Long id;
+
+    /**
+     * Database Column Remarks:
+     *   手机号
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column user.phone
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    private String phone;
+
+    /**
+     * Database Column Remarks:
+     *   邮箱
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column user.email
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    private String email;
+
+    /**
+     * Database Column Remarks:
+     *   用户名称
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column user.name
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    private String name;
+
+    /**
+     * Database Column Remarks:
+     *   密码
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column user.password
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    private String password;
+
+    /**
+     * Database Column Remarks:
+     *   创建时间
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column user.create_time
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    private Date createTime;
+
+    /**
+     * Database Column Remarks:
+     *   更新时间
+     *
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column user.update_time
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    private Date updateTime;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column user.id
+     *
+     * @return the value of user.id
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column user.id
+     *
+     * @param id the value for user.id
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column user.phone
+     *
+     * @return the value of user.phone
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public String getPhone() {
+        return phone;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column user.phone
+     *
+     * @param phone the value for user.phone
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column user.email
+     *
+     * @return the value of user.email
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public String getEmail() {
+        return email;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column user.email
+     *
+     * @param email the value for user.email
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column user.name
+     *
+     * @return the value of user.name
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column user.name
+     *
+     * @param name the value for user.name
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column user.password
+     *
+     * @return the value of user.password
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public String getPassword() {
+        return password;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column user.password
+     *
+     * @param password the value for user.password
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column user.create_time
+     *
+     * @return the value of user.create_time
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column user.create_time
+     *
+     * @param createTime the value for user.create_time
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column user.update_time
+     *
+     * @return the value of user.update_time
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column user.update_time
+     *
+     * @param updateTime the value for user.update_time
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", phone=").append(phone);
+        sb.append(", email=").append(email);
+        sb.append(", name=").append(name);
+        sb.append(", password=").append(password);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 763 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/model/po/UserExample.java

@@ -0,0 +1,763 @@
+package com.tzld.piaoquan.risk.control.model.po;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class UserExample {
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    protected String orderByClause;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    protected boolean distinct;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    protected List<Criteria> oredCriteria;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public UserExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Long value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Long value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Long value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Long value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Long value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Long> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Long> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Long value1, Long value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Long value1, Long value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneIsNull() {
+            addCriterion("phone is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneIsNotNull() {
+            addCriterion("phone is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneEqualTo(String value) {
+            addCriterion("phone =", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneNotEqualTo(String value) {
+            addCriterion("phone <>", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneGreaterThan(String value) {
+            addCriterion("phone >", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneGreaterThanOrEqualTo(String value) {
+            addCriterion("phone >=", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneLessThan(String value) {
+            addCriterion("phone <", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneLessThanOrEqualTo(String value) {
+            addCriterion("phone <=", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneLike(String value) {
+            addCriterion("phone like", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneNotLike(String value) {
+            addCriterion("phone not like", value, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneIn(List<String> values) {
+            addCriterion("phone in", values, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneNotIn(List<String> values) {
+            addCriterion("phone not in", values, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneBetween(String value1, String value2) {
+            addCriterion("phone between", value1, value2, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andPhoneNotBetween(String value1, String value2) {
+            addCriterion("phone not between", value1, value2, "phone");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailIsNull() {
+            addCriterion("email is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailIsNotNull() {
+            addCriterion("email is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailEqualTo(String value) {
+            addCriterion("email =", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailNotEqualTo(String value) {
+            addCriterion("email <>", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailGreaterThan(String value) {
+            addCriterion("email >", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailGreaterThanOrEqualTo(String value) {
+            addCriterion("email >=", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailLessThan(String value) {
+            addCriterion("email <", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailLessThanOrEqualTo(String value) {
+            addCriterion("email <=", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailLike(String value) {
+            addCriterion("email like", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailNotLike(String value) {
+            addCriterion("email not like", value, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailIn(List<String> values) {
+            addCriterion("email in", values, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailNotIn(List<String> values) {
+            addCriterion("email not in", values, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailBetween(String value1, String value2) {
+            addCriterion("email between", value1, value2, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andEmailNotBetween(String value1, String value2) {
+            addCriterion("email not between", value1, value2, "email");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIsNull() {
+            addCriterion("`name` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIsNotNull() {
+            addCriterion("`name` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameEqualTo(String value) {
+            addCriterion("`name` =", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotEqualTo(String value) {
+            addCriterion("`name` <>", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameGreaterThan(String value) {
+            addCriterion("`name` >", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameGreaterThanOrEqualTo(String value) {
+            addCriterion("`name` >=", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLessThan(String value) {
+            addCriterion("`name` <", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLessThanOrEqualTo(String value) {
+            addCriterion("`name` <=", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLike(String value) {
+            addCriterion("`name` like", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotLike(String value) {
+            addCriterion("`name` not like", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIn(List<String> values) {
+            addCriterion("`name` in", values, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotIn(List<String> values) {
+            addCriterion("`name` not in", values, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameBetween(String value1, String value2) {
+            addCriterion("`name` between", value1, value2, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotBetween(String value1, String value2) {
+            addCriterion("`name` not between", value1, value2, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordIsNull() {
+            addCriterion("`password` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordIsNotNull() {
+            addCriterion("`password` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordEqualTo(String value) {
+            addCriterion("`password` =", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordNotEqualTo(String value) {
+            addCriterion("`password` <>", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordGreaterThan(String value) {
+            addCriterion("`password` >", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordGreaterThanOrEqualTo(String value) {
+            addCriterion("`password` >=", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordLessThan(String value) {
+            addCriterion("`password` <", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordLessThanOrEqualTo(String value) {
+            addCriterion("`password` <=", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordLike(String value) {
+            addCriterion("`password` like", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordNotLike(String value) {
+            addCriterion("`password` not like", value, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordIn(List<String> values) {
+            addCriterion("`password` in", values, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordNotIn(List<String> values) {
+            addCriterion("`password` not in", values, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordBetween(String value1, String value2) {
+            addCriterion("`password` between", value1, value2, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andPasswordNotBetween(String value1, String value2) {
+            addCriterion("`password` not between", value1, value2, "password");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table user
+     *
+     * @mbg.generated do_not_delete_during_merge Wed May 21 19:08:42 CST 2025
+     */
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table user
+     *
+     * @mbg.generated Wed May 21 19:08:42 CST 2025
+     */
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 10 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/UserService.java

@@ -0,0 +1,10 @@
+package com.tzld.piaoquan.risk.control.service;
+
+import com.tzld.piaoquan.risk.control.model.dto.LoginDTO;
+import com.tzld.piaoquan.risk.control.model.param.LoginAndRegisterParam;
+
+public interface UserService {
+    LoginDTO login(LoginAndRegisterParam param);
+
+    void register(LoginAndRegisterParam param);
+}

+ 117 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/impl/UserServiceImpl.java

@@ -0,0 +1,117 @@
+package com.tzld.piaoquan.risk.control.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.tzld.piaoquan.risk.control.common.enums.ExceptionEnum;
+import com.tzld.piaoquan.risk.control.common.enums.RedisPrefixEnum;
+import com.tzld.piaoquan.risk.control.common.exception.CommonException;
+import com.tzld.piaoquan.risk.control.component.RedisUtils;
+import com.tzld.piaoquan.risk.control.dao.mapper.UserMapper;
+import com.tzld.piaoquan.risk.control.model.dto.LoginDTO;
+import com.tzld.piaoquan.risk.control.model.param.LoginAndRegisterParam;
+import com.tzld.piaoquan.risk.control.model.po.User;
+import com.tzld.piaoquan.risk.control.model.po.UserExample;
+import com.tzld.piaoquan.risk.control.service.UserService;
+import com.tzld.piaoquan.risk.control.util.TokenUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Slf4j
+@Service
+public class UserServiceImpl implements UserService {
+
+    @Autowired
+    private UserMapper userMapper;
+    @Autowired
+    private PasswordEncoder passwordEncoder;
+    @Resource
+    private RedisUtils redisUtils;
+
+    @Override
+    public LoginDTO login(LoginAndRegisterParam param) {
+
+        if (StringUtils.isAnyBlank(param.getAccount(), param.getPassword())) {
+            throw new CommonException(ExceptionEnum.PARAMS_INVALID);
+        }
+
+        UserExample example = new UserExample();
+        if (this.isValidPhone(param.getAccount())) {
+            example.createCriteria().andPhoneEqualTo(param.getAccount());
+        } else if (this.isValidEmail(param.getAccount())) {
+            example.createCriteria().andEmailEqualTo(param.getAccount());
+        } else {
+            throw new CommonException(ExceptionEnum.PARAMS_INVALID);
+        }
+        List<User> users = userMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(users)) {
+            throw new CommonException(ExceptionEnum.ACCOUNT_NOT_EXIST);
+        }
+
+        User user = users.get(0);
+
+        if (!passwordEncoder.matches(param.getPassword(), user.getPassword())) {
+            throw new CommonException(ExceptionEnum.ILLEGAL_OPERATION, "密码错误");
+        }
+
+        // 设置Token缓存
+        String token = TokenUtil.genTokenByUUIDFormat();
+        String key = RedisPrefixEnum.RISK_CONTROL_TOKEN.getPrefix().replace("{token}", token);
+        redisUtils.set(key, JSON.toJSONString(user), 24 * 60 * 60);
+
+        LoginDTO loginDTO = new LoginDTO();
+        loginDTO.setToken(token);
+        loginDTO.setName(user.getName());
+        return loginDTO;
+    }
+
+    @Override
+    public void register(LoginAndRegisterParam param) {
+
+        if (StringUtils.isAnyBlank(param.getAccount(), param.getPassword())) {
+            throw new CommonException(ExceptionEnum.PARAMS_INVALID);
+        }
+
+        User user = new User();
+
+        UserExample example = new UserExample();
+        if (this.isValidPhone(param.getAccount())) {
+            example.createCriteria().andPhoneEqualTo(param.getAccount());
+            user.setPhone(param.getAccount());
+        } else if (this.isValidEmail(param.getAccount())) {
+            example.createCriteria().andEmailEqualTo(param.getAccount());
+            user.setEmail(param.getAccount());
+        } else {
+            throw new CommonException(ExceptionEnum.DATA_ERROR);
+        }
+
+        long count = userMapper.countByExample(example);
+        if (count > 0) {
+            throw new CommonException(ExceptionEnum.ACCOUNT_EXIST);
+        }
+        String newPassword = passwordEncoder.encode(param.getPassword());
+        user.setPassword(newPassword);
+        user.setName(param.getName());
+        userMapper.insertSelective(user);
+    }
+
+    // 邮箱正则校验
+    private boolean isValidEmail(String email) {
+        // 实现邮箱正则校验的逻辑
+        String emailRegex = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
+        return email.matches(emailRegex);
+    }
+
+    // 手机号正则校验
+    private boolean isValidPhone(String phoneNumber) {
+        String phoneRegex = "^1[3456789]\\d{9}$";
+        return phoneNumber.matches(phoneRegex);
+    }
+
+
+}

+ 19 - 0
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/util/TokenUtil.java

@@ -0,0 +1,19 @@
+package com.tzld.piaoquan.risk.control.util;
+
+import java.security.SecureRandom;
+import java.util.Base64;
+import java.util.UUID;
+
+public class TokenUtil {
+
+    public static String genTokenByUUIDFormat(){
+        return UUID.randomUUID().toString();
+    }
+
+    public static String generateToken(int tokenLength) {
+        SecureRandom random = new SecureRandom();
+        byte[] bytes = new byte[tokenLength];
+        random.nextBytes(bytes);
+        return Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);
+    }
+}

+ 318 - 0
risk-control-core/src/main/resources/mapper/UserMapper.xml

@@ -0,0 +1,318 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzld.piaoquan.risk.control.dao.mapper.UserMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.risk.control.model.po.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="phone" jdbcType="VARCHAR" property="phone" />
+    <result column="email" jdbcType="VARCHAR" property="email" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="password" jdbcType="VARCHAR" property="password" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    id, phone, email, `name`, `password`, create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.risk.control.model.po.UserExample" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from user
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    delete from user
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.risk.control.model.po.UserExample">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    delete from user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.risk.control.model.po.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    insert into user (id, phone, email, 
+      `name`, `password`, create_time, 
+      update_time)
+    values (#{id,jdbcType=BIGINT}, #{phone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, 
+      #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.risk.control.model.po.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    insert into user
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="phone != null">
+        phone,
+      </if>
+      <if test="email != null">
+        email,
+      </if>
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="password != null">
+        `password`,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="phone != null">
+        #{phone,jdbcType=VARCHAR},
+      </if>
+      <if test="email != null">
+        #{email,jdbcType=VARCHAR},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="password != null">
+        #{password,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.risk.control.model.po.UserExample" resultType="java.lang.Long">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    select count(*) from user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    update user
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.phone != null">
+        phone = #{record.phone,jdbcType=VARCHAR},
+      </if>
+      <if test="record.email != null">
+        email = #{record.email,jdbcType=VARCHAR},
+      </if>
+      <if test="record.name != null">
+        `name` = #{record.name,jdbcType=VARCHAR},
+      </if>
+      <if test="record.password != null">
+        `password` = #{record.password,jdbcType=VARCHAR},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.updateTime != null">
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    update user
+    set id = #{record.id,jdbcType=BIGINT},
+      phone = #{record.phone,jdbcType=VARCHAR},
+      email = #{record.email,jdbcType=VARCHAR},
+      `name` = #{record.name,jdbcType=VARCHAR},
+      `password` = #{record.password,jdbcType=VARCHAR},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.risk.control.model.po.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    update user
+    <set>
+      <if test="phone != null">
+        phone = #{phone,jdbcType=VARCHAR},
+      </if>
+      <if test="email != null">
+        email = #{email,jdbcType=VARCHAR},
+      </if>
+      <if test="name != null">
+        `name` = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="password != null">
+        `password` = #{password,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.risk.control.model.po.User">
+    <!--
+      WARNING - @mbg.generated
+      This element is automatically generated by MyBatis Generator, do not modify.
+      This element was generated on Wed May 21 19:08:42 CST 2025.
+    -->
+    update user
+    set phone = #{phone,jdbcType=VARCHAR},
+      email = #{email,jdbcType=VARCHAR},
+      `name` = #{name,jdbcType=VARCHAR},
+      `password` = #{password,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 3 - 3
risk-control-core/src/main/resources/mybatis-generator-config.xml

@@ -24,7 +24,7 @@
         <!-- 保留原有JDBC配置 -->
         <jdbcConnection
                 driverClass="com.mysql.jdbc.Driver"
-                connectionURL="jdbc:mysql://rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com:3306/test?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false"
+                connectionURL="jdbc:mysql://rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com:3306/riskcontrol?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false"
                 userId="wx2016_longvideo"
                 password="wx2016_longvideoP@assword1234">
         </jdbcConnection>
@@ -55,7 +55,7 @@
         </javaClientGenerator>
 
         <!-- 表配置 -->
-        <table tableName="qywx_user_base" domainObjectName="UserBase"/>
-        <table tableName="qywx_user_corp" domainObjectName="UserCorp"/>
+        <table tableName="user" domainObjectName="User"/>
+        <!-- <table tableName="qywx_user_corp" domainObjectName="UserCorp"/> -->
     </context>
 </generatorConfiguration>

+ 10 - 10
risk-control-server/src/main/java/com/tzld/piaoquan/risk/control/controller/QwLoginController.java

@@ -56,16 +56,16 @@ public class QwLoginController {
         }
     }
 
-    @PostMapping("/checkLogin")
-    public CommonResponse<String> checkLogin(@RequestBody QwLoginCheckCode checkCode) {
-        int ret = qwLoginService.checkQRCode(checkCode);
-        if(ret == 0) {
-            return CommonResponse.success();
-        } else {
-            LOGGER.error("checkQRCode failed, ret: {}", ret);
-            return CommonResponse.error("failed");
-        }
-    }
+    // @PostMapping("/checkLogin")
+    // public CommonResponse<String> checkLogin(@RequestBody QwLoginCheckCode checkCode) {
+    //     int ret = qwLoginService.checkQRCode(checkCode);
+    //     if(ret == 0) {
+    //         return CommonResponse.success();
+    //     } else {
+    //         LOGGER.error("checkQRCode failed, ret: {}", ret);
+    //         return CommonResponse.error("failed");
+    //     }
+    // }
 
     @PostMapping("/automaticLogin")
     public CommonResponse<String> automaticLogin(@RequestBody QwLoginCheckCode checkCode) {

+ 38 - 0
risk-control-server/src/main/java/com/tzld/piaoquan/risk/control/controller/UserController.java

@@ -0,0 +1,38 @@
+package com.tzld.piaoquan.risk.control.controller;
+
+import com.tzld.piaoquan.risk.control.common.annotation.UnAuth;
+import com.tzld.piaoquan.risk.control.common.base.CommonResponse;
+import com.tzld.piaoquan.risk.control.model.dto.LoginDTO;
+import com.tzld.piaoquan.risk.control.model.param.LoginAndRegisterParam;
+import com.tzld.piaoquan.risk.control.service.UserService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RestController
+@RequestMapping("/user")
+public class UserController {
+
+    @Autowired
+    private UserService loginService;
+
+    @UnAuth
+    @PostMapping("/login")
+    public CommonResponse<LoginDTO> login(@RequestBody LoginAndRegisterParam param) {
+        log.info("[user login]. param:{}", param);
+        return CommonResponse.create(loginService.login(param));
+    }
+
+    @UnAuth
+    @PostMapping("/register")
+    public CommonResponse<Void> register(@RequestBody LoginAndRegisterParam param) {
+        log.info("[user register]. param:{}", param);
+        loginService.register(param);
+        return CommonResponse.create();
+    }
+
+}

+ 14 - 2
risk-control-server/src/main/resources/application-dev.yml

@@ -10,7 +10,7 @@ eureka:
   client:
     registry-fetch-interval-seconds: 5  #定时从Eureka Server拉取服务注册信息的间隔时间
     serviceUrl:
-      defaultZone: http://deveureka-internal.piaoquantv.com/eureka/
+      defaultZone: http://127.0.0.1:7000/eureka/
 
 spring:
   datasource:
@@ -24,6 +24,18 @@ spring:
       maximum-pool-size: 20
       connection-test-query: SELECT 1
 
+  redis:
+    hostName: r-bp1ps6my7lzg8rdhwx682.redis.rds.aliyuncs.com
+    port: 6379
+    password: Wqsd@2019
+    timeout: 1000
+    lettuce:
+      pool:
+        max-active: 8
+        max-wait: -1
+        max-idle: 8
+        min-idle: 0
+
 logging:
   file:
     path: ./datalog/weblog/${project.name}
@@ -38,7 +50,7 @@ apollo:
 
 aliyun:
   log:
-    endpoint: cn-hangzhou-intranet.log.aliyuncs.com
+    endpoint: cn-hangzhou.log.aliyuncs.com
     accessKeyId: LTAIP6x1l3DXfSxm
     accessKeySecret: KbTaM9ars4OX3PMS6Xm7rtxGr1FLon
     project: risk-control-test

+ 11 - 0
risk-control-server/src/main/resources/application-pre.yml

@@ -23,6 +23,17 @@ spring:
       minimum-idle: 10
       maximum-pool-size: 20
       connection-test-query: SELECT 1
+  redis:
+    hostName: r-bp1wa750bo6lch8ze4.redis.rds.aliyuncs.com
+    port: 6379
+    password: riskcontrol1234@
+    timeout: 1000
+    lettuce:
+      pool:
+        max-active: 8
+        max-wait: -1
+        max-idle: 8
+        min-idle: 0
 
 logging:
   file:

+ 12 - 0
risk-control-server/src/main/resources/application-prod.yml

@@ -24,6 +24,18 @@ spring:
       maximum-pool-size: 20
       connection-test-query: SELECT 1
 
+  redis:
+    hostName: r-bp1wa750bo6lch8ze4.redis.rds.aliyuncs.com
+    port: 6379
+    password: riskcontrol1234@
+    timeout: 1000
+    lettuce:
+      pool:
+        max-active: 8
+        max-wait: -1
+        max-idle: 8
+        min-idle: 0
+
 logging:
   file:
     path: /datalog/weblog/${project.name}

+ 11 - 0
risk-control-server/src/main/resources/application-stress.yml

@@ -24,6 +24,17 @@ spring:
       maximum-pool-size: 20
       connection-test-query: SELECT 1
 
+  redis:
+    hostName: r-bp1ps6my7lzg8rdhwx682.redis.rds.aliyuncs.com
+    port: 6379
+    password: Wqsd@2019
+    timeout: 1000
+    lettuce:
+      pool:
+        max-active: 8
+        max-wait: -1
+        max-idle: 8
+        min-idle: 0
 
 logging:
   file:

+ 11 - 0
risk-control-server/src/main/resources/application-test.yml

@@ -24,6 +24,17 @@ spring:
       maximum-pool-size: 20
       connection-test-query: SELECT 1
 
+  redis:
+    hostName: r-bp1ps6my7lzg8rdhwx682.redis.rds.aliyuncs.com
+    port: 6379
+    password: Wqsd@2019
+    timeout: 1000
+    lettuce:
+      pool:
+        max-active: 8
+        max-wait: -1
+        max-idle: 8
+        min-idle: 0
 
 logging:
   file: