30262728@qq.com vor 2 Wochen
Ursprung
Commit
0b97c73e53
100 geänderte Dateien mit 4416 neuen und 818 gelöschten Zeilen
  1. 1 1
      qnfhq-admin/src/main/java/com/qnfhq/modules/job/config/ScheduleConfig.java
  2. 0 2
      qnfhq-admin/src/main/java/com/qnfhq/modules/sys/dao/SysDeptDao.java
  3. 1 1
      qnfhq-admin/src/main/resources/application.yml
  4. 44 1
      qnfhq-api/pom.xml
  5. 32 0
      qnfhq-api/src/main/java/com/qnfhq/aliyun/AlConfig.java
  6. 0 78
      qnfhq-api/src/main/java/com/qnfhq/config/WebMvcConfig.java
  7. 17 0
      qnfhq-api/src/main/java/com/qnfhq/constant/ApiConstant.java
  8. 0 52
      qnfhq-api/src/main/java/com/qnfhq/controller/ApiLoginController.java
  9. 0 46
      qnfhq-api/src/main/java/com/qnfhq/controller/ApiRegisterController.java
  10. 0 45
      qnfhq-api/src/main/java/com/qnfhq/controller/ApiTestController.java
  11. 0 17
      qnfhq-api/src/main/java/com/qnfhq/dao/TokenDao.java
  12. 0 17
      qnfhq-api/src/main/java/com/qnfhq/dao/UserDao.java
  13. 0 24
      qnfhq-api/src/main/java/com/qnfhq/dto/LoginDTO.java
  14. 0 24
      qnfhq-api/src/main/java/com/qnfhq/dto/RegisterDTO.java
  15. 0 39
      qnfhq-api/src/main/java/com/qnfhq/entity/TokenEntity.java
  16. 0 44
      qnfhq-api/src/main/java/com/qnfhq/entity/UserEntity.java
  17. 0 117
      qnfhq-api/src/main/java/com/qnfhq/exception/GlobalExceptionHandler.java
  18. 0 64
      qnfhq-api/src/main/java/com/qnfhq/interceptor/AuthorizationInterceptor.java
  19. 180 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/controller/ApiAppUserController.java
  20. 16 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppAssetDao.java
  21. 21 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppUserDao.java
  22. 16 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppUserDetailDao.java
  23. 17 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppuserLoginLogDao.java
  24. 16 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/SettingDao.java
  25. 16 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/SmsSendDao.java
  26. 16 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/SmsTplDao.java
  27. 60 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppAssetDTO.java
  28. 51 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppLoginDTO.java
  29. 50 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppRegisterDTO.java
  30. 91 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppUserDTO.java
  31. 95 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppUserDetailDTO.java
  32. 52 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppuserLoginLogDTO.java
  33. 51 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/ResetPwdByEmailDTO.java
  34. 43 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/ResetPwdByPhoneDTO.java
  35. 20 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SendEmailCodeDTO.java
  36. 17 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SendPhoneCodeDTO.java
  37. 30 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SendPhoneDto.java
  38. 44 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SettingDTO.java
  39. 45 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SmsSendDTO.java
  40. 37 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SmsTplDTO.java
  41. 50 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/setting/AssetSymbolSetting.java
  42. 22 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/setting/EmailSetting.java
  43. 17 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/setting/SmsSetting.java
  44. 70 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppAssetEntity.java
  45. 113 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppUserDetailEntity.java
  46. 115 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppUserEntity.java
  47. 63 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppuserLoginLogEntity.java
  48. 48 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/SettingEntity.java
  49. 53 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/SmsSendEntity.java
  50. 40 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/SmsTplEntity.java
  51. 43 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/AssetEnum.java
  52. 154 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/CachePrefix.java
  53. 90 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/SettingEnum.java
  54. 37 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/UserBlackEnum.java
  55. 48 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/UserCodeTypeEnum.java
  56. 14 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppAssetService.java
  57. 14 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppUserDetailService.java
  58. 68 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppUserService.java
  59. 19 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppuserLoginLogService.java
  60. 25 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/CaptchaService.java
  61. 14 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/SettingService.java
  62. 21 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/SmsSendService.java
  63. 15 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/SmsTplService.java
  64. 33 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppAssetServiceImpl.java
  65. 33 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppUserDetailServiceImpl.java
  66. 509 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppUserServiceImpl.java
  67. 66 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppuserLoginLogServiceImpl.java
  68. 90 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/CaptchaServiceImpl.java
  69. 37 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/SettingServiceImpl.java
  70. 96 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/SmsSendServiceImpl.java
  71. 41 0
      qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/SmsTplServiceImpl.java
  72. 0 45
      qnfhq-api/src/main/java/com/qnfhq/resolver/LoginUserHandlerMethodArgumentResolver.java
  73. 0 28
      qnfhq-api/src/main/java/com/qnfhq/service/TokenService.java
  74. 0 26
      qnfhq-api/src/main/java/com/qnfhq/service/UserService.java
  75. 0 90
      qnfhq-api/src/main/java/com/qnfhq/service/impl/TokenServiceImpl.java
  76. 0 55
      qnfhq-api/src/main/java/com/qnfhq/service/impl/UserServiceImpl.java
  77. 168 0
      qnfhq-api/src/main/java/com/qnfhq/utils/EmailUtils.java
  78. 85 0
      qnfhq-api/src/main/java/com/qnfhq/utils/OrderUtils.java
  79. 662 0
      qnfhq-api/src/main/java/com/qnfhq/utils/password/BCrypt.java
  80. 83 0
      qnfhq-api/src/main/java/com/qnfhq/utils/password/BCryptPasswordEncoder.java
  81. 30 0
      qnfhq-api/src/main/java/com/qnfhq/utils/password/PasswordEncoder.java
  82. 61 0
      qnfhq-api/src/main/java/com/qnfhq/utils/password/PasswordUtils.java
  83. 132 0
      qnfhq-api/src/main/java/com/qnfhq/utils/sms/SmsSenderUtil.java
  84. 2 2
      qnfhq-api/src/main/resources/application.yml
  85. 0 0
      qnfhq-api/src/main/resources/i18n/messages.properties
  86. 0 0
      qnfhq-api/src/main/resources/i18n/messages_de.properties
  87. 0 0
      qnfhq-api/src/main/resources/i18n/messages_en.properties
  88. 0 0
      qnfhq-api/src/main/resources/i18n/messages_es.properties
  89. 0 0
      qnfhq-api/src/main/resources/i18n/messages_fr.properties
  90. 0 0
      qnfhq-api/src/main/resources/i18n/messages_ja.properties
  91. 0 0
      qnfhq-api/src/main/resources/i18n/messages_ko.properties
  92. 0 0
      qnfhq-api/src/main/resources/i18n/messages_th.properties
  93. 0 0
      qnfhq-api/src/main/resources/i18n/messages_tw.properties
  94. 0 0
      qnfhq-api/src/main/resources/i18n/messages_vi.properties
  95. 51 0
      qnfhq-api/src/main/resources/i18n/messages_zh.properties
  96. 1 0
      qnfhq-api/src/main/resources/i18n/validation.properties
  97. 1 0
      qnfhq-api/src/main/resources/i18n/validation_de.properties
  98. 1 0
      qnfhq-api/src/main/resources/i18n/validation_en.properties
  99. 1 0
      qnfhq-api/src/main/resources/i18n/validation_es.properties
  100. 1 0
      qnfhq-api/src/main/resources/i18n/validation_fr.properties

+ 1 - 1
qnfhq-admin/src/main/java/com/qnfhq/modules/job/config/ScheduleConfig.java

@@ -6,7 +6,7 @@
 // * 版权所有,侵权必究!
 // */
 //
-//package io.renren.modules.job.config;
+//package com.qnfhq.modules.job.config;
 //
 //import org.springframework.context.annotation.Bean;
 //import org.springframework.context.annotation.Configuration;

+ 0 - 2
qnfhq-admin/src/main/java/com/qnfhq/modules/sys/dao/SysDeptDao.java

@@ -1,5 +1,3 @@
-
-
 package com.qnfhq.modules.sys.dao;
 
 import com.qnfhq.common.dao.BaseDao;

+ 1 - 1
qnfhq-admin/src/main/resources/application.yml

@@ -60,7 +60,7 @@ renren:
 mybatis-plus:
   mapper-locations: classpath*:/mapper/**/*.xml
   #实体扫描,多个package用逗号或者分号分隔
-  typeAliasesPackage: io.renren.modules.*.entity
+  typeAliasesPackage: com.qnfhq.modules.*.entity
   global-config:
     #数据库相关配置
     db-config:

+ 44 - 1
qnfhq-api/pom.xml

@@ -8,7 +8,13 @@
 	<artifactId>qnfhq-api</artifactId>
 	<packaging>jar</packaging>
 	<description>qnfhq-api</description>
-
+    <properties>
+        <captcha.version>1.6.2</captcha.version>
+        <bitwalker.version>1.21</bitwalker.version>
+        <mail.version>2.0.2</mail.version>
+        <freemarker.version>2.3.34</freemarker.version>
+        <aliyun.sms.version>4.1.1</aliyun.sms.version>
+    </properties>
 	<dependencies>
 		<dependency>
 			<groupId>com.qnfhq</groupId>
@@ -20,6 +26,43 @@
 			<artifactId>qnfhq-dynamic-datasource</artifactId>
 			<version>5.5.0</version>
 		</dependency>
+
+<!--        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-security</artifactId>
+        </dependency>-->
+
+        <!-- 解析客户端操作系统、浏览器等 -->
+        <dependency>
+            <groupId>eu.bitwalker</groupId>
+            <artifactId>UserAgentUtils</artifactId>
+            <version>${bitwalker.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>jakarta.mail</artifactId>
+            <version>${mail.version}</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+            <version>${freemarker.version}</version>
+        </dependency>
+
+        <!-- 阿里云 短信及服务 -->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>dysmsapi20170525</artifactId>
+            <version>${aliyun.sms.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.whvcse</groupId>
+            <artifactId>easy-captcha</artifactId>
+            <version>${captcha.version}</version>
+        </dependency>
 	</dependencies>
 
 	<build>

+ 32 - 0
qnfhq-api/src/main/java/com/qnfhq/aliyun/AlConfig.java

@@ -0,0 +1,32 @@
+package com.qnfhq.aliyun;
+
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.teaopenapi.models.Config;
+
+import java.util.Map;
+
+public class AlConfig {
+
+    public static Client createClient(String accessKeyId,String accessKeySecret) throws Exception {
+        Config config = new Config()
+                .setAccessKeyId(accessKeyId)
+                .setAccessKeySecret(accessKeySecret);
+        config.endpoint = "dysmsapi.aliyuncs.com";
+        return new Client(config);
+    }
+
+
+    /**
+     * 获取参数值
+     * @param content
+     * @param params
+     * @return
+     */
+    public static String getTplParams(String content, Map<String, String> params) {
+        for (Map.Entry<String, String> entry : params.entrySet()) {
+            content = content.replace("${" + entry.getKey() + "}", entry.getValue());
+        }
+        return content;
+    }
+
+}

+ 0 - 78
qnfhq-api/src/main/java/com/qnfhq/config/WebMvcConfig.java

@@ -1,78 +0,0 @@
-package com.qnfhq.config;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
-import com.qnfhq.common.utils.DateUtils;
-import com.qnfhq.interceptor.AuthorizationInterceptor;
-import com.qnfhq.resolver.LoginUserHandlerMethodArgumentResolver;
-import jakarta.annotation.Resource;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.converter.ByteArrayHttpMessageConverter;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.ResourceHttpMessageConverter;
-import org.springframework.http.converter.StringHttpMessageConverter;
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
-import org.springframework.web.method.support.HandlerMethodArgumentResolver;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-import java.text.SimpleDateFormat;
-import java.util.List;
-import java.util.TimeZone;
-
-/**
- * MVC配置
- *
- * @author Mark sunlightcs@gmail.com
- */
-@Configuration
-public class WebMvcConfig implements WebMvcConfigurer {
-    @Resource
-    private AuthorizationInterceptor authorizationInterceptor;
-    @Resource
-    private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver;
-
-    @Override
-    public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/api/**");
-    }
-
-    @Override
-    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
-        argumentResolvers.add(loginUserHandlerMethodArgumentResolver);
-    }
-
-    @Override
-    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
-        converters.add(new ByteArrayHttpMessageConverter());
-        converters.add(new StringHttpMessageConverter());
-        converters.add(new ResourceHttpMessageConverter());
-        converters.add(new AllEncompassingFormHttpMessageConverter());
-        converters.add(new StringHttpMessageConverter());
-        converters.add(jackson2HttpMessageConverter());
-    }
-
-    @Bean
-    public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() {
-        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
-        ObjectMapper mapper = new ObjectMapper();
-
-        //日期格式转换
-        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-        mapper.setDateFormat(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN));
-        mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
-
-        //Long类型转String类型
-        SimpleModule simpleModule = new SimpleModule();
-        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
-        simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
-        mapper.registerModule(simpleModule);
-
-        converter.setObjectMapper(mapper);
-        return converter;
-    }
-}

+ 17 - 0
qnfhq-api/src/main/java/com/qnfhq/constant/ApiConstant.java

@@ -0,0 +1,17 @@
+package com.qnfhq.constant;
+
+/**
+ * 常量
+ *
+ * @author Yelz
+ */
+public interface ApiConstant {
+    /**
+     * 短信验证码过期时间 5分钟
+     */
+    int SMS_EXPIRE = 300;
+    /**
+     * 邮箱验证码过期时间 5分钟
+     */
+    int EMAIL_EXPIRE = 300;
+}

+ 0 - 52
qnfhq-api/src/main/java/com/qnfhq/controller/ApiLoginController.java

@@ -1,52 +0,0 @@
-package com.qnfhq.controller;
-
-
-import com.qnfhq.annotation.Login;
-import com.qnfhq.common.utils.Result;
-import com.qnfhq.common.validator.ValidatorUtils;
-import com.qnfhq.dto.LoginDTO;
-import com.qnfhq.service.TokenService;
-import com.qnfhq.service.UserService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.Map;
-
-/**
- * 登录接口
- *
- * @author Mark sunlightcs@gmail.com
- */
-@RestController
-@RequestMapping("/api")
-@Tag(name = "登录接口")
-@AllArgsConstructor
-public class ApiLoginController {
-    private final UserService userService;
-    private final TokenService tokenService;
-
-
-    @PostMapping("login")
-    @Operation(summary = "登录")
-    public Result<Map<String, Object>> login(@RequestBody LoginDTO dto) {
-        //表单校验
-        ValidatorUtils.validateEntity(dto);
-
-        //用户登录
-        Map<String, Object> map = userService.login(dto);
-
-        return new Result().ok(map);
-    }
-
-    @Login
-    @PostMapping("logout")
-    @Operation(summary = "退出")
-    public Result logout(@Parameter(hidden = true) @RequestAttribute("userId") Long userId) {
-        tokenService.expireToken(userId);
-        return new Result();
-    }
-
-}

+ 0 - 46
qnfhq-api/src/main/java/com/qnfhq/controller/ApiRegisterController.java

@@ -1,46 +0,0 @@
-package com.qnfhq.controller;
-
-import cn.hutool.crypto.digest.DigestUtil;
-import com.qnfhq.common.utils.Result;
-import com.qnfhq.common.validator.ValidatorUtils;
-import com.qnfhq.dto.RegisterDTO;
-import com.qnfhq.entity.UserEntity;
-import com.qnfhq.service.UserService;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import lombok.AllArgsConstructor;
-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;
-
-import java.util.Date;
-
-/**
- * 注册接口
- *
- * @author Mark sunlightcs@gmail.com
- */
-@RestController
-@RequestMapping("/api")
-@Tag(name = "注册接口")
-@AllArgsConstructor
-public class ApiRegisterController {
-    private final UserService userService;
-
-    @PostMapping("register")
-    @Operation(summary = "注册")
-    public Result register(@RequestBody RegisterDTO dto) {
-        //表单校验
-        ValidatorUtils.validateEntity(dto);
-
-        UserEntity user = new UserEntity();
-        user.setMobile(dto.getMobile());
-        user.setUsername(dto.getMobile());
-        user.setPassword(DigestUtil.sha256Hex(dto.getPassword()));
-        user.setCreateDate(new Date());
-        userService.insert(user);
-
-        return new Result();
-    }
-}

+ 0 - 45
qnfhq-api/src/main/java/com/qnfhq/controller/ApiTestController.java

@@ -1,45 +0,0 @@
-package com.qnfhq.controller;
-
-import com.qnfhq.annotation.Login;
-import com.qnfhq.annotation.LoginUser;
-import com.qnfhq.common.utils.Result;
-import com.qnfhq.entity.UserEntity;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
-import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 测试接口
- *
- * @author Mark sunlightcs@gmail.com
- */
-@RestController
-@RequestMapping("/api")
-@Tag(name = "测试接口")
-public class ApiTestController {
-
-    @Login
-    @GetMapping("userInfo")
-    @Operation(summary = "获取用户信息")
-    public Result<UserEntity> userInfo(@Parameter(hidden = true) @LoginUser UserEntity user) {
-        return new Result<UserEntity>().ok(user);
-    }
-
-    @Login
-    @GetMapping("userId")
-    @Operation(summary = "获取用户ID")
-    public Result<Long> userInfo(@Parameter(hidden = true) @RequestAttribute("userId") Long userId) {
-        return new Result<Long>().ok(userId);
-    }
-
-    @GetMapping("notToken")
-    @Operation(summary = "忽略Token验证测试")
-    public Result<String> notToken() {
-        return new Result<String>().ok("无需token也能访问。。。");
-    }
-
-}

+ 0 - 17
qnfhq-api/src/main/java/com/qnfhq/dao/TokenDao.java

@@ -1,17 +0,0 @@
-package com.qnfhq.dao;
-
-import com.qnfhq.common.dao.BaseDao;
-import com.qnfhq.entity.TokenEntity;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * 用户Token
- * 
- * @author Mark sunlightcs@gmail.com
- */
-@Mapper
-public interface TokenDao extends BaseDao<TokenEntity> {
-    TokenEntity getByToken(String token);
-
-    TokenEntity getByUserId(Long userId);
-}

+ 0 - 17
qnfhq-api/src/main/java/com/qnfhq/dao/UserDao.java

@@ -1,17 +0,0 @@
-package com.qnfhq.dao;
-
-import com.qnfhq.common.dao.BaseDao;
-import com.qnfhq.entity.UserEntity;
-import org.apache.ibatis.annotations.Mapper;
-
-/**
- * 用户
- * 
- * @author Mark sunlightcs@gmail.com
- */
-@Mapper
-public interface UserDao extends BaseDao<UserEntity> {
-    UserEntity getUserByMobile(String mobile);
-
-    UserEntity getUserByUserId(Long userId);
-}

+ 0 - 24
qnfhq-api/src/main/java/com/qnfhq/dto/LoginDTO.java

@@ -1,24 +0,0 @@
-package com.qnfhq.dto;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import jakarta.validation.constraints.NotBlank;
-import lombok.Data;
-
-
-/**
- * 登录表单
- *
- * @author Mark sunlightcs@gmail.com
- */
-@Data
-@Schema(title = "登录表单")
-public class LoginDTO {
-    @Schema(title = "手机号")
-    @NotBlank(message="手机号不能为空")
-    private String mobile;
-
-    @Schema(title = "密码")
-    @NotBlank(message="密码不能为空")
-    private String password;
-
-}

+ 0 - 24
qnfhq-api/src/main/java/com/qnfhq/dto/RegisterDTO.java

@@ -1,24 +0,0 @@
-package com.qnfhq.dto;
-
-import io.swagger.v3.oas.annotations.media.Schema;
-import jakarta.validation.constraints.NotBlank;
-import lombok.Data;
-
-
-/**
- * 注册表单
- *
- * @author Mark sunlightcs@gmail.com
- */
-@Data
-@Schema(title = "注册表单")
-public class RegisterDTO {
-    @Schema(title = "手机号")
-    @NotBlank(message="手机号不能为空")
-    private String mobile;
-
-    @Schema(title = "密码")
-    @NotBlank(message="密码不能为空")
-    private String password;
-
-}

+ 0 - 39
qnfhq-api/src/main/java/com/qnfhq/entity/TokenEntity.java

@@ -1,39 +0,0 @@
-package com.qnfhq.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 用户Token
- * 
- * @author Mark sunlightcs@gmail.com
- */
-@Data
-@TableName("tb_token")
-public class TokenEntity implements Serializable {
-	private static final long serialVersionUID = 1L;
-
-	@TableId
-	private Long id;
-	/**
-	 * 用户ID
-	 */
-	private Long userId;
-	/**
-	 * 用户token
-	 */
-	private String token;
-	/**
-	 * 过期时间
-	 */
-	private Date expireDate;
-	/**
-	 * 更新时间
-	 */
-	private Date updateDate;
-
-}

+ 0 - 44
qnfhq-api/src/main/java/com/qnfhq/entity/UserEntity.java

@@ -1,44 +0,0 @@
-package com.qnfhq.entity;
-
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.Date;
-
-/**
- * 用户
- * 
- * @author Mark sunlightcs@gmail.com
- */
-@Data
-@TableName("tb_user")
-public class UserEntity implements Serializable {
-	private static final long serialVersionUID = 1L;
-
-	/**
-	 * 用户ID
-	 */
-	@TableId
-	private Long id;
-	/**
-	 * 用户名
-	 */
-	private String username;
-	/**
-	 * 手机号
-	 */
-	private String mobile;
-	/**
-	 * 密码
-	 */
-	@JsonIgnore
-	private String password;
-	/**
-	 * 创建时间
-	 */
-	private Date createDate;
-
-}

+ 0 - 117
qnfhq-api/src/main/java/com/qnfhq/exception/GlobalExceptionHandler.java

@@ -1,117 +0,0 @@
-package com.qnfhq.exception;
-
-import com.qnfhq.common.utils.Result;
-import jakarta.servlet.http.HttpServletRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.validation.BindException;
-import org.springframework.web.HttpRequestMethodNotSupportedException;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-
-
-
-/**
- * 全局异常处理器
- *
- */
-@RestControllerAdvice
-public class GlobalExceptionHandler
-{
-    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
-
-    /**
-     * 权限校验异常
-     */
-//    @ExceptionHandler(AccessDeniedException.class)
-//    public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
-//    {
-//        String requestURI = request.getRequestURI();
-//        log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
-//        return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
-//    }
-
-    /**
-     * 请求方式不支持
-     */
-    @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
-    public Result handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
-                                                      HttpServletRequest request)
-    {
-        String requestURI = request.getRequestURI();
-        log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
-        Result result = new Result();
-        result.error(e.getMessage());
-        return result;
-    }
-
-    /**
-     * 业务异常
-     */
-//    @ExceptionHandler(ServiceException.class)
-//    public Result handleServiceException(ServiceException e, HttpServletRequest request)
-//    {
-//        log.error(e.getMessage(), e);
-//        Integer code = e.getCode();
-//        return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
-//    }
-
-
-    /**
-     * 拦截未知的运行时异常
-     */
-    @ExceptionHandler(RuntimeException.class)
-    public Result handleRuntimeException(RuntimeException e, HttpServletRequest request)
-    {
-        String requestURI = request.getRequestURI();
-        log.error("请求地址'{}',发生未知异常.", requestURI, e);
-        Result result = new Result();
-        result.error(e.getMessage());
-        return result;
-    }
-
-    /**
-     * 系统异常
-     */
-    @ExceptionHandler(Exception.class)
-    public Result handleException(Exception e, HttpServletRequest request)
-    {
-        String requestURI = request.getRequestURI();
-        log.error("请求地址'{}',发生系统异常.", requestURI, e);
-        Result result = new Result();
-        result.error(e.getMessage());
-        return result;
-    }
-
-    /**
-     * 自定义验证异常
-     */
-    @ExceptionHandler(BindException.class)
-    public Result handleBindException(BindException e)
-    {
-        log.error(e.getMessage(), e);
-        String message = e.getAllErrors().get(0).getDefaultMessage();
-        Result result = new Result();
-        result.error(message);
-        return result;
-    }
-
-    /**
-     * 自定义验证异常
-     */
-    @ExceptionHandler(MethodArgumentNotValidException.class)
-    public Result handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
-    {
-        log.error(e.getMessage(), e);
-        String message = e.getBindingResult().getFieldError().getDefaultMessage();
-        Result result = new Result();
-        result.error(message);
-        return result;
-    }
-
-
-
-
-
-}

+ 0 - 64
qnfhq-api/src/main/java/com/qnfhq/interceptor/AuthorizationInterceptor.java

@@ -1,64 +0,0 @@
-package com.qnfhq.interceptor;
-
-import cn.hutool.core.util.StrUtil;
-import com.qnfhq.annotation.Login;
-import com.qnfhq.common.exception.ErrorCode;
-import com.qnfhq.common.exception.RenException;
-import com.qnfhq.entity.TokenEntity;
-import com.qnfhq.service.TokenService;
-import jakarta.annotation.Resource;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import org.springframework.stereotype.Component;
-import org.springframework.web.method.HandlerMethod;
-import org.springframework.web.servlet.HandlerInterceptor;
-
-/**
- * 权限(Token)验证
- *
- * @author Mark sunlightcs@gmail.com
- */
-@Component
-public class AuthorizationInterceptor implements HandlerInterceptor {
-    @Resource
-    private TokenService tokenService;
-
-    public static final String USER_KEY = "userId";
-
-    @Override
-    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-        Login annotation;
-        if (handler instanceof HandlerMethod) {
-            annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class);
-        } else {
-            return true;
-        }
-
-        if (annotation == null) {
-            return true;
-        }
-
-        //从header中获取token
-        String token = request.getHeader("token");
-        //如果header中不存在token,则从参数中获取token
-        if (StrUtil.isBlank(token)) {
-            token = request.getParameter("token");
-        }
-
-        //token为空
-        if (StrUtil.isBlank(token)) {
-            throw new RenException(ErrorCode.TOKEN_NOT_EMPTY);
-        }
-
-        //查询token信息
-        TokenEntity tokenEntity = tokenService.getByToken(token);
-        if (tokenEntity == null || tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()) {
-            throw new RenException(ErrorCode.TOKEN_INVALID);
-        }
-
-        //设置userId到request里,后续根据userId,获取用户信息
-        request.setAttribute(USER_KEY, tokenEntity.getUserId());
-
-        return true;
-    }
-}

