赵嘉康 hace 4 días
commit
728aef75de
Se han modificado 51 ficheros con 2691 adiciones y 0 borrados
  1. 33 0
      .gitignore
  2. 175 0
      pom.xml
  3. 53 0
      src/main/java/com/zhentao/Cj.java
  4. 14 0
      src/main/java/com/zhentao/Demo1Application.java
  5. 13 0
      src/main/java/com/zhentao/common/annotation/NoAuthLogin.java
  6. 184 0
      src/main/java/com/zhentao/common/config/IntercepterConfig.java
  7. 35 0
      src/main/java/com/zhentao/common/config/MyBatisPlusConfig.java
  8. 131 0
      src/main/java/com/zhentao/common/config/RedisConfig.java
  9. 16 0
      src/main/java/com/zhentao/common/config/RedisHostConfig.java
  10. 15 0
      src/main/java/com/zhentao/common/config/RedissonConfig.java
  11. 16 0
      src/main/java/com/zhentao/common/config/UserThreadLocal.java
  12. 16 0
      src/main/java/com/zhentao/common/constant/CommonConstant.java
  13. 20 0
      src/main/java/com/zhentao/common/enums/ApiEnum.java
  14. 27 0
      src/main/java/com/zhentao/common/exception/ApiException.java
  15. 32 0
      src/main/java/com/zhentao/common/exception/GloableException.java
  16. 17 0
      src/main/java/com/zhentao/common/intercepter/AuthIntercepter.java
  17. 111 0
      src/main/java/com/zhentao/common/util/TokenUtils.java
  18. 23 0
      src/main/java/com/zhentao/controller/LoginController.java
  19. 183 0
      src/main/java/com/zhentao/domain/Document.java
  20. 315 0
      src/main/java/com/zhentao/domain/Pond.java
  21. 183 0
      src/main/java/com/zhentao/domain/Prize.java
  22. 183 0
      src/main/java/com/zhentao/domain/UserLogin.java
  23. 13 0
      src/main/java/com/zhentao/dto/CjDto.java
  24. 13 0
      src/main/java/com/zhentao/dto/LoginDto.java
  25. 9 0
      src/main/java/com/zhentao/dto/LotteryDto.java
  26. 18 0
      src/main/java/com/zhentao/mapper/DocumentMapper.java
  27. 18 0
      src/main/java/com/zhentao/mapper/PondMapper.java
  28. 18 0
      src/main/java/com/zhentao/mapper/PrizeMapper.java
  29. 18 0
      src/main/java/com/zhentao/mapper/UserLoginMapper.java
  30. 13 0
      src/main/java/com/zhentao/service/DocumentService.java
  31. 14 0
      src/main/java/com/zhentao/service/PondService.java
  32. 18 0
      src/main/java/com/zhentao/service/PrizeService.java
  33. 15 0
      src/main/java/com/zhentao/service/UserLoginService.java
  34. 9 0
      src/main/java/com/zhentao/service/UserService.java
  35. 22 0
      src/main/java/com/zhentao/service/impl/DocumentServiceImpl.java
  36. 31 0
      src/main/java/com/zhentao/service/impl/PondServiceImpl.java
  37. 44 0
      src/main/java/com/zhentao/service/impl/PrizeServiceImpl.java
  38. 31 0
      src/main/java/com/zhentao/service/impl/UserLoginServiceImpl.java
  39. 88 0
      src/main/java/com/zhentao/service/impl/UserServiceImpl.java
  40. 25 0
      src/main/java/com/zhentao/student.java
  41. 40 0
      src/main/java/com/zhentao/user.java
  42. 10 0
      src/main/java/com/zhentao/vo/LoginVo.java
  43. 54 0
      src/main/java/com/zhentao/vo/Result.java
  44. 127 0
      src/main/resources/application-dev.yml
  45. 120 0
      src/main/resources/application-prod.yml
  46. 27 0
      src/main/resources/application.yml
  47. 20 0
      src/main/resources/mapper/DocumentMapper.xml
  48. 28 0
      src/main/resources/mapper/PondMapper.xml
  49. 20 0
      src/main/resources/mapper/PrizeMapper.xml
  50. 20 0
      src/main/resources/mapper/UserLoginMapper.xml
  51. 13 0
      src/test/java/com/zhentao/Demo1ApplicationTests.java

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 175 - 0
pom.xml

@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.zhentao</groupId>
+    <artifactId>demo1</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>demo1</name>
+    <description>demo1</description>
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <java.version>17</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <spring-boot.version>2.6.13</spring-boot.version>
+        <mybatisplus.version>3.4.2</mybatisplus.version>
+        <druid.version>1.1.21</druid.version>
+        <fastjson.version>1.2.80</fastjson.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <!--        <dependency>-->
+        <!--            <groupId>jakarta.validation</groupId>-->
+        <!--            <artifactId>jakarta.validation-api</artifactId>-->
+        <!--            <version>3.0.2</version> &lt;!&ndash; 最新稳定版 &ndash;&gt;-->
+        <!--        </dependency>-->
+        <!--        <dependency>-->
+        <!--            <groupId>org.hibernate.validator</groupId>-->
+        <!--            <artifactId>hibernate-validator</artifactId>-->
+        <!--            <version>8.0.1.Final</version>-->
+        <!--        </dependency>-->
+        <!--        &lt;!&ndash; 对于 Jakarta 环境,还需添加验证引擎 &ndash;&gt;-->
+        <!--        <dependency>-->
+        <!--            <groupId>org.hibernate.validator</groupId>-->
+        <!--            <artifactId>hibernate-validator-annotation-processor</artifactId>-->
+        <!--            <version>8.0.1.Final</version>-->
+        <!--        </dependency>-->
+
+        <!-- Spring 集成支持(若使用 Spring Boot,可省略,已自动集成) -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-validation</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>${mybatisplus.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.baomidou</groupId>
+                    <artifactId>mybatis-plus-generator</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>${druid.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.9.0</version>
+        </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.7.15</version>
+        </dependency>
+        <!-- apache commons end -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>${fastjson.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson-spring-boot-starter</artifactId>
+            <version>3.23.0</version> <!-- 版本可根据需求调整,建议使用稳定版 -->
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.kafka</groupId>
+            <artifactId>spring-kafka</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.5</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>jakarta.xml.bind</groupId>
+            <artifactId>jakarta.xml.bind-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jaxb</groupId>
+            <artifactId>jaxb-runtime</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+    </dependencies>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring-boot.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>UTF-8</encoding>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot.version}</version>
+                <configuration>
+                    <mainClass>com.futu.FutuGoodsApplication</mainClass>
+                    <skip>true</skip>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>repackage</id>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 53 - 0
src/main/java/com/zhentao/Cj.java

@@ -0,0 +1,53 @@
+package com.zhentao;
+
+import cn.hutool.core.util.RandomUtil;
+import com.zhentao.dto.CjDto;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Cj {
+    public static void main(String[] args) {
+        List<CjDto> list = new ArrayList<>();
+        for (int i = 0; i < 5; i++) {
+            CjDto dto = new CjDto();
+            dto.setId(1);
+            dto.setName("笔");
+            list.add(dto);
+        }
+
+        for (int i = 0; i < 2; i++) {
+            CjDto dto = new CjDto();
+            dto.setId(2);
+            dto.setName("10元代金券");
+            list.add(dto);
+        }
+
+
+        for (int i = 0; i < 18; i++) {
+            CjDto dto = new CjDto();
+            dto.setId(3);
+            dto.setName("本子");
+            list.add(dto);
+        }
+
+
+        for (int i = 0; i < 2; i++) {
+            CjDto dto = new CjDto();
+            dto.setId(4);
+            dto.setName("手机");
+            list.add(dto);
+        }
+
+
+        CjDto dto = new CjDto();
+        dto.setId(5);
+        dto.setName("一等奖");
+        list.add(dto);
+
+        int i = RandomUtil.randomInt(28);
+        System.out.println(i);
+        CjDto dto1 = list.get(i);
+        System.out.println(dto1.getName());
+    }
+}

+ 14 - 0
src/main/java/com/zhentao/Demo1Application.java

@@ -0,0 +1,14 @@
+package com.zhentao;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@MapperScan("com.zhentao.mapper")
+public class Demo1Application {
+    public static void main(String[] args) {
+        SpringApplication.run(Demo1Application.class, args);
+    }
+
+}

+ 13 - 0
src/main/java/com/zhentao/common/annotation/NoAuthLogin.java

@@ -0,0 +1,13 @@
+package com.zhentao.common.annotation;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface NoAuthLogin {
+}

+ 184 - 0
src/main/java/com/zhentao/common/config/IntercepterConfig.java

@@ -0,0 +1,184 @@
+package com.zhentao.common.config;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.zhentao.common.intercepter.AuthIntercepter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
+import org.springframework.web.filter.HttpPutFormContentFilter;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+import java.io.IOException;
+
+@Configuration
+@Slf4j
+//@EnableWebMvc
+public class IntercepterConfig extends WebMvcConfigurationSupport {
+
+//    @Override
+//    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
+//        log.info("IntercepterConfig--------------------");
+//        resolvers.add(new CurrentUserHandler());
+//    }
+//    @Autowired
+//    AuthIntercepter authIntercepter;
+//    @Autowired
+//    protected RedisTemplate redisTemplate;
+
+    @Override
+    public void addInterceptors(InterceptorRegistry registry) {
+        // 拦截所有请求,通过判断是否有 @LoginRequired 注解 决定是否需要登录
+        registry.addInterceptor(authenticationInterceptor()).excludePathPatterns("**.html").excludePathPatterns("**.txt")
+                .excludePathPatterns("/webjars/**")
+                .excludePathPatterns("/dashboard/list")
+                .excludePathPatterns("/swagger-ui.html")
+                .excludePathPatterns("/swagger-resources/**").excludePathPatterns("/error").addPathPatterns("/**");
+        super.addInterceptors(registry);
+    }
+
+
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        super.addResourceHandlers(registry);
+        registry.addResourceHandler("/**")
+                .addResourceLocations("classpath:/static/")
+                .addResourceLocations("classpath:/templates/")
+                .addResourceLocations("classpath:/resources/");
+        registry.addResourceHandler("swagger-ui.html")
+                .addResourceLocations("classpath:/META-INF/resources/");
+        registry.addResourceHandler("/webjars/**")
+                .addResourceLocations("classpath:/META-INF/resources/webjars/");
+        registry.addResourceHandler("SFLMPwcUTv.txt")
+                .addResourceLocations("classpath:/resources/");
+
+    }
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+        super.addCorsMappings(registry);
+        registry
+                .addMapping("/**")
+                .allowedHeaders("*")
+                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
+                .allowedOrigins("*");
+    }
+    
+    @Bean
+    public AuthIntercepter authenticationInterceptor() {
+        return new AuthIntercepter();
+    }
+    
+//    @Bean
+//    public CurrentUserMethodArgumentResolver currentUserMethodArgumentResolver() {
+//        return new CurrentUserMethodArgumentResolver();
+//    }
+//    @Override
+////    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
+////        argumentResolvers.add(currentUserMethodArgumentResolver());
+////        super.addArgumentResolvers(argumentResolvers);
+////    }
+
+    /**
+     * @Description 解决使用put请求   服务器接收不到参数
+     * @author DengKaiTao
+     * @date 2018/12/4 16:35
+     * @return org.springframework.web.filter.HttpPutFormContentFilter
+     * @version v1.0
+     **/
+    @Bean
+    public HttpPutFormContentFilter httpPutFormContentFilter() {
+        return new HttpPutFormContentFilter();
+    }
+    
+//    @Override
+//    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
+//
+////        FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
+////        FastJsonConfig config = new FastJsonConfig();
+////        config.setSerializerFeatures(
+////                //保留map空的字段
+////                SerializerFeature.WriteMapNullValue,
+////                // 将String类型的NULL转化为""
+////                SerializerFeature.WriteNullStringAsEmpty,
+////                // 将Number类型的NULL转化为0
+////                SerializerFeature.WriteNullNumberAsZero,
+////                // 将List类型的NULL转成[]
+////                SerializerFeature.WriteNullListAsEmpty,
+////                // 将Boolean类型的NULL转化为false
+////                SerializerFeature.WriteNullBooleanAsFalse,
+////                SerializerFeature.PrettyFormat,
+////                // 避免循环引用
+////                SerializerFeature.DisableCircularReferenceDetect);
+////
+////        converter.setFastJsonConfig(config);
+////        converter.setDefaultCharset(Charset.forName("UTF-8"));
+////
+////        List<MediaType> mediaTypeList = new ArrayList<>();
+////        // 解决中文乱码问题,相当于在Controller上的@RequestMapping中加了个属性produces = "application/json"
+////        mediaTypeList.add(MediaType.APPLICATION_JSON);
+////        converter.setSupportedMediaTypes(mediaTypeList);
+////        converters.add(converter);
+//        //定义Json转换器
+//        MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
+//        ObjectMapper objectMapper = new ObjectMapper();
+//        //定义对象模型
+//        SimpleModule simpleModule = new SimpleModule();
+//        //添加对长整型的转换关系
+//        simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
+////        simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
+////        simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
+////        simpleModule.addSerializer(Date.class,ToStringSerializer.instance);
+//        //将对象模型添加至对象映射器
+//        objectMapper.registerModule(simpleModule);
+//        jackson2HttpMessageConverter.setObjectMapper(objectMapper);
+//        //在转换器列表中添加自定义的Json转换器
+//        converters.add(jackson2HttpMessageConverter);
+//        //添加utf-8的默认String转换器
+//        converters.add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
+//    }
+
+    @Bean
+    @Primary
+    @ConditionalOnMissingBean(ObjectMapper.class)
+    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder)
+    {
+        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
+
+        // 通过该方法对mapper对象进行设置,所有序列化的对象都将按改规则进行系列化
+        // Include.Include.ALWAYS 默认
+        // Include.NON_DEFAULT 属性为默认值不序列化
+        // Include.NON_EMPTY 属性为 空("") 或者为 NULL 都不序列化,则返回的json是没有这个字段的。这样对移动端会更省流量
+        // Include.NON_NULL 属性为NULL 不序列化
+        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+        // 允许出现特殊字符和转义符
+        objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
+        // 允许出现单引号
+        objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
+        // 字段保留,将null值转为""
+        objectMapper.getSerializerProvider().setNullValueSerializer(new JsonSerializer<Object>()
+        {
+            @Override
+            public void serialize(Object o, JsonGenerator jsonGenerator,
+                                  SerializerProvider serializerProvider)
+                    throws IOException
+            {
+                jsonGenerator.writeString("");
+            }
+        });
+        return objectMapper;
+    }
+
+
+
+}

+ 35 - 0
src/main/java/com/zhentao/common/config/MyBatisPlusConfig.java

@@ -0,0 +1,35 @@
+package com.zhentao.common.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @className: MyBatisPlusConfig
+ * @Description:
+ * @author: huangqinghua
+ * @date: 2022/4/23/0023 17:01
+ */
+@Configuration
+@MapperScan(basePackages = {"com.futu.**.mapper"})
+public class MyBatisPlusConfig {
+
+    /**
+     * 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
+     */
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return interceptor;
+    }
+
+    @Bean
+    public ConfigurationCustomizer configurationCustomizer() {
+        return configuration -> configuration.setUseDeprecatedExecutor(false);
+    }
+}

+ 131 - 0
src/main/java/com/zhentao/common/config/RedisConfig.java