+ 180 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/controller/ApiAppUserController.java

@@ -0,0 +1,180 @@
+package com.qnfhq.modules.user.controller;
+
+import cn.dev33.satoken.stp.StpUtil;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.qnfhq.common.exception.ErrorCode;
+import com.qnfhq.common.exception.RenException;
+import com.qnfhq.common.utils.MessageUtils;
+import com.qnfhq.common.utils.Result;
+import com.qnfhq.common.validator.AssertUtils;
+import com.qnfhq.common.validator.ValidatorUtils;
+import com.qnfhq.modules.user.entity.AppUserEntity;
+import com.qnfhq.modules.user.dto.*;
+import com.qnfhq.modules.user.service.AppUserService;
+import com.qnfhq.modules.user.service.AppuserLoginLogService;
+import com.qnfhq.modules.user.service.CaptchaService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+
+
+/**
+ * 注册接口
+ * 登录接口
+ * 退出接口
+ * @author yelz
+ */
+@RestController
+@RequestMapping("/user")
+@Tag(name = "App用户接口")
+public class ApiAppUserController {
+    private static final Logger logger = LoggerFactory.getLogger(ApiAppUserController.class);
+
+    @Resource
+    private AppuserLoginLogService appuserLoginLogService;
+
+    @Resource
+    private AppUserService appUserService;
+
+    @Resource
+    private CaptchaService captchaService;
+
+
+    @PostMapping("/register")
+    @Operation(summary = "注册")
+    public Result register(@RequestBody AppRegisterDTO dto, HttpServletRequest request) {
+        //表单校验
+        ValidatorUtils.validateEntity(dto);
+
+//        int signType = dto.getSignType();
+//        if(signType==1) {
+//            if(StringUtils.isEmpty(dto.getEmail())) {
+//                throw new RenException(MessageUtils.message("email.code_empty"));//邮箱不能为空!
+//            }
+//        } else if (signType==2) {
+//            if(StringUtils.isEmpty(dto.getPhone())) {
+//                throw new RenException(MessageUtils.message("phone_code_empty"));//手机号不能为空!
+//            }
+//        } else {
+//            throw new RenException(MessageUtils.message("user.register.signtype.err"));//登录类型错误
+//        }
+
+        return appUserService.register(dto,request);
+    }
+
+
+    @PostMapping("/login")
+    @Operation(summary = "登录")
+    public Result login(@RequestBody AppLoginDTO dto, HttpServletRequest request) {
+
+        ValidatorUtils.validateEntity(dto);
+
+        return appUserService.login(dto,request);
+    }
+
+    @GetMapping("/info")
+    @Operation(summary = "登陆用户信息")
+    public Result info() throws IOException {
+        Result result = new Result();
+        if(StpUtil.isLogin()) {
+            Long userId = StpUtil.getLoginIdAsLong();
+            logger.info("userId = {}", userId);
+            AppUserEntity user = appUserService.getUserByUserId(userId);
+
+            result.setMsg("success");
+            result.setData(user);
+            return result;
+        } else {
+            return result.error(MessageUtils.message("user.not.login.err"));//未登陆
+
+        }
+    }
+
+
+    @PostMapping("/logout")
+    @Operation(summary = "退出")
+    public Result logout(HttpServletRequest request) {
+        if(StpUtil.isLogin()) {
+            Long userId = StpUtil.getLoginIdAsLong();
+            StpUtil.logout(userId);
+            AppUserEntity one = appUserService.getUserByUserId(userId);
+            appuserLoginLogService.insertAppActionLog(one, "用户退出", "0", request);
+        }
+        return new Result();
+    }
+
+
+
+    /**
+     * 发送email通用验证码
+     */
+    @Operation(summary = "发送邮箱验证码")
+    @PostMapping("/sendEmailCode")
+    public Result sendEmailCode(@RequestBody SendEmailCodeDTO sendCodeDTO) {
+
+        ValidatorUtils.validateEntity(sendCodeDTO);
+
+        if (StringUtils.isEmpty(sendCodeDTO.getEmail())) {
+            throw new RenException(MessageUtils.message("email.code_empty"));//邮箱不能为空!
+        }
+
+        return appUserService.sendEmailCode(sendCodeDTO.getCodeType(),sendCodeDTO.getEmail());
+
+    }
+
+
+    /**
+     * 发送手机通用验证码
+     *
+     * @return
+     */
+    @PostMapping("/sendMobileCode")
+    public Result sendMobileCode (@RequestBody SendPhoneCodeDTO codeDTO){
+        return appUserService.sendMobileCode(codeDTO.getCodeType(),codeDTO.getPhone(),codeDTO.getZone() == null ? "" : codeDTO.getZone());
+    }
+
+
+    @GetMapping("/captcha")
+    @Operation(summary = "验证码")
+    @Parameter(in = ParameterIn.QUERY, ref = "string", name = "uuid", required = true)
+    public void captcha(HttpServletResponse response, String uuid) throws IOException {
+        //唯一标识不能为空
+        AssertUtils.isBlank(uuid, ErrorCode.IDENTIFIER_NOT_NULL);
+
+        //生成验证码
+        captchaService.create(response, uuid);
+    }
+
+    /**
+     * 重置登陆密码
+     *
+     * @return
+     */
+    @PostMapping("/resetPwdByEmail")
+    public Result resetPwdByEmail (@RequestBody ResetPwdByEmailDTO codeDTO){
+        ValidatorUtils.validateEntity(codeDTO);
+
+        return appUserService.resetPwdByEmail(codeDTO);
+    }
+
+    /**
+     * 重置登陆密码
+     *
+     * @return
+     */
+    @PostMapping("/resetPwdByPhone")
+    public Result resetPwdByPhone (@RequestBody ResetPwdByPhoneDTO codeDTO){
+        ValidatorUtils.validateEntity(codeDTO);
+
+        return appUserService.resetPwdByPhone(codeDTO);
+    }
+}

+ 16 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppAssetDao.java

@@ -0,0 +1,16 @@
+package com.qnfhq.modules.user.dao;
+
+import com.qnfhq.common.dao.BaseDao;
+import com.qnfhq.modules.user.entity.AppAssetEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 玩家资产表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Mapper
+public interface AppAssetDao extends BaseDao<AppAssetEntity> {
+	
+}

+ 21 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppUserDao.java

@@ -0,0 +1,21 @@
+package com.qnfhq.modules.user.dao;
+
+import com.qnfhq.common.dao.BaseDao;
+import com.qnfhq.modules.user.entity.AppUserEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 玩家用户表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Mapper
+public interface AppUserDao extends BaseDao<AppUserEntity> {
+
+    AppUserEntity getUserByMobile(String mobile);
+
+    AppUserEntity getUserByUserId(Long userId);
+
+    AppUserEntity getUserByActiveCode(String activeCode);
+}

+ 16 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppUserDetailDao.java

@@ -0,0 +1,16 @@
+package com.qnfhq.modules.user.dao;
+
+import com.qnfhq.common.dao.BaseDao;
+import com.qnfhq.modules.user.entity.AppUserDetailEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 用户详细信息
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Mapper
+public interface AppUserDetailDao extends BaseDao<AppUserDetailEntity> {
+	
+}

+ 17 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/AppuserLoginLogDao.java

@@ -0,0 +1,17 @@
+package com.qnfhq.modules.user.dao;
+
+import com.qnfhq.common.dao.BaseDao;
+import com.qnfhq.modules.user.entity.AppuserLoginLogEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+
+/**
+ * 系统访问记录
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Mapper
+public interface AppuserLoginLogDao extends BaseDao<AppuserLoginLogEntity> {
+	
+}

+ 16 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/SettingDao.java

@@ -0,0 +1,16 @@
+package com.qnfhq.modules.user.dao;
+
+import com.qnfhq.common.dao.BaseDao;
+import com.qnfhq.modules.user.entity.SettingEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 配置(短信邮箱等)
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Mapper
+public interface SettingDao extends BaseDao<SettingEntity> {
+	
+}

+ 16 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/SmsSendDao.java

@@ -0,0 +1,16 @@
+package com.qnfhq.modules.user.dao;
+
+import com.qnfhq.common.dao.BaseDao;
+import com.qnfhq.modules.user.entity.SmsSendEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 短信发送情况
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Mapper
+public interface SmsSendDao extends BaseDao<SmsSendEntity> {
+	
+}

+ 16 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dao/SmsTplDao.java

@@ -0,0 +1,16 @@
+package com.qnfhq.modules.user.dao;
+
+import com.qnfhq.common.dao.BaseDao;
+import com.qnfhq.modules.user.entity.SmsTplEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 短信模板
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Mapper
+public interface SmsTplDao extends BaseDao<SmsTplEntity> {
+	
+}

+ 60 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppAssetDTO.java

@@ -0,0 +1,60 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import java.math.BigDecimal;
+
+/**
+ * 玩家资产表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@Schema(name = "玩家资产表")
+public class AppAssetDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	@SchemaProperty(name = "")
+	private Long id;
+
+	@SchemaProperty(name = "")
+	private Long userId;
+
+	@SchemaProperty(name = "币种")
+	private String symbol;
+
+	@SchemaProperty(name = "资产总额")
+	private BigDecimal amout;
+
+	@SchemaProperty(name = "占用资产")
+	private BigDecimal occupiedAmount;
+
+	@SchemaProperty(name = "可用资产")
+	private BigDecimal availableAmount;
+
+	@SchemaProperty(name = "资产类型 1=平台资产 2=理财资产 3=合约账户")
+	private String type;
+
+	@SchemaProperty(name = "创建人")
+	private String createBy;
+
+	@SchemaProperty(name = "创建时间")
+	private Date createTime;
+
+	@SchemaProperty(name = "更新人")
+	private String updateBy;
+
+	@SchemaProperty(name = "更新时间")
+	private Date updateTime;
+
+	@SchemaProperty(name = "备注")
+	private String remark;
+
+
+}

+ 51 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppLoginDTO.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2018 人人开源 All rights reserved.
+ *
+ * https://www.renren.io
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+
+/**
+ * 登陆
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+@Data
+@Schema(title = "登陆表单")
+public class AppLoginDTO {
+
+    @Schema(title = "密码")
+    @NotBlank(message="{AppLoginDTO.loginPassword.NotBlank}")//密码不能为空
+    private String loginPassword;
+
+    @Schema(title = "账号")
+    @NotBlank(message="AppLoginDTO.loginName.NotBlank")//账号不能为空
+    private String loginName;
+
+    @Schema(title = "验证码")
+    @NotBlank(message="AppLoginDTO.code.NotBlank")//验证码不能为空
+    private String code;
+
+    @Schema(title = "唯一标识")
+    @NotBlank(message="AppLoginDTO.uuid.NotBlank")//唯一标识不能为空
+    private String uuid;
+
+//    @Schema(title = "登录类型")
+//    @NotNull(message="登录类型不能为空")
+//    private int signType;
+//
+//    @Schema(title = "区号")
+//    @NotBlank(message="区号不能为空")
+//    private String zone;
+
+
+}

+ 50 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppRegisterDTO.java

@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2018 人人开源 All rights reserved.
+ *
+ * https://www.renren.io
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+
+/**
+ * 注册表单
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+@Data
+@Schema(title = "注册表单")
+public class AppRegisterDTO {
+
+    @Schema(title = "密码")
+    @NotBlank(message="{AppRegisterDTO.loginPassword.NotBlank}")//密码不能为空
+    private String loginPassword;
+
+    @Schema(title = "邮箱")
+    @NotBlank(message="{AppRegisterDTO.email.NotBlank}")//邮箱不能为空
+    private String email;
+
+    @Schema(title = "验证码")
+    @NotBlank(message="{AppRegisterDTO.code.NotBlank}")//验证码不能为空
+    private String code;
+
+//    @Schema(title = "手机号")
+//    private String phone;
+
+//    @Schema(title = "登录类型")
+//    @NotNull(message="{AppRegisterDTO.signType.NotNull}")//登录类型不能为空
+//    private int signType;
+
+    @Schema(title = "推荐码")
+    private String activeCode;
+
+//    @Schema(title = "区号")
+//    private String zone;
+}

+ 91 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppUserDTO.java

@@ -0,0 +1,91 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 玩家用户表
+ * 1
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Data
+@Schema(name = "玩家用户表")
+public class AppUserDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	@SchemaProperty(name = "")
+	private Long userId;
+
+	@SchemaProperty(name = "姓名")
+	private String loginName;
+
+	@SchemaProperty(name = "登陆密码")
+	private String loginPassword;
+
+	@SchemaProperty(name = "手机号")
+	private String phone;
+
+	@SchemaProperty(name = "0-正常 1-测试")
+	private Integer isTest;
+
+	@SchemaProperty(name = "0正常1冻结")
+	private Integer status;
+
+	@SchemaProperty(name = "app代理ids")
+	private String appParentIds;
+
+	@SchemaProperty(name = "上一层ID")
+	private Integer parentId;
+
+	@SchemaProperty(name = "后台代理ids")
+	private String adminParentIds;
+
+	@SchemaProperty(name = "邀请码")
+	private String activeCode;
+
+	@SchemaProperty(name = "注册ip")
+	private String registerIp;
+
+	@SchemaProperty(name = "注册域名")
+	private String host;
+
+	@SchemaProperty(name = "邮箱")
+	private String email;
+
+	@SchemaProperty(name = "vip等级 ")
+	private Integer level;
+
+	@SchemaProperty(name = "是否冻结  1=正常 2=冻结")
+	private String isFreeze;
+
+	@SchemaProperty(name = "创建人")
+	private String createBy;
+
+	@SchemaProperty(name = "创建时间")
+	private Date createTime;
+
+	@SchemaProperty(name = "更新人")
+	private String updateBy;
+
+	@SchemaProperty(name = "更新时间")
+	private Date updateTime;
+
+	@SchemaProperty(name = "备注")
+	private String remark;
+
+	@SchemaProperty(name = "黑名单 1=正常 2拉黑")
+	private Integer isBlack;
+
+	@SchemaProperty(name = "头像地址")
+	private String avatar;
+
+	@SchemaProperty(name = "昵称")
+	private String nickname;
+
+
+}

+ 95 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppUserDetailDTO.java

@@ -0,0 +1,95 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 用户详细信息
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@Schema(name = "用户详细信息")
+public class AppUserDetailDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	@SchemaProperty(name = "")
+	private Long id;
+
+	@SchemaProperty(name = "")
+	private Long userId;
+
+	@SchemaProperty(name = "真实姓名")
+	private String realName;
+
+	@SchemaProperty(name = "身份证号码")
+	private String idCard;
+
+	@SchemaProperty(name = "身份证正面照片")
+	private String frontUrl;
+
+	@SchemaProperty(name = "国际")
+	private String country;
+
+	@SchemaProperty(name = "")
+	private String cardType;
+
+	@SchemaProperty(name = "手持身份证照片")
+	private String handelUrl;
+
+	@SchemaProperty(name = "身份证反面照片")
+	private String backUrl;
+
+	@SchemaProperty(name = "用户交易密码")
+	private String userTardPwd;
+
+	@SchemaProperty(name = "")
+	private String createBy;
+
+	@SchemaProperty(name = "")
+	private Date createTime;
+
+	@SchemaProperty(name = "")
+	private String updateBy;
+
+	@SchemaProperty(name = "")
+	private Date updateTime;
+
+	@SchemaProperty(name = "")
+	private String remark;
+
+	@SchemaProperty(name = "验证状态")
+	private Integer auditStatus;
+
+	@SchemaProperty(name = "信用分")
+	private Integer credits;
+
+	@SchemaProperty(name = "用户充值地址")
+	private String userRechargeAddress;
+
+	@SchemaProperty(name = "交易是否被限制 1 为限制")
+	private String tradeFlag;
+
+	@SchemaProperty(name = "金额是否被限制 1 为限制")
+	private String amountFlag;
+
+	@SchemaProperty(name = "金额限制提示语")
+	private String pushMessage;
+
+	@SchemaProperty(name = "交易限制提示语")
+	private String tradeMessage;
+
+	@SchemaProperty(name = "实名认证时间")
+	private Date operateTime;
+
+	@SchemaProperty(name = "重新实名认证次数")
+	private Integer reKyc;
+
+
+}

+ 52 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/AppuserLoginLogDTO.java

@@ -0,0 +1,52 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+import lombok.Data;
+import java.io.Serializable;
+import java.util.Date;
+import io.swagger.v3.oas.annotations.media.Schema;
+
+
+/**
+ * 系统访问记录
+ * 1
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Data
+@Schema(name = "系统访问记录")
+public class AppuserLoginLogDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	@SchemaProperty(name = "主键ID")
+	private Long id;
+
+	@SchemaProperty(name = "登录用户ID")
+	private Long userId;
+
+	@SchemaProperty(name = "登录用户名")
+	private String username;
+
+	@SchemaProperty(name = "访问IP")
+	private String ipaddr;
+
+	@SchemaProperty(name = "访问位置")
+	private String loginLocation;
+
+	@SchemaProperty(name = "浏览器")
+	private String browser;
+
+	@SchemaProperty(name = "系统OS")
+	private String os;
+
+	@SchemaProperty(name = "登录状态(0成功 1失败)")
+	private String status;
+
+	@SchemaProperty(name = "")
+	private String msg;
+
+	@SchemaProperty(name = "访问时间")
+	private Date loginTime;
+
+
+}

+ 51 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/ResetPwdByEmailDTO.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2018 人人开源 All rights reserved.
+ *
+ * https://www.renren.io
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+
+/**
+ * 重设密码
+ *
+ * @author Yelz 30262728@qq.com
+ */
+@Data
+@Schema(title = "重设密码表单")
+public class ResetPwdByEmailDTO {
+
+
+
+    @Schema(title = "密码")
+    @NotBlank(message="{ResetPwdDTO.newPwd.NotBlank}")//新密码不能为空
+    private String newPwd;
+
+    @Schema(title = "邮箱")
+    @NotBlank(message="ResetPwdDTO.email.NotBlank")//邮箱不能为空
+    private String email;
+
+    @Schema(title = "邮箱验证码")
+    @NotBlank(message="ResetPwdDTO.code.NotBlank")//邮箱验证码不能为空
+    private String code;
+
+//    @Schema(title = "谷歌验证码")
+//    @NotBlank(message="ResetPwdDTO.googleCode.NotBlank")//谷歌验证码不能为空
+//    private String googleCode;
+
+//    @Schema(title = "图形验证码")
+//    @NotBlank(message="ResetPwdDTO.uuidCode.NotBlank")//图形验证码不能为空
+//    private String uuidCode;
+//
+//    @Schema(title = "唯一标识")
+//    private String uuid;
+
+
+}

+ 43 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/ResetPwdByPhoneDTO.java

@@ -0,0 +1,43 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+/**
+ * 一句话描述
+ *
+ * @Author: Yelz
+ * @Date: 2025/11/14 15:04
+ * @Description:
+ */
+@Data
+@Schema(title = "重设密码表单")
+public class ResetPwdByPhoneDTO {
+    @Schema(title = "密码")
+    @NotBlank(message="{ResetPwdDTO.newPwd.NotBlank}")//新密码不能为空
+    private String newPwd;
+
+    @Schema(title = "手机号")
+    @NotBlank(message="ResetPwdDTO.phone.NotBlank")//手机号不能为空
+    private String phone;
+
+    @Schema(title = "验证码")
+    @NotBlank(message="ResetPwdDTO.code.NotBlank")//验证码不能为空
+    private String code;
+
+    @Schema(title = "区号")
+    @NotBlank(message="ResetPwdDTO.zone.NotBlank")//区号不能为空
+    private String zone;
+
+//    @Schema(title = "谷歌验证码")
+//    @NotBlank(message="ResetPwdDTO.googleCode.NotBlank")//谷歌验证码不能为空
+//    private String googleCode;
+
+//    @Schema(title = "图形验证码")
+//    @NotBlank(message="ResetPwdDTO.uuidCode.NotBlank")//图形验证码不能为空
+//    private String uuidCode;
+//
+//    @Schema(title = "唯一标识")
+//    private String uuid;
+}

+ 20 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SendEmailCodeDTO.java

@@ -0,0 +1,20 @@
+package com.qnfhq.modules.user.dto;
+
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+@Data
+public class SendEmailCodeDTO {
+
+    @Schema(title = "验证码类型")
+    @NotBlank(message="{SendEmailCodeDTO.codeType.NotBlank}")//验证码类型不能空
+    private String codeType;
+
+    @Schema(title = "邮箱")
+    @NotBlank(message="{SendEmailCodeDTO.email.NotBlank}")//邮箱不能为空
+    private String email;
+
+
+}

+ 17 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SendPhoneCodeDTO.java

@@ -0,0 +1,17 @@
+package com.qnfhq.modules.user.dto;
+
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class SendPhoneCodeDTO {
+
+    @Schema(title = "验证码类型")
+    private String codeType;
+
+    private String phone;
+
+    private String zone;
+
+}

+ 30 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SendPhoneDto.java

@@ -0,0 +1,30 @@
+package com.qnfhq.modules.user.dto;
+
+import lombok.Data;
+
+import java.util.Map;
+
+@Data
+public class SendPhoneDto {
+
+    private String account;
+    //API账号对应密钥
+    private String password;
+    //短信内容
+    private String msg;
+    //手机号码
+    private String mobile;
+    //客户自定义批次号
+    private String uid;
+    //用户收到短信之后显示的发件人国内不支持自定义,国外支持,但是需要提前和运营商沟通注册,具体请与NODE对接人员确定。选填
+    private String senderId;
+    //退订开启标识
+    private String tdFlag;
+
+
+
+    //短信类型
+    private String code;
+    //存放参数
+    private Map<String, String> params;
+}

+ 44 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SettingDTO.java

@@ -0,0 +1,44 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 配置
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@Schema(name = "配置")
+public class SettingDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	@SchemaProperty(name = "ID")
+	private String id;
+
+	@SchemaProperty(name = "创建者")
+	private String createBy;
+
+	@SchemaProperty(name = "创建时间")
+	private Date createTime;
+
+	@SchemaProperty(name = "删除标志 true/false 删除/未删除")
+	private Boolean deleteFlag;
+
+	@SchemaProperty(name = "更新者")
+	private String updateBy;
+
+	@SchemaProperty(name = "更新时间")
+	private Date updateTime;
+
+	@SchemaProperty(name = "配置值value")
+	private String settingValue;
+
+
+}

+ 45 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SmsSendDTO.java

@@ -0,0 +1,45 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+
+/**
+ * 短信发送情况
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@Schema(name = "短信发送情况")
+public class SmsSendDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	private Long id;
+
+	@SchemaProperty(name = "手机号码")
+	private String mobile;
+
+	@SchemaProperty(name = "发送内容")
+	private String content;
+
+	@SchemaProperty(name = "code")
+	private String code;
+
+	@SchemaProperty(name = "发送时间")
+	private Integer time;
+
+	@SchemaProperty(name = "错误信息")
+	private String error;
+
+	@SchemaProperty(name = "默认0未成功")
+	private Integer isSuccess;
+
+	@SchemaProperty(name = "sass")
+	private Integer sassid;
+
+
+}

+ 37 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/SmsTplDTO.java

@@ -0,0 +1,37 @@
+package com.qnfhq.modules.user.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+/**
+ * 短信模板
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@Schema(name = "短信模板")
+public class SmsTplDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+	private Integer id;
+
+	@SchemaProperty(name = "标题")
+	private String title;
+
+	@SchemaProperty(name = "短信内容")
+	private String content;
+
+	@SchemaProperty(name = "官方code")
+	private String sendCode;
+
+	@SchemaProperty(name = " code")
+	private String code;
+
+
+}

+ 50 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/setting/AssetSymbolSetting.java

@@ -0,0 +1,50 @@
+package com.qnfhq.modules.user.dto.setting;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 充值通道配置
+ */
+@Data
+public class AssetSymbolSetting {
+    /**
+     * 币种名称
+     */
+    private String symbolName;
+    /**
+     * 币种类型
+     */
+    private String symbol;
+    /**
+     * U-ERC充值地址
+     */
+    private String symbolAddress;
+    /**
+     * 充值次数
+     */
+    private Integer rechargeNum;
+    /**
+     * 充值最大额度
+     */
+    private BigDecimal rechargeMax;
+    /**
+     * 充值最小额度
+     */
+    private BigDecimal rechargeMin;
+    /**
+     * 合约地址
+     */
+    private String contractAddress;
+    /**
+     * 币种
+     */
+    private String virtualSymbol;
+
+    /**
+     * 公有链/区块平台
+     */
+    private String blockchainPlatform;
+
+}

+ 22 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/setting/EmailSetting.java

@@ -0,0 +1,22 @@
+package com.qnfhq.modules.user.dto.setting;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 邮箱配置
+ */
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class EmailSetting {
+
+    private String mailTemplate;
+    private String mailAppName;
+    private String mailUsername;
+    private String mailPassword;
+    private String mailHost;
+    private String mailPort;
+}

+ 17 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/dto/setting/SmsSetting.java

@@ -0,0 +1,17 @@
+package com.qnfhq.modules.user.dto.setting;
+
+import lombok.Data;
+
+/**
+ * 短信配置
+ */
+@Data
+public class SmsSetting {
+
+
+    private String name;//签名
+    private String mobileAccount;//AccessKeyId
+    private String mobilePassword;//AccessKeySecret
+    private String mobileUrl;//=https://api.nodesms.com/send/json
+
+}

+ 70 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppAssetEntity.java

@@ -0,0 +1,70 @@
+package com.qnfhq.modules.user.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 玩家资产表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@TableName("t_app_asset")
+public class AppAssetEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @TableId(type = IdType.AUTO)
+	private Long id;
+    /**
+     * 
+     */
+	private Long userId;
+
+    /**
+     * 币种
+     */
+	private String symbol;
+    /**
+     * 资产总额
+     */
+	private BigDecimal total;
+    /**
+     * 占用资产
+     */
+	private BigDecimal frozen;
+    /**
+     * 可用资产
+     */
+	private BigDecimal available;
+    /**
+     * 资产类型 1=平台资产 2=理财资产 3=合约账户
+     */
+	private Integer type;
+    /**
+     * 创建人
+     */
+	private String createBy;
+    /**
+     * 创建时间
+     */
+	private Date createTime;
+    /**
+     * 更新人
+     */
+	private String updateBy;
+    /**
+     * 更新时间
+     */
+	private Date updateTime;
+    /**
+     * 备注
+     */
+	private String remark;
+}

+ 113 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppUserDetailEntity.java

@@ -0,0 +1,113 @@
+package com.qnfhq.modules.user.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 用户详细信息
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@TableName("t_app_user_detail")
+public class AppUserDetailEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+    @TableId(type = IdType.AUTO)
+	private Long id;
+    /**
+     * 
+     */
+	private Long userId;
+    /**
+     * 真实姓名
+     */
+	private String realName;
+    /**
+     * 身份证号码
+     */
+	private String idCard;
+    /**
+     * 身份证正面照片
+     */
+	private String frontUrl;
+    /**
+     * 国际
+     */
+	private String country;
+    /**
+     * 
+     */
+	private String cardType;
+    /**
+     * 手持身份证照片
+     */
+	private String handelUrl;
+    /**
+     * 身份证反面照片
+     */
+	private String backUrl;
+    /**
+     * 用户交易密码
+     */
+	private String userTardPwd;
+    /**
+     * 
+     */
+	private String createBy;
+    /**
+     * 
+     */
+	private Date createTime;
+    /**
+     * 
+     */
+	private String updateBy;
+    /**
+     * 
+     */
+	private Date updateTime;
+    /**
+     * 
+     */
+	private String remark;
+    /**
+     * 验证状态
+     */
+	private Integer auditStatus;
+    /**
+     * 信用分
+     */
+	private Integer credits;
+    /**
+     * 交易是否被限制 1 为限制
+     */
+	private String tradeFlag;
+    /**
+     * 金额是否被限制 1 为限制
+     */
+	private String amountFlag;
+    /**
+     * 金额限制提示语
+     */
+	private String pushMessage;
+    /**
+     * 交易限制提示语
+     */
+	private String tradeMessage;
+    /**
+     * 实名认证时间
+     */
+	private Date operateTime;
+    /**
+     * 重新实名认证次数
+     */
+	private Integer reKyc;
+}

+ 115 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppUserEntity.java

@@ -0,0 +1,115 @@
+package com.qnfhq.modules.user.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 玩家用户表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Data
+@TableName("t_app_user")
+public class AppUserEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+    @TableId(type = IdType.AUTO)
+	private Long id;
+
+    private String uid;
+    /**
+     * 登陆账号
+     */
+	private String loginName;
+    /**
+     * 登陆密码
+     */
+    @JsonIgnore
+	private String loginPassword;
+    /**
+     * 手机号
+     */
+	private String phone;
+    /**
+     * 0-正常 1-测试
+     */
+	private Integer isTest;
+    /**
+     * 0正常 1冻结
+     */
+	private Integer status;
+    /**
+     * app代理ids
+     */
+	private String appParentIds;
+    /**
+     * 上一层ID
+     */
+	private Long parentId;
+    /**
+     * 后台代理ids
+     */
+	private String adminParentIds;
+    /**
+     * 邀请码
+     */
+	private String activeCode;
+    /**
+     * 注册ip
+     */
+	private String registerIp;
+    /**
+     * 注册域名
+     */
+	private String host;
+    /**
+     * 邮箱
+     */
+	private String email;
+    /**
+     * vip等级 
+     */
+	private Integer level;
+
+    /**
+     * 创建人
+     */
+	private String createBy;
+    /**
+     * 创建时间
+     */
+	private Date createTime;
+    /**
+     * 更新人
+     */
+	private String updateBy;
+    /**
+     * 更新时间
+     */
+	private Date updateTime;
+    /**
+     * 备注
+     */
+	private String remark;
+    /**
+     * 黑名单 1=正常 2拉黑
+     */
+	private Integer isBlack;
+
+    /**
+     * 头像地址
+     */
+	private String avatar;
+    /**
+     * 昵称
+     */
+	private String nickname;
+}

+ 63 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/AppuserLoginLogEntity.java

@@ -0,0 +1,63 @@
+package com.qnfhq.modules.user.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 系统访问记录
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Data
+@TableName("t_appuser_login_log")
+public class AppuserLoginLogEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+	private Long id;
+    /**
+     * 登录用户ID
+     */
+	private Long userId;
+    /**
+     * 登录用户名
+     */
+	private String username;
+    /**
+     * 访问IP
+     */
+	private String ipaddr;
+    /**
+     * 访问位置
+     */
+	private String loginLocation;
+    /**
+     * 浏览器
+     */
+	private String browser;
+    /**
+     * 系统OS
+     */
+	private String os;
+    /**
+     * 登录状态(0成功 1失败)
+     */
+	private String status;
+    /**
+     * 
+     */
+	private String msg;
+    /**
+     * 访问时间
+     */
+	private Date loginTime;
+}

+ 48 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/SettingEntity.java

@@ -0,0 +1,48 @@
+package com.qnfhq.modules.user.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 配置(短信邮箱等)
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@TableName("t_setting")
+public class SettingEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+	private String id;
+    /**
+     * 创建者
+     */
+	private String createBy;
+    /**
+     * 创建时间
+     */
+	private Date createTime;
+    /**
+     * 删除标志 true/false 删除/未删除
+     */
+	private Boolean deleteFlag;
+    /**
+     * 更新者
+     */
+	private String updateBy;
+    /**
+     * 更新时间
+     */
+	private Date updateTime;
+    /**
+     * 配置值value
+     */
+	private String settingValue;
+}

+ 53 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/SmsSendEntity.java

@@ -0,0 +1,53 @@
+package com.qnfhq.modules.user.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 短信发送情况
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@TableName("t_sms_send")
+public class SmsSendEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+    @TableId(type = IdType.AUTO)
+	private Long id;
+    /**
+     * 手机号码
+     */
+	private String mobile;
+    /**
+     * 发送内容
+     */
+	private String content;
+    /**
+     * code
+     */
+	private String code;
+    /**
+     * 发送时间
+     */
+    private Date createTime;
+    /**
+     * 错误信息
+     */
+	private String error;
+    /**
+     * 默认0未成功
+     */
+	private Integer isSuccess;
+    /**
+     * sass
+     */
+	private Integer sassid;
+}

+ 40 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/entity/SmsTplEntity.java

@@ -0,0 +1,40 @@
+package com.qnfhq.modules.user.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 短信模板
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Data
+@TableName("t_sms_tpl")
+public class SmsTplEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+
+    @TableId(type = IdType.AUTO)
+	private Integer id;
+    /**
+     * 标题
+     */
+	private String title;
+    /**
+     * 短信内容
+     */
+	private String content;
+    /**
+     * 官方code
+     */
+	private String sendCode;
+    /**
+     *  code
+     */
+	private String code;
+}

+ 43 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/AssetEnum.java

@@ -0,0 +1,43 @@
+package com.qnfhq.modules.user.enums;
+
+public enum AssetEnum {
+
+
+
+    /**
+     * 平台资产
+     */
+    PLATFORM_ASSETS(1,"平台资产"),
+
+    /**
+     * 理财资产
+     */
+    FINANCIAL_ASSETS(2,"理财资产"),
+    /**
+     * 合约资产
+     */
+    CONTRACT_ASSETS(3,"合约账户"),
+
+
+
+
+    ;
+    private Integer code;
+
+    private String desc;
+
+    public Integer getCode()
+    {
+        return code;
+    }
+
+    public String getInfo()
+    {
+        return desc;
+    }
+
+    AssetEnum(Integer code, String desc){
+        this.code = code;
+        this.desc = desc;
+    }
+}