@@ -0,0 +1,131 @@
+package com.zhentao.common.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.KeyGenerator;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.serializer.*;
+
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Configuration
+@EnableCaching
+public class RedisConfig extends CachingConfigurerSupport {
+
+    @Autowired
+    private LettuceConnectionFactory lettuceConnectionFactory;
+    private Duration timeToLive = Duration.ZERO;
+
+    public void setTimeToLive(Duration timeToLive) {
+        this.timeToLive = timeToLive;
+    }
+
+    private RedisSerializer<String> keySerializer() {
+        return new StringRedisSerializer();
+    }
+
+    private RedisSerializer<Object> valueSerializer() {
+        return new GenericJackson2JsonRedisSerializer();
+    }
+
+    @Bean
+    public KeyGenerator simpleKeyGenerator() {
+        return (o, method, objects) -> {
+            StringBuilder stringBuilder = new StringBuilder();
+            stringBuilder.append(o.getClass().getSimpleName());
+            stringBuilder.append(".");
+            stringBuilder.append(method.getName());
+            stringBuilder.append("[");
+            for (Object obj : objects) {
+                stringBuilder.append(obj.toString());
+            }
+            stringBuilder.append("]");
+
+            return stringBuilder.toString();
+        };
+    }
+
+    private RedisCacheConfiguration getRedisCacheConfigurationWithTtl(Integer seconds) {
+        Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
+        ObjectMapper om = new ObjectMapper();
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        jackson2JsonRedisSerializer.setObjectMapper(om);
+
+        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
+        redisCacheConfiguration = redisCacheConfiguration.serializeValuesWith(
+                RedisSerializationContext
+                        .SerializationPair
+                        .fromSerializer(jackson2JsonRedisSerializer)
+        ).entryTtl(Duration.ofSeconds(seconds));
+
+        return redisCacheConfiguration;
+    }
+
+
+    private Map<String, RedisCacheConfiguration> getRedisCacheConfigurationMap() {
+        Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
+        redisCacheConfigurationMap.put("UserInfoList", this.getRedisCacheConfigurationWithTtl(30));
+        redisCacheConfigurationMap.put("UserInfoListAnother", this.getRedisCacheConfigurationWithTtl(18000));
+
+        return redisCacheConfigurationMap;
+    }
+
+    @Bean
+    public RedisCacheManager cacheManager(RedisConnectionFactory factory) {
+        log.info("自定义RedisCacheManager加载完成");
+        return new RedisCacheManager(
+                RedisCacheWriter.nonLockingRedisCacheWriter(factory),
+                this.getRedisCacheConfigurationWithTtl(600), // 默认策略,未配置的 key 会使用这个
+                this.getRedisCacheConfigurationMap() // 指定 key 策略
+        );
+
+
+    }
+
+    @Bean(name = "stringRedisTemplate")
+    public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
+        StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(factory);
+        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
+        ObjectMapper om = new ObjectMapper();
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        jackson2JsonRedisSerializer.setObjectMapper(om);
+        stringRedisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
+        stringRedisTemplate.afterPropertiesSet();
+        log.debug("自定义stringRedisTemplate加载完成");
+        return stringRedisTemplate;
+    }
+    @Bean(name = "redisTemplate")
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+//        redisTemplate.setConnectionFactory(redisConnectionFactory);
+        redisTemplate.setConnectionFactory(lettuceConnectionFactory);
+
+        redisTemplate.setKeySerializer(keySerializer());
+        redisTemplate.setHashKeySerializer(keySerializer());
+        redisTemplate.setValueSerializer(valueSerializer());
+        redisTemplate.setHashValueSerializer(valueSerializer());
+
+
+        log.debug("自定义RedisTemplate加载完成");
+        return redisTemplate;
+    }
+
+}

+ 16 - 0
src/main/java/com/zhentao/common/config/RedisHostConfig.java

@@ -0,0 +1,16 @@
+package com.zhentao.common.config;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.Serializable;
+
+@Component
+@Data
+public class RedisHostConfig implements Serializable {
+    @Value("${spring.redis.host}"    )
+    String redisHost;
+    @Value("${spring.redis.database}")
+    Integer redisdb;
+}

+ 15 - 0
src/main/java/com/zhentao/common/config/RedissonConfig.java

@@ -0,0 +1,15 @@
+package com.zhentao.common.config;
+
+import org.redisson.Redisson;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+
+public class RedissonConfig {
+    public static RedissonClient getRedissonClient(String host,Integer db) {
+        Config config = new Config();
+        config.useSingleServer()
+                .setAddress("redis://"+host+":6379") // Redis地址
+                .setDatabase(db); // 数据库编号
+        return Redisson.create(config);
+    }
+}

+ 16 - 0
src/main/java/com/zhentao/common/config/UserThreadLocal.java

@@ -0,0 +1,16 @@
+package com.zhentao.common.config;
+
+public class UserThreadLocal {
+        private static ThreadLocal<Long> userDetail=new ThreadLocal<>();
+
+        public static void setUserDetail(Long userId){
+            userDetail.set(userId);
+        }
+
+        public static Long getUserDetail(){
+          return   userDetail.get();
+        }
+        public static void remove(){
+            userDetail.remove();
+        }
+}

+ 16 - 0
src/main/java/com/zhentao/common/constant/CommonConstant.java

@@ -0,0 +1,16 @@
+package com.zhentao.common.constant;
+
+public class CommonConstant {
+//    token
+    public static final String TOKEN = "token";
+//    成功提示
+    public static final String SUCCESS_MSG="success";
+//    失败提示数
+    public static final Integer ERROR_CODE = 400;
+//    失败提示
+    public static final String ERROR_MSG = "error";
+//    全局异常报错
+    public static final Integer EXCEPTION_CODE = 001;
+    public static final Integer METHOD_CODE = 002;
+    public static final Integer TOKEN_CODE = 4040;
+}

+ 20 - 0
src/main/java/com/zhentao/common/enums/ApiEnum.java

@@ -0,0 +1,20 @@
+package com.zhentao.common.enums;
+
+import lombok.Data;
+import lombok.Getter;
+
+@Getter
+public enum ApiEnum {
+
+
+    USER_NOEXIS(10001,"用户不存在");
+
+    private Integer code;
+
+    private String msg;
+
+    ApiEnum(Integer code,String msg){
+        this.code=code;
+        this.msg=msg;
+    }
+}

+ 27 - 0
src/main/java/com/zhentao/common/exception/ApiException.java

@@ -0,0 +1,27 @@
+package com.zhentao.common.exception;
+
+import lombok.Data;
+
+@Data
+public class ApiException extends RuntimeException{
+
+    private Integer code;
+    private String msg;
+
+    public ApiException(String msg){
+        super(msg);
+        this.code=0;
+        this.msg=msg;
+    }
+
+    public  ApiException(Integer code,String msg){
+        super(msg);
+        this.code=code;
+        this.msg=msg;
+    }
+
+
+
+
+
+}

+ 32 - 0
src/main/java/com/zhentao/common/exception/GloableException.java

@@ -0,0 +1,32 @@
+package com.zhentao.common.exception;
+
+import com.zhentao.common.constant.CommonConstant;
+import com.zhentao.vo.Result;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+@RestControllerAdvice
+public class GloableException {
+
+    @ExceptionHandler(value = ApiException.class)
+    public Result getApiException(ApiException a){
+        return Result.fail(a.getCode(), a.getMsg());
+    }
+
+
+
+    @ExceptionHandler(value = Exception.class)
+    public Result getException(Exception e){
+        e.printStackTrace();
+        return Result.fail(CommonConstant.EXCEPTION_CODE,"sys_exception");
+
+    }
+
+
+    @ExceptionHandler(value = MethodArgumentNotValidException.class)
+    public Result getMethodException(MethodArgumentNotValidException m){
+        return Result.fail(CommonConstant.METHOD_CODE,m.getMessage());
+    }
+
+}

+ 17 - 0
src/main/java/com/zhentao/common/intercepter/AuthIntercepter.java

@@ -0,0 +1,17 @@
+package com.zhentao.common.intercepter;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+@Component
+@Slf4j
+public class AuthIntercepter implements HandlerInterceptor {
+
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+}

+ 111 - 0
src/main/java/com/zhentao/common/util/TokenUtils.java