+ 154 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/CachePrefix.java

@@ -0,0 +1,154 @@
+package com.qnfhq.modules.user.enums;
+
+public enum CachePrefix {
+
+    /**
+     * token 信息
+     */
+    ACCESS_TOKEN,
+    /**
+     * token 信息
+     */
+    REFRESH_TOKEN,
+    /**
+     * 用户错误登录限制
+     */
+    LOGIN_TIME_LIMIT,
+    /**
+     * 普通验证码
+     */
+    CODE,
+    /**
+     * 短信验证码
+     */
+    SMS_CODE,
+    /**
+     * 邮箱验证码
+     */
+    EMAIL_CODE,
+    /**
+     * 币种汇率
+     */
+    CURRENCY_PRICE,
+    /**
+     * 24小时开盘价
+     */
+    CURRENCY_OPEN_PRICE,
+
+    /**
+     * 虚拟交易
+     */
+    VIRTUAL_TRANSACTION,
+
+    /**
+     * 收盘价
+     **/
+    CURRENCY_CLOSE_PRICE,
+    /**
+     * 用户多币种充值地址
+     */
+    USER_ADDRESS,
+    /**
+     * 秒合约订单
+     */
+    ORDER_SECOND_CONTRACT,
+    /**
+     * 钱包KEY
+     */
+    USER_WALLET,
+    /**
+     * 用户借贷KEY
+     */
+    APP_LOADORDER,
+    /**
+     * 理财购买限制
+     */
+    MINE_FINANCIAL,
+    /**
+     *理财购买成交频繁限制
+     */
+    MINE_FINANCIAL_ORDER,
+    /**
+     * 玩家的站内信
+     */
+    USER_MAIL,
+    /**
+     * 玩家公共的站内信
+     */
+    COMMONALITY_MAIL,
+    /**
+     * 币币交易订单key
+     */
+    REDIS_KEY_CURRENCY_ORDER,
+    /**
+     * 用户登录 标识
+     */
+    USER_LOGIN_ADDRESS_FLAG,
+
+    /**
+     * 自有币种缓存
+     */
+    OWN_COIN_CACHE,
+    /**
+     * 币种k线缓存
+     */
+    COIN_KLINE,
+    /**
+     * 币种交易
+     */
+    COIN_TRADE,
+    /**
+     * 币种详情
+     */
+    COIN_DETAIL,
+    /**
+     * 止盈
+     */
+    POSITION_PRICE,
+    /**
+     * 用户上次提现地址
+     */
+    USER_ADDRESS_WITHDRAW,
+    /**
+     * 自动提币打款
+     */
+    SUBMIT_COIN_REVIEW,
+    UPDATE_WALLET_USERID,
+    /**
+     * 修改合约保证金
+     */
+    CONTRACT_ADJUST_AMOUNT,
+    /**
+     * 手动触发归集锁
+     */
+    AUTO_COLLECT_DATA_LOCK,
+    /**
+     * 获取eth和时生成另一个防止重复入库锁
+     */
+    ETH_BNB_ADD_ANOTHER_ADDRESS,
+    /**
+     * 谷歌验证器
+     */
+    GOOGLE_AUTHENTICATOR,
+    TRANSFER_FUNDS,
+
+    //币种兑换
+    CURRRENCY_EXCHANGE_CHECK
+
+    ;
+
+
+    public static String removePrefix(String str) {
+        return str.substring(str.lastIndexOf("}_") + 2);
+    }
+
+    /**
+     * 通用获取缓存key值
+     *
+     * @return 缓存key值
+     */
+    public String getPrefix() {
+        return "{" + this.name() + "}_:";
+    }
+
+}

+ 90 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/SettingEnum.java

@@ -0,0 +1,90 @@
+package com.qnfhq.modules.user.enums;
+
+/**
+ * 系统设置
+ *
+ * @author Chopper
+ * @since 2020/9/11 17:03
+ */
+public enum SettingEnum {
+    //提币配置
+    SUBMIT_SETTING,
+    //归集配置
+    COLLECT_SETTING,
+    //基础配置
+    BASE_SETTING,
+    //邮箱配置
+    EMAIL_SETTING,
+    //阿里OSS配置
+    OSS_SETTING,
+    //短信配置
+    SMS_SETTING,
+    //IM 配置
+    IM_SETTING,
+    //充值通道配置
+    ASSET_COIN,
+    //登录注册 开关
+    LOGIN_REGIS_SETTING,
+    //market 地址
+    MARKET_URL,
+    //侧边栏
+    APP_SIDEBAR_SETTING,
+    //贷款配置
+    LOAD_SETTING,
+    //提现通道配置
+    WITHDRAWAL_CHANNEL_SETTING,
+    //理财结算配置
+    FINANCIAL_SETTLEMENT_SETTING,
+    //平台设置
+    PLATFORM_SETTING,
+    //后台ip控制
+    WHITE_IP_SETTING,
+    //客服设置
+    SUPPORT_STAFF_SETTING,
+    //充值返佣
+    RECHARGE_REBATE_SETTING,
+    //理财返佣
+    FINANCIAL_REBATE_SETTING,
+    //挖框结算
+    MING_SETTLEMENT_SETTING,
+    //冲提语音包配置
+    WITHDRAWAL_RECHARGE_VOICE,
+    //白皮书
+    WHITE_PAPER_SETTING,
+    //defi挖矿收益配置
+    DEFI_INCOME_SETTING,
+    //玩法配置
+    PLAYING_SETTING,
+    //头部Tab平台 理财 合约
+    TAB_SETTING,
+    //底部菜单
+    BOTTOM_MENU_SETTING,
+    //金刚区
+    MIDDLE_MENU_SETTING,
+    //logo配置
+    LOGO_SETTING,
+    //首页币种配置
+    HOME_COIN_SETTING,
+    //下载地址配置
+    DOWNLOAD_SETTING,
+    //TG机器人配置
+    TG_BOT_SETTING,
+    //提现实名限额
+    AUTH_LIMIT,
+    //三方充提配置
+    THIRD_CHANNL,
+    //vip等级配置
+    VIP_LEVEL_SETTING,
+    //vip 说明
+    VIP_DIRECTIONS_SETTING,
+
+    ADD_MOSAIC_SETTING,
+
+    //后台配置第三银行
+    BANK_SETTING,
+
+    //充值手续费
+    CHARGE_FEE,
+
+    ;
+}

+ 37 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/UserBlackEnum.java

@@ -0,0 +1,37 @@
+package com.qnfhq.modules.user.enums;
+
+/**
+ * 黑名单
+ */
+public enum UserBlackEnum {
+
+
+    /**
+     * 正常用户
+     */
+    NORMAL(1,"正常用户"),
+
+    /**
+     * 拉黑用户
+     */
+    BLOCK(2,"拉黑用户"),
+
+
+    ;
+    private Integer code;
+
+    private String value;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    UserBlackEnum(Integer code, String value){
+        this.code = code;
+        this.value = value;
+    }
+}

+ 48 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/enums/UserCodeTypeEnum.java

@@ -0,0 +1,48 @@
+package com.qnfhq.modules.user.enums;
+
+/**
+ * 用户验证码类型
+ */
+public enum UserCodeTypeEnum {
+
+
+    /**
+     * 登录
+     */
+    LOGIN,
+
+    /**
+     * 注册
+     */
+    REGISTER,
+
+    /**
+     * 找回用户
+     */
+    FIND_USER  ,
+    /**
+     * 找回用户
+     */
+    FIND_PASSWORD  ,
+    /**
+     * 修改密码
+     */
+    UPD_PASSWORD,
+
+    /**
+     * 绑定
+     */
+    BIND,
+    /**
+     * 提现
+     */
+    WITHDRAW,
+    /**
+     * 管理员验证码
+     */
+    ADMIN_YZM,
+    /**
+     * c2c申诉
+     */
+    COMPLAIN,
+}

+ 14 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppAssetService.java

@@ -0,0 +1,14 @@
+package com.qnfhq.modules.user.service;
+
+import com.qnfhq.common.service.BaseService;
+import com.qnfhq.modules.user.entity.AppAssetEntity;
+
+/**
+ * 玩家资产表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+public interface AppAssetService extends BaseService<AppAssetEntity> {
+
+}

+ 14 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppUserDetailService.java

@@ -0,0 +1,14 @@
+package com.qnfhq.modules.user.service;
+
+import com.qnfhq.common.service.BaseService;
+import com.qnfhq.modules.user.entity.AppUserDetailEntity;
+
+/**
+ * 用户详细信息
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+public interface AppUserDetailService extends BaseService<AppUserDetailEntity> {
+
+}

+ 68 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppUserService.java

@@ -0,0 +1,68 @@
+package com.qnfhq.modules.user.service;
+
+import com.qnfhq.common.service.BaseService;
+import com.qnfhq.common.utils.Result;
+import com.qnfhq.modules.user.dto.AppLoginDTO;
+import com.qnfhq.modules.user.dto.AppRegisterDTO;
+import com.qnfhq.modules.user.dto.ResetPwdByEmailDTO;
+import com.qnfhq.modules.user.dto.ResetPwdByPhoneDTO;
+import com.qnfhq.modules.user.entity.AppUserEntity;
+import jakarta.servlet.http.HttpServletRequest;
+
+/**
+ * 玩家用户表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+public interface AppUserService extends BaseService<AppUserEntity> {
+
+    AppUserEntity getUserByEmail(String email);
+
+    AppUserEntity getUserByMobile(String mobile);
+
+    AppUserEntity getUserByUserId(Long userId);
+
+    AppUserEntity getUserByActiveCode(String activeCode);
+
+    /**
+     * 注册
+     * @param dto
+     * @param request
+     * @return
+     */
+    Result register(AppRegisterDTO dto, HttpServletRequest request);
+
+
+    /**
+     * 登陆
+     * @param dto
+     * @param request
+     * @return
+     */
+    Result login(AppLoginDTO dto, HttpServletRequest request);
+
+    /**
+     * 邮箱发送验证码
+     * @param codeType 类型:LOGIN 登录使用
+     * @param email 邮箱
+     * @return
+     */
+    public Result sendEmailCode(String codeType, String email);
+
+    /**
+     * 手机发送验证码
+     * @param codeType 类型:LOGIN 登录使用
+     * @param phone 手机号
+     * @param zone 区号
+     * @return
+     */
+    public Result sendMobileCode(String codeType,String phone,String zone);
+
+
+
+    Result resetPwdByEmail(ResetPwdByEmailDTO codeDTO);
+    Result resetPwdByPhone(ResetPwdByPhoneDTO codeDTO);
+
+
+}

+ 19 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/AppuserLoginLogService.java

@@ -0,0 +1,19 @@
+package com.qnfhq.modules.user.service;
+
+import com.qnfhq.common.service.BaseService;
+import com.qnfhq.modules.user.entity.AppUserEntity;
+import com.qnfhq.modules.user.entity.AppuserLoginLogEntity;
+import jakarta.servlet.http.HttpServletRequest;
+
+/**
+ * 系统访问记录
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+public interface AppuserLoginLogService extends BaseService<AppuserLoginLogEntity> {
+
+
+    void insertAppActionLog(AppUserEntity user, String msg, String status, HttpServletRequest request);
+
+}

+ 25 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/CaptchaService.java

@@ -0,0 +1,25 @@
+package com.qnfhq.modules.user.service;
+
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * 验证码
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+public interface CaptchaService {
+
+    /**
+     * 图片验证码
+     */
+    void create(HttpServletResponse response, String uuid) throws IOException;
+
+    /**
+     * 验证码效验
+     * @param uuid  uuid
+     * @param code  验证码
+     * @return  true:成功  false:失败
+     */
+    boolean validate(String uuid, String code);
+}

+ 14 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/SettingService.java

@@ -0,0 +1,14 @@
+package com.qnfhq.modules.user.service;
+
+import com.qnfhq.common.service.BaseService;
+import com.qnfhq.modules.user.entity.SettingEntity;
+
+/**
+ * 配置
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+public interface SettingService extends BaseService<SettingEntity> {
+    SettingEntity getSetting(String id);
+}

+ 21 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/SmsSendService.java

@@ -0,0 +1,21 @@
+package com.qnfhq.modules.user.service;
+
+import com.qnfhq.common.service.BaseService;
+import com.qnfhq.common.utils.Result;
+import com.qnfhq.modules.user.dto.SendPhoneDto;
+import com.qnfhq.modules.user.entity.SmsSendEntity;
+
+/**
+ * 短信发送情况
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+public interface SmsSendService extends BaseService<SmsSendEntity> {
+    /**
+     * 新版本发送验证码
+     * @param mobileNumber
+     * @return
+     */
+    Result sendMobileCodeV2(SendPhoneDto mobileNumber);
+}

+ 15 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/SmsTplService.java