@@ -0,0 +1,111 @@
+package com.zhentao.common.util;
+
+import com.zhentao.common.exception.ApiException;
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.JwtBuilder;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.bind.DatatypeConverter;
+import java.security.Key;
+import java.util.Date;
+
+/**
+ * 生成Token工具类
+ */
+public class TokenUtils {
+
+    /**
+     * 签名秘钥
+     */
+    public static final String SECRET = "cjyfutu1688";
+
+    /**
+     * 生成token
+     * @param id 一般传入userName
+     * @return
+     */
+    public static String createJwtToken(String id){
+        String issuer = "www.workervip.com";
+        String subject = "65532781@qq.com";
+        long ttlMillis = System.currentTimeMillis();
+        return createJwtToken(id, issuer, subject, ttlMillis);
+    }
+
+    /**
+     * 生成Token
+     *
+     * @param id
+     *            编号
+     * @param issuer
+     *            该JWT的签发者,是否使用是可选的
+     * @param subject
+     *            该JWT所面向的用户,是否使用是可选的;
+     * @param ttlMillis
+     *            签发时间
+     * @return token String
+     */
+    public static String createJwtToken(String id, String issuer, String subject, long ttlMillis) {
+
+        // 签名算法 ,将对token进行签名
+        SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
+
+        // 生成签发时间
+        long nowMillis = System.currentTimeMillis();
+        Date now = new Date(nowMillis);
+
+        // 通过秘钥签名JWT
+        byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(SECRET);
+        Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
+
+        // Let's set the JWT Claims
+        JwtBuilder builder = Jwts.builder().setId(id)
+                .setIssuedAt(now)
+                .setSubject(subject)
+                .setIssuer(issuer)
+                .signWith(signatureAlgorithm, signingKey);
+
+        // if it has been specified, let's add the expiration
+        if (ttlMillis >= 0) {
+            long expMillis = nowMillis + ttlMillis;
+            Date exp = new Date(expMillis);
+            builder.setExpiration(exp);
+        }
+
+        // Builds the JWT and serializes it to a compact, URL-safe string
+        return builder.compact();
+
+    }
+
+    // Sample method to validate and read the JWT
+    public static Claims parseJWT(String jwt) {
+        // This line will throw an exception if it is not a signed JWS (as expected)
+        Claims claims = Jwts.parser()
+                .setSigningKey(DatatypeConverter.parseBase64Binary(SECRET))
+                .parseClaimsJws(jwt).getBody();
+        return claims;
+    }
+
+    public static Long getUserId(String token){
+        Claims claims = null;
+        try {
+            claims = TokenUtils.parseJWT(token);
+        } catch (Exception e) {
+            throw new ApiException(101,"token错误,请重新登录");
+        }
+
+        if(null==claims) {
+            throw new ApiException("token错误,请重新登录");
+        }
+        String id = claims.getId();
+        Long userId=Long.valueOf(id);
+
+        return userId;
+
+
+    }
+
+    public static void main(String[] args) {
+        System.out.println(TokenUtils.createJwtToken("admin"));
+    }
+}

+ 23 - 0
src/main/java/com/zhentao/controller/LoginController.java

@@ -0,0 +1,23 @@
+package com.zhentao.controller;
+
+import com.zhentao.dto.LoginDto;
+import com.zhentao.service.UserService;
+import com.zhentao.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/user")
+public class LoginController {
+
+    @Autowired
+    UserService userService;
+
+    @RequestMapping("/login")
+    public Result login(@Validated @RequestBody LoginDto dto){
+        return userService.userLogin(dto);
+    }
+}

+ 183 - 0
src/main/java/com/zhentao/domain/Document.java