@@ -0,0 +1,15 @@
+package com.qnfhq.modules.user.service;
+
+import com.qnfhq.common.service.BaseService;
+import com.qnfhq.modules.user.entity.SmsTplEntity;
+
+/**
+ * 短信模板
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+public interface SmsTplService extends BaseService<SmsTplEntity> {
+
+    SmsTplEntity selectSmsTplByCode(String code);
+}

+ 33 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppAssetServiceImpl.java

@@ -0,0 +1,33 @@
+package com.qnfhq.modules.user.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qnfhq.common.service.impl.BaseServiceImpl;
+import com.qnfhq.modules.user.dao.AppAssetDao;
+import com.qnfhq.modules.user.entity.AppAssetEntity;
+import com.qnfhq.modules.user.service.AppAssetService;
+import cn.hutool.core.util.StrUtil;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * 玩家资产表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Service
+public class AppAssetServiceImpl extends BaseServiceImpl<AppAssetDao, AppAssetEntity> implements AppAssetService {
+
+
+    public QueryWrapper<AppAssetEntity> getWrapper(Map<String, Object> params){
+        String id = (String)params.get("id");
+
+        QueryWrapper<AppAssetEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
+
+        return wrapper;
+    }
+
+
+}

+ 33 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppUserDetailServiceImpl.java

@@ -0,0 +1,33 @@
+package com.qnfhq.modules.user.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qnfhq.common.service.impl.BaseServiceImpl;
+import com.qnfhq.modules.user.dao.AppUserDetailDao;
+import com.qnfhq.modules.user.entity.AppUserDetailEntity;
+import com.qnfhq.modules.user.service.AppUserDetailService;
+import cn.hutool.core.util.StrUtil;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * 用户详细信息
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Service
+public class AppUserDetailServiceImpl extends BaseServiceImpl<AppUserDetailDao, AppUserDetailEntity> implements AppUserDetailService {
+
+
+    public QueryWrapper<AppUserDetailEntity> getWrapper(Map<String, Object> params){
+        String id = (String)params.get("id");
+
+        QueryWrapper<AppUserDetailEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
+
+        return wrapper;
+    }
+
+
+}

+ 509 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppUserServiceImpl.java

@@ -0,0 +1,509 @@
+package com.qnfhq.modules.user.service.impl;
+
+import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.qnfhq.common.exception.RenException;
+import com.qnfhq.common.redis.RedisUtils;
+import com.qnfhq.common.utils.IpUtils;
+import com.qnfhq.common.utils.MessageUtils;
+import com.qnfhq.common.utils.Result;
+import com.qnfhq.constant.ApiConstant;
+import com.qnfhq.modules.user.dao.AppUserDao;
+import com.qnfhq.modules.user.dto.*;
+import com.qnfhq.modules.user.dto.setting.AssetSymbolSetting;
+import com.qnfhq.modules.user.entity.AppAssetEntity;
+import com.qnfhq.modules.user.entity.AppUserDetailEntity;
+import com.qnfhq.modules.user.entity.AppUserEntity;
+import com.qnfhq.modules.user.entity.SettingEntity;
+import com.qnfhq.modules.user.enums.*;
+import com.qnfhq.modules.user.service.*;
+import com.qnfhq.utils.EmailUtils;
+import com.qnfhq.utils.OrderUtils;
+import com.qnfhq.utils.password.PasswordUtils;
+import com.qnfhq.utils.sms.SmsSenderUtil;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import com.qnfhq.common.service.impl.BaseServiceImpl;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+import lombok.AllArgsConstructor;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * 玩家用户表
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Slf4j
+@Service
+@AllArgsConstructor
+public class AppUserServiceImpl extends BaseServiceImpl<AppUserDao, AppUserEntity> implements AppUserService {
+
+    @Resource
+    RedisUtils redisUtils;
+
+    @Resource
+    private SettingService settingService;
+
+    @Resource
+    private AppUserDetailService detailService;
+
+    @Resource
+    private AppAssetService assetService;
+
+    @Resource
+    AppuserLoginLogService appuserLoginLogService;
+
+    @Resource
+    private SmsSendService smsSendService;
+
+    @Resource
+    private CaptchaService captchaService;
+
+    @Override
+    public AppUserEntity getUserByEmail(String email) {
+        return baseDao.selectOne(new LambdaQueryWrapper<AppUserEntity>()
+                .eq(AppUserEntity::getEmail, email)
+                .last(" limit 1")
+        );
+    }
+
+    @Override
+    public AppUserEntity getUserByMobile(String mobile) {
+        return baseDao.selectOne(new LambdaQueryWrapper<AppUserEntity>()
+                .eq(AppUserEntity::getPhone, mobile)
+                .last(" limit 1")
+        );
+    }
+
+    @Override
+    public AppUserEntity getUserByUserId(Long userId) {
+        return baseDao.selectOne(new LambdaQueryWrapper<AppUserEntity>()
+                .eq(AppUserEntity::getId, userId)
+                .last(" limit 1")
+        );
+    }
+
+    @Override
+    public AppUserEntity getUserByActiveCode(String activeCode) {
+        return baseDao.selectOne(new LambdaQueryWrapper<AppUserEntity>()
+                .eq(AppUserEntity::getActiveCode, activeCode)
+                .last(" limit 1")
+        );
+    }
+
+    public AppUserEntity getUserByLoginName(String loginName) {
+        return baseDao.selectOne(new LambdaQueryWrapper<AppUserEntity>()
+                .eq(AppUserEntity::getLoginName, loginName)
+                .last(" limit 1")
+        );
+    }
+
+    /**
+     * 注册
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public Result register(AppRegisterDTO registerDto, HttpServletRequest request) {
+        AppUserEntity fUser = null;
+        //判断推荐码是否存在
+        if(StringUtils.isNotEmpty(registerDto.getActiveCode())) {
+            fUser  = getUserByActiveCode(registerDto.getActiveCode());
+            if(null == fUser) {
+                throw new RenException(MessageUtils.message("user.register.activecode.notexisit"));//推荐码不存在
+            }
+        }
+
+        AppUserEntity appUserEntity = new AppUserEntity();
+//        int signType = registerDto.getSignType();
+//        if(signType==1) {//使用邮箱注册、校验验证码
+            AppUserEntity appUser = baseDao.selectOne(new LambdaQueryWrapper<AppUserEntity>()
+                    .eq(AppUserEntity::getEmail, registerDto.getEmail())
+                    .last(" limit 1")
+            );
+            if(Objects.nonNull(appUser)){
+                throw new RenException(MessageUtils.message("user.register.email.exisit"));//邮箱已存在
+            }
+
+
+            final String registerEmailCode = String.format("%s%s", CachePrefix.EMAIL_CODE.getPrefix()+ UserCodeTypeEnum.valueOf("REGISTER"), registerDto.getEmail());
+            Object emailCode = redisUtils.get(registerEmailCode);
+            if (emailCode == null) {
+                throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+            } else {
+                final String codeKeyTry = String.format("%s%s", registerEmailCode,"try");
+                checkCodeTryTimes(codeKeyTry);
+                String validCode = emailCode.toString();
+                if (!registerDto.getCode().equalsIgnoreCase(validCode)) {
+                    redisUtils.increment(codeKeyTry, 1L, ApiConstant.EMAIL_EXPIRE);
+                    throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+                }
+            }
+            redisUtils.delete(registerEmailCode);
+            appUserEntity.setLoginName(registerDto.getEmail());
+//        } else if (signType==2) {//使用手机号注册
+//            AppUserEntity appUser = baseDao.selectOne(new LambdaQueryWrapper<AppUserEntity>()
+//                    .eq(AppUserEntity::getPhone, registerDto.getPhone())
+//                    .last(" limit 1")
+//            );
+//            if(Objects.nonNull(appUser)){
+//                throw new RenException(MessageUtils.message("user.register.phone.exist"));//手机号已经存在
+//            }
+//
+//            final String registerPhoneCode = String.format("%s%s%s", CachePrefix.SMS_CODE.getPrefix()+ UserCodeTypeEnum.valueOf("REGISTER"), registerDto.getZone(), registerDto.getPhone());
+//            Object smsCode = redisUtils.get(registerPhoneCode);
+//            if (smsCode == null) {
+//                throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+//            } else {
+//                String validCode = smsCode.toString();
+//                if (!registerDto.getCode().equalsIgnoreCase(validCode)) {
+//                    redisUtils.delete(registerPhoneCode);
+//                    throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+//                }
+//            }
+//            redisUtils.delete(registerPhoneCode);
+//            appUserEntity.setLoginName(registerDto.getPhone());
+//        } else {
+//            throw new RenException(MessageUtils.message("user.register.signtype.err"));//登录类型错误
+//        }
+
+        String host = request.getServerName();
+        appUserEntity.setHost(host);
+        appUserEntity.setRegisterIp(IpUtils.getIpAddr(request));
+        appUserEntity.setEmail(registerDto.getEmail());
+        //appUserEntity.setPhone(registerDto.getPhone());
+        appUserEntity.setStatus(0);
+        appUserEntity.setIsTest(0);
+        appUserEntity.setIsBlack(UserBlackEnum.NORMAL.getCode());
+        appUserEntity.setLoginPassword(PasswordUtils.encode(registerDto.getLoginPassword()));
+
+        //设置6位随机邀请码
+        String activeCodeKey = "register_active_code";
+        Long activeCode = redisUtils.increment(activeCodeKey, 1L, -1L);
+        String registerActiveCode = activeCode.toString();
+        if(activeCode<100000L) {
+            registerActiveCode=OrderUtils.generateActiveCode(6,activeCode);
+        }
+        appUserEntity.setActiveCode(registerActiveCode);
+
+        //设置推荐人
+        if (null != fUser) {
+            String appParentIds = fUser.getAppParentIds();
+            String userId = fUser.getId() + "";
+            if (StringUtils.isNotBlank(appParentIds)) {
+                String[] split = appParentIds.split(",");
+                if (split.length >= 3) {
+                    for (int i = 0; i < split.length - 1; i++) {
+                        userId += "," + split[i];
+                    }
+                    appUserEntity.setAppParentIds(userId);
+                } else {
+                    appUserEntity.setAppParentIds(userId + "," + appParentIds);
+                }
+            } else {
+                appUserEntity.setAppParentIds(fUser.getId() + "");
+            }
+            //存代理关系
+            appUserEntity.setAdminParentIds(fUser.getAdminParentIds());
+            appUserEntity.setParentId(fUser.getId());
+        }
+        //设置昵称
+        appUserEntity.setNickname(OrderUtils.generateNickname("QN",12));
+        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+        //用户唯一标识
+        appUserEntity.setUid(uuid);
+        appUserEntity.setCreateTime(new Date());
+        appUserEntity.setUpdateTime(new Date());
+        if(baseDao.insert(appUserEntity)<=0) {
+            throw new RenException(MessageUtils.message("user.register.fail"));//注册失败
+        }
+
+        //初始化玩家详情表
+        initAppUserDetail(appUserEntity);
+        //初始化玩家用户钱包-平台资产、理财、合约
+        initAppUserAsset(appUserEntity);
+
+        appUserEntity.setLoginPassword(null);
+        Result result = new Result();
+        result.setMsg(MessageUtils.message("user.register.success"));//注册成功
+        result.setData(appUserEntity);
+        return result;
+    }
+
+
+    /**
+     * 登陆
+     * @return
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public Result login(AppLoginDTO dto, HttpServletRequest request)
+    {
+        if(!captchaService.validate(dto.getUuid(), dto.getCode())) {
+            throw new RenException(MessageUtils.message("appUser.login.code.err"));//验证码错误
+        }
+
+        //账号密码校验
+        AppUserEntity appUser = getUserByLoginName(dto.getLoginName());
+        if(appUser==null) {
+            throw new RenException(MessageUtils.message("appUser.loginName.or.password.err"));//账号或密码错误
+        }
+        if(!PasswordUtils.matches(dto.getLoginPassword(),appUser.getLoginPassword())){
+            throw new RenException(MessageUtils.message("appUser.loginName.or.password.err"));//账号或密码错误
+        }
+        //是否黑名单
+        if(Objects.nonNull(appUser.getIsBlack()) && appUser.getIsBlack() == UserBlackEnum.BLOCK.getCode()){
+            throw new RenException(MessageUtils.message("user_is_black"));//您的账号已被列入黑名单,无法登录。
+        }
+        StpUtil.login(appUser.getId());
+        appuserLoginLogService.insertAppActionLog(appUser, "用户登录", "0", request);
+
+        Result result = new Result();
+        result.setMsg(MessageUtils.message("appUser.login.success"));//登陆成功
+        result.setData(MapUtil.of(StpUtil.getTokenName(), StpUtil.getTokenValue()));
+        return result;
+    }
+
+
+    private void initAppUserDetail(AppUserEntity user) {
+        //添加玩家详情表
+        AppUserDetailEntity tAppUserDetail = new AppUserDetailEntity();
+        tAppUserDetail.setUserId(user.getId());
+        //信用设置
+        Integer credits = 100;
+        SettingEntity setting1 = settingService.getSetting(SettingEnum.LOGIN_REGIS_SETTING.name());
+        if (Objects.nonNull(setting1)) {
+            JSONObject loginRegisSetting = JSONUtil.parseObj(setting1.getSettingValue());
+            credits=loginRegisSetting.getInt("credits");
+        }
+        tAppUserDetail.setCredits(credits);
+        detailService.insert(tAppUserDetail);
+    }
+
+
+
+    private void initAppUserAsset(AppUserEntity user) {
+        SettingEntity setting = settingService.getSetting(SettingEnum.ASSET_COIN.name());
+        List<AssetSymbolSetting> currencyList = JSONUtil.toList(JSONUtil.parseArray(setting.getSettingValue()), AssetSymbolSetting.class);
+        if (!CollectionUtils.isEmpty(currencyList)) {
+            Map<String, List<AssetSymbolSetting>> symbolGroup = currencyList.stream().collect(Collectors.groupingBy(AssetSymbolSetting::getSymbol));
+            symbolGroup.forEach((symbol, assetList) -> {
+                AppAssetEntity tAppAsset = new AppAssetEntity();
+                tAppAsset.setUserId(user.getId());
+                tAppAsset.setSymbol(symbol);
+                tAppAsset.setTotal(BigDecimal.ZERO);
+                tAppAsset.setFrozen(BigDecimal.ZERO);
+                tAppAsset.setAvailable(BigDecimal.ZERO);
+                tAppAsset.setType(AssetEnum.PLATFORM_ASSETS.getCode());
+                tAppAsset.setCreateTime(new Date());
+                tAppAsset.setUpdateTime(new Date());
+                assetService.insert(tAppAsset);
+            });
+        }
+
+        //初始化玩家用户钱包-理财资产
+        AppAssetEntity tAppAsset = new AppAssetEntity();
+        tAppAsset.setUserId(user.getId());
+        tAppAsset.setSymbol("usdt");
+        tAppAsset.setTotal(BigDecimal.ZERO);
+        tAppAsset.setFrozen(BigDecimal.ZERO);
+        tAppAsset.setAvailable(BigDecimal.ZERO);
+        tAppAsset.setType(AssetEnum.FINANCIAL_ASSETS.getCode());
+        tAppAsset.setCreateTime(new Date());
+        tAppAsset.setUpdateTime(new Date());
+        assetService.insert(tAppAsset);
+
+        //初始化玩家用户钱包-合约账户
+        tAppAsset.setType(AssetEnum.CONTRACT_ASSETS.getCode());
+        tAppAsset.setId(null);
+        assetService.insert(tAppAsset);
+    }
+
+
+    /**
+     * 发送邮箱验证码
+     * 校验邮箱 已存在
+     * @param codeType 类型:LOGIN 登录使用
+     * @param email 邮箱
+     * @return
+     */
+    @Override
+    public Result sendEmailCode(String codeType, String email) {
+
+        email = email.trim();
+        if (!EmailUtils.checkEmail(email)) {
+            throw new RenException(MessageUtils.message("user.register.email.format"));//邮箱格式不正确
+        }
+
+        if(codeType.toLowerCase().equals("register")) {
+            AppUserEntity existUser = getUserByEmail(email);
+            if (Objects.nonNull(existUser)) {
+                throw new RenException(MessageUtils.message("user.register.email.exisit"));//邮箱已存在
+            }
+        }
+
+        final String emailKey = String.format("%s%s%s",CachePrefix.EMAIL_CODE.getPrefix(),UserCodeTypeEnum.valueOf(codeType),email);
+        sendCodeFrequencyLimit(ApiConstant.EMAIL_EXPIRE,emailKey);
+
+        Result result = new Result();
+        try {
+            EmailUtils.formMail(email, codeType);
+        } catch (Exception e) {
+            log.error("EmailUtils.formMail.err:{}",e.getMessage());
+            return result.error(MessageUtils.message("user.email.send.fail"));//邮箱发送失败
+        }
+        result.setMsg(MessageUtils.message("app.verification.email.code"));//验证码已发送到您的邮箱,请注意查收
+        return result;
+    }
+
+    /**
+     * 发送手机验证码
+     *
+     * @param codeType 类型:LOGIN 登录使用
+     * @param phone 手机号
+     * @param zone 区号
+     * @return
+     */
+    @Override
+    public Result sendMobileCode(String codeType, String phone, String zone) {
+
+        if(StringUtils.isEmpty(phone)){
+            throw new RenException(MessageUtils.message("phone_code_empty"));//手机号不能为空!
+        }
+
+        if(codeType.toLowerCase().equals("register")) {
+            AppUserEntity appUser = getUserByMobile(phone);
+            if(Objects.nonNull(appUser)){
+                throw new RenException(MessageUtils.message("user.register.phone.exist"));//手机号已经存在
+            }
+        }
+
+
+        final String smsKey = String.format("%s%s%s%s",CachePrefix.SMS_CODE.getPrefix(),UserCodeTypeEnum.valueOf(codeType),zone,phone);
+        sendCodeFrequencyLimit(ApiConstant.SMS_EXPIRE,smsKey);
+
+        //发送验证码
+        String randomCode = String.valueOf(SmsSenderUtil.getRandomNumber(100000, 999999));
+        Map<String, String> map = new HashMap<>();
+        map.put("code", randomCode);
+        SendPhoneDto sendPhoneDto = new SendPhoneDto();
+        sendPhoneDto.setMobile(zone + phone);
+        sendPhoneDto.setCode(codeType);
+        sendPhoneDto.setParams(map);
+        Result result = smsSendService.sendMobileCodeV2(sendPhoneDto);
+        log.info("result={}", result);
+        if(result.getCode() == 200){
+            //验证码有效期5分钟
+            redisUtils.set(smsKey, randomCode, ApiConstant.SMS_EXPIRE);
+            final String codeTryKey = String.format("%s%s", smsKey,"try");
+            redisUtils.delete(codeTryKey);
+            result.setMsg(MessageUtils.message("user.code.send"));//验证码发送成功
+        }
+        return result;
+
+    }
+
+
+    private void sendCodeFrequencyLimit(long expireSet,String key) {
+        long expireTime = redisUtils.getExpire(key);
+        if(expireSet-expireTime < 60){
+            throw new RenException(MessageUtils.message("user.sendcode.frequency.limit"));//验证码请求太过频率,请60秒后再试
+        }
+    }
+
+
+    /**
+     * 重设密码
+     * @param codeDTO
+     * @return
+     */
+    @Override
+    public Result resetPwdByEmail(ResetPwdByEmailDTO codeDTO) {
+        Result result = new Result();
+
+        //校验邮箱验证码
+        final String emailCodeKey = String.format("%s%s", CachePrefix.EMAIL_CODE.getPrefix()+ UserCodeTypeEnum.valueOf("FIND_PASSWORD"), codeDTO.getEmail());
+        Object emailCode = redisUtils.get(emailCodeKey);
+        if (emailCode == null) {
+            throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+        } else {
+            final String codeKeyTry = String.format("%s%s", emailCodeKey,"try");
+            checkCodeTryTimes(codeKeyTry);
+            String validCode = emailCode.toString();
+            if (!codeDTO.getCode().equalsIgnoreCase(validCode)) {
+                redisUtils.increment(codeKeyTry, 1L, ApiConstant.EMAIL_EXPIRE);
+                throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+            }
+        }
+        redisUtils.delete(emailCodeKey);
+
+        AppUserEntity appUser = getUserByEmail(codeDTO.getEmail());
+        if(Objects.isNull(appUser)){
+            throw new RenException(MessageUtils.message("user.not.exist"));//用户不存在
+        }
+        appUser.setLoginPassword(PasswordUtils.encode(codeDTO.getNewPwd()));
+        updateById(appUser);
+        return result;
+
+    }
+
+    /**
+     * 重设密码
+     * @param codeDTO
+     * @return
+     */
+    @Override
+    public Result resetPwdByPhone(ResetPwdByPhoneDTO codeDTO) {
+        Result result = new Result();
+
+        //校验手机验证码
+        final String phoneCodeKey = String.format("%s%s%s%s",CachePrefix.SMS_CODE.getPrefix(),UserCodeTypeEnum.valueOf("FIND_PASSWORD"),codeDTO.getZone(),codeDTO.getPhone());
+        Object phoneCode = redisUtils.get(phoneCodeKey);
+        if (phoneCode == null) {
+            throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+        } else {
+            final String codeKeyTry = String.format("%s%s", phoneCodeKey,"try");
+            checkCodeTryTimes(codeKeyTry);
+            String validCode = phoneCode.toString();
+            if (!codeDTO.getCode().equalsIgnoreCase(validCode)) {
+                redisUtils.increment(codeKeyTry, 1L, ApiConstant.SMS_EXPIRE);
+                throw new RenException(MessageUtils.message("user.register.code.err"));//验证码错误
+            }
+        }
+        redisUtils.delete(phoneCodeKey);
+
+        AppUserEntity appUser = getUserByMobile(codeDTO.getPhone());
+        if(Objects.isNull(appUser)){
+            throw new RenException(MessageUtils.message("user.not.exist"));//用户不存在
+        }
+        appUser.setLoginPassword(PasswordUtils.encode(codeDTO.getNewPwd()));
+        updateById(appUser);
+        return result;
+
+    }
+
+    //重试5次验证失败
+    private void checkCodeTryTimes(String codeKey) {
+        Object tryTimesObj = redisUtils.get(codeKey);
+        if(Objects.nonNull(tryTimesObj)){
+            long tryTimes = Long.valueOf(tryTimesObj.toString());
+            if(tryTimes>4L){
+                throw new RenException(MessageUtils.message("code.try.times.limit"));//重试次数过多
+            }
+        }
+
+
+    }
+
+
+}

+ 66 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/AppuserLoginLogServiceImpl.java

@@ -0,0 +1,66 @@
+package com.qnfhq.modules.user.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qnfhq.common.service.impl.BaseServiceImpl;
+import com.qnfhq.common.utils.IpUtils;
+import com.qnfhq.modules.user.dao.AppuserLoginLogDao;
+import com.qnfhq.modules.user.entity.AppUserEntity;
+import com.qnfhq.modules.user.entity.AppuserLoginLogEntity;
+import com.qnfhq.modules.user.service.AppuserLoginLogService;
+import cn.hutool.core.util.StrUtil;
+import eu.bitwalker.useragentutils.UserAgent;
+import jakarta.servlet.http.HttpServletRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * 系统访问记录
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-11
+ */
+@Service
+public class AppuserLoginLogServiceImpl extends BaseServiceImpl<AppuserLoginLogDao, AppuserLoginLogEntity> implements AppuserLoginLogService {
+
+    private static final Logger logger = LoggerFactory.getLogger(AppuserLoginLogServiceImpl.class);
+
+    public QueryWrapper<AppuserLoginLogEntity> getWrapper(Map<String, Object> params){
+        String id = (String)params.get("id");
+
+        QueryWrapper<AppuserLoginLogEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
+
+        return wrapper;
+    }
+
+
+    @Override
+    public void insertAppActionLog(AppUserEntity user, String msg, String status, HttpServletRequest request) {
+        AppuserLoginLogEntity log = new AppuserLoginLogEntity();
+        final UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
+        // 获取客户端操作系统
+        String os = userAgent.getOperatingSystem().getName();
+        // 获取客户端浏览器
+        String browser = userAgent.getBrowser().getName();
+        // 封装对象
+        log.setUserId(user.getId());
+        log.setUsername(user.getLoginName());
+        String ip = IpUtils.getIpAddr(request);
+        log.setIpaddr(ip);
+        try {
+            log.setLoginLocation(IpUtils.getCityInfo(ip));
+        } catch (Exception e) {
+            logger.error("error in IpUtils.getCityInfo:"+e.getMessage());
+        }
+        log.setBrowser(browser);
+        log.setOs(os);
+        log.setMsg(msg);
+        log.setStatus(status);
+        log.setLoginTime(new Date());
+        baseDao.insert(log);
+    }
+
+}

+ 90 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/CaptchaServiceImpl.java

@@ -0,0 +1,90 @@
+package com.qnfhq.modules.user.service.impl;
+
+import cn.hutool.cache.Cache;
+import cn.hutool.cache.CacheUtil;
+import com.qnfhq.common.redis.RedisKeys;
+import com.qnfhq.common.redis.RedisUtils;
+import com.qnfhq.modules.user.service.CaptchaService;
+import com.wf.captcha.SpecCaptcha;
+import com.wf.captcha.base.Captcha;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletResponse;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import java.io.IOException;
+
+/**
+ * 验证码
+ *
+ * @author Mark sunlightcs@gmail.com
+ */
+@Service
+public class CaptchaServiceImpl implements CaptchaService {
+    @Resource
+    private RedisUtils redisUtils;
+    @Value("${renren.redis.open: true}")
+    private boolean open;
+    /**
+     * Local Cache  5分钟过期
+     */
+    Cache<String, String> localCache = CacheUtil.newLRUCache(1000, 1000 * 60 * 5);
+
+    @Override
+    public void create(HttpServletResponse response, String uuid) throws IOException {
+        response.setContentType("image/gif");
+        response.setHeader("Pragma", "No-cache");
+        response.setHeader("Cache-Control", "no-cache");
+        response.setDateHeader("Expires", 0);
+
+        //生成验证码
+        SpecCaptcha captcha = new SpecCaptcha(150, 40);
+        captcha.setLen(5);
+        captcha.setCharType(Captcha.TYPE_DEFAULT);
+        captcha.out(response.getOutputStream());
+
+        //保存到缓存
+        setCache(uuid, captcha.text());
+    }
+
+    @Override
+    public boolean validate(String uuid, String code) {
+        //获取验证码
+        String captcha = getCache(uuid);
+
+        //效验成功
+        if (code.equalsIgnoreCase(captcha)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    private void setCache(String key, String value) {
+        if (open) {
+            key = RedisKeys.getCaptchaKey(key);
+            redisUtils.set(key, value, 300);
+        } else {
+            localCache.put(key, value);
+        }
+    }
+
+    private String getCache(String key) {
+        if (open) {
+            key = RedisKeys.getCaptchaKey(key);
+            String captcha = (String) redisUtils.get(key);
+            //删除验证码
+            if (captcha != null) {
+                redisUtils.delete(key);
+            }
+
+            return captcha;
+        }
+
+        String captcha = localCache.get(key);
+        //删除验证码
+        if (captcha != null) {
+            localCache.remove(key);
+        }
+        return captcha;
+    }
+}

+ 37 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/SettingServiceImpl.java

@@ -0,0 +1,37 @@
+package com.qnfhq.modules.user.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qnfhq.common.service.impl.BaseServiceImpl;
+import com.qnfhq.modules.user.dao.SettingDao;
+import com.qnfhq.modules.user.entity.SettingEntity;
+import com.qnfhq.modules.user.service.SettingService;
+import cn.hutool.core.util.StrUtil;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * 配置(短信邮箱等)
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Service
+public class SettingServiceImpl extends BaseServiceImpl<SettingDao, SettingEntity> implements SettingService {
+
+
+    public QueryWrapper<SettingEntity> getWrapper(Map<String, Object> params){
+        String id = (String)params.get("id");
+
+        QueryWrapper<SettingEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
+
+        return wrapper;
+    }
+
+    @Override
+    public SettingEntity getSetting(String id){
+        return baseDao.selectById(id);
+    }
+
+}

+ 96 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/SmsSendServiceImpl.java

@@ -0,0 +1,96 @@
+package com.qnfhq.modules.user.service.impl;
+
+import cn.hutool.json.JSONUtil;
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
+import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
+import com.qnfhq.aliyun.AlConfig;
+import com.qnfhq.common.exception.RenException;
+import com.qnfhq.common.service.impl.BaseServiceImpl;
+import com.qnfhq.common.utils.MessageUtils;
+import com.qnfhq.common.utils.Result;
+import com.qnfhq.modules.user.dao.SmsSendDao;
+import com.qnfhq.modules.user.dto.SendPhoneDto;
+import com.qnfhq.modules.user.dto.setting.SmsSetting;
+import com.qnfhq.modules.user.entity.SettingEntity;
+import com.qnfhq.modules.user.entity.SmsSendEntity;
+import com.qnfhq.modules.user.entity.SmsTplEntity;
+import com.qnfhq.modules.user.enums.SettingEnum;
+import com.qnfhq.modules.user.service.SettingService;
+import com.qnfhq.modules.user.service.SmsSendService;
+import com.qnfhq.modules.user.service.SmsTplService;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * 短信发送情况
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Service
+public class SmsSendServiceImpl extends BaseServiceImpl<SmsSendDao, SmsSendEntity> implements SmsSendService {
+
+    @Resource
+    private SettingService settingService;
+
+    @Resource
+    private SmsTplService smsTplService;
+
+
+    /**
+     * 新版本发送验证码
+     * @param mobileNumber
+     * @return
+     */
+    @Override
+    public Result sendMobileCodeV2(SendPhoneDto mobileNumber) {
+        //短信发送状态
+        Result result = new Result();
+        try {
+            SettingEntity setting = settingService.getSetting(SettingEnum.SMS_SETTING.name());
+            SmsSetting smsSetting = JSONUtil.toBean(setting.getSettingValue(), SmsSetting.class);
+            Client client = AlConfig.createClient(smsSetting.getMobileAccount(), smsSetting.getMobilePassword());
+
+            SmsTplEntity smsTpl = smsTplService.selectSmsTplByCode(mobileNumber.getCode());
+            if(smsTpl == null) {
+                throw new RenException(MessageUtils.message("sms.template.not.exist"));//短信模板不存在
+            }
+            //构建短信数据
+            SmsSendEntity smsSend = new SmsSendEntity();
+            smsSend.setCode(mobileNumber.getCode());
+            smsSend.setMobile(mobileNumber.getMobile());
+            smsSend.setCreateTime(new Date());
+            smsSend.setContent(AlConfig.getTplParams(smsTpl.getContent(),mobileNumber.getParams()));
+            //发送短信信息
+            SendSmsRequest sendSmsRequest = new SendSmsRequest()
+                    .setPhoneNumbers(mobileNumber.getMobile())
+                    .setSignName(smsSetting.getName())
+                    .setTemplateCode(smsTpl.getSendCode())
+                    .setTemplateParam(JSONUtil.toJsonStr(mobileNumber.getParams()));
+            // 获取响应对象
+            SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
+            if(sendSmsResponse.getBody().getCode().equals("OK")) {
+//                result.setCode(200);
+                result.setMsg(MessageUtils.message("common.send.success"));//发送成功
+                smsSend.setIsSuccess(1);
+            } else {
+                smsSend.setIsSuccess(-1);
+                smsSend.setError(sendSmsResponse.getBody().getMessage());
+                result.error(sendSmsResponse.getBody().getMessage());
+                log.error("in err----------"+sendSmsResponse.getBody().getMessage());
+            }
+            insert(smsSend);
+            return result;
+
+
+        } catch (Exception e) {
+
+            log.error(e.getMessage(), e);
+            return result.error(e.getMessage());
+        }
+
+    }
+}

+ 41 - 0
qnfhq-api/src/main/java/com/qnfhq/modules/user/service/impl/SmsTplServiceImpl.java

@@ -0,0 +1,41 @@
+package com.qnfhq.modules.user.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qnfhq.common.service.impl.BaseServiceImpl;
+import com.qnfhq.modules.user.dao.SmsTplDao;
+import com.qnfhq.modules.user.entity.SmsTplEntity;
+import com.qnfhq.modules.user.service.SmsTplService;
+import cn.hutool.core.util.StrUtil;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * 短信模板
+ *
+ * @author yelz 30262728@qq.com
+ * @since 1.0.0 2025-11-13
+ */
+@Service
+public class SmsTplServiceImpl extends BaseServiceImpl<SmsTplDao, SmsTplEntity> implements SmsTplService {
+
+
+    public QueryWrapper<SmsTplEntity> getWrapper(Map<String, Object> params){
+        String id = (String)params.get("id");
+
+        QueryWrapper<SmsTplEntity> wrapper = new QueryWrapper<>();
+        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
+
+        return wrapper;
+    }
+
+    @Override
+    public SmsTplEntity selectSmsTplByCode(String code) {
+        return baseDao.selectOne(new LambdaQueryWrapper<SmsTplEntity>()
+                .eq(SmsTplEntity::getCode, code)
+                .last(" limit 1")
+        );
+    }
+
+}

+ 0 - 45
qnfhq-api/src/main/java/com/qnfhq/resolver/LoginUserHandlerMethodArgumentResolver.java

@@ -1,45 +0,0 @@
-package com.qnfhq.resolver;
-
-import com.qnfhq.annotation.LoginUser;
-import com.qnfhq.entity.UserEntity;
-import com.qnfhq.interceptor.AuthorizationInterceptor;
-import com.qnfhq.service.UserService;
-import lombok.AllArgsConstructor;
-import org.springframework.core.MethodParameter;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.support.WebDataBinderFactory;
-import org.springframework.web.context.request.NativeWebRequest;
-import org.springframework.web.context.request.RequestAttributes;
-import org.springframework.web.method.support.HandlerMethodArgumentResolver;
-import org.springframework.web.method.support.ModelAndViewContainer;
-
-/**
- * 有@LoginUser注解的方法参数,注入当前登录用户
- *
- * @author Mark sunlightcs@gmail.com
- */
-@Component
-@AllArgsConstructor
-public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
-    private final UserService userService;
-
-    @Override
-    public boolean supportsParameter(MethodParameter parameter) {
-        return parameter.getParameterType().isAssignableFrom(UserEntity.class) && parameter.hasParameterAnnotation(LoginUser.class);
-    }
-
-    @Override
-    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,
-                                  NativeWebRequest request, WebDataBinderFactory factory) throws Exception {
-        //获取用户ID
-        Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST);
-        if (object == null) {
-            return null;
-        }
-
-        //获取用户信息
-        UserEntity user = userService.getUserByUserId((Long) object);
-
-        return user;
-    }
-}

+ 0 - 28
qnfhq-api/src/main/java/com/qnfhq/service/TokenService.java

@@ -1,28 +0,0 @@
-package com.qnfhq.service;
-
-import com.qnfhq.common.service.BaseService;
-import com.qnfhq.entity.TokenEntity;
-
-/**
- * 用户Token
- * 
- * @author Mark sunlightcs@gmail.com
- */
-public interface TokenService extends BaseService<TokenEntity> {
-
-	TokenEntity getByToken(String token);
-
-	/**
-	 * 生成token
-	 * @param userId  用户ID
-	 * @return        返回token信息
-	 */
-	TokenEntity createToken(Long userId);
-
-	/**
-	 * 设置token过期
-	 * @param userId 用户ID
-	 */
-	void expireToken(Long userId);
-
-}

+ 0 - 26
qnfhq-api/src/main/java/com/qnfhq/service/UserService.java

@@ -1,26 +0,0 @@
-package com.qnfhq.service;
-
-import com.qnfhq.common.service.BaseService;
-import com.qnfhq.entity.UserEntity;
-import com.qnfhq.dto.LoginDTO;
-
-import java.util.Map;
-
-/**
- * 用户
- * 
- * @author Mark sunlightcs@gmail.com
- */
-public interface UserService extends BaseService<UserEntity> {
-
-	UserEntity getByMobile(String mobile);
-
-	UserEntity getUserByUserId(Long userId);
-
-	/**
-	 * 用户登录
-	 * @param dto    登录表单
-	 * @return        返回登录信息
-	 */
-	Map<String, Object> login(LoginDTO dto);
-}

+ 0 - 90
qnfhq-api/src/main/java/com/qnfhq/service/impl/TokenServiceImpl.java

@@ -1,90 +0,0 @@
-package com.qnfhq.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.qnfhq.common.service.impl.BaseServiceImpl;
-import com.qnfhq.dao.TokenDao;
-import com.qnfhq.entity.TokenEntity;
-import com.qnfhq.service.TokenService;
-import jakarta.annotation.Resource;
-import org.springframework.stereotype.Service;
-
-import java.util.Date;
-import java.util.UUID;
-
-
-@Service
-public class TokenServiceImpl extends BaseServiceImpl<TokenDao, TokenEntity> implements TokenService {
-
-    @Resource
-	private TokenDao tokenDao;
-
-	/**
-	 * 12小时后过期
-	 */
-	private final static int EXPIRE = 3600 * 12;
-
-	@Override
-	public TokenEntity getByToken(String token) {
-		return baseDao.getByToken(token);
-	}
-
-	@Override
-	public TokenEntity createToken(Long userId) {
-		//当前时间
-		Date now = new Date();
-		//过期时间
-		Date expireTime = new Date(now.getTime() + EXPIRE * 1000);
-
-		//用户token
-		String token;
-
-		//判断是否生成过token
-		TokenEntity tokenEntity = baseDao.getByUserId(userId);
-		if(tokenEntity == null){
-			//生成一个token
-			token = generateToken();
-
-			tokenEntity = new TokenEntity();
-			tokenEntity.setUserId(userId);
-			tokenEntity.setToken(token);
-			tokenEntity.setUpdateDate(now);
-			tokenEntity.setExpireDate(expireTime);
-
-			//保存token
-			this.insert(tokenEntity);
-		}else{
-			//判断token是否过期
-			if(tokenEntity.getExpireDate().getTime() < System.currentTimeMillis()){
-				//token过期,重新生成token
-				token = generateToken();
-			}else {
-				token = tokenEntity.getToken();
-			}
-
-			tokenEntity.setToken(token);
-			tokenEntity.setUpdateDate(now);
-			tokenEntity.setExpireDate(expireTime);
-
-			//更新token
-			this.updateById(tokenEntity);
-		}
-
-		return tokenEntity;
-	}
-
-	@Override
-	public void expireToken(Long userId){
-		Date now = new Date();
-
-		LambdaUpdateWrapper<TokenEntity> updateWrapper = new LambdaUpdateWrapper<>();
-		updateWrapper.eq(TokenEntity::getUserId, userId);
-		updateWrapper.set(TokenEntity::getExpireDate, now);
-		updateWrapper.set(TokenEntity::getUpdateDate, now);
-
-		tokenDao.update(updateWrapper);
-	}
-
-	private String generateToken(){
-		return UUID.randomUUID().toString().replace("-", "");
-	}
-}

+ 0 - 55
qnfhq-api/src/main/java/com/qnfhq/service/impl/UserServiceImpl.java

@@ -1,55 +0,0 @@
-package com.qnfhq.service.impl;
-
-import cn.hutool.crypto.digest.DigestUtil;
-import com.qnfhq.common.exception.ErrorCode;
-import com.qnfhq.common.exception.RenException;
-import com.qnfhq.common.service.impl.BaseServiceImpl;
-import com.qnfhq.common.validator.AssertUtils;
-import com.qnfhq.dao.UserDao;
-import com.qnfhq.dto.LoginDTO;
-import com.qnfhq.entity.TokenEntity;
-import com.qnfhq.entity.UserEntity;
-import com.qnfhq.service.TokenService;
-import com.qnfhq.service.UserService;
-import lombok.AllArgsConstructor;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@Service
-@AllArgsConstructor
-public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implements UserService {
-    private final TokenService tokenService;
-
-    @Override
-    public UserEntity getByMobile(String mobile) {
-        return baseDao.getUserByMobile(mobile);
-    }
-
-    @Override
-    public UserEntity getUserByUserId(Long userId) {
-        return baseDao.getUserByUserId(userId);
-    }
-
-    @Override
-    public Map<String, Object> login(LoginDTO dto) {
-        UserEntity user = getByMobile(dto.getMobile());
-        AssertUtils.isNull(user, ErrorCode.ACCOUNT_PASSWORD_ERROR);
-
-        //密码错误
-        if (!user.getPassword().equals(DigestUtil.sha256Hex(dto.getPassword()))) {
-            throw new RenException(ErrorCode.ACCOUNT_PASSWORD_ERROR);
-        }
-
-        //获取登录token
-        TokenEntity tokenEntity = tokenService.createToken(user.getId());
-
-        Map<String, Object> map = new HashMap<>(2);
-        map.put("token", tokenEntity.getToken());
-        map.put("expire", tokenEntity.getExpireDate().getTime() - System.currentTimeMillis());
-
-        return map;
-    }
-
-}

+ 168 - 0
qnfhq-api/src/main/java/com/qnfhq/utils/EmailUtils.java

@@ -0,0 +1,168 @@
+package com.qnfhq.utils;
+
+import com.qnfhq.common.redis.RedisUtils;
+import com.qnfhq.common.utils.SpringContextUtils;
+import com.qnfhq.constant.ApiConstant;
+import com.qnfhq.modules.user.dto.setting.EmailSetting;
+import com.qnfhq.modules.user.enums.CachePrefix;
+import com.qnfhq.modules.user.enums.UserCodeTypeEnum;
+import com.qnfhq.modules.user.service.impl.AppUserServiceImpl;
+import com.qnfhq.utils.sms.SmsSenderUtil;
+import com.sun.mail.util.MailSSLSocketFactory;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
+
+import jakarta.mail.*;
+import jakarta.mail.internet.*;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * @packageName:com.zebra.common.utils
+ * @className:EmailUtils
+ * @description:邮箱工具类
+ * @version:1.0.0
+ * @author:xuanyihun
+ * @createDate:2022-05-06 11:07
+ */
+@Slf4j
+public class EmailUtils {
+
+
+
+    private static List<EmailSetting> emailSettingList = new ArrayList<EmailSetting>(){
+        {
+            add(new EmailSetting("bindCodeEmail.ftl","ADAE","adae@bnccy.top","uI7aE5qX1nU7oS3f","smtpdm.aliyun.com","465"));
+            add(new EmailSetting("bindCodeEmail.ftl","ADAE","adae@plaids.top","fS0iS2pH2iG2aS9c","smtpdm.aliyun.com","465"));
+
+        }
+    };
+
+    /**
+     * 随机方案
+     */
+    private static final Random RANDOM = new Random();
+
+
+    /**
+     * @description 验证邮箱
+     * @param email(邮箱)
+     * @version 1.0.0
+     * @author xuanyihun
+     * @createDate 2022-05-06 11:23
+     * @return boolean
+    */
+    public static boolean checkEmail(String email) {
+
+        boolean flag = false;
+        try {
+            String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
+            Pattern regex = Pattern.compile(check);
+            Matcher matcher = regex.matcher(email);
+            flag = matcher.matches();
+        } catch (Exception exception) {
+            flag = false;
+        }
+        return flag;
+
+    }
+
+
+
+
+    public static void formMail(String email,String type) throws Exception {
+        RedisUtils redisUtils = SpringContextUtils.getBean(RedisUtils.class);
+//        SettingService settingService = SpringContextUtils.getBean(SettingService.class);
+        String randomCode = String.valueOf(SmsSenderUtil.getRandomNumber(100000, 999999));
+        AppUserServiceImpl bean = SpringContextUtils.getBean(AppUserServiceImpl.class);
+        int index = RANDOM.nextInt(emailSettingList.size());
+        System.out.println("邮箱随机发送:" + index);
+        EmailSetting emailSetting =  emailSettingList.get(index);
+        /**
+        Setting setting = settingService.get(SettingEnum.EMAIL_SETTING.name());
+        EmailSetting emailSetting = JSONUtil.toBean(setting.getSettingValue(), EmailSetting.class);
+         **/
+        String appName = emailSetting.getMailAppName();
+        String host = emailSetting.getMailHost();
+        String port = emailSetting.getMailPort();
+        String username = emailSetting.getMailUsername();
+        String password = emailSetting.getMailPassword();
+        String templateCode = emailSetting.getMailTemplate();
+
+
+        // 1.创建连接对象javax.mail.Session
+        // 2.创建邮件对象 javax.mail.Message
+        // 3.发送一封激活邮件
+        Properties properties = System.getProperties();// 获取系统属性
+
+        properties.setProperty("mail.smtp.host", host);// 设置邮件服务器
+        properties.setProperty("mail.transport.protocol","smtp");
+        properties.setProperty("mail.smtp.port", port);  //不需要 默认端口
+        properties.setProperty("mail.smtp.auth", "true");// 打开认证
+        //  properties.put("mail.smtp.socketFactory", "javax.net.ssl.SSLSocketFactory");
+        try {
+            // QQ邮箱需要下面这段代码,163邮箱不需要
+            MailSSLSocketFactory sf = new MailSSLSocketFactory();
+            sf.setTrustAllHosts(true);
+            properties.put("mail.smtp.ssl.enable", "true");
+            properties.put("mail.smtp.ssl.socketFactory", sf);
+            properties.put("mail.smtp.ssl.protocols", "TLSv1.2"); //加上这句解决问题
+
+            // 1.获取默认session对象
+            Session session = Session.getInstance(properties, new Authenticator() {
+                @Override
+                public PasswordAuthentication getPasswordAuthentication() {
+                    return new PasswordAuthentication(username, password);
+                }
+            });
+
+          //  session.setDebug(true);
+
+            //2、通过session得到transport对象
+            Transport transport = session.getTransport();
+            //3、使用用户名和授权码连上邮件服务器
+            transport.connect(host,username,password);
+
+
+            // 4.创建邮件对象
+            Message message = new MimeMessage(session);
+            // 4.1设置发件人
+            message.setFrom(new InternetAddress(username));
+            // 4.2设置接收人
+            message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
+            // 4.3设置邮件主题
+            String title = appName;
+            message.setSubject(title);
+
+            Map<String, Object> model = new HashMap<>(16);
+            model.put("code", randomCode);
+            Configuration cfg = new Configuration(Configuration.VERSION_2_3_26);
+            cfg.setClassForTemplateLoading(bean.getClass(), "/templates");
+            Template template = cfg.getTemplate(templateCode);
+            String html = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
+            // 2.4设置邮件内容
+            message.setContent(html, "text/html;charset=UTF-8");
+            //5、发送邮件
+            transport.sendMessage(message,message.getAllRecipients());
+            //6、关闭连接
+            transport.close();
+        } catch (Exception e) {
+
+            log.error("===================================发送邮箱报错==================================={}",e.getMessage());
+            throw new Exception(e.getMessage());
+        }
+
+        //绑定邮箱 5分钟
+        final String emailKey = String.format("%s%s%s",CachePrefix.EMAIL_CODE.getPrefix(),UserCodeTypeEnum.valueOf(type),email);
+        redisUtils.set(emailKey, randomCode, ApiConstant.EMAIL_EXPIRE);
+        final String codeTryKey = String.format("%s%s", emailKey,"try");
+        redisUtils.delete(codeTryKey);
+    }
+
+
+
+}