@@ -0,0 +1,183 @@
+package com.zhentao.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 
+ * @TableName document
+ */
+@TableName(value ="document")
+public class Document implements Serializable {
+    /**
+     * 抽奖记录ID
+     */
+    @TableId
+    private Long id;
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    /**
+     * 奖品ID
+     */
+    private Long prizeId;
+
+    /**
+     * 奖品名称
+     */
+    private String prizesNickname;
+
+    /**
+     * 奖池ID
+     */
+    private Long pondId;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 抽奖记录ID
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * 抽奖记录ID
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 用户ID
+     */
+    public Long getUserId() {
+        return userId;
+    }
+
+    /**
+     * 用户ID
+     */
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * 奖品ID
+     */
+    public Long getPrizeId() {
+        return prizeId;
+    }
+
+    /**
+     * 奖品ID
+     */
+    public void setPrizeId(Long prizeId) {
+        this.prizeId = prizeId;
+    }
+
+    /**
+     * 奖品名称
+     */
+    public String getPrizesNickname() {
+        return prizesNickname;
+    }
+
+    /**
+     * 奖品名称
+     */
+    public void setPrizesNickname(String prizesNickname) {
+        this.prizesNickname = prizesNickname;
+    }
+
+    /**
+     * 奖池ID
+     */
+    public Long getPondId() {
+        return pondId;
+    }
+
+    /**
+     * 奖池ID
+     */
+    public void setPondId(Long pondId) {
+        this.pondId = pondId;
+    }
+
+    /**
+     * 创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Document other = (Document) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
+            && (this.getPrizeId() == null ? other.getPrizeId() == null : this.getPrizeId().equals(other.getPrizeId()))
+            && (this.getPrizesNickname() == null ? other.getPrizesNickname() == null : this.getPrizesNickname().equals(other.getPrizesNickname()))
+            && (this.getPondId() == null ? other.getPondId() == null : this.getPondId().equals(other.getPondId()))
+            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
+        result = prime * result + ((getPrizeId() == null) ? 0 : getPrizeId().hashCode());
+        result = prime * result + ((getPrizesNickname() == null) ? 0 : getPrizesNickname().hashCode());
+        result = prime * result + ((getPondId() == null) ? 0 : getPondId().hashCode());
+        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", userId=").append(userId);
+        sb.append(", prizeId=").append(prizeId);
+        sb.append(", prizesNickname=").append(prizesNickname);
+        sb.append(", pondId=").append(pondId);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 315 - 0
src/main/java/com/zhentao/domain/Pond.java

@@ -0,0 +1,315 @@
+package com.zhentao.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 
+ * @TableName pond
+ */
+@TableName(value ="pond")
+public class Pond implements Serializable {
+    /**
+     * 奖池ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 奖池名称
+     */
+    private String name;
+
+    /**
+     * 是否免费 1:收费   0:免费
+     */
+    private Integer isfree;
+
+    /**
+     * 积分
+     */
+    private Integer poin;
+
+    /**
+     * 是否会员 1:会员  0:普通用户
+     */
+    private Integer ismember;
+
+    /**
+     * 状态 1:开启  0:关闭
+     */
+    private Integer status;
+
+    /**
+     * 抽奖次数
+     */
+    private Integer luckCount;
+
+    /**
+     * 人数 1:固定人数  0:不固定人数
+     */
+    private Integer people;
+
+    /**
+     * 是否固定时间 1:固定时间 0:不固定
+     */
+    private Integer times;
+
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 奖池ID
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * 奖池ID
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 奖池名称
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * 奖池名称
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 是否免费 1:收费   0:免费
+     */
+    public Integer getIsfree() {
+        return isfree;
+    }
+
+    /**
+     * 是否免费 1:收费   0:免费
+     */
+    public void setIsfree(Integer isfree) {
+        this.isfree = isfree;
+    }
+
+    /**
+     * 积分
+     */
+    public Integer getPoin() {
+        return poin;
+    }
+
+    /**
+     * 积分
+     */
+    public void setPoin(Integer poin) {
+        this.poin = poin;
+    }
+
+    /**
+     * 是否会员 1:会员  0:普通用户
+     */
+    public Integer getIsmember() {
+        return ismember;
+    }
+
+    /**
+     * 是否会员 1:会员  0:普通用户
+     */
+    public void setIsmember(Integer ismember) {
+        this.ismember = ismember;
+    }
+
+    /**
+     * 状态 1:开启  0:关闭
+     */
+    public Integer getStatus() {
+        return status;
+    }
+
+    /**
+     * 状态 1:开启  0:关闭
+     */
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    /**
+     * 抽奖次数
+     */
+    public Integer getLuckCount() {
+        return luckCount;
+    }
+
+    /**
+     * 抽奖次数
+     */
+    public void setLuckCount(Integer luckCount) {
+        this.luckCount = luckCount;
+    }
+
+    /**
+     * 人数 1:固定人数  0:不固定人数
+     */
+    public Integer getPeople() {
+        return people;
+    }
+
+    /**
+     * 人数 1:固定人数  0:不固定人数
+     */
+    public void setPeople(Integer people) {
+        this.people = people;
+    }
+
+    /**
+     * 是否固定时间 1:固定时间 0:不固定
+     */
+    public Integer getTimes() {
+        return times;
+    }
+
+    /**
+     * 是否固定时间 1:固定时间 0:不固定
+     */
+    public void setTimes(Integer times) {
+        this.times = times;
+    }
+
+    /**
+     * 开始时间
+     */
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    /**
+     * 开始时间
+     */
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    /**
+     * 结束时间
+     */
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    /**
+     * 结束时间
+     */
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    /**
+     * 创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Pond other = (Pond) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
+            && (this.getIsfree() == null ? other.getIsfree() == null : this.getIsfree().equals(other.getIsfree()))
+            && (this.getPoin() == null ? other.getPoin() == null : this.getPoin().equals(other.getPoin()))
+            && (this.getIsmember() == null ? other.getIsmember() == null : this.getIsmember().equals(other.getIsmember()))
+            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
+            && (this.getLuckCount() == null ? other.getLuckCount() == null : this.getLuckCount().equals(other.getLuckCount()))
+            && (this.getPeople() == null ? other.getPeople() == null : this.getPeople().equals(other.getPeople()))
+            && (this.getTimes() == null ? other.getTimes() == null : this.getTimes().equals(other.getTimes()))
+            && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
+            && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()))
+            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
+        result = prime * result + ((getIsfree() == null) ? 0 : getIsfree().hashCode());
+        result = prime * result + ((getPoin() == null) ? 0 : getPoin().hashCode());
+        result = prime * result + ((getIsmember() == null) ? 0 : getIsmember().hashCode());
+        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
+        result = prime * result + ((getLuckCount() == null) ? 0 : getLuckCount().hashCode());
+        result = prime * result + ((getPeople() == null) ? 0 : getPeople().hashCode());
+        result = prime * result + ((getTimes() == null) ? 0 : getTimes().hashCode());
+        result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
+        result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode());
+        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", name=").append(name);
+        sb.append(", isfree=").append(isfree);
+        sb.append(", poin=").append(poin);
+        sb.append(", ismember=").append(ismember);
+        sb.append(", status=").append(status);
+        sb.append(", luckCount=").append(luckCount);
+        sb.append(", people=").append(people);
+        sb.append(", times=").append(times);
+        sb.append(", startTime=").append(startTime);
+        sb.append(", endTime=").append(endTime);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 183 - 0
src/main/java/com/zhentao/domain/Prize.java

@@ -0,0 +1,183 @@
+package com.zhentao.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 
+ * @TableName prize
+ */
+@TableName(value ="prize")
+public class Prize implements Serializable {
+    /**
+     * 奖品ID
+     */
+    @TableId
+    private Long id;
+
+    /**
+     * 奖池ID
+     */
+    private Long pondId;
+
+    /**
+     * 奖品名称
+     */
+    private String prizeName;
+
+    /**
+     * 奖品数量
+     */
+    private Integer num;
+
+    /**
+     * 奖品状态
+     */
+    private String prizeStatus;
+
+    /**
+     * 价值
+     */
+    private BigDecimal price;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 奖品ID
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * 奖品ID
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 奖池ID
+     */
+    public Long getPondId() {
+        return pondId;
+    }
+
+    /**
+     * 奖池ID
+     */
+    public void setPondId(Long pondId) {
+        this.pondId = pondId;
+    }
+
+    /**
+     * 奖品名称
+     */
+    public String getPrizeName() {
+        return prizeName;
+    }
+
+    /**
+     * 奖品名称
+     */
+    public void setPrizeName(String prizeName) {
+        this.prizeName = prizeName;
+    }
+
+    /**
+     * 奖品数量
+     */
+    public Integer getNum() {
+        return num;
+    }
+
+    /**
+     * 奖品数量
+     */
+    public void setNum(Integer num) {
+        this.num = num;
+    }
+
+    /**
+     * 奖品状态
+     */
+    public String getPrizeStatus() {
+        return prizeStatus;
+    }
+
+    /**
+     * 奖品状态
+     */
+    public void setPrizeStatus(String prizeStatus) {
+        this.prizeStatus = prizeStatus;
+    }
+
+    /**
+     * 价值
+     */
+    public BigDecimal getPrice() {
+        return price;
+    }
+
+    /**
+     * 价值
+     */
+    public void setPrice(BigDecimal price) {
+        this.price = price;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Prize other = (Prize) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getPondId() == null ? other.getPondId() == null : this.getPondId().equals(other.getPondId()))
+            && (this.getPrizeName() == null ? other.getPrizeName() == null : this.getPrizeName().equals(other.getPrizeName()))
+            && (this.getNum() == null ? other.getNum() == null : this.getNum().equals(other.getNum()))
+            && (this.getPrizeStatus() == null ? other.getPrizeStatus() == null : this.getPrizeStatus().equals(other.getPrizeStatus()))
+            && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getPondId() == null) ? 0 : getPondId().hashCode());
+        result = prime * result + ((getPrizeName() == null) ? 0 : getPrizeName().hashCode());
+        result = prime * result + ((getNum() == null) ? 0 : getNum().hashCode());
+        result = prime * result + ((getPrizeStatus() == null) ? 0 : getPrizeStatus().hashCode());
+        result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", pondId=").append(pondId);
+        sb.append(", prizeName=").append(prizeName);
+        sb.append(", num=").append(num);
+        sb.append(", prizeStatus=").append(prizeStatus);
+        sb.append(", price=").append(price);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 183 - 0
src/main/java/com/zhentao/domain/UserLogin.java