+ 85 - 0
qnfhq-api/src/main/java/com/qnfhq/utils/OrderUtils.java

@@ -0,0 +1,85 @@
+package com.qnfhq.utils;
+
+import org.springframework.stereotype.Component;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+@Component
+public class OrderUtils {
+
+    public static synchronized String generateOrderNum() {
+        Random random = new Random();
+        SimpleDateFormat allTime = new SimpleDateFormat("MMddHHmmSS");
+        String subjectno = allTime.format(new Date())+random.nextInt(10);
+        return subjectno+random.nextInt(10);
+    }
+
+    /**
+     * n位随机数
+     * @param n
+     * @return
+     */
+    public static String randomNumber(int n){
+        String str="0123456789ABCDEFGHIGKLMNPQRSTUVWXYZ";
+        StringBuilder sb=new StringBuilder(n);
+        for(int i=0;i<n;i++){
+            char ch=str.charAt(new Random().nextInt(str.length()));
+            sb.append(ch);
+        }
+        return sb.toString();
+    }
+
+    public static String generateNickname(String prefix,int n){
+        String str="0123456789abcdefghiklmnopqrstuvwxyz";
+        StringBuilder sb=new StringBuilder();
+        sb.append(prefix);
+        for(int i=0;i<n;i++){
+            char ch=str.charAt(new Random().nextInt(str.length()));
+            sb.append(ch);
+        }
+        return sb.toString();
+    }
+
+    /**
+     * 返回n位随机数
+     * @param code
+     * @return
+     */
+    public static String generateActiveCode(int n,Long code){
+        StringBuilder sb=new StringBuilder(n);
+        String activeCode = "";
+        if(code != null){
+            activeCode = code.toString();
+        }
+        if(activeCode.length()<n){
+            int shortNum = n-activeCode.length();
+            String str="0123456789ABCDEFGHIGKLMNPQRSTUVWXYZ";
+            for(int i=0;i<shortNum;i++){
+                char ch=str.charAt(new Random().nextInt(str.length()));
+                sb.append(ch);
+            }
+            sb.append(activeCode);
+        }
+        return sb.toString();
+    }
+
+
+    public static String randomNumberLower(int n){
+        String str="0123456789abcdef";
+        StringBuilder sb=new StringBuilder(n);
+        for(int i=0;i<5;i++){
+            char ch=str.charAt(new Random().nextInt(str.length()));
+            sb.append(ch);
+        }
+        return sb.toString();
+    }
+
+    public static synchronized String generateAdNum() {
+        Random random = new Random();
+        SimpleDateFormat allTime = new SimpleDateFormat("YYYYMMddHHmmSS");
+        String subjectno = allTime.format(new Date())+random.nextInt(10);
+        return subjectno+random.nextInt(10);
+    }
+
+}

+ 662 - 0
qnfhq-api/src/main/java/com/qnfhq/utils/password/BCrypt.java

@@ -0,0 +1,662 @@
+package com.qnfhq.utils.password;
+
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.SecureRandom;
+
+/**
+ * BCrypt implements OpenBSD-style Blowfish password hashing using the scheme described in
+ * "A Future-Adaptable Password Scheme" by Niels Provos and David Mazieres.
+ * <p>
+ * This password hashing system tries to thwart off-line password cracking using a
+ * computationally-intensive hashing algorithm, based on Bruce Schneier's Blowfish cipher.
+ * The work factor of the algorithm is parameterised, so it can be increased as computers
+ * get faster.
+ * <p>
+ * Usage is really simple. To hash a password for the first time, call the hashpw method
+ * with a random salt, like this:
+ * <p>
+ * <code>
+ * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br>
+ * </code>
+ * <p>
+ * To check whether a plaintext password matches one that has been hashed previously, use
+ * the checkpw method:
+ * <p>
+ * <code>
+ * if (BCrypt.checkpw(candidate_password, stored_hash))<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It matches");<br>
+ * else<br>
+ * &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It does not match");<br>
+ * </code>
+ * <p>
+ * The gensalt() method takes an optional parameter (log_rounds) that determines the
+ * computational complexity of the hashing:
+ * <p>
+ * <code>
+ * String strong_salt = BCrypt.gensalt(10)<br>
+ * String stronger_salt = BCrypt.gensalt(12)<br>
+ * </code>
+ * <p>
+ * The amount of work increases exponentially (2**log_rounds), so each increment is twice
+ * as much work. The default log_rounds is 10, and the valid range is 4 to 31.
+ *
+ * @author Damien Miller
+ */
+public class BCrypt {
+	// BCrypt parameters
+
+	private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10;
+	private static final int BCRYPT_SALT_LEN = 16;
+	// Blowfish parameters
+	private static final int BLOWFISH_NUM_ROUNDS = 16;
+	// Initial contents of key schedule
+	private static final int P_orig[] = { 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
+			0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377,
+			0xbe5466cf, 0x34e90c6c, 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
+			0x9216d5d9, 0x8979fb1b };
+	private static final int S_orig[] = { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
+			0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7,
+			0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
+			0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5,
+			0x9c30d539, 0x2af26013, 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
+			0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27,
+			0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
+			0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993,
+			0xb3ee1411, 0x636fbc2a, 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
+			0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af,
+			0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
+			0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5,
+			0x0f6d6ff3, 0x83f44239, 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
+			0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68,
+			0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
+			0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4,
+			0x7d84a5c3, 0x3b8b5ebe, 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
+			0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248,
+			0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
+			0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4,
+			0x5e5c9ec2, 0x196a2463, 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
+			0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd,
+			0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
+			0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc,
+			0x8ea5e9f8, 0xdb3222f8, 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
+			0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0,
+			0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
+			0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8,
+			0x4afcb56c, 0x2dd1d35b, 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
+			0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01,
+			0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
+			0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64,
+			0x8888b812, 0x900df01c, 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
+			0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8,
+			0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
+			0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86,
+			0xc75442f5, 0xfb9d35cf, 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
+			0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e,
+			0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
+			0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a,
+			0x1b510052, 0x9a532915, 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
+			0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6,
+			0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
+			0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
+			0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
+			0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
+			0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
+			0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
+			0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
+			0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
+			0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
+			0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
+			0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
+			0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
+			0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
+			0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
+			0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
+			0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
+			0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
+			0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
+			0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
+			0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
+			0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
+			0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
+			0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
+			0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
+			0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
+			0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
+			0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
+			0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
+			0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
+			0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
+			0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
+			0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
+			0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
+			0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
+			0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
+			0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
+			0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
+			0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
+			0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
+			0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
+			0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
+			0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
+			0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
+			0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, 0xe93d5a68, 0x948140f7,
+			0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
+			0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546,
+			0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
+			0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, 0x96eb27b3, 0x55fd3941,
+			0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
+			0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c,
+			0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
+			0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, 0x1dc9faf7, 0x4b6d1856,
+			0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
+			0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87,
+			0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
+			0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, 0xfdf8e802, 0x04272f70,
+			0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
+			0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1,
+			0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
+			0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, 0x6b2395e0, 0x333e92e1,
+			0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
+			0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa,
+			0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
+			0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, 0xc67b5510, 0x6d672c37,
+			0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
+			0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24,
+			0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
+			0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, 0x6a124237, 0xb79251e7,
+			0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
+			0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f,
+			0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
+			0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, 0x83426b33, 0xf01eab71,
+			0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
+			0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74,
+			0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
+			0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, 0xb90bace1, 0xbb8205d0,
+			0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
+			0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df,
+			0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
+			0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, 0x9af88c27, 0x773f8641,
+			0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
+			0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de,
+			0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
+			0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, 0xed545578, 0x08fca5b5,
+			0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
+			0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212,
+			0x670efa8e, 0x406000e0, 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
+			0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315,
+			0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
+			0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d,
+			0xd5730a1d, 0x4cd04dc6, 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
+			0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6,
+			0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
+			0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da,
+			0x3f046f69, 0x77fa0a59, 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
+			0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d,
+			0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
+			0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc,
+			0xf8d56629, 0x79132e28, 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
+			0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2,
+			0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
+			0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8,
+			0xabcc5167, 0xccad925f, 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
+			0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46,
+			0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
+			0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40,
+			0xccd2017f, 0x6bb4e3bb, 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
+			0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e,
+			0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
+			0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d,
+			0x06b89fb4, 0xce6ea048, 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
+			0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b,
+			0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
+			0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667,
+			0x8df9317c, 0xe0b12b4f, 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
+			0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb,
+			0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
+			0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df,
+			0xd3a0342b, 0x8971f21e, 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
+			0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891,
+			0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
+			0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5,
+			0x6e163697, 0x88d273cc, 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
+			0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00,
+			0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
+			0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76,
+			0x77afa1c5, 0x20756060, 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
+			0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0,
+			0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 };
+	// bcrypt IV: "OrpheanBeholderScryDoubt"
+	static private final int bf_crypt_ciphertext[] = { 0x4f727068, 0x65616e42,
+			0x65686f6c, 0x64657253, 0x63727944, 0x6f756274 };
+	// Table for Base64 encoding
+	static private final char base64_code[] = { '.', '/', 'A', 'B', 'C', 'D', 'E', 'F',
+			'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
+			'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
+			'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
+			'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
+	// Table for Base64 decoding
+	static private final byte index_64[] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+			-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 54, 55,
+			56, 57, 58, 59, 60, 61, 62, 63, -1, -1, -1, -1, -1, -1, -1, 2, 3, 4, 5, 6, 7,
+			8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
+			-1, -1, -1, -1, -1, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+			41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, -1, -1, -1, -1, -1 };
+	static final int MIN_LOG_ROUNDS = 4;
+	static final int MAX_LOG_ROUNDS = 31;
+	// Expanded Blowfish key
+	private int P[];
+	private int S[];
+
+	/**
+	 * Encode a byte array using bcrypt's slightly-modified base64 encoding scheme. Note
+	 * that this is <strong>not</strong> compatible with the standard MIME-base64
+	 * encoding.
+	 *
+	 * @param d the byte array to encode
+	 * @param len the number of bytes to encode
+	 * @param rs the destination buffer for the base64-encoded string
+	 * @exception IllegalArgumentException if the length is invalid
+	 */
+	static void encode_base64(byte d[], int len, StringBuilder rs)
+			throws IllegalArgumentException {
+		int off = 0;
+		int c1, c2;
+
+		if (len <= 0 || len > d.length) {
+			throw new IllegalArgumentException("Invalid len");
+		}
+
+		while (off < len) {
+			c1 = d[off++] & 0xff;
+			rs.append(base64_code[(c1 >> 2) & 0x3f]);
+			c1 = (c1 & 0x03) << 4;
+			if (off >= len) {
+				rs.append(base64_code[c1 & 0x3f]);
+				break;
+			}
+			c2 = d[off++] & 0xff;
+			c1 |= (c2 >> 4) & 0x0f;
+			rs.append(base64_code[c1 & 0x3f]);
+			c1 = (c2 & 0x0f) << 2;
+			if (off >= len) {
+				rs.append(base64_code[c1 & 0x3f]);
+				break;
+			}
+			c2 = d[off++] & 0xff;
+			c1 |= (c2 >> 6) & 0x03;
+			rs.append(base64_code[c1 & 0x3f]);
+			rs.append(base64_code[c2 & 0x3f]);
+		}
+	}
+
+	/**
+	 * Look up the 3 bits base64-encoded by the specified character, range-checking
+	 * against conversion table
+	 * @param x the base64-encoded value
+	 * @return the decoded value of x
+	 */
+	private static byte char64(char x) {
+		if (x > index_64.length) {
+			return -1;
+		}
+		return index_64[x];
+	}
+
+	/**
+	 * Decode a string encoded using bcrypt's base64 scheme to a byte array. Note that
+	 * this is *not* compatible with the standard MIME-base64 encoding.
+	 * @param s the string to decode
+	 * @param maxolen the maximum number of bytes to decode
+	 * @return an array containing the decoded bytes
+	 * @throws IllegalArgumentException if maxolen is invalid
+	 */
+	static byte[] decode_base64(String s, int maxolen) throws IllegalArgumentException {
+		ByteArrayOutputStream out = new ByteArrayOutputStream(maxolen);
+		int off = 0, slen = s.length(), olen = 0;
+		byte c1, c2, c3, c4, o;
+
+		if (maxolen <= 0) {
+			throw new IllegalArgumentException("Invalid maxolen");
+		}
+
+		while (off < slen - 1 && olen < maxolen) {
+			c1 = char64(s.charAt(off++));
+			c2 = char64(s.charAt(off++));
+			if (c1 == -1 || c2 == -1) {
+				break;
+			}
+			o = (byte) (c1 << 2);
+			o |= (c2 & 0x30) >> 4;
+			out.write(o);
+			if (++olen >= maxolen || off >= slen) {
+				break;
+			}
+			c3 = char64(s.charAt(off++));
+			if (c3 == -1) {
+				break;
+			}
+			o = (byte) ((c2 & 0x0f) << 4);
+			o |= (c3 & 0x3c) >> 2;
+			out.write(o);
+			if (++olen >= maxolen || off >= slen) {
+				break;
+			}
+			c4 = char64(s.charAt(off++));
+			o = (byte) ((c3 & 0x03) << 6);
+			o |= c4;
+			out.write(o);
+			++olen;
+		}
+
+		return out.toByteArray();
+	}
+
+	/**
+	 * Blowfish encipher a single 64-bit block encoded as two 32-bit halves
+	 * @param lr an array containing the two 32-bit half blocks
+	 * @param off the position in the array of the blocks
+	 */
+	private final void encipher(int lr[], int off) {
+		int i, n, l = lr[off], r = lr[off + 1];
+
+		l ^= P[0];
+		for (i = 0; i <= BLOWFISH_NUM_ROUNDS - 2;) {
+			// Feistel substitution on left word
+			n = S[(l >> 24) & 0xff];
+			n += S[0x100 | ((l >> 16) & 0xff)];
+			n ^= S[0x200 | ((l >> 8) & 0xff)];
+			n += S[0x300 | (l & 0xff)];
+			r ^= n ^ P[++i];
+
+			// Feistel substitution on right word
+			n = S[(r >> 24) & 0xff];
+			n += S[0x100 | ((r >> 16) & 0xff)];
+			n ^= S[0x200 | ((r >> 8) & 0xff)];
+			n += S[0x300 | (r & 0xff)];
+			l ^= n ^ P[++i];
+		}
+		lr[off] = r ^ P[BLOWFISH_NUM_ROUNDS + 1];
+		lr[off + 1] = l;
+	}
+
+	/**
+	 * Cycically extract a word of key material
+	 * @param data the string to extract the data from
+	 * @param offp a "pointer" (as a one-entry array) to the current offset into data
+	 * @return the next word of material from data
+	 */
+	private static int streamtoword(byte data[], int offp[]) {
+		int i;
+		int word = 0;
+		int off = offp[0];
+
+		for (i = 0; i < 4; i++) {
+			word = (word << 8) | (data[off] & 0xff);
+			off = (off + 1) % data.length;
+		}
+
+		offp[0] = off;
+		return word;
+	}
+
+	/**
+	 * Initialise the Blowfish key schedule
+	 */
+	private void init_key() {
+		P = (int[]) P_orig.clone();
+		S = (int[]) S_orig.clone();
+	}
+
+	/**
+	 * Key the Blowfish cipher
+	 * @param key an array containing the key
+	 */
+	private void key(byte key[]) {
+		int i;
+		int koffp[] = { 0 };
+		int lr[] = { 0, 0 };
+		int plen = P.length, slen = S.length;
+
+		for (i = 0; i < plen; i++) {
+			P[i] = P[i] ^ streamtoword(key, koffp);
+		}
+
+		for (i = 0; i < plen; i += 2) {
+			encipher(lr, 0);
+			P[i] = lr[0];
+			P[i + 1] = lr[1];
+		}
+
+		for (i = 0; i < slen; i += 2) {
+			encipher(lr, 0);
+			S[i] = lr[0];
+			S[i + 1] = lr[1];
+		}
+	}
+
+	/**
+	 * Perform the "enhanced key schedule" step described by Provos and Mazieres in
+	 * "A Future-Adaptable Password Scheme" http://www.openbsd.org/papers/bcrypt-paper.ps
+	 * @param data salt information
+	 * @param key password information
+	 */
+	private void ekskey(byte data[], byte key[]) {
+		int i;
+		int koffp[] = { 0 }, doffp[] = { 0 };
+		int lr[] = { 0, 0 };
+		int plen = P.length, slen = S.length;
+
+		for (i = 0; i < plen; i++) {
+			P[i] = P[i] ^ streamtoword(key, koffp);
+		}
+
+		for (i = 0; i < plen; i += 2) {
+			lr[0] ^= streamtoword(data, doffp);
+			lr[1] ^= streamtoword(data, doffp);
+			encipher(lr, 0);
+			P[i] = lr[0];
+			P[i + 1] = lr[1];
+		}
+
+		for (i = 0; i < slen; i += 2) {
+			lr[0] ^= streamtoword(data, doffp);
+			lr[1] ^= streamtoword(data, doffp);
+			encipher(lr, 0);
+			S[i] = lr[0];
+			S[i + 1] = lr[1];
+		}
+	}
+
+	static long roundsForLogRounds(int log_rounds) {
+		if (log_rounds < 4 || log_rounds > 31) {
+			throw new IllegalArgumentException("Bad number of rounds");
+		}
+		return 1L << log_rounds;
+	}
+
+	/**
+	 * Perform the central password hashing step in the bcrypt scheme
+	 * @param password the password to hash
+	 * @param salt the binary salt to hash with the password
+	 * @param log_rounds the binary logarithm of the number of rounds of hashing to apply
+	 * @return an array containing the binary hashed password
+	 */
+	private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) {
+		int cdata[] = (int[]) bf_crypt_ciphertext.clone();
+		int clen = cdata.length;
+		byte ret[];
+
+		long rounds = roundsForLogRounds(log_rounds);
+
+		init_key();
+		ekskey(salt, password);
+		for (long i = 0; i < rounds; i++) {
+			key(password);
+			key(salt);
+		}
+
+		for (int i = 0; i < 64; i++) {
+			for (int j = 0; j < (clen >> 1); j++) {
+				encipher(cdata, j << 1);
+			}
+		}
+
+		ret = new byte[clen * 4];
+		for (int i = 0, j = 0; i < clen; i++) {
+			ret[j++] = (byte) ((cdata[i] >> 24) & 0xff);
+			ret[j++] = (byte) ((cdata[i] >> 16) & 0xff);
+			ret[j++] = (byte) ((cdata[i] >> 8) & 0xff);
+			ret[j++] = (byte) (cdata[i] & 0xff);
+		}
+		return ret;
+	}
+
+	/**
+	 * Hash a password using the OpenBSD bcrypt scheme
+	 * @param password the password to hash
+	 * @param salt the salt to hash with (perhaps generated using BCrypt.gensalt)
+	 * @return the hashed password
+	 * @throws IllegalArgumentException if invalid salt is passed
+	 */
+	public static String hashpw(String password, String salt) throws IllegalArgumentException {
+		BCrypt B;
+		String real_salt;
+		byte passwordb[], saltb[], hashed[];
+		char minor = (char) 0;
+		int rounds, off = 0;
+		StringBuilder rs = new StringBuilder();
+
+		if (salt == null) {
+			throw new IllegalArgumentException("salt cannot be null");
+		}
+
+		int saltLength = salt.length();
+
+		if (saltLength < 28) {
+			throw new IllegalArgumentException("Invalid salt");
+		}
+
+		if (salt.charAt(0) != '$' || salt.charAt(1) != '2') {
+			throw new IllegalArgumentException("Invalid salt version");
+		}
+		if (salt.charAt(2) == '$') {
+			off = 3;
+		}
+		else {
+			minor = salt.charAt(2);
+			if (minor != 'a' || salt.charAt(3) != '$') {
+				throw new IllegalArgumentException("Invalid salt revision");
+			}
+			off = 4;
+		}
+
+		if (saltLength - off < 25) {
+			throw new IllegalArgumentException("Invalid salt");
+		}
+
+		// Extract number of rounds
+		if (salt.charAt(off + 2) > '$') {
+			throw new IllegalArgumentException("Missing salt rounds");
+		}
+		rounds = Integer.parseInt(salt.substring(off, off + 2));
+
+		real_salt = salt.substring(off + 3, off + 25);
+		try {
+			passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8");
+		}
+		catch (UnsupportedEncodingException uee) {
+			throw new AssertionError("UTF-8 is not supported");
+		}
+
+		saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);
+
+		B = new BCrypt();
+		hashed = B.crypt_raw(passwordb, saltb, rounds);
+
+		rs.append("$2");
+		if (minor >= 'a') {
+			rs.append(minor);
+		}
+		rs.append("$");
+		if (rounds < 10) {
+			rs.append("0");
+		}
+		rs.append(rounds);
+		rs.append("$");
+		encode_base64(saltb, saltb.length, rs);
+		encode_base64(hashed, bf_crypt_ciphertext.length * 4 - 1, rs);
+		return rs.toString();
+	}
+
+	/**
+	 * Generate a salt for use with the BCrypt.hashpw() method
+	 * @param log_rounds the log2 of the number of rounds of hashing to apply - the work
+	 * factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.
+	 * @param random an instance of SecureRandom to use
+	 * @return an encoded salt value
+	 */
+	public static String gensalt(int log_rounds, SecureRandom random) {
+		if (log_rounds < MIN_LOG_ROUNDS || log_rounds > MAX_LOG_ROUNDS) {
+			throw new IllegalArgumentException("Bad number of rounds");
+		}
+		StringBuilder rs = new StringBuilder();
+		byte rnd[] = new byte[BCRYPT_SALT_LEN];
+
+		random.nextBytes(rnd);
+
+		rs.append("$2a$");
+		if (log_rounds < 10) {
+			rs.append("0");
+		}
+		rs.append(log_rounds);
+		rs.append("$");
+		encode_base64(rnd, rnd.length, rs);
+		return rs.toString();
+	}
+
+	/**
+	 * Generate a salt for use with the BCrypt.hashpw() method
+	 * @param log_rounds the log2 of the number of rounds of hashing to apply - the work
+	 * factor therefore increases as 2**log_rounds. Minimum 4, maximum 31.
+	 * @return an encoded salt value
+	 */
+	public static String gensalt(int log_rounds) {
+		return gensalt(log_rounds, new SecureRandom());
+	}
+
+	/**
+	 * Generate a salt for use with the BCrypt.hashpw() method, selecting a reasonable
+	 * default for the number of hashing rounds to apply
+	 * @return an encoded salt value
+	 */
+	public static String gensalt() {
+		return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS);
+	}
+
+	/**
+	 * Check that a plaintext password matches a previously hashed one
+	 * @param plaintext the plaintext password to verify
+	 * @param hashed the previously-hashed password
+	 * @return true if the passwords match, false otherwise
+	 */
+	public static boolean checkpw(String plaintext, String hashed) {
+		return equalsNoEarlyReturn(hashed, hashpw(plaintext, hashed));
+	}
+
+	static boolean equalsNoEarlyReturn(String a, String b) {
+		char[] caa = a.toCharArray();
+		char[] cab = b.toCharArray();
+
+		if (caa.length != cab.length) {
+			return false;
+		}
+
+		byte ret = 0;
+		for (int i = 0; i < caa.length; i++) {
+			ret |= caa[i] ^ cab[i];
+		}
+		return ret == 0;
+	}
+}