@@ -0,0 +1,183 @@
+package com.zhentao.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 
+ * @TableName user_login
+ */
+@TableName(value ="user_login")
+public class UserLogin implements Serializable {
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    private Long userId;
+
+    /**
+     * 
+     */
+    private String username;
+
+    /**
+     * 
+     */
+    private String password;
+
+    /**
+     * 
+     */
+    private String salt;
+
+    /**
+     * 
+     */
+    private Date createTime;
+
+    /**
+     * 
+     */
+    private Date updateTime;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 
+     */
+    public Long getUserId() {
+        return userId;
+    }
+
+    /**
+     * 
+     */
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    /**
+     * 
+     */
+    public String getUsername() {
+        return username;
+    }
+
+    /**
+     * 
+     */
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    /**
+     * 
+     */
+    public String getPassword() {
+        return password;
+    }
+
+    /**
+     * 
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /**
+     * 
+     */
+    public String getSalt() {
+        return salt;
+    }
+
+    /**
+     * 
+     */
+    public void setSalt(String salt) {
+        this.salt = salt;
+    }
+
+    /**
+     * 
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * 
+     */
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    /**
+     * 
+     */
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        UserLogin other = (UserLogin) that;
+        return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
+            && (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
+            && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
+            && (this.getSalt() == null ? other.getSalt() == null : this.getSalt().equals(other.getSalt()))
+            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
+            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
+        result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
+        result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
+        result = prime * result + ((getSalt() == null) ? 0 : getSalt().hashCode());
+        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", userId=").append(userId);
+        sb.append(", username=").append(username);
+        sb.append(", password=").append(password);
+        sb.append(", salt=").append(salt);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 13 - 0
src/main/java/com/zhentao/dto/CjDto.java

@@ -0,0 +1,13 @@
+package com.zhentao.dto;
+
+import lombok.Data;
+
+@Data
+public class CjDto {
+    private Integer id;
+
+    private String name;
+
+
+    private Integer num;
+}

+ 13 - 0
src/main/java/com/zhentao/dto/LoginDto.java

@@ -0,0 +1,13 @@
+package com.zhentao.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class LoginDto {
+    @NotNull(message = "用户名不能为空")
+    private String username;
+    @NotNull(message = "密码不能为空")
+    private String password;
+}

+ 9 - 0
src/main/java/com/zhentao/dto/LotteryDto.java

@@ -0,0 +1,9 @@
+package com.zhentao.dto;
+
+import lombok.Data;
+
+@Data
+public class LotteryDto {
+
+    private Long pondId;
+}

+ 18 - 0
src/main/java/com/zhentao/mapper/DocumentMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.mapper;
+
+import com.zhentao.domain.Document;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author lenovo
+* @description 针对表【document】的数据库操作Mapper
+* @createDate 2025-11-28 15:02:01
+* @Entity com.zhentao.domain.Document
+*/
+public interface DocumentMapper extends BaseMapper<Document> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/zhentao/mapper/PondMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.mapper;
+
+import com.zhentao.domain.Pond;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author lenovo
+* @description 针对表【pond】的数据库操作Mapper
+* @createDate 2025-11-28 15:02:01
+* @Entity com.zhentao.domain.Pond
+*/
+public interface PondMapper extends BaseMapper<Pond> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/zhentao/mapper/PrizeMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.mapper;
+
+import com.zhentao.domain.Prize;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author lenovo
+* @description 针对表【prize】的数据库操作Mapper
+* @createDate 2025-11-28 15:02:01
+* @Entity com.zhentao.domain.Prize
+*/
+public interface PrizeMapper extends BaseMapper<Prize> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/zhentao/mapper/UserLoginMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.mapper;
+
+import com.zhentao.domain.UserLogin;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author lenovo
+* @description 针对表【user_login】的数据库操作Mapper
+* @createDate 2025-11-26 15:44:33
+* @Entity com.zhentao.domain.UserLogin
+*/
+public interface UserLoginMapper extends BaseMapper<UserLogin> {
+
+}
+
+
+
+

+ 13 - 0
src/main/java/com/zhentao/service/DocumentService.java

@@ -0,0 +1,13 @@
+package com.zhentao.service;
+
+import com.zhentao.domain.Document;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author lenovo
+* @description 针对表【document】的数据库操作Service
+* @createDate 2025-11-28 15:02:01
+*/
+public interface DocumentService extends IService<Document> {
+
+}

+ 14 - 0
src/main/java/com/zhentao/service/PondService.java

@@ -0,0 +1,14 @@
+package com.zhentao.service;
+
+import com.zhentao.domain.Pond;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author lenovo
+* @description 针对表【pond】的数据库操作Service
+* @createDate 2025-11-28 15:02:01
+*/
+public interface PondService extends IService<Pond> {
+
+    Pond getPond();//查询奖池
+}

+ 18 - 0
src/main/java/com/zhentao/service/PrizeService.java

@@ -0,0 +1,18 @@
+package com.zhentao.service;
+
+import com.zhentao.domain.Prize;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+* @author lenovo
+* @description 针对表【prize】的数据库操作Service
+* @createDate 2025-11-28 15:02:01
+*/
+public interface PrizeService extends IService<Prize> {
+
+    List<Prize> getPondList(Long pondId);//根据奖池ID找到属于该奖池的奖品
+
+    Boolean prizeNum(Long id);//根据奖品ID修改奖品的数量
+}

+ 15 - 0
src/main/java/com/zhentao/service/UserLoginService.java

@@ -0,0 +1,15 @@
+package com.zhentao.service;
+
+import com.zhentao.domain.UserLogin;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author lenovo
+* @description 针对表【user_login】的数据库操作Service
+* @createDate 2025-11-26 15:44:33
+*/
+public interface UserLoginService extends IService<UserLogin> {
+
+    UserLogin  selectUsername(String username);
+
+}

+ 9 - 0
src/main/java/com/zhentao/service/UserService.java

@@ -0,0 +1,9 @@
+package com.zhentao.service;
+
+import com.zhentao.dto.LoginDto;
+import com.zhentao.vo.Result;
+
+public interface UserService {
+
+    Result userLogin(LoginDto dto);
+}

+ 22 - 0
src/main/java/com/zhentao/service/impl/DocumentServiceImpl.java

@@ -0,0 +1,22 @@
+package com.zhentao.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.domain.Document;
+import com.zhentao.service.DocumentService;
+import com.zhentao.mapper.DocumentMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author lenovo
+* @description 针对表【document】的数据库操作Service实现
+* @createDate 2025-11-28 15:02:01
+*/
+@Service
+public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document>
+    implements DocumentService{
+
+}
+
+
+
+

+ 31 - 0
src/main/java/com/zhentao/service/impl/PondServiceImpl.java

@@ -0,0 +1,31 @@
+package com.zhentao.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.domain.Pond;
+import com.zhentao.service.PondService;
+import com.zhentao.mapper.PondMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author lenovo
+* @description 针对表【pond】的数据库操作Service实现
+* @createDate 2025-11-28 15:02:01
+*/
+@Service
+public class PondServiceImpl extends ServiceImpl<PondMapper, Pond>
+    implements PondService{
+
+    @Override
+    public Pond getPond() {
+        QueryWrapper wrapper = new QueryWrapper();
+        wrapper.eq("status",1);
+        wrapper.last("limit 1");
+        Pond one = this.getOne(wrapper);
+        return one;
+    }
+}
+
+
+
+

+ 44 - 0
src/main/java/com/zhentao/service/impl/PrizeServiceImpl.java

@@ -0,0 +1,44 @@
+package com.zhentao.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.domain.Prize;
+import com.zhentao.service.PrizeService;
+import com.zhentao.mapper.PrizeMapper;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+* @author lenovo
+* @description 针对表【prize】的数据库操作Service实现
+* @createDate 2025-11-28 15:02:01
+*/
+@Service
+public class PrizeServiceImpl extends ServiceImpl<PrizeMapper, Prize>
+    implements PrizeService{
+
+    @Override
+    public List<Prize> getPondList(Long pondId) {
+        QueryWrapper wrapper  = new QueryWrapper();
+        wrapper.eq("pond_id",pondId);
+        wrapper.eq("status",1);
+        wrapper.orderByAsc("prize_sort");
+        List<Prize> list = this.list();
+        return list;
+    }
+
+    @Override
+    public Boolean prizeNum(Long id) {
+        UpdateWrapper wrapper = new UpdateWrapper();
+        wrapper.eq("id",id);
+        wrapper.setSql("num=num-1");
+        boolean update = this.update(wrapper);
+        return update;
+    }
+}
+
+
+
+

+ 31 - 0
src/main/java/com/zhentao/service/impl/UserLoginServiceImpl.java

@@ -0,0 +1,31 @@
+package com.zhentao.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.domain.UserLogin;
+import com.zhentao.mapper.UserLoginMapper;
+import com.zhentao.service.UserLoginService;
+import org.springframework.stereotype.Service;
+
+/**
+* @author lenovo
+* @description 针对表【user_login】的数据库操作Service实现
+* @createDate 2025-11-26 15:44:33
+*/
+@Service
+public class UserLoginServiceImpl extends ServiceImpl<UserLoginMapper, UserLogin>
+    implements UserLoginService{
+
+    @Override
+    public UserLogin selectUsername(String username) {
+        LambdaQueryWrapper<UserLogin> wrapper = new LambdaQueryWrapper();
+        wrapper.select(UserLogin::getUserId,UserLogin::getUsername,UserLogin::getPassword,UserLogin::getSalt);
+        wrapper.eq(UserLogin::getUsername,username);
+        UserLogin userLogin = this.getBaseMapper().selectOne(wrapper);
+        return userLogin;
+    }
+}
+
+
+
+

+ 88 - 0
src/main/java/com/zhentao/service/impl/UserServiceImpl.java

@@ -0,0 +1,88 @@
+package com.zhentao.service.impl;
+
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.crypto.digest.MD5;
+import com.zhentao.common.config.RedisHostConfig;
+import com.zhentao.common.config.RedissonConfig;
+import com.zhentao.common.constant.CommonConstant;
+import com.zhentao.common.exception.ApiException;
+import com.zhentao.common.util.TokenUtils;
+import com.zhentao.domain.UserLogin;
+import com.zhentao.dto.LoginDto;
+import com.zhentao.service.UserLoginService;
+import com.zhentao.service.UserService;
+import com.zhentao.vo.LoginVo;
+import com.zhentao.vo.Result;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+@Service
+public class UserServiceImpl implements UserService {
+
+    @Autowired
+    private RedisHostConfig config;
+
+    @Autowired
+    private UserLoginService userLoginService;
+
+    @Autowired
+    private  RedisTemplate redisTemplate;
+
+
+    @Override
+    public Result userLogin(LoginDto dto) {
+        RedissonClient client = RedissonConfig.getRedissonClient(config.getRedisHost(), config.getRedisdb());
+        RLock lock = client.getLock("loginLock" + dto.getUsername());
+        try {
+            boolean b = lock.tryLock(10, 10, TimeUnit.SECONDS);
+            if(b){
+                System.out.println("Redisson锁获取成功,执行任务....");
+                UserLogin userLogin = userLoginService.selectUsername(dto.getUsername());
+                System.out.println(dto.getUsername());
+                if(userLogin==null){
+//                    注册
+                    UserLogin user = new UserLogin();
+                    Long l = IdUtil.getSnowflake().nextId();
+                    user.setUserId(l);
+                    user.setCreateTime(new Date());
+                    user.setUsername(dto.getUsername());
+                    String salt = UUID.randomUUID().toString();
+                    String newPassword = MD5.create().digestHex16(dto.getPassword() + salt);
+                    user.setPassword(newPassword);
+                    user.setSalt(salt);
+                    userLoginService.save(user);
+                    return Result.OK(user);
+                }else {
+                    String password = userLogin.getPassword();
+                    String salt = userLogin.getSalt();
+                    String newPassword = MD5.create().digestHex16(dto.getPassword() + salt);
+                    if(!password.equals(newPassword)){
+                        throw new ApiException(000,"用户名或密码错误");
+                    }
+                }
+
+                String token = TokenUtils.createJwtToken(userLogin.getUserId().toString());
+                LoginVo loginVo = new LoginVo();
+                loginVo.setUsername(userLogin.getUsername());
+                loginVo.setToken(token);
+                redisTemplate.opsForValue().set(CommonConstant.TOKEN,userLogin.getUserId());
+                return Result.OK(loginVo);
+            }
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }finally {
+            if(lock.isHeldByCurrentThread()){
+                lock.unlock();
+            }
+        }
+        client.shutdown();
+        return Result.fail(1001,"error");
+    }
+}

+ 25 - 0
src/main/java/com/zhentao/student.java

@@ -0,0 +1,25 @@
+package com.zhentao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class student {
+    public static void main(String[] args) {
+        Map<Integer,String> map = new HashMap<>();
+        map.put(1,"A");
+        map.put(2,"B");
+        //Map 转 Entry 列表
+        List<Map.Entry<Integer,String>> list =map.entrySet().stream().collect(Collectors.toList());
+        System.out.println(list);
+
+//        Map 转 Key 列表
+        List<Integer> list1 = map.keySet().stream().collect(Collectors.toList());
+        System.out.println(list1);
+//        Map 转 Value 列表
+        List<String> list2 = map.values().stream().collect(Collectors.toList());
+        System.out.println(list2);
+    }
+
+}

+ 40 - 0
src/main/java/com/zhentao/user.java

@@ -0,0 +1,40 @@
+package com.zhentao;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+@Data
+@AllArgsConstructor
+public class user {
+    private Integer id;
+
+    private String name;
+
+//list转map
+    public static void main(String[] args) {
+        List<user> list = new ArrayList<>();
+        list.add(new user(1,"虞江增"));
+        list.add(new user(2,"张云淞"));
+        list.add(new user(3,"李凯"));
+        Map<Integer, user> map = list.stream().collect(Collectors.toMap(user::getId, Function.identity()));
+        System.out.println(map);
+        Map<Integer ,String> map1 = list.stream().collect(Collectors.toMap(user::getId,user::getName));
+        System.out.println(map1);
+
+
+
+        //当有id重复时,用新的覆盖旧的
+        list.add(new user(1,"申书豪"));
+        list.add(new user(2,"申子硕"));
+        list.add(new user(3,"于鑫洋"));
+        Map<Integer,user> map2 = list.stream().collect(Collectors.toMap(user::getId,Function.identity(),((user, user2) -> user2)));
+        System.out.println(map2);
+
+    }
+}

+ 10 - 0
src/main/java/com/zhentao/vo/LoginVo.java

@@ -0,0 +1,10 @@
+package com.zhentao.vo;
+
+import lombok.Data;
+
+@Data
+public class LoginVo {
+
+    private String username;
+    private String token;
+}

+ 54 - 0
src/main/java/com/zhentao/vo/Result.java

@@ -0,0 +1,54 @@
+package com.zhentao.vo;
+
+import cn.hutool.http.HttpStatus;
+import com.zhentao.common.constant.CommonConstant;
+import lombok.Data;
+
+@Data
+public class Result<T> {
+
+    private Integer code;
+
+    private String msg;
+
+    private T data;
+
+
+
+    public static Result OK(){
+        Result result  = new Result();
+        result.setCode(HttpStatus.HTTP_OK);
+        result.setMsg(CommonConstant.SUCCESS_MSG);
+        return result;
+    }
+
+
+    public static Result OK(Object data){
+        Result result  = new Result();
+        result.setCode(HttpStatus.HTTP_OK);
+        result.setMsg(CommonConstant.SUCCESS_MSG);
+        result.setData(data);
+        return result;
+    }
+
+
+
+
+    public static Result fail(){
+        Result result  = new Result();
+        result.setCode(HttpStatus.HTTP_OK);
+        result.setMsg(CommonConstant.SUCCESS_MSG);
+        return result;
+    }
+
+
+
+
+
+    public static Result fail(Integer code,String msg){
+        Result result  = new Result();
+        result.setCode(code);
+        result.setMsg(msg);
+        return result;
+    }
+}

+ 127 - 0
src/main/resources/application-dev.yml

@@ -0,0 +1,127 @@
+server:
+  # 服务器的HTTP端口,默认为8080
+  port: 8099
+  servlet:
+    # 应用的访问路径
+    context-path: /
+    multipart:
+      max-file-size: 20MB   # 最大文件大小
+      max-request-size: 20MB # 最大请求大小,包括文件内容和表单数据
+  tomcat:
+    # tomcat的URI编码
+    uri-encoding: UTF-8
+    # 连接数满后的排队数,默认为100
+    accept-count: 1000
+    threads:
+      # tomcat最大线程数,默认为200
+      max: 800
+      # Tomcat启动初始化的线程数,默认值10
+      min-spare: 100
+
+# 数据源配置
+spring:
+  datasource:
+    druid:
+      url: jdbc:mysql://127.0.0.1:3306/shop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+      username: root
+      password: root
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: futu
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1500
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+      type: com.alibaba.druid.pool.DruidDataSource
+      driver-class-name: com.mysql.cj.jdbc.Driver
+  redis:
+    # 地址
+    host: 127.0.0.1
+    # 端口,默认为6379
+    port: 6379
+    # 数据库索引
+    database: 1
+    # 密码
+    password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+  kafka:
+    producer:
+      key-serializer: org.apache.kafka.common.serialization.StringSerializer
+      value-serializer: org.apache.kafka.common.serialization.StringSerializer
+      batch-size: 16384
+      buffer-memory: 33554432
+      retries: 3
+      linger: 1
+    bootstrap-servers: 47.113.122.246:9092
+    consumer:
+      group-id: my-group
+      auto-offset-reset: earliest #latest
+      enable-auto-commit: false
+      auto-commit-interval: 100
+      max-poll-records: 500
+      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+
+  elasticsearch:
+    uris: http://localhost:9200
+
+xss:
+  # 过滤开关
+  enabled: true
+  # 排除链接(多个用逗号分隔)
+  excludes: /system/notice
+  # 匹配链接
+  urlPatterns: /api/commit,/monitor/*,/tool/*
+
+
+swagger:
+    enable: true
+redisson:
+    singleServerConfig:
+    idleConnectionTimeout: 10000
+    connectTimeout: 10000
+    timeout: 3000
+    retryAttempts: 3

+ 120 - 0
src/main/resources/application-prod.yml

@@ -0,0 +1,120 @@
+server:
+  # 服务器的HTTP端口,默认为8080
+  port: 8099
+  servlet:
+    # 应用的访问路径
+    context-path: /
+    multipart:
+      max-file-size: 20MB   # 最大文件大小
+      max-request-size: 20MB # 最大请求大小,包括文件内容和表单数据
+  tomcat:
+    # tomcat的URI编码
+    uri-encoding: UTF-8
+    # 连接数满后的排队数,默认为100
+    accept-count: 1000
+    threads:
+      # tomcat最大线程数,默认为200
+      max: 800
+      # Tomcat启动初始化的线程数,默认值10
+      min-spare: 100
+
+# 数据源配置
+spring:
+  datasource:
+    druid:
+      url: jdbc:mysql://127.0.0.1:3306/shop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+      username: root
+      password: book
+      # 初始连接数
+      initialSize: 5
+      # 最小连接池数量
+      minIdle: 10
+      # 最大连接池数量
+      maxActive: 20
+      # 配置获取连接等待超时的时间
+      maxWait: 60000
+      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+      timeBetweenEvictionRunsMillis: 60000
+      # 配置一个连接在池中最小生存的时间,单位是毫秒
+      minEvictableIdleTimeMillis: 300000
+      # 配置一个连接在池中最大生存的时间,单位是毫秒
+      maxEvictableIdleTimeMillis: 900000
+      # 配置检测连接是否有效
+      validationQuery: SELECT 1 FROM DUAL
+      testWhileIdle: true
+      testOnBorrow: false
+      testOnReturn: false
+      webStatFilter:
+        enabled: true
+      statViewServlet:
+        enabled: true
+        # 设置白名单,不填则允许所有访问
+        allow:
+        url-pattern: /druid/*
+        # 控制台管理用户名和密码
+        login-username: futu
+        login-password: 123456
+      filter:
+        stat:
+          enabled: true
+          # 慢SQL记录
+          log-slow-sql: true
+          slow-sql-millis: 1500
+          merge-sql: true
+        wall:
+          config:
+            multi-statement-allow: true
+      type: com.alibaba.druid.pool.DruidDataSource
+      driver-class-name: com.mysql.cj.jdbc.Driver
+  redis:
+    # 地址
+    host: 127.0.0.1
+    # 端口,默认为6379
+    port: 6379
+    # 数据库索引
+    database: 1
+    # 密码
+    password:
+    # 连接超时时间
+    timeout: 10s
+    lettuce:
+      pool:
+        # 连接池中的最小空闲连接
+        min-idle: 0
+        # 连接池中的最大空闲连接
+        max-idle: 8
+        # 连接池的最大数据库连接数
+        max-active: 8
+        # #连接池最大阻塞等待时间(使用负值表示没有限制)
+        max-wait: -1ms
+  kafka:
+    producer:
+      key-serializer: org.apache.kafka.common.serialization.StringSerializer
+      value-serializer: org.apache.kafka.common.serialization.StringSerializer
+      batch-size: 16384
+      buffer-memory: 33554432
+      retries: 3
+      linger: 1
+    bootstrap-servers: 47.113.122.246:9092
+    consumer:
+      group-id: my-group
+      auto-offset-reset: earliest #latest
+      enable-auto-commit: false
+      auto-commit-interval: 100
+      max-poll-records: 500
+      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
+
+  elasticsearch:
+    uris: http://localhost:9200
+
+xss:
+  # 过滤开关
+  enabled: true
+  # 排除链接(多个用逗号分隔)
+  excludes: /system/notice
+  # 匹配链接
+  urlPatterns: /api/commit,/monitor/*,/tool/*
+
+swagger:
+    enable: false

+ 27 - 0
src/main/resources/application.yml

@@ -0,0 +1,27 @@
+spring:
+  profiles:
+    active: dev
+
+mybatis-plus:
+  mapper-locations: classpath*:/mapper/**/*.xml
+  #实体扫描,多个package用逗号或者分号分隔
+  type-aliases-package: com.futu.*.domain
+  global-config:
+    #数据库相关配置
+    db-config:
+      #主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
+      #      id-type: AUTO
+      logic-delete-value: 1
+      logic-not-delete-value: 0
+    banner: false
+  #原生配置
+  configuration:
+    map-underscore-to-camel-case: true
+    cache-enabled: false
+    call-setters-on-nulls: true
+    jdbc-type-for-null: 'null'
+#  type-handlers-package: com.waker.best.commons.handle
+#  typeEnumsPackage: com.waker.best.domain.enums
+springfox:
+    documentation:
+          enabled: true

+ 20 - 0
src/main/resources/mapper/DocumentMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.DocumentMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.domain.Document">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="userId" column="user_id" jdbcType="BIGINT"/>
+            <result property="prizeId" column="prize_id" jdbcType="BIGINT"/>
+            <result property="prizesNickname" column="prizes_nickname" jdbcType="VARCHAR"/>
+            <result property="pondId" column="pond_id" jdbcType="BIGINT"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,user_id,prize_id,
+        prizes_nickname,pond_id,create_time
+    </sql>
+</mapper>

+ 28 - 0
src/main/resources/mapper/PondMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.PondMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.domain.Pond">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="name" column="name" jdbcType="VARCHAR"/>
+            <result property="isfree" column="isfree" jdbcType="TINYINT"/>
+            <result property="poin" column="poin" jdbcType="INTEGER"/>
+            <result property="ismember" column="ismember" jdbcType="TINYINT"/>
+            <result property="status" column="status" jdbcType="TINYINT"/>
+            <result property="luckCount" column="luck_count" jdbcType="INTEGER"/>
+            <result property="people" column="people" jdbcType="INTEGER"/>
+            <result property="times" column="times" jdbcType="TINYINT"/>
+            <result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
+            <result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,name,isfree,
+        poin,ismember,status,
+        luck_count,people,times,
+        start_time,end_time,create_time
+    </sql>
+</mapper>

+ 20 - 0
src/main/resources/mapper/PrizeMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.PrizeMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.domain.Prize">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="pondId" column="pond_id" jdbcType="BIGINT"/>
+            <result property="prizeName" column="prize_name" jdbcType="VARCHAR"/>
+            <result property="num" column="num" jdbcType="INTEGER"/>
+            <result property="prizeStatus" column="prize_status" jdbcType="VARCHAR"/>
+            <result property="price" column="price" jdbcType="DECIMAL"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,pond_id,prize_name,
+        num,prize_status,price
+    </sql>
+</mapper>

+ 20 - 0
src/main/resources/mapper/UserLoginMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.mapper.UserLoginMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.domain.UserLogin">
+            <id property="userId" column="user_id" jdbcType="BIGINT"/>
+            <result property="username" column="username" jdbcType="VARCHAR"/>
+            <result property="password" column="password" jdbcType="VARCHAR"/>
+            <result property="salt" column="salt" jdbcType="VARCHAR"/>
+            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        user_id,username,password,
+        salt,create_time,update_time
+    </sql>
+</mapper>

+ 13 - 0
src/test/java/com/zhentao/Demo1ApplicationTests.java

@@ -0,0 +1,13 @@
+package com.zhentao;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class Demo1ApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}