+ 83 - 0
qnfhq-api/src/main/java/com/qnfhq/utils/password/BCryptPasswordEncoder.java

@@ -0,0 +1,83 @@
+package com.qnfhq.utils.password;
+
+import com.qnfhq.utils.password.PasswordEncoder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.security.SecureRandom;
+import java.util.regex.Pattern;
+
+/**
+ * Implementation of PasswordEncoder that uses the BCrypt strong hashing function. Clients
+ * can optionally supply a "strength" (a.k.a. log rounds in BCrypt) and a SecureRandom
+ * instance. The larger the strength parameter the more work will have to be done
+ * (exponentially) to hash the passwords. The default value is 10.
+ *
+ * @author Dave Syer
+ *
+ */
+public class BCryptPasswordEncoder implements PasswordEncoder {
+	private Pattern BCRYPT_PATTERN = Pattern
+			.compile("\\A\\$2a?\\$\\d\\d\\$[./0-9A-Za-z]{53}");
+	private final Log logger = LogFactory.getLog(getClass());
+
+	private final int strength;
+
+	private final SecureRandom random;
+
+	public BCryptPasswordEncoder() {
+		this(-1);
+	}
+
+	/**
+	 * @param strength the log rounds to use, between 4 and 31
+	 */
+	public BCryptPasswordEncoder(int strength) {
+		this(strength, null);
+	}
+
+	/**
+	 * @param strength the log rounds to use, between 4 and 31
+	 * @param random the secure random instance to use
+	 *
+	 */
+	public BCryptPasswordEncoder(int strength, SecureRandom random) {
+		if (strength != -1 && (strength < BCrypt.MIN_LOG_ROUNDS || strength > BCrypt.MAX_LOG_ROUNDS)) {
+			throw new IllegalArgumentException("Bad strength");
+		}
+		this.strength = strength;
+		this.random = random;
+	}
+
+	@Override
+	public String encode(CharSequence rawPassword) {
+		String salt;
+		if (strength > 0) {
+			if (random != null) {
+				salt = BCrypt.gensalt(strength, random);
+			}
+			else {
+				salt = BCrypt.gensalt(strength);
+			}
+		}
+		else {
+			salt = BCrypt.gensalt();
+		}
+		return BCrypt.hashpw(rawPassword.toString(), salt);
+	}
+
+    @Override
+	public boolean matches(CharSequence rawPassword, String encodedPassword) {
+		if (encodedPassword == null || encodedPassword.length() == 0) {
+			logger.warn("Empty encoded password");
+			return false;
+		}
+
+		if (!BCRYPT_PATTERN.matcher(encodedPassword).matches()) {
+			logger.warn("Encoded password does not look like BCrypt");
+			return false;
+		}
+
+		return BCrypt.checkpw(rawPassword.toString(), encodedPassword);
+	}
+}

+ 30 - 0
qnfhq-api/src/main/java/com/qnfhq/utils/password/PasswordEncoder.java

@@ -0,0 +1,30 @@
+package com.qnfhq.utils.password;
+
+/**
+ * Service interface for encoding passwords.
+ *
+ * The preferred implementation is {@code BCryptPasswordEncoder}.
+ *
+ * @author Keith Donald
+ */
+public interface PasswordEncoder {
+
+	/**
+	 * Encode the raw password. Generally, a good encoding algorithm applies a SHA-1 or
+	 * greater hash combined with an 8-byte or greater randomly generated salt.
+	 */
+	String encode(CharSequence rawPassword);
+
+	/**
+	 * Verify the encoded password obtained from storage matches the submitted raw
+	 * password after it too is encoded. Returns true if the passwords match, false if
+	 * they do not. The stored password itself is never decoded.
+	 *
+	 * @param rawPassword the raw password to encode and match
+	 * @param encodedPassword the encoded password from storage to compare with
+	 * @return true if the raw password, after encoding, matches the encoded password from
+	 * storage
+	 */
+	boolean matches(CharSequence rawPassword, String encodedPassword);
+
+}

+ 61 - 0
qnfhq-api/src/main/java/com/qnfhq/utils/password/PasswordUtils.java

@@ -0,0 +1,61 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ * <p>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * <p>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * <p>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.qnfhq.utils.password;
+
+import com.qnfhq.utils.password.BCryptPasswordEncoder;
+import com.qnfhq.utils.password.PasswordEncoder;
+
+/**
+ * 密码工具类
+ *
+ * @author Mark sunlightcs@gmail.com
+ * @since 1.0.0
+ */
+public class PasswordUtils {
+    private static PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
+
+    /**
+     * 加密
+     * @param str  字符串
+     * @return     返回加密字符串
+     */
+    public static String encode(String str){
+        return passwordEncoder.encode(str);
+    }
+
+
+    /**
+     * 比较密码是否相等
+     * @param str  明文密码
+     * @param  password  加密后密码
+     * @return     true:成功    false:失败
+     */
+    public static boolean matches(String str, String password){
+        return passwordEncoder.matches(str, password);
+    }
+
+
+    public static void main(String[] args) {
+        String str = "admin";
+        String password = encode(str);
+
+        System.out.println(password);
+        System.out.println(matches(str, password));
+    }
+
+}

+ 132 - 0
qnfhq-api/src/main/java/com/qnfhq/utils/sms/SmsSenderUtil.java

@@ -0,0 +1,132 @@
+package com.qnfhq.utils.sms;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class SmsSenderUtil {
+
+    protected static Random random = new Random();
+
+    private final static String accesskey = "622473a05437743e74b3fe1b";
+    private final static String secretkey = "b3c087e157054bf5ada1da85197e9c0a";
+
+    private static final String signId ="622f97fd5437743e74b3fe50";
+    //模板ID(登录后台页面获取)
+    private static final String templateId ="622f99325437743e74b3fe52";
+
+    public String stringMD5(String input) throws NoSuchAlgorithmException {
+        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
+        byte[] inputByteArray = input.getBytes();
+        messageDigest.update(inputByteArray);
+        byte[] resultByteArray = messageDigest.digest();
+        return byteArrayToHex(resultByteArray);
+    }
+
+    protected String strToHash(String str) throws NoSuchAlgorithmException {
+        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
+        byte[] inputByteArray = str.getBytes();
+        messageDigest.update(inputByteArray);
+        byte[] resultByteArray = messageDigest.digest();
+        return byteArrayToHex(resultByteArray);
+    }
+
+    public String byteArrayToHex(byte[] byteArray) {
+        char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+        char[] resultCharArray = new char[byteArray.length * 2];
+        int index = 0;
+        for (byte b : byteArray) {
+            resultCharArray[index++] = hexDigits[b >>> 4 & 0xf];
+            resultCharArray[index++] = hexDigits[b & 0xf];
+        }
+        return new String(resultCharArray);
+    }
+
+    public static int getRandom() {
+        return random.nextInt(999999)%900000+100000;
+    }
+
+    public static int getRandomNumber(int from, int to) {
+        float a = from + (to - from) * (new Random().nextFloat());
+        int b = (int) a;
+        return ((a - b) > 0.5 ? 1 : 0) + b;
+    }
+
+    public HttpURLConnection getPostHttpConn(String url) throws Exception {
+        URL object = new URL(url);
+        HttpURLConnection conn;
+        conn = (HttpURLConnection) object.openConnection();
+        conn.setDoOutput(true);
+        conn.setDoInput(true);
+        conn.setRequestProperty("Content-Type", "application/json");
+        conn.setRequestProperty("Accept", "application/json");
+        conn.setRequestMethod("POST");
+        return conn;
+    }
+
+    public String calculateSig(
+            String accesskey,
+            long random,
+            String msg,
+            long curTime,
+            ArrayList<String> phoneNumbers) throws NoSuchAlgorithmException {
+        String phoneNumbersString = phoneNumbers.get(0);
+        for (int i = 1; i < phoneNumbers.size(); i++) {
+            phoneNumbersString += "," + phoneNumbers.get(i);
+        }
+        return strToHash(String.format(
+                "accesskey=%s&random=%d&time=%d&mobile=%s",
+                accesskey, random, curTime, phoneNumbersString));
+    }
+
+    public String calculateSigForTempl(
+            String accesskey,
+            long random,
+            long curTime,
+            ArrayList<String> phoneNumbers) throws NoSuchAlgorithmException {
+        String phoneNumbersString = phoneNumbers.get(0);
+        for (int i = 1; i < phoneNumbers.size(); i++) {
+            phoneNumbersString += "," + phoneNumbers.get(i);
+        }
+        return strToHash(String.format(
+                "accesskey=%s&random=%d&time=%d&mobile=%s",
+                accesskey, random, curTime, phoneNumbersString));
+    }
+
+    public String calculateSigForTempl(
+            String accesskey,
+            long random,
+            long curTime,
+            String phoneNumber) throws NoSuchAlgorithmException {
+        ArrayList<String> phoneNumbers = new ArrayList<>();
+        phoneNumbers.add(phoneNumber);
+        return calculateSigForTempl(accesskey, random, curTime, phoneNumbers);
+    }
+
+    public JSONArray phoneNumbersToJSONArray(String nationCode, ArrayList<String> phoneNumbers) {
+        JSONArray tel = new JSONArray();
+        int i = 0;
+        do {
+            JSONObject telElement = new JSONObject();
+            telElement.put("nationcode", nationCode);
+            telElement.put("mobile", phoneNumbers.get(i));
+            tel.put(telElement);
+        } while (++i < phoneNumbers.size());
+
+        return tel;
+    }
+
+    public JSONArray smsParamsToJSONArray(List<String> params) {
+        JSONArray smsParams = new JSONArray();
+        for (int i = 0; i < params.size(); i++) {
+            smsParams.put(params.get(i));
+        }
+        return smsParams;
+    }
+}

+ 2 - 2
qnfhq-api/src/main/resources/application.yml

@@ -57,14 +57,14 @@ spring:
 
 renren:
   redis:
-    open: false  # 是否开启redis缓存  true开启   false关闭
+    open: true  # 是否开启redis缓存  true开启   false关闭
 
 
 #mybatis
 mybatis-plus:
   mapper-locations: classpath*:/mapper/**/*.xml
   #实体扫描,多个package用逗号或者分号分隔
-  typeAliasesPackage: io.renren.entity
+  typeAliasesPackage: com.qnfhq.entity
   global-config:
     #数据库相关配置
     db-config:

+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_de.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_en.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_es.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_fr.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_ja.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_ko.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_th.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_tw.properties


+ 0 - 0
qnfhq-api/src/main/resources/i18n/messages_vi.properties


+ 51 - 0
qnfhq-api/src/main/resources/i18n/messages_zh.properties

@@ -0,0 +1,51 @@
+500=\u670d\u52a1\u5668\u5185\u90e8\u5f02\u5e38
+401=\u672a\u6388\u6743
+10001={0}\u4e0d\u80fd\u4e3a\u7a7a
+10002=\u6570\u636e\u5e93\u4e2d\u5df2\u5b58\u5728\u8be5\u8bb0\u5f55
+10003=\u83b7\u53d6\u53c2\u6570\u5931\u8d25
+10004=\u8d26\u53f7\u6216\u5bc6\u7801\u9519\u8bef
+10005=\u8d26\u53f7\u5df2\u88ab\u505c\u7528
+10006=\u552f\u4e00\u6807\u8bc6\u4e0d\u80fd\u4e3a\u7a7a
+10007=\u9a8c\u8bc1\u7801\u4e0d\u6b63\u786e
+10008=\u5148\u5220\u9664\u5b50\u83dc\u5355\u6216\u6309\u94ae
+10009=\u539f\u5bc6\u7801\u4e0d\u6b63\u786e
+10010=\u8d26\u53f7\u4e0d\u5b58\u5728
+10011=\u4e0a\u7ea7\u90e8\u95e8\u9009\u62e9\u9519\u8bef
+10012=\u4e0a\u7ea7\u83dc\u5355\u4e0d\u80fd\u4e3a\u81ea\u8eab
+10013=\u6570\u636e\u6743\u9650\u63a5\u53e3\uff0c\u53ea\u80fd\u662fMap\u7c7b\u578b\u53c2\u6570
+10014=\u8bf7\u5148\u5220\u9664\u4e0b\u7ea7\u90e8\u95e8
+10015=\u8bf7\u5148\u5220\u9664\u90e8\u95e8\u4e0b\u7684\u7528\u6237
+10019=\u8bf7\u4e0a\u4f20\u6587\u4ef6
+10020=token\u4e0d\u80fd\u4e3a\u7a7a
+10021=token\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55
+10022=\u8d26\u53f7\u5df2\u88ab\u9501\u5b9a
+10024=\u4e0a\u4f20\u6587\u4ef6\u5931\u8d25{0}
+10027=Redis\u670d\u52a1\u5f02\u5e38
+10028=\u5b9a\u65f6\u4efb\u52a1\u5931\u8d25
+10029=\u4e0d\u80fd\u5305\u542b\u975e\u6cd5\u5b57\u7b26
+
+user.register.signtype.err=\u767b\u5f55\u7c7b\u578b\u9519\u8bef
+user.register.fail=\u6ce8\u518c\u5931\u8d25
+user.register.success=\u6ce8\u518c\u6210\u529f
+user.register.code.err=\u9a8c\u8bc1\u7801\u9519\u8bef
+user.register.activecode.notexisit=\u63a8\u8350\u7801\u4e0d\u5b58\u5728
+user.register.email.format=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E
+user.register.email.exisit=\u90AE\u7BB1\u5DF2\u5B58\u5728
+user.register.phone.exist=\u624B\u673A\u53F7\u5DF2\u7ECF\u5B58\u5728
+phone_code_empty=\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A!
+email.code_empty=\u90AE\u7BB1\u4E0D\u80FD\u4E3A\u7A7A!
+user.code.send=\u9A8C\u8BC1\u7801\u53D1\u9001\u6210\u529F
+app.verification.email.code=\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u5230\u60A8\u7684\u90AE\u7BB1\uFF0C\u8BF7\u6CE8\u610F\u67E5\u6536
+common.send.success=\u53d1\u9001\u6210\u529f
+sms.template.not.exist=\u77ED\u4FE1\u6A21\u677F\u4E0D\u5B58\u5728
+appUser.login.code.err=\u9a8c\u8bc1\u7801\u9519\u8bef
+appUser.loginName.or.password.err=\u8d26\u53f7\u6216\u5bc6\u7801\u9519\u8bef
+user_is_black=\u60a8\u7684\u8d26\u53f7\u5df2\u88ab\u5217\u5165\u9ed1\u540d\u5355\uff0c\u65e0\u6cd5\u767b\u5f55\u3002
+appUser.login.success=\u767b\u9646\u6210\u529f
+user.not.login.err=\u672a\u767b\u9646
+user.not.exist=\u7528\u6237\u4e0d\u5b58\u5728
+code.try.times.limit=\u91cd\u8bd5\u6b21\u6570\u8fc7\u591a
+user.sendcode.frequency.limit=\u9a8c\u8bc1\u7801\u8bf7\u6c42\u592a\u8fc7\u9891\u7387\uff0c\u8bf760\u79d2\u540e\u518d\u8bd5
+user.email.send.fail=\u90ae\u7bb1\u53d1\u9001\u5931\u8d25
+
+

+ 1 - 0
qnfhq-api/src/main/resources/i18n/validation.properties

@@ -0,0 +1 @@
+appregister.loginpassword.required=Kata laluan tidak boleh kosong.

+ 1 - 0
qnfhq-api/src/main/resources/i18n/validation_de.properties

@@ -0,0 +1 @@
+appregister.loginpassword.required=Kata laluan tidak boleh kosong.

+ 1 - 0
qnfhq-api/src/main/resources/i18n/validation_en.properties

@@ -0,0 +1 @@
+appregister.loginpassword.required=Password cannot be empty.

+ 1 - 0
qnfhq-api/src/main/resources/i18n/validation_es.properties

@@ -0,0 +1 @@
+appregister.loginpassword.required=Kata laluan tidak boleh kosong.

+ 1 - 0
qnfhq-api/src/main/resources/i18n/validation_fr.properties

@@ -0,0 +1 @@
+appregister.loginpassword.required=Kata laluan tidak boleh kosong.

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.