Commit 93eb74bac1543aca3dcdf1981330efbaf1ae3811
Merge branch 'dev' of http://101.95.0.106:8888/youxiw20000/trash into dev
Showing
44 changed files
with
329 additions
and
1206 deletions
trash-admin/pom.xml
| @@ -90,6 +90,11 @@ | @@ -90,6 +90,11 @@ | ||
| 90 | <groupId>com.trash</groupId> | 90 | <groupId>com.trash</groupId> |
| 91 | <artifactId>trash-unit</artifactId> | 91 | <artifactId>trash-unit</artifactId> |
| 92 | </dependency> | 92 | </dependency> |
| 93 | + <dependency> | ||
| 94 | + <groupId>com.trash</groupId> | ||
| 95 | + <artifactId>trash-garbage</artifactId> | ||
| 96 | + <version>3.2.0</version> | ||
| 97 | + </dependency> | ||
| 93 | </dependencies> | 98 | </dependencies> |
| 94 | 99 | ||
| 95 | <build> | 100 | <build> |
trash-admin/src/main/resources/application-dev.yml
| @@ -32,10 +32,10 @@ spring: | @@ -32,10 +32,10 @@ spring: | ||
| 32 | druid: | 32 | druid: |
| 33 | # 主库数据源 | 33 | # 主库数据源 |
| 34 | master: | 34 | master: |
| 35 | - #url: jdbc:mysql://localhost:3306/trash?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true | ||
| 36 | - url: jdbc:mysql://192.168.168.141:3306/trash?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true | 35 | + url: jdbc:mysql://localhost:3306/trash?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true |
| 36 | +# url: jdbc:mysql://192.168.168.141:3306/trash?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true | ||
| 37 | username: root | 37 | username: root |
| 38 | - password: root | 38 | + password: guzijian |
| 39 | # 从库数据源 | 39 | # 从库数据源 |
| 40 | slave: | 40 | slave: |
| 41 | # 从数据源开关/默认关闭 | 41 | # 从数据源开关/默认关闭 |
trash-admin/src/main/resources/application.yml
| @@ -58,14 +58,14 @@ token: | @@ -58,14 +58,14 @@ token: | ||
| 58 | # 令牌有效期(默认30分钟) | 58 | # 令牌有效期(默认30分钟) |
| 59 | expireTime: 120 | 59 | expireTime: 120 |
| 60 | 60 | ||
| 61 | -# MyBatis配置 | ||
| 62 | -mybatis: | ||
| 63 | - # 搜索指定包别名 | ||
| 64 | - typeAliasesPackage: com.trash.**.domain | ||
| 65 | - # 配置mapper的扫描,找到所有的mapper.xml映射文件 | ||
| 66 | - mapperLocations: classpath*:mapper/**/*Mapper.xml | ||
| 67 | - # 加载全局的配置文件 | ||
| 68 | - configLocation: classpath:mybatis/mybatis-config.xml | 61 | +# MyBatis Plus配置 |
| 62 | +mybatis-plus: | ||
| 63 | + # 搜索指定包别名 | ||
| 64 | + typeAliasesPackage: com.trash.**.domain | ||
| 65 | + # 配置mapper的扫描,找到所有的mapper.xml映射文件 | ||
| 66 | + mapperLocations: classpath*:mapper/**/*Mapper.xml | ||
| 67 | + # 加载全局的配置文件 | ||
| 68 | + configLocation: classpath:mybatis/mybatis-config.xml | ||
| 69 | 69 | ||
| 70 | # PageHelper分页插件 | 70 | # PageHelper分页插件 |
| 71 | pagehelper: | 71 | pagehelper: |
trash-common/pom.xml
| @@ -124,6 +124,12 @@ | @@ -124,6 +124,12 @@ | ||
| 124 | <artifactId>esdk-obs-java</artifactId> | 124 | <artifactId>esdk-obs-java</artifactId> |
| 125 | <version>[3.20.6.1,)</version> | 125 | <version>[3.20.6.1,)</version> |
| 126 | </dependency> | 126 | </dependency> |
| 127 | + <!-- mybatis-plus 增强CRUD --> | ||
| 128 | + <dependency> | ||
| 129 | + <groupId>com.baomidou</groupId> | ||
| 130 | + <artifactId>mybatis-plus-boot-starter</artifactId> | ||
| 131 | + <version>3.4.1</version> | ||
| 132 | + </dependency> | ||
| 127 | 133 | ||
| 128 | </dependencies> | 134 | </dependencies> |
| 129 | 135 |
trash-framework/pom.xml
| @@ -34,11 +34,13 @@ | @@ -34,11 +34,13 @@ | ||
| 34 | <groupId>com.alibaba</groupId> | 34 | <groupId>com.alibaba</groupId> |
| 35 | <artifactId>druid-spring-boot-starter</artifactId> | 35 | <artifactId>druid-spring-boot-starter</artifactId> |
| 36 | </dependency> | 36 | </dependency> |
| 37 | + <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter --> | ||
| 37 | <dependency> | 38 | <dependency> |
| 38 | <groupId>org.mybatis.spring.boot</groupId> | 39 | <groupId>org.mybatis.spring.boot</groupId> |
| 39 | <artifactId>mybatis-spring-boot-starter</artifactId> | 40 | <artifactId>mybatis-spring-boot-starter</artifactId> |
| 40 | - <version>2.1.2</version> | 41 | + <version>2.3.1</version> |
| 41 | </dependency> | 42 | </dependency> |
| 43 | + | ||
| 42 | <!-- 验证码 --> | 44 | <!-- 验证码 --> |
| 43 | <dependency> | 45 | <dependency> |
| 44 | <groupId>com.github.penggle</groupId> | 46 | <groupId>com.github.penggle</groupId> |
trash-framework/src/main/java/com/trash/framework/config/MyBatisConfig.java deleted
100644 → 0
| 1 | -package com.trash.framework.config; | ||
| 2 | - | ||
| 3 | -import java.io.IOException; | ||
| 4 | -import java.util.ArrayList; | ||
| 5 | -import java.util.HashSet; | ||
| 6 | -import java.util.List; | ||
| 7 | -import javax.sql.DataSource; | ||
| 8 | -import org.apache.ibatis.io.VFS; | ||
| 9 | -import org.apache.ibatis.session.SqlSessionFactory; | ||
| 10 | -import org.mybatis.spring.SqlSessionFactoryBean; | ||
| 11 | -import org.mybatis.spring.boot.autoconfigure.SpringBootVFS; | ||
| 12 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | -import org.springframework.context.annotation.Bean; | ||
| 14 | -import org.springframework.context.annotation.Configuration; | ||
| 15 | -import org.springframework.core.env.Environment; | ||
| 16 | -import org.springframework.core.io.DefaultResourceLoader; | ||
| 17 | -import org.springframework.core.io.Resource; | ||
| 18 | -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | ||
| 19 | -import org.springframework.core.io.support.ResourcePatternResolver; | ||
| 20 | -import org.springframework.core.type.classreading.CachingMetadataReaderFactory; | ||
| 21 | -import org.springframework.core.type.classreading.MetadataReader; | ||
| 22 | -import org.springframework.core.type.classreading.MetadataReaderFactory; | ||
| 23 | -import org.springframework.util.ClassUtils; | ||
| 24 | - | ||
| 25 | -/** | ||
| 26 | - * Mybatis支持*匹配扫描包 | ||
| 27 | - * | ||
| 28 | - * @author trash | ||
| 29 | - */ | ||
| 30 | -@Configuration | ||
| 31 | -public class MyBatisConfig | ||
| 32 | -{ | ||
| 33 | - @Autowired | ||
| 34 | - private Environment env; | ||
| 35 | - | ||
| 36 | - static final String DEFAULT_RESOURCE_PATTERN = "**/*.class"; | ||
| 37 | - | ||
| 38 | - public static String setTypeAliasesPackage(String typeAliasesPackage) | ||
| 39 | - { | ||
| 40 | - ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); | ||
| 41 | - MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver); | ||
| 42 | - List<String> allResult = new ArrayList<String>(); | ||
| 43 | - try | ||
| 44 | - { | ||
| 45 | - for (String aliasesPackage : typeAliasesPackage.split(",")) | ||
| 46 | - { | ||
| 47 | - List<String> result = new ArrayList<String>(); | ||
| 48 | - aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX | ||
| 49 | - + ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN; | ||
| 50 | - Resource[] resources = resolver.getResources(aliasesPackage); | ||
| 51 | - if (resources != null && resources.length > 0) | ||
| 52 | - { | ||
| 53 | - MetadataReader metadataReader = null; | ||
| 54 | - for (Resource resource : resources) | ||
| 55 | - { | ||
| 56 | - if (resource.isReadable()) | ||
| 57 | - { | ||
| 58 | - metadataReader = metadataReaderFactory.getMetadataReader(resource); | ||
| 59 | - try | ||
| 60 | - { | ||
| 61 | - result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName()); | ||
| 62 | - } | ||
| 63 | - catch (ClassNotFoundException e) | ||
| 64 | - { | ||
| 65 | - e.printStackTrace(); | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - } | ||
| 69 | - } | ||
| 70 | - if (result.size() > 0) | ||
| 71 | - { | ||
| 72 | - HashSet<String> hashResult = new HashSet<String>(result); | ||
| 73 | - allResult.addAll(hashResult); | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - if (allResult.size() > 0) | ||
| 77 | - { | ||
| 78 | - typeAliasesPackage = String.join(",", allResult.toArray(new String[0])); | ||
| 79 | - } | ||
| 80 | - else | ||
| 81 | - { | ||
| 82 | - throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包"); | ||
| 83 | - } | ||
| 84 | - } | ||
| 85 | - catch (IOException e) | ||
| 86 | - { | ||
| 87 | - e.printStackTrace(); | ||
| 88 | - } | ||
| 89 | - return typeAliasesPackage; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - @Bean | ||
| 93 | - public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception | ||
| 94 | - { | ||
| 95 | - String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage"); | ||
| 96 | - String mapperLocations = env.getProperty("mybatis.mapperLocations"); | ||
| 97 | - String configLocation = env.getProperty("mybatis.configLocation"); | ||
| 98 | - typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage); | ||
| 99 | - VFS.addImplClass(SpringBootVFS.class); | ||
| 100 | - | ||
| 101 | - final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); | ||
| 102 | - sessionFactory.setDataSource(dataSource); | ||
| 103 | - sessionFactory.setTypeAliasesPackage(typeAliasesPackage); | ||
| 104 | - sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations)); | ||
| 105 | - sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation)); | ||
| 106 | - return sessionFactory.getObject(); | ||
| 107 | - } | ||
| 108 | -} | ||
| 109 | \ No newline at end of file | 0 | \ No newline at end of file |
trash-framework/src/main/java/com/trash/framework/config/MybatisPlusConfig.java
0 → 100644
| 1 | +package com.trash.framework.config; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.DbType; | ||
| 4 | +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | ||
| 5 | +import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor; | ||
| 6 | +import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; | ||
| 7 | +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; | ||
| 8 | +import org.springframework.context.annotation.Bean; | ||
| 9 | +import org.springframework.context.annotation.Configuration; | ||
| 10 | +import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Mybatis Plus 配置 | ||
| 14 | + * | ||
| 15 | + * @author ruoyi | ||
| 16 | + */ | ||
| 17 | +@EnableTransactionManagement(proxyTargetClass = true) | ||
| 18 | +@Configuration | ||
| 19 | +public class MybatisPlusConfig | ||
| 20 | +{ | ||
| 21 | + @Bean | ||
| 22 | + public MybatisPlusInterceptor mybatisPlusInterceptor() | ||
| 23 | + { | ||
| 24 | + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); | ||
| 25 | + // 分页插件 | ||
| 26 | + interceptor.addInnerInterceptor(paginationInnerInterceptor()); | ||
| 27 | + // 乐观锁插件 | ||
| 28 | + interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor()); | ||
| 29 | + // 阻断插件 | ||
| 30 | + interceptor.addInnerInterceptor(blockAttackInnerInterceptor()); | ||
| 31 | + return interceptor; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html | ||
| 36 | + */ | ||
| 37 | + public PaginationInnerInterceptor paginationInnerInterceptor() | ||
| 38 | + { | ||
| 39 | + PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(); | ||
| 40 | + // 设置数据库类型为mysql | ||
| 41 | + paginationInnerInterceptor.setDbType(DbType.MYSQL); | ||
| 42 | + // 设置最大单页限制数量,默认 500 条,-1 不受限制 | ||
| 43 | + paginationInnerInterceptor.setMaxLimit(-1L); | ||
| 44 | + return paginationInnerInterceptor; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 乐观锁插件 https://baomidou.com/guide/interceptor-optimistic-locker.html | ||
| 49 | + */ | ||
| 50 | + public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() | ||
| 51 | + { | ||
| 52 | + return new OptimisticLockerInnerInterceptor(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 如果是对全表的删除或更新操作,就会终止该操作 https://baomidou.com/guide/interceptor-block-attack.html | ||
| 57 | + */ | ||
| 58 | + public BlockAttackInnerInterceptor blockAttackInnerInterceptor() | ||
| 59 | + { | ||
| 60 | + return new BlockAttackInnerInterceptor(); | ||
| 61 | + } | ||
| 62 | +} | ||
| 0 | \ No newline at end of file | 63 | \ No newline at end of file |
trash-framework/src/main/java/com/trash/framework/config/SecurityConfig.java
| @@ -117,6 +117,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter | @@ -117,6 +117,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter | ||
| 117 | .antMatchers("/webjars/**").anonymous() | 117 | .antMatchers("/webjars/**").anonymous() |
| 118 | .antMatchers("/*/api-docs").anonymous() | 118 | .antMatchers("/*/api-docs").anonymous() |
| 119 | .antMatchers("/druid/**").anonymous() | 119 | .antMatchers("/druid/**").anonymous() |
| 120 | + .antMatchers("/user/login").anonymous() | ||
| 121 | + .antMatchers("/user/send/verify").anonymous() | ||
| 122 | + .antMatchers("/user/logout").anonymous() | ||
| 120 | .antMatchers("/system/post/all").anonymous() | 123 | .antMatchers("/system/post/all").anonymous() |
| 121 | .antMatchers("/system/user/all").anonymous() | 124 | .antMatchers("/system/user/all").anonymous() |
| 122 | // .antMatchers("/workflow/add").anonymous()//测试 | 125 | // .antMatchers("/workflow/add").anonymous()//测试 |
trash-garbage/pom.xml
| @@ -8,111 +8,56 @@ | @@ -8,111 +8,56 @@ | ||
| 8 | <version>3.2.0</version> | 8 | <version>3.2.0</version> |
| 9 | </parent> | 9 | </parent> |
| 10 | <modelVersion>4.0.0</modelVersion> | 10 | <modelVersion>4.0.0</modelVersion> |
| 11 | - | ||
| 12 | <artifactId>trash-garbage</artifactId> | 11 | <artifactId>trash-garbage</artifactId> |
| 13 | - | ||
| 14 | <properties> | 12 | <properties> |
| 15 | <maven.compiler.source>8</maven.compiler.source> | 13 | <maven.compiler.source>8</maven.compiler.source> |
| 16 | <maven.compiler.target>8</maven.compiler.target> | 14 | <maven.compiler.target>8</maven.compiler.target> |
| 17 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | 15 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| 18 | </properties> | 16 | </properties> |
| 19 | - | ||
| 20 | <dependencies> | 17 | <dependencies> |
| 21 | <dependency> | 18 | <dependency> |
| 22 | <groupId>com.trash</groupId> | 19 | <groupId>com.trash</groupId> |
| 23 | <artifactId>trash-common</artifactId> | 20 | <artifactId>trash-common</artifactId> |
| 24 | </dependency> | 21 | </dependency> |
| 25 | - <!-- mysql connect--> | ||
| 26 | - <dependency> | ||
| 27 | - <groupId>mysql</groupId> | ||
| 28 | - <artifactId>mysql-connector-java</artifactId> | ||
| 29 | - </dependency> | ||
| 30 | <dependency> | 22 | <dependency> |
| 31 | - <groupId>com.alibaba</groupId> | ||
| 32 | - <artifactId>druid-spring-boot-starter</artifactId> | ||
| 33 | - <version>1.2.1</version> | 23 | + <groupId>com.trash</groupId> |
| 24 | + <artifactId>trash-activiti</artifactId> | ||
| 34 | </dependency> | 25 | </dependency> |
| 35 | - <!-- mybatis plus--> | ||
| 36 | <dependency> | 26 | <dependency> |
| 37 | - <groupId>com.baomidou</groupId> | ||
| 38 | - <artifactId>mybatis-plus-boot-starter</artifactId> | ||
| 39 | - <version>3.5.4.1</version> | 27 | + <groupId>com.trash</groupId> |
| 28 | + <artifactId>trash-framework</artifactId> | ||
| 40 | </dependency> | 29 | </dependency> |
| 41 | <dependency> | 30 | <dependency> |
| 42 | - <groupId>org.springframework.boot</groupId> | ||
| 43 | - <artifactId>spring-boot-starter-web</artifactId> | 31 | + <groupId>com.aliyun</groupId> |
| 32 | + <artifactId>aliyun-java-sdk-core</artifactId> | ||
| 33 | + <version>4.5.16</version> | ||
| 44 | </dependency> | 34 | </dependency> |
| 45 | - <!-- knife4j swagger-ui--> | ||
| 46 | <dependency> | 35 | <dependency> |
| 47 | - <groupId>com.github.xiaoymin</groupId> | ||
| 48 | - <artifactId>knife4j-spring-boot-starter</artifactId> | ||
| 49 | - <!--在引用时请在maven中央仓库搜索2.X最新版本号--> | ||
| 50 | - <version>2.0.7</version> | 36 | + <groupId>com.aliyun</groupId> |
| 37 | + <artifactId>aliyun-java-sdk-dysmsapi</artifactId> | ||
| 38 | + <version>2.1.0</version> | ||
| 51 | </dependency> | 39 | </dependency> |
| 52 | <dependency> | 40 | <dependency> |
| 53 | <groupId>org.projectlombok</groupId> | 41 | <groupId>org.projectlombok</groupId> |
| 54 | <artifactId>lombok</artifactId> | 42 | <artifactId>lombok</artifactId> |
| 55 | </dependency> | 43 | </dependency> |
| 56 | - <!-- jjwt --> | ||
| 57 | - <dependency> | ||
| 58 | - <groupId>io.jsonwebtoken</groupId> | ||
| 59 | - <artifactId>jjwt</artifactId> | ||
| 60 | - </dependency> | ||
| 61 | - <!-- fastjson--> | ||
| 62 | - <dependency> | ||
| 63 | - <groupId>com.alibaba</groupId> | ||
| 64 | - <artifactId>fastjson</artifactId> | ||
| 65 | - </dependency> | ||
| 66 | - <!-- hutool 工具包--> | ||
| 67 | <dependency> | 44 | <dependency> |
| 68 | <groupId>cn.hutool</groupId> | 45 | <groupId>cn.hutool</groupId> |
| 69 | <artifactId>hutool-all</artifactId> | 46 | <artifactId>hutool-all</artifactId> |
| 70 | <version>5.3.8</version> | 47 | <version>5.3.8</version> |
| 71 | </dependency> | 48 | </dependency> |
| 72 | - <!-- 引入redis连接池的依赖 --> | ||
| 73 | - <!-- 我配置文件配置了redis连接池 所以需要这个依赖--> | ||
| 74 | - <dependency> | ||
| 75 | - <groupId>org.apache.commons</groupId> | ||
| 76 | - <artifactId>commons-pool2</artifactId> | ||
| 77 | - <version>2.8.1</version> | ||
| 78 | - </dependency> | ||
| 79 | - <dependency> | ||
| 80 | - <groupId>org.springframework</groupId> | ||
| 81 | - <artifactId>spring-webmvc</artifactId> | ||
| 82 | - </dependency> | ||
| 83 | - <!-- jackson 2.x 相关依赖 --> | ||
| 84 | - | ||
| 85 | - <dependency> | ||
| 86 | - <groupId>com.fasterxml.jackson.core</groupId> | ||
| 87 | - <artifactId>jackson-core</artifactId> | ||
| 88 | - </dependency> | ||
| 89 | - <dependency> | ||
| 90 | - <groupId>com.fasterxml.jackson.core</groupId> | ||
| 91 | - <artifactId>jackson-databind</artifactId> | ||
| 92 | - </dependency> | ||
| 93 | - <dependency> | ||
| 94 | - <groupId>com.fasterxml.jackson.core</groupId> | ||
| 95 | - <artifactId>jackson-annotations</artifactId> | ||
| 96 | - </dependency> | ||
| 97 | - <dependency> | ||
| 98 | - <groupId>com.aliyun</groupId> | ||
| 99 | - <artifactId>aliyun-java-sdk-core</artifactId> | ||
| 100 | - <version>4.5.16</version> | ||
| 101 | - </dependency> | ||
| 102 | - <dependency> | ||
| 103 | - <groupId>com.aliyun</groupId> | ||
| 104 | - <artifactId>aliyun-java-sdk-dysmsapi</artifactId> | ||
| 105 | - <version>2.1.0</version> | ||
| 106 | - </dependency> | ||
| 107 | </dependencies> | 49 | </dependencies> |
| 108 | - | 50 | + <!-- 项目打包时会将java目录中的*.xml文件也进行打包 --> |
| 109 | <build> | 51 | <build> |
| 110 | - <finalName>garbage</finalName> | ||
| 111 | - <plugins> | ||
| 112 | - <plugin> | ||
| 113 | - <groupId>org.springframework.boot</groupId> | ||
| 114 | - <artifactId>spring-boot-maven-plugin</artifactId> | ||
| 115 | - </plugin> | ||
| 116 | - </plugins> | 52 | + <resources> |
| 53 | + <resource> | ||
| 54 | + <directory>src/main/java</directory> | ||
| 55 | + <includes> | ||
| 56 | + <include>**/*.xml</include> | ||
| 57 | + </includes> | ||
| 58 | + <filtering>false</filtering> | ||
| 59 | + </resource> | ||
| 60 | + </resources> | ||
| 117 | </build> | 61 | </build> |
| 62 | + | ||
| 118 | </project> | 63 | </project> |
| 119 | \ No newline at end of file | 64 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/GarbageApplication.java deleted
100644 → 0
| 1 | -package com.trash.garbage; | ||
| 2 | - | ||
| 3 | -import lombok.extern.slf4j.Slf4j; | ||
| 4 | -import org.springframework.boot.SpringApplication; | ||
| 5 | -import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| 6 | -import org.springframework.context.ConfigurableApplicationContext; | ||
| 7 | -import org.springframework.core.env.ConfigurableEnvironment; | ||
| 8 | -import org.springframework.scheduling.annotation.EnableAsync; | ||
| 9 | - | ||
| 10 | -import java.net.InetAddress; | ||
| 11 | -import java.net.UnknownHostException; | ||
| 12 | -import java.util.ArrayList; | ||
| 13 | -import java.util.List; | ||
| 14 | -import java.util.regex.Matcher; | ||
| 15 | -import java.util.regex.Pattern; | ||
| 16 | - | ||
| 17 | -/** | ||
| 18 | - * @author trash | ||
| 19 | - */ | ||
| 20 | -@SpringBootApplication | ||
| 21 | -@EnableAsync | ||
| 22 | -@Slf4j | ||
| 23 | -public class GarbageApplication { | ||
| 24 | - public static void main(String[] args) throws UnknownHostException { | ||
| 25 | - ConfigurableApplicationContext run = SpringApplication.run(GarbageApplication.class, args); | ||
| 26 | - ConfigurableEnvironment env = run.getEnvironment(); | ||
| 27 | - String ip = InetAddress.getLocalHost().getHostAddress(); | ||
| 28 | - String port = env.getProperty("server.port"); | ||
| 29 | - String path = env.getProperty("server.servlet.context-path"); | ||
| 30 | - String redisPort = env.getProperty("spring.redis.port"); | ||
| 31 | - String redisHost = env.getProperty("spring.redis.host"); | ||
| 32 | - String sqlUrl = env.getProperty("spring.datasource.druid.url"); | ||
| 33 | - List<String> sqlInfo = getSqlInfo(sqlUrl); | ||
| 34 | - log.info( | ||
| 35 | - "\n Swagger访问地址:http://" + ip + ":" + port + path + "/doc.html \n" + | ||
| 36 | - " Redis服务器地址:" + redisHost + ":" + redisPort + "\n" + | ||
| 37 | - " Mysql服务器地址:" + sqlInfo.get(0) + ":" + sqlInfo.get(1)); | ||
| 38 | - log.info("--装修垃圾服务启动成功 --"); | ||
| 39 | - } | ||
| 40 | - private static List<String> getSqlInfo(String sqlInfo) { | ||
| 41 | - List<String> str = new ArrayList<>(3); | ||
| 42 | - Pattern pattern = Pattern.compile("jdbc:mysql://([a-zA-Z0-9.-]+):(\\d+)/"); | ||
| 43 | - Matcher matcher = pattern.matcher(sqlInfo); | ||
| 44 | - if (matcher.find()) { | ||
| 45 | - str.add(matcher.group(1)); | ||
| 46 | - str.add(matcher.group(2)); | ||
| 47 | - } | ||
| 48 | - return str; | ||
| 49 | - } | ||
| 50 | -} |
trash-garbage/src/main/java/com/trash/garbage/config/CorsConfig.java deleted
100644 → 0
| 1 | -package com.trash.garbage.config; | ||
| 2 | - | ||
| 3 | -import org.springframework.context.annotation.Configuration; | ||
| 4 | -import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
| 5 | -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * | ||
| 9 | - * 允许跨域 后期修改 前端做服务代理 | ||
| 10 | - * @author 20412 | ||
| 11 | - */ | ||
| 12 | -@Configuration | ||
| 13 | -public class CorsConfig implements WebMvcConfigurer { | ||
| 14 | - | ||
| 15 | - @Override | ||
| 16 | - public void addCorsMappings(CorsRegistry registry) { | ||
| 17 | - registry.addMapping("/**") | ||
| 18 | - .allowedOrigins("*") | ||
| 19 | - .allowCredentials(true) | ||
| 20 | - .allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH") | ||
| 21 | - .maxAge(3600); | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | -} |
trash-garbage/src/main/java/com/trash/garbage/config/MybatisConfig.java deleted
100644 → 0
| 1 | -package com.trash.garbage.config; | ||
| 2 | - | ||
| 3 | -import com.baomidou.mybatisplus.annotation.DbType; | ||
| 4 | -import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; | ||
| 5 | -import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; | ||
| 6 | -import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; | ||
| 7 | -import org.mybatis.spring.annotation.MapperScan; | ||
| 8 | -import org.springframework.context.annotation.Bean; | ||
| 9 | -import org.springframework.context.annotation.Configuration; | ||
| 10 | - | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * @author 20412 | ||
| 14 | - */ | ||
| 15 | -@Configuration | ||
| 16 | -@MapperScan("com.trash.garbage.mapper") | ||
| 17 | -public class MybatisConfig { | ||
| 18 | - | ||
| 19 | - @Bean | ||
| 20 | - public MybatisPlusInterceptor mybatisPlusInterceptor() { | ||
| 21 | - MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); | ||
| 22 | - interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); | ||
| 23 | - return interceptor; | ||
| 24 | - } | ||
| 25 | -} |
trash-garbage/src/main/java/com/trash/garbage/config/RedisConfig.java deleted
100644 → 0
| 1 | -package com.trash.garbage.config; | ||
| 2 | - | ||
| 3 | -import com.trash.garbage.utils.FastJson2JsonRedisSerializer; | ||
| 4 | -import org.springframework.cache.CacheManager; | ||
| 5 | -import org.springframework.context.annotation.Bean; | ||
| 6 | -import org.springframework.context.annotation.Configuration; | ||
| 7 | -import org.springframework.data.redis.cache.RedisCacheConfiguration; | ||
| 8 | -import org.springframework.data.redis.cache.RedisCacheManager; | ||
| 9 | -import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
| 10 | -import org.springframework.data.redis.core.RedisTemplate; | ||
| 11 | -import org.springframework.data.redis.serializer.RedisSerializationContext; | ||
| 12 | -import org.springframework.data.redis.serializer.RedisSerializer; | ||
| 13 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
| 14 | - | ||
| 15 | -import java.time.Duration; | ||
| 16 | - | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * redis 配置文件 | ||
| 20 | - * @author 20412 | ||
| 21 | - */ | ||
| 22 | -// 开启缓存 | ||
| 23 | -//@EnableCaching | ||
| 24 | -@Configuration | ||
| 25 | -public class RedisConfig { | ||
| 26 | - @Bean | ||
| 27 | - public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { | ||
| 28 | - RedisTemplate<String, Object> template = new RedisTemplate<>(); | ||
| 29 | - StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); | ||
| 30 | -// Jackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); | ||
| 31 | - // 使用fast json来完成反序列 | ||
| 32 | - FastJson2JsonRedisSerializer<Object> fastJson2JsonRedisSerializer = new FastJson2JsonRedisSerializer<>(Object.class); | ||
| 33 | -// ObjectMapper om = new ObjectMapper(); | ||
| 34 | -// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | ||
| 35 | - // 解决linkArraylist反序列化问题 | ||
| 36 | -// om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance ,ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_ARRAY); | ||
| 37 | -// genericJackson2JsonRedisSerializer.setObjectMapper(om); | ||
| 38 | - template.setConnectionFactory(factory); | ||
| 39 | - //key序列化方式 | ||
| 40 | - template.setKeySerializer(stringRedisSerializer); | ||
| 41 | - //value序列化 | ||
| 42 | - template.setValueSerializer(fastJson2JsonRedisSerializer); | ||
| 43 | - template.setHashKeySerializer(stringRedisSerializer); | ||
| 44 | - //value hashmap序列化 Jackson2JsonRedisSerializer 主要针对String类型的数据 | ||
| 45 | - template.setHashValueSerializer(fastJson2JsonRedisSerializer); | ||
| 46 | - return template; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - @Bean | ||
| 50 | - public CacheManager cacheManager(RedisConnectionFactory factory) { | ||
| 51 | - RedisSerializer<String> redisSerializer = new StringRedisSerializer(); | ||
| 52 | - FastJson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new FastJson2JsonRedisSerializer<>(Object.class); | ||
| 53 | -// 配置序列化(解决乱码的问题),过期时间600秒 | ||
| 54 | - RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() | ||
| 55 | - .entryTtl(Duration.ofSeconds(600)) | ||
| 56 | - .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(redisSerializer)) | ||
| 57 | - .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer)) | ||
| 58 | - .disableCachingNullValues(); | ||
| 59 | - RedisCacheManager cacheManager = RedisCacheManager.builder(factory) | ||
| 60 | - .cacheDefaults(config) | ||
| 61 | - .build(); | ||
| 62 | - return cacheManager; | ||
| 63 | - } | ||
| 64 | -} | ||
| 65 | \ No newline at end of file | 0 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/config/RestTemplateConfig.java deleted
100644 → 0
| 1 | -package com.trash.garbage.config; | ||
| 2 | - | ||
| 3 | -import org.springframework.context.annotation.Bean; | ||
| 4 | -import org.springframework.context.annotation.Configuration; | ||
| 5 | -import org.springframework.web.client.RestTemplate; | ||
| 6 | - | ||
| 7 | -@Configuration | ||
| 8 | -public class RestTemplateConfig { | ||
| 9 | - @Bean | ||
| 10 | - public RestTemplate getRestTemplate(){ | ||
| 11 | - return new RestTemplate(); | ||
| 12 | - } | ||
| 13 | -} |
trash-garbage/src/main/java/com/trash/garbage/config/SwaggerConfiguration.java deleted
100644 → 0
| 1 | -package com.trash.garbage.config; | ||
| 2 | - | ||
| 3 | -import com.trash.garbage.global.ResultCode; | ||
| 4 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 5 | -import org.springframework.context.annotation.Bean; | ||
| 6 | -import org.springframework.context.annotation.Configuration; | ||
| 7 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | -import springfox.documentation.builders.ApiInfoBuilder; | ||
| 9 | -import springfox.documentation.builders.PathSelectors; | ||
| 10 | -import springfox.documentation.builders.RequestHandlerSelectors; | ||
| 11 | -import springfox.documentation.builders.ResponseMessageBuilder; | ||
| 12 | -import springfox.documentation.schema.ModelRef; | ||
| 13 | -import springfox.documentation.service.ApiInfo; | ||
| 14 | -import springfox.documentation.service.ResponseMessage; | ||
| 15 | -import springfox.documentation.spi.DocumentationType; | ||
| 16 | -import springfox.documentation.spring.web.plugins.Docket; | ||
| 17 | -import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
| 18 | - | ||
| 19 | -import java.util.ArrayList; | ||
| 20 | -import java.util.Arrays; | ||
| 21 | -import java.util.List; | ||
| 22 | - | ||
| 23 | -/** | ||
| 24 | - * @author guzijian | ||
| 25 | - * 2020/11/07 9:26 | ||
| 26 | - * @since:knife4j-spring-boot-fast-demo 1.0 | ||
| 27 | - */ | ||
| 28 | -@Configuration | ||
| 29 | -@EnableSwagger2 | ||
| 30 | -public class SwaggerConfiguration { | ||
| 31 | - | ||
| 32 | - @Bean(value = "defaultApi2") | ||
| 33 | - public Docket defaultApi2() { | ||
| 34 | - //添加全局响应状态码 | ||
| 35 | - List<ResponseMessage> responseMessageList = new ArrayList<>(); | ||
| 36 | - Arrays.stream(ResultCode.values()).forEach(errorEnum -> { | ||
| 37 | - responseMessageList.add( | ||
| 38 | - new ResponseMessageBuilder().code(errorEnum.getCode()).message(errorEnum.getMsg()).responseModel( | ||
| 39 | - new ModelRef(errorEnum.getMsg())) | ||
| 40 | - .build() | ||
| 41 | - ); | ||
| 42 | - }); | ||
| 43 | - | ||
| 44 | - String groupName="学习间swagger"; | ||
| 45 | - | ||
| 46 | - Docket docket=new Docket(DocumentationType.SWAGGER_2) | ||
| 47 | - .globalResponseMessage(RequestMethod.GET,responseMessageList) | ||
| 48 | - .globalResponseMessage(RequestMethod.POST,responseMessageList) | ||
| 49 | - .globalResponseMessage(RequestMethod.DELETE,responseMessageList) | ||
| 50 | - .globalResponseMessage(RequestMethod.PUT,responseMessageList) | ||
| 51 | - .host("http://localhost:9090/") | ||
| 52 | - .apiInfo(apiInfo()) | ||
| 53 | - .groupName(groupName) | ||
| 54 | - .select() | ||
| 55 | - .apis(RequestHandlerSelectors.basePackage("com.trash.garbage")) | ||
| 56 | - .paths(PathSelectors.any()) | ||
| 57 | - .build(); | ||
| 58 | - return docket; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - private ApiInfo apiInfo() { | ||
| 62 | - return new ApiInfoBuilder() | ||
| 63 | - .description(" 学习间接口文档 ") | ||
| 64 | - .contact("204126329@qq.com") | ||
| 65 | - .version("1.0") | ||
| 66 | - .build(); | ||
| 67 | - } | ||
| 68 | -} | ||
| 69 | \ No newline at end of file | 0 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/config/WebSecurityConfig.java deleted
100644 → 0
| 1 | -package com.trash.garbage.config; | ||
| 2 | -import com.trash.garbage.security.JwtAuthenticationFilterAbstract; | ||
| 3 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 4 | -import org.springframework.beans.factory.annotation.Value; | ||
| 5 | -import org.springframework.context.annotation.Bean; | ||
| 6 | -import org.springframework.context.annotation.Configuration; | ||
| 7 | -import org.springframework.security.authentication.AuthenticationManager; | ||
| 8 | -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | ||
| 9 | -import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
| 10 | -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
| 11 | -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
| 12 | -import org.springframework.security.config.http.SessionCreationPolicy; | ||
| 13 | -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
| 14 | -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; | ||
| 15 | -import org.springframework.security.web.util.matcher.OrRequestMatcher; | ||
| 16 | -import org.springframework.security.web.util.matcher.RequestMatcher; | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * security配置类 | ||
| 20 | - * @author gzj | ||
| 21 | - */ | ||
| 22 | -@Configuration | ||
| 23 | -@EnableWebSecurity | ||
| 24 | -@EnableGlobalMethodSecurity(prePostEnabled = true) | ||
| 25 | -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
| 26 | - | ||
| 27 | - @Autowired | ||
| 28 | - private JwtAuthenticationFilterAbstract jwtAuthenticationFilter; | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * 放行路径 | ||
| 32 | - */ | ||
| 33 | - @Value("${trash.garbage.config.location.exclude}") | ||
| 34 | - private String[] exclude; | ||
| 35 | - | ||
| 36 | - /** | ||
| 37 | - * 放行端口 和security配置 | ||
| 38 | - * @param http | ||
| 39 | - * @throws Exception | ||
| 40 | - */ | ||
| 41 | - @Override | ||
| 42 | - protected void configure(HttpSecurity http) throws Exception { | ||
| 43 | - | ||
| 44 | - RequestMatcher PUBLIC_URLS = new OrRequestMatcher( | ||
| 45 | - new AntPathRequestMatcher("/**", "OPTIONS"), | ||
| 46 | - new AntPathRequestMatcher("/error/**") | ||
| 47 | - ); | ||
| 48 | - | ||
| 49 | - http | ||
| 50 | - // 关闭 csrf | ||
| 51 | - .csrf().disable() | ||
| 52 | - // 前后端分离的项目session就不管用了 不通过session获取securityContext | ||
| 53 | - .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) | ||
| 54 | - .and() | ||
| 55 | - .authorizeRequests() | ||
| 56 | - // 对于登录接口 允许匿名访问 | ||
| 57 | - .antMatchers(exclude).anonymous() | ||
| 58 | - .requestMatchers(PUBLIC_URLS).permitAll() | ||
| 59 | - // 任意认证成功后都可以访问 | ||
| 60 | - .anyRequest().authenticated(); | ||
| 61 | - | ||
| 62 | - http.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); | ||
| 63 | - // spring security 异常处理 用于权限认证 | ||
| 64 | -// http.exceptionHandling() | ||
| 65 | - // 权限异常 | ||
| 66 | -// .accessDeniedHandler() | ||
| 67 | - // 认证异常 | ||
| 68 | -// .authenticationEntryPoint(); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - /** | ||
| 72 | - * 重写认证管理 | ||
| 73 | - * @return | ||
| 74 | - * @throws Exception | ||
| 75 | - */ | ||
| 76 | - @Bean | ||
| 77 | - @Override | ||
| 78 | - public AuthenticationManager authenticationManagerBean() throws Exception { | ||
| 79 | - return super.authenticationManagerBean(); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - /** | ||
| 83 | - * 监听器 监听认证结果 当认证成功后触发 | ||
| 84 | - * @param applicationEventPublisher | ||
| 85 | - * @return | ||
| 86 | - */ | ||
| 87 | -// @Bean | ||
| 88 | -// public AuthenticationEventPublisher authenticationEventPublisher | ||
| 89 | -// (ApplicationEventPublisher applicationEventPublisher) { | ||
| 90 | -// return new DefaultAuthenticationEventPublisher(applicationEventPublisher); | ||
| 91 | -// } | ||
| 92 | - | ||
| 93 | - | ||
| 94 | -} | ||
| 95 | \ No newline at end of file | 0 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/controller/GarbageUserController.java
| @@ -6,9 +6,8 @@ import com.trash.garbage.pojo.domain.GarAddress; | @@ -6,9 +6,8 @@ import com.trash.garbage.pojo.domain.GarAddress; | ||
| 6 | import com.trash.garbage.pojo.dto.AddressDto; | 6 | import com.trash.garbage.pojo.dto.AddressDto; |
| 7 | import com.trash.garbage.pojo.dto.LoginDto; | 7 | import com.trash.garbage.pojo.dto.LoginDto; |
| 8 | import com.trash.garbage.service.GarUserService; | 8 | import com.trash.garbage.service.GarUserService; |
| 9 | -import io.swagger.annotations.Api; | ||
| 10 | -import io.swagger.annotations.ApiOperation; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | +import org.springframework.validation.annotation.Validated; | ||
| 12 | import org.springframework.web.bind.annotation.*; | 11 | import org.springframework.web.bind.annotation.*; |
| 13 | 12 | ||
| 14 | import java.util.List; | 13 | import java.util.List; |
| @@ -18,7 +17,6 @@ import java.util.List; | @@ -18,7 +17,6 @@ import java.util.List; | ||
| 18 | */ | 17 | */ |
| 19 | @RestController | 18 | @RestController |
| 20 | @RequestMapping("user") | 19 | @RequestMapping("user") |
| 21 | -@Api(tags = "建筑垃圾-用户接口") | ||
| 22 | public class GarbageUserController { | 20 | public class GarbageUserController { |
| 23 | 21 | ||
| 24 | @Autowired | 22 | @Autowired |
| @@ -30,13 +28,11 @@ public class GarbageUserController { | @@ -30,13 +28,11 @@ public class GarbageUserController { | ||
| 30 | * @param user | 28 | * @param user |
| 31 | * @return | 29 | * @return |
| 32 | */ | 30 | */ |
| 33 | - @ApiOperation("用户接口-用户登录") | ||
| 34 | @PostMapping("/login") | 31 | @PostMapping("/login") |
| 35 | public Result<String> login(@RequestBody LoginDto user) { | 32 | public Result<String> login(@RequestBody LoginDto user) { |
| 36 | return Result.OK(garUserService.login(user)); | 33 | return Result.OK(garUserService.login(user)); |
| 37 | } | 34 | } |
| 38 | 35 | ||
| 39 | - @ApiOperation("用户接口-发送验证码") | ||
| 40 | @GetMapping("/send/verify") | 36 | @GetMapping("/send/verify") |
| 41 | public Result<?> sendVerify(@RequestParam("tel") String tel) { | 37 | public Result<?> sendVerify(@RequestParam("tel") String tel) { |
| 42 | try { | 38 | try { |
| @@ -48,15 +44,27 @@ public class GarbageUserController { | @@ -48,15 +44,27 @@ public class GarbageUserController { | ||
| 48 | } | 44 | } |
| 49 | } | 45 | } |
| 50 | 46 | ||
| 51 | - @ApiOperation("用户接口-获取用户地址") | ||
| 52 | @GetMapping("/query/address/{type}") | 47 | @GetMapping("/query/address/{type}") |
| 53 | - public Result<List<GarAddress>> queryAddress(@PathVariable("type") String type){ | 48 | + public Result<List<GarAddress>> queryAddress(@PathVariable("type") String type) { |
| 54 | return Result.OK(garUserService.queryAddress(type)); | 49 | return Result.OK(garUserService.queryAddress(type)); |
| 55 | } | 50 | } |
| 56 | 51 | ||
| 57 | - @ApiOperation("用户接口-新增地址") | ||
| 58 | @PostMapping("/save/address") | 52 | @PostMapping("/save/address") |
| 59 | - public Result<String> saveAddress(@RequestBody AddressDto dto){ | ||
| 60 | - return Result.OK(garUserService.saveAddress(dto)); | 53 | + public Result<String> saveAddress(@Validated @RequestBody AddressDto dto) { |
| 54 | + return Result.OK(null, garUserService.saveAddress(dto)); | ||
| 61 | } | 55 | } |
| 56 | + | ||
| 57 | + | ||
| 58 | + @PostMapping("/update/address") | ||
| 59 | + public Result<String> updateAddress(@Validated @RequestBody AddressDto dto) { | ||
| 60 | + return Result.OK(null, garUserService.updateAddress(dto)); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + | ||
| 64 | + @DeleteMapping("/delete/address/{addressId}") | ||
| 65 | + public Result<String> deleteAddress(@PathVariable("addressId") String addressId) { | ||
| 66 | + return Result.OK(null, garUserService.deleteAddress(addressId)); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + | ||
| 62 | } | 70 | } |
trash-garbage/src/main/java/com/trash/garbage/filter/JwtAuthenticationFilter.java deleted
100644 → 0
| 1 | -package com.trash.garbage.filter; | ||
| 2 | - | ||
| 3 | -import com.trash.common.utils.StringUtils; | ||
| 4 | -import com.trash.garbage.global.GlobalRedisProperties; | ||
| 5 | -import com.trash.garbage.security.JwtAuthenticationFilterAbstract; | ||
| 6 | -import com.trash.garbage.security.UserCustom; | ||
| 7 | -import com.trash.garbage.utils.JwtUtils; | ||
| 8 | -import com.trash.garbage.utils.RedisUtils; | ||
| 9 | -import lombok.extern.slf4j.Slf4j; | ||
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | -import org.springframework.beans.factory.annotation.Value; | ||
| 12 | -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
| 13 | -import org.springframework.security.core.Authentication; | ||
| 14 | -import org.springframework.security.core.context.SecurityContextHolder; | ||
| 15 | -import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
| 16 | -import org.springframework.stereotype.Component; | ||
| 17 | -import org.springframework.util.AntPathMatcher; | ||
| 18 | -import javax.servlet.FilterChain; | ||
| 19 | -import javax.servlet.ServletException; | ||
| 20 | -import javax.servlet.http.HttpServletRequest; | ||
| 21 | -import javax.servlet.http.HttpServletResponse; | ||
| 22 | -import java.io.IOException; | ||
| 23 | -import static com.trash.garbage.interfaces.Authorization.AUTHORIZATION; | ||
| 24 | - | ||
| 25 | -/** | ||
| 26 | - * 实现登录认证逻辑 | ||
| 27 | - * @author 20412 | ||
| 28 | - */ | ||
| 29 | -@Component | ||
| 30 | -@Slf4j | ||
| 31 | -public class JwtAuthenticationFilter extends JwtAuthenticationFilterAbstract { | ||
| 32 | - | ||
| 33 | - private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher(); | ||
| 34 | - | ||
| 35 | - @Autowired | ||
| 36 | - private RedisUtils redisUtils; | ||
| 37 | - | ||
| 38 | - @Value("${trash.garbage.config.location.exclude}") | ||
| 39 | - private String[] exclude; | ||
| 40 | - | ||
| 41 | - @Override | ||
| 42 | - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { | ||
| 43 | - String token = request.getHeader(AUTHORIZATION); | ||
| 44 | - // 如果为空说明没有认证 进入下一层过滤器进行安全认证 | ||
| 45 | - if(StringUtils.isBlank(token) || doCheck(request.getRequestURI())){ | ||
| 46 | - filterChain.doFilter(request, response); | ||
| 47 | - return; | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - String userId = JwtUtils.getUserId(token); | ||
| 51 | - UserCustom customUser = (UserCustom) redisUtils.get(GlobalRedisProperties.REDIS_USER_HEADER.getValue() + userId); | ||
| 52 | - if(customUser == null){ | ||
| 53 | - throw new UsernameNotFoundException("认证信息过期,请重新登录"); | ||
| 54 | - } | ||
| 55 | - log.info("userId:{}",userId); | ||
| 56 | - Authentication authenticationToken = new UsernamePasswordAuthenticationToken(customUser,null,null); | ||
| 57 | - SecurityContextHolder.getContext().setAuthentication(authenticationToken); | ||
| 58 | - // 放行 | ||
| 59 | - filterChain.doFilter(request,response); | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - private boolean doCheck(String url) { | ||
| 63 | - for (String location : exclude) { | ||
| 64 | - if (PATH_MATCHER.match(location,url)){ | ||
| 65 | - return true; | ||
| 66 | - } | ||
| 67 | - } | ||
| 68 | - return false; | ||
| 69 | - } | ||
| 70 | -} | ||
| 71 | \ No newline at end of file | 0 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/global/GlobalStatus.java
| @@ -2,6 +2,7 @@ package com.trash.garbage.global; | @@ -2,6 +2,7 @@ package com.trash.garbage.global; | ||
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * 全局状态管理 | 4 | * 全局状态管理 |
| 5 | + * | ||
| 5 | * @author guzijian | 6 | * @author guzijian |
| 6 | */ | 7 | */ |
| 7 | public class GlobalStatus { | 8 | public class GlobalStatus { |
| @@ -26,43 +27,55 @@ public class GlobalStatus { | @@ -26,43 +27,55 @@ public class GlobalStatus { | ||
| 26 | /** | 27 | /** |
| 27 | * 用户状态管理 | 28 | * 用户状态管理 |
| 28 | */ | 29 | */ |
| 29 | - public enum UserStatusEnum{ | 30 | + public enum UserStatusEnum { |
| 30 | /** | 31 | /** |
| 31 | - * 管理员 | 32 | + * 微信登录 |
| 32 | */ | 33 | */ |
| 33 | - WX_LOGIN(1,"微信登录"), | 34 | + WX_LOGIN(1, "微信登录"), |
| 34 | /** | 35 | /** |
| 35 | - * 普通用户 | 36 | + * 普通登录 |
| 36 | */ | 37 | */ |
| 37 | - NORMAL_LOGIN(0,"普通登录"); | 38 | + NORMAL_LOGIN(0, "普通登录"), |
| 39 | + NORMAL_USER(0, "普通用户"), | ||
| 40 | + DRIVER_USER(1, "驾驶员用户"); | ||
| 38 | 41 | ||
| 39 | private Integer status; | 42 | private Integer status; |
| 40 | private String description; | 43 | private String description; |
| 41 | - public int getStatus(){ | 44 | + |
| 45 | + public int getStatus() { | ||
| 42 | return this.status; | 46 | return this.status; |
| 43 | } | 47 | } |
| 44 | - UserStatusEnum(Integer status,String description){ | 48 | + |
| 49 | + public String getDescription() { | ||
| 50 | + return this.description; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + UserStatusEnum(Integer status, String description) { | ||
| 45 | this.status = status; | 54 | this.status = status; |
| 46 | this.description = description; | 55 | this.description = description; |
| 47 | } | 56 | } |
| 48 | } | 57 | } |
| 58 | + | ||
| 49 | /** | 59 | /** |
| 50 | * 字典 | 60 | * 字典 |
| 51 | */ | 61 | */ |
| 52 | public enum GarAddressStatus { | 62 | public enum GarAddressStatus { |
| 53 | - NORMAL_ADDRESS(0,"地址"), | ||
| 54 | - DEFAULT_ADDRESS(1,"默认地址"), | ||
| 55 | - CURRENT_ADDRESS(2,"当前选中地址"); | ||
| 56 | - GarAddressStatus(Integer status,String description){ | 63 | + NORMAL_ADDRESS(0, "地址"), |
| 64 | + CURRENT_ADDRESS(1, "当前地址"); | ||
| 65 | + | ||
| 66 | + GarAddressStatus(Integer status, String description) { | ||
| 57 | this.status = status; | 67 | this.status = status; |
| 58 | this.description = description; | 68 | this.description = description; |
| 59 | } | 69 | } |
| 70 | + | ||
| 60 | private String description; | 71 | private String description; |
| 61 | private Integer status; | 72 | private Integer status; |
| 62 | - public Integer getValue(){ | 73 | + |
| 74 | + public Integer getValue() { | ||
| 63 | return this.status; | 75 | return this.status; |
| 64 | } | 76 | } |
| 65 | - public String getDescription(){ | 77 | + |
| 78 | + public String getDescription() { | ||
| 66 | return this.description; | 79 | return this.description; |
| 67 | } | 80 | } |
| 68 | 81 |
trash-garbage/src/main/java/com/trash/garbage/global/Result.java
| 1 | package com.trash.garbage.global; | 1 | package com.trash.garbage.global; |
| 2 | 2 | ||
| 3 | -import io.swagger.annotations.ApiModel; | ||
| 4 | -import io.swagger.annotations.ApiModelProperty; | ||
| 5 | import lombok.Data; | 3 | import lombok.Data; |
| 6 | 4 | ||
| 7 | import static com.trash.garbage.global.ResultCode.CODE_200; | 5 | import static com.trash.garbage.global.ResultCode.CODE_200; |
| @@ -13,19 +11,14 @@ import static com.trash.garbage.global.ResultCode.CODE_500; | @@ -13,19 +11,14 @@ import static com.trash.garbage.global.ResultCode.CODE_500; | ||
| 13 | * @author 20412 | 11 | * @author 20412 |
| 14 | */ | 12 | */ |
| 15 | @Data | 13 | @Data |
| 16 | -@ApiModel("返回结果") | ||
| 17 | public class Result<T extends Object> { | 14 | public class Result<T extends Object> { |
| 18 | 15 | ||
| 19 | - @ApiModelProperty(value = "是否成功") | ||
| 20 | private Boolean success; | 16 | private Boolean success; |
| 21 | 17 | ||
| 22 | - @ApiModelProperty(value = "状态码") | ||
| 23 | private Integer code; | 18 | private Integer code; |
| 24 | 19 | ||
| 25 | - @ApiModelProperty(value = "返回消息") | ||
| 26 | private String msg; | 20 | private String msg; |
| 27 | 21 | ||
| 28 | - @ApiModelProperty(value = "返回对象") | ||
| 29 | private T data ; | 22 | private T data ; |
| 30 | 23 | ||
| 31 | private Result() {} | 24 | private Result() {} |
| @@ -39,15 +32,6 @@ public class Result<T extends Object> { | @@ -39,15 +32,6 @@ public class Result<T extends Object> { | ||
| 39 | return r; | 32 | return r; |
| 40 | } | 33 | } |
| 41 | 34 | ||
| 42 | - public static <T> Result<T> OK(ResultCode code,T data){ | ||
| 43 | - Result r = new Result(); | ||
| 44 | - r.setSuccess(true); | ||
| 45 | - r.setCode(code.getCode()); | ||
| 46 | - r.setMsg("部分成功"); | ||
| 47 | - r.setData(data); | ||
| 48 | - return r; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | /** 成功静态方法 */ | 35 | /** 成功静态方法 */ |
| 52 | public static <T> Result<T> OK(T data) { | 36 | public static <T> Result<T> OK(T data) { |
| 53 | Result r = new Result(); | 37 | Result r = new Result(); |
trash-garbage/src/main/java/com/trash/garbage/interceptor/MyMetaObjectHandler.java
| 1 | package com.trash.garbage.interceptor; | 1 | package com.trash.garbage.interceptor; |
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; | 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| 4 | -import com.trash.garbage.utils.SecurityUtil; | 4 | +import com.trash.common.utils.SecurityUtils; |
| 5 | import lombok.extern.slf4j.Slf4j; | 5 | import lombok.extern.slf4j.Slf4j; |
| 6 | import org.apache.ibatis.reflection.MetaObject; | 6 | import org.apache.ibatis.reflection.MetaObject; |
| 7 | import org.springframework.stereotype.Component; | 7 | import org.springframework.stereotype.Component; |
| 8 | 8 | ||
| 9 | import java.util.Date; | 9 | import java.util.Date; |
| 10 | -import java.util.Objects; | ||
| 11 | 10 | ||
| 12 | /** | 11 | /** |
| 13 | * mybatis 拦截器全局注入 | 12 | * mybatis 拦截器全局注入 |
| 13 | + * | ||
| 14 | * @author 20412 | 14 | * @author 20412 |
| 15 | */ | 15 | */ |
| 16 | @Slf4j | 16 | @Slf4j |
| @@ -20,39 +20,33 @@ public class MyMetaObjectHandler implements MetaObjectHandler { | @@ -20,39 +20,33 @@ public class MyMetaObjectHandler implements MetaObjectHandler { | ||
| 20 | @Override | 20 | @Override |
| 21 | public void insertFill(MetaObject metaObject) { | 21 | public void insertFill(MetaObject metaObject) { |
| 22 | log.info("start insert fill ...."); | 22 | log.info("start insert fill ...."); |
| 23 | - if (metaObject.hasGetter("garCreateTime")){ | 23 | + if (metaObject.hasGetter("garCreateTime")) { |
| 24 | this.strictInsertFill(metaObject, "garCreateTime", Date.class, new Date()); | 24 | this.strictInsertFill(metaObject, "garCreateTime", Date.class, new Date()); |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | - if (metaObject.hasGetter("garCreateBy")){ | ||
| 28 | - if (!Objects.isNull(SecurityUtil.getUserCustom())){ | ||
| 29 | - this.strictInsertFill(metaObject, "garCreateBy", String.class, SecurityUtil.getUserCustom().getUser().getGarUserId()); | ||
| 30 | - } | 27 | + if (metaObject.hasGetter("garCreateBy")) { |
| 28 | + this.strictInsertFill(metaObject, "garCreateBy", String.class, SecurityUtils.getLoginUser().getUser().getUserId()); | ||
| 31 | } | 29 | } |
| 32 | 30 | ||
| 33 | - if (metaObject.hasGetter("garUpdateTime")){ | 31 | + if (metaObject.hasGetter("garUpdateTime")) { |
| 34 | this.strictInsertFill(metaObject, "garUpdateTime", Date.class, new Date()); | 32 | this.strictInsertFill(metaObject, "garUpdateTime", Date.class, new Date()); |
| 35 | } | 33 | } |
| 36 | - if (metaObject.hasGetter("garUserId")){ | ||
| 37 | - if (!Objects.isNull(SecurityUtil.getUserCustom())) { | ||
| 38 | - this.strictInsertFill(metaObject, "garUserId", String.class, SecurityUtil.getUserCustom().getUser().getGarUserId()); | ||
| 39 | - } | 34 | + if (metaObject.hasGetter("garUserId")) { |
| 35 | + this.strictInsertFill(metaObject, "garUserId", String.class, SecurityUtils.getLoginUser().getUser().getUserId()); | ||
| 40 | } | 36 | } |
| 41 | - if (metaObject.hasGetter("garUpdateBy")){ | ||
| 42 | - if (!Objects.isNull(SecurityUtil.getUserCustom())){ | ||
| 43 | - this.strictInsertFill(metaObject, "garUpdateBy", String.class, SecurityUtil.getUserCustom().getUser().getGarUserId()); | ||
| 44 | - } | 37 | + if (metaObject.hasGetter("garUpdateBy")) { |
| 38 | + this.strictInsertFill(metaObject, "garUpdateBy", String.class, SecurityUtils.getLoginUser().getUser().getUserId()); | ||
| 45 | } | 39 | } |
| 46 | } | 40 | } |
| 47 | 41 | ||
| 48 | @Override | 42 | @Override |
| 49 | public void updateFill(MetaObject metaObject) { | 43 | public void updateFill(MetaObject metaObject) { |
| 50 | log.info("start update fill ...."); | 44 | log.info("start update fill ...."); |
| 51 | - if (metaObject.hasGetter("garUpdateTime")){ | 45 | + if (metaObject.hasGetter("garUpdateTime")) { |
| 52 | this.strictUpdateFill(metaObject, "garUpdateTime", Date.class, new Date()); | 46 | this.strictUpdateFill(metaObject, "garUpdateTime", Date.class, new Date()); |
| 53 | } | 47 | } |
| 54 | - if (metaObject.hasGetter("garUpdateBy")){ | ||
| 55 | - this.strictUpdateFill(metaObject,"garUpdateBy",String.class,SecurityUtil.getUserCustom().getUser().getGarUserId()); | 48 | + if (metaObject.hasGetter("garUpdateBy")) { |
| 49 | + this.strictUpdateFill(metaObject, "garUpdateBy", String.class, SecurityUtils.getLoginUser().getUser().getUserId()); | ||
| 56 | } | 50 | } |
| 57 | } | 51 | } |
| 58 | } | 52 | } |
| 59 | \ No newline at end of file | 53 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/interfaces/Authorization.java deleted
100644 → 0
| 1 | -package com.trash.garbage.interfaces; | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * 请求头规范 | ||
| 5 | - * @date 2023-3-21 | ||
| 6 | - * @author 20412 | ||
| 7 | - */ | ||
| 8 | -public interface Authorization { | ||
| 9 | - String AUTHORIZATION = "Authorization"; | ||
| 10 | - | ||
| 11 | - /** | ||
| 12 | - * 这个已经被淘汰,请使用AUTHORIZATION | ||
| 13 | - */ | ||
| 14 | - @Deprecated | ||
| 15 | - String TOKEN = "X-TOKEN-AUTH"; | ||
| 16 | -} |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarAddressMapper.java
| @@ -2,6 +2,7 @@ package com.trash.garbage.mapper; | @@ -2,6 +2,7 @@ package com.trash.garbage.mapper; | ||
| 2 | 2 | ||
| 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 4 | import com.trash.garbage.pojo.domain.GarAddress; | 4 | import com.trash.garbage.pojo.domain.GarAddress; |
| 5 | +import org.apache.ibatis.annotations.Mapper; | ||
| 5 | 6 | ||
| 6 | /** | 7 | /** |
| 7 | * @author 20412 | 8 | * @author 20412 |
trash-garbage/src/main/java/com/trash/garbage/mapper/GarUserMapper.java
| @@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper; | @@ -10,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 10 | * @createDate 2023-11-20 16:03:15 | 10 | * @createDate 2023-11-20 16:03:15 |
| 11 | * @Entity garbage.domain.GarUser | 11 | * @Entity garbage.domain.GarUser |
| 12 | */ | 12 | */ |
| 13 | -@Mapper | ||
| 14 | public interface GarUserMapper extends BaseMapper<GarUser> { | 13 | public interface GarUserMapper extends BaseMapper<GarUser> { |
| 15 | 14 | ||
| 16 | } | 15 | } |
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarAddress.java
| @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | ||
| 8 | import java.io.Serializable; | 8 | import java.io.Serializable; |
| 9 | import java.util.Date; | 9 | import java.util.Date; |
| 10 | 10 | ||
| 11 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 11 | import lombok.Data; | 12 | import lombok.Data; |
| 12 | 13 | ||
| 13 | 14 | ||
| @@ -24,11 +25,12 @@ public class GarAddress implements Serializable { | @@ -24,11 +25,12 @@ public class GarAddress implements Serializable { | ||
| 24 | * 地址id | 25 | * 地址id |
| 25 | */ | 26 | */ |
| 26 | @TableId | 27 | @TableId |
| 27 | - private Long garAddressId; | 28 | + private String garAddressId; |
| 28 | 29 | ||
| 29 | /** | 30 | /** |
| 30 | * 用户id | 31 | * 用户id |
| 31 | */ | 32 | */ |
| 33 | + @TableField(select = false) | ||
| 32 | private String garUserId; | 34 | private String garUserId; |
| 33 | 35 | ||
| 34 | /** | 36 | /** |
| @@ -44,13 +46,15 @@ public class GarAddress implements Serializable { | @@ -44,13 +46,15 @@ public class GarAddress implements Serializable { | ||
| 44 | /** | 46 | /** |
| 45 | * 创建时间 | 47 | * 创建时间 |
| 46 | */ | 48 | */ |
| 47 | - @TableField(fill = FieldFill.INSERT) | 49 | + @TableField(fill = FieldFill.INSERT, select = false) |
| 50 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:dd") | ||
| 48 | private Date garCreateTime; | 51 | private Date garCreateTime; |
| 49 | 52 | ||
| 50 | /** | 53 | /** |
| 51 | * 修改时间 | 54 | * 修改时间 |
| 52 | */ | 55 | */ |
| 53 | - @TableField(fill = FieldFill.INSERT_UPDATE) | 56 | + @TableField(fill = FieldFill.INSERT_UPDATE, select = false) |
| 57 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:dd") | ||
| 54 | private Date garUpdateTime; | 58 | private Date garUpdateTime; |
| 55 | 59 | ||
| 56 | /** | 60 | /** |
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarUser.java
| @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | @@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | import java.io.Serializable; | 7 | import java.io.Serializable; |
| 8 | import java.util.Date; | 8 | import java.util.Date; |
| 9 | 9 | ||
| 10 | -import com.trash.garbage.security.UserAbstract; | 10 | +import com.fasterxml.jackson.annotation.JsonFormat; |
| 11 | import lombok.Data; | 11 | import lombok.Data; |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| @@ -16,7 +16,7 @@ import lombok.Data; | @@ -16,7 +16,7 @@ import lombok.Data; | ||
| 16 | */ | 16 | */ |
| 17 | @TableName(value ="gar_user") | 17 | @TableName(value ="gar_user") |
| 18 | @Data | 18 | @Data |
| 19 | -public class GarUser extends UserAbstract implements Serializable { | 19 | +public class GarUser implements Serializable { |
| 20 | /** | 20 | /** |
| 21 | * 建筑垃圾用户id | 21 | * 建筑垃圾用户id |
| 22 | */ | 22 | */ |
| @@ -53,12 +53,14 @@ public class GarUser extends UserAbstract implements Serializable { | @@ -53,12 +53,14 @@ public class GarUser extends UserAbstract implements Serializable { | ||
| 53 | */ | 53 | */ |
| 54 | 54 | ||
| 55 | @TableField(fill = FieldFill.INSERT) | 55 | @TableField(fill = FieldFill.INSERT) |
| 56 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:dd") | ||
| 56 | private Date garCreateTime; | 57 | private Date garCreateTime; |
| 57 | 58 | ||
| 58 | /** | 59 | /** |
| 59 | * 修改时间 | 60 | * 修改时间 |
| 60 | */ | 61 | */ |
| 61 | @TableField(fill = FieldFill.INSERT_UPDATE) | 62 | @TableField(fill = FieldFill.INSERT_UPDATE) |
| 63 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:dd") | ||
| 62 | private Date garUpdateTime; | 64 | private Date garUpdateTime; |
| 63 | 65 | ||
| 64 | /** | 66 | /** |
| @@ -128,8 +130,4 @@ public class GarUser extends UserAbstract implements Serializable { | @@ -128,8 +130,4 @@ public class GarUser extends UserAbstract implements Serializable { | ||
| 128 | return sb.toString(); | 130 | return sb.toString(); |
| 129 | } | 131 | } |
| 130 | 132 | ||
| 131 | - @Override | ||
| 132 | - public String getTel() { | ||
| 133 | - return this.garUserTel; | ||
| 134 | - } | ||
| 135 | } | 133 | } |
| 136 | \ No newline at end of file | 134 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/pojo/dto/AddressDto.java
| @@ -2,14 +2,24 @@ package com.trash.garbage.pojo.dto; | @@ -2,14 +2,24 @@ package com.trash.garbage.pojo.dto; | ||
| 2 | 2 | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | +import javax.validation.constraints.NotBlank; | ||
| 6 | +import javax.validation.constraints.NotEmpty; | ||
| 7 | +import javax.validation.constraints.NotNull; | ||
| 8 | + | ||
| 5 | /** | 9 | /** |
| 6 | * @author 20412 | 10 | * @author 20412 |
| 7 | */ | 11 | */ |
| 8 | @Data | 12 | @Data |
| 9 | public class AddressDto { | 13 | public class AddressDto { |
| 10 | - private String address; | ||
| 11 | - private String details; | ||
| 12 | - private String contactName; | ||
| 13 | - private String contactTel; | ||
| 14 | - private Integer defaultFlag; | 14 | + private String garAddressId; |
| 15 | + @NotBlank(message = "所在地区不能为空") | ||
| 16 | + private String addressArea; | ||
| 17 | + @NotBlank(message = "详细地址不能为空") | ||
| 18 | + private String addressDetail; | ||
| 19 | + @NotBlank(message = "联系人不能为空") | ||
| 20 | + private String contactPerson; | ||
| 21 | + @NotBlank(message = "联系电话不能为空") | ||
| 22 | + private String contactIphoneNumber; | ||
| 23 | + @NotNull(message = "defaultFlag不能为空") | ||
| 24 | + private Boolean defaultFlag; | ||
| 15 | } | 25 | } |
trash-garbage/src/main/java/com/trash/garbage/pojo/dto/LoginDto.java
| 1 | package com.trash.garbage.pojo.dto; | 1 | package com.trash.garbage.pojo.dto; |
| 2 | 2 | ||
| 3 | -import io.swagger.annotations.ApiModel; | ||
| 4 | -import io.swagger.annotations.ApiModelProperty; | ||
| 5 | import lombok.Data; | 3 | import lombok.Data; |
| 6 | 4 | ||
| 7 | /** | 5 | /** |
| 8 | * @author 20412 | 6 | * @author 20412 |
| 9 | */ | 7 | */ |
| 10 | @Data | 8 | @Data |
| 11 | -@ApiModel(value = "登录vo") | ||
| 12 | public class LoginDto { | 9 | public class LoginDto { |
| 13 | - @ApiModelProperty(value = "登录vo-手机号") | ||
| 14 | private String tel; | 10 | private String tel; |
| 15 | - @ApiModelProperty(value = "登录vo-验证码") | ||
| 16 | - private Integer code; | ||
| 17 | - @ApiModelProperty(value = "登录vo-用户昵称") | 11 | + private String code; |
| 18 | private String nickname; | 12 | private String nickname; |
| 19 | - @ApiModelProperty(value = "登录vo-wxCode") | ||
| 20 | private String wxCode; | 13 | private String wxCode; |
| 21 | - @ApiModelProperty(value = "登录vo-loginType:0 手机号登录 , 1 微信登录") | ||
| 22 | private Integer loginType; | 14 | private Integer loginType; |
| 23 | private String encryptedData; | 15 | private String encryptedData; |
| 24 | private String iv; | 16 | private String iv; |
trash-garbage/src/main/java/com/trash/garbage/security/JwtAuthenticationFilterAbstract.java deleted
100644 → 0
| 1 | -package com.trash.garbage.security; | ||
| 2 | - | ||
| 3 | -import org.springframework.web.filter.OncePerRequestFilter; | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * 使用抽象类 | ||
| 9 | - * 因为不同的调用者可能需要的过滤不一样 | ||
| 10 | - * 由调用者自己实现 | ||
| 11 | - * @author 20412 | ||
| 12 | - */ | ||
| 13 | -public abstract class JwtAuthenticationFilterAbstract extends OncePerRequestFilter { | ||
| 14 | - | ||
| 15 | -} |
trash-garbage/src/main/java/com/trash/garbage/security/PasswordCustom.java deleted
100644 → 0
| 1 | -package com.trash.garbage.security; | ||
| 2 | - | ||
| 3 | -import org.springframework.security.crypto.password.PasswordEncoder; | ||
| 4 | -import org.springframework.stereotype.Component; | ||
| 5 | -import org.springframework.util.DigestUtils; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * @author 20412 | ||
| 9 | - */ | ||
| 10 | -@Component | ||
| 11 | -public class PasswordCustom implements PasswordEncoder { | ||
| 12 | - | ||
| 13 | - /** 密码加密 */ | ||
| 14 | - @Override | ||
| 15 | - public String encode(CharSequence charSequence) { | ||
| 16 | - return ""; | ||
| 17 | - } | ||
| 18 | - | ||
| 19 | - /** 密码配对 用户登录的密码加密后是否配对上 */ | ||
| 20 | - @Override | ||
| 21 | - public boolean matches(CharSequence rawPassword, String password) { | ||
| 22 | - return true; | ||
| 23 | - } | ||
| 24 | -} |
trash-garbage/src/main/java/com/trash/garbage/security/UserAbstract.java deleted
100644 → 0
| 1 | -package com.trash.garbage.security; | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * 封装用户信息必须实现一下模板 | ||
| 5 | - * @author guzijian | ||
| 6 | - */ | ||
| 7 | -public abstract class UserAbstract { | ||
| 8 | - | ||
| 9 | - /** | ||
| 10 | - * 可选属性 根据需要设置 | ||
| 11 | - */ | ||
| 12 | - String garUserId; | ||
| 13 | - | ||
| 14 | - /** | ||
| 15 | - * 实现获取用手机号 | ||
| 16 | - * @return | ||
| 17 | - */ | ||
| 18 | - public abstract String getTel(); | ||
| 19 | - | ||
| 20 | - public String getGarUserId(){ | ||
| 21 | - return this.garUserId; | ||
| 22 | - } | ||
| 23 | - | ||
| 24 | -} |
trash-garbage/src/main/java/com/trash/garbage/security/UserCustom.java deleted
100644 → 0
| 1 | -package com.trash.garbage.security; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.annotation.JSONField; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.NoArgsConstructor; | ||
| 6 | -import org.springframework.security.core.GrantedAuthority; | ||
| 7 | -import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
| 8 | -import org.springframework.security.core.userdetails.UserDetails; | ||
| 9 | -import java.io.Serializable; | ||
| 10 | -import java.util.Collection; | ||
| 11 | -import java.util.List; | ||
| 12 | -import java.util.stream.Collectors; | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * @author 20412 | ||
| 16 | - */ | ||
| 17 | -@Data | ||
| 18 | -@NoArgsConstructor | ||
| 19 | -public class UserCustom implements Serializable , UserDetails { | ||
| 20 | - | ||
| 21 | - private static final long serialVersionUID = -2L; | ||
| 22 | - | ||
| 23 | - /** | ||
| 24 | - * 用户实体 | ||
| 25 | - */ | ||
| 26 | - private UserAbstract user; | ||
| 27 | - | ||
| 28 | - /** | ||
| 29 | - * 权限集合 | ||
| 30 | - */ | ||
| 31 | - private List<String> permissions; | ||
| 32 | - @JSONField(serialize = false) | ||
| 33 | - private Collection<? extends GrantedAuthority> authorities; | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * 初始化构造 | ||
| 37 | - * @param user 用户实体 | ||
| 38 | - * @param permissions 权限集合 | ||
| 39 | - */ | ||
| 40 | - public UserCustom(UserAbstract user, List<String> permissions) { | ||
| 41 | - this.user = user; | ||
| 42 | - this.permissions = permissions; | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - public UserAbstract getUser() { | ||
| 46 | - return this.user; | ||
| 47 | - } | ||
| 48 | - | ||
| 49 | - @Override | ||
| 50 | - public Collection<? extends GrantedAuthority> getAuthorities() { | ||
| 51 | - if (authorities != null){ | ||
| 52 | - return authorities; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - authorities = permissions.stream() | ||
| 56 | - .map(SimpleGrantedAuthority::new) | ||
| 57 | - .collect(Collectors.toList()); | ||
| 58 | - | ||
| 59 | - return this.authorities; | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - @Override | ||
| 63 | - public String getPassword() { | ||
| 64 | - return this.user.getTel(); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - @Override | ||
| 68 | - public String getUsername() { | ||
| 69 | - return this.user.getTel(); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @Override | ||
| 73 | - public boolean isAccountNonExpired() { | ||
| 74 | - return true; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - @Override | ||
| 78 | - public boolean isAccountNonLocked() { | ||
| 79 | - return true; | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - @Override | ||
| 83 | - public boolean isCredentialsNonExpired() { | ||
| 84 | - return true; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @Override | ||
| 88 | - public boolean isEnabled() { | ||
| 89 | - return true; | ||
| 90 | - } | ||
| 91 | -} |
trash-garbage/src/main/java/com/trash/garbage/service/GarUserService.java
| @@ -23,4 +23,8 @@ public interface GarUserService extends IService<GarUser> { | @@ -23,4 +23,8 @@ public interface GarUserService extends IService<GarUser> { | ||
| 23 | List<GarAddress> queryAddress(String type); | 23 | List<GarAddress> queryAddress(String type); |
| 24 | 24 | ||
| 25 | String saveAddress(AddressDto dto); | 25 | String saveAddress(AddressDto dto); |
| 26 | + | ||
| 27 | + String updateAddress(AddressDto dto); | ||
| 28 | + | ||
| 29 | + String deleteAddress(String addressId); | ||
| 26 | } | 30 | } |
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarUserServiceImpl.java
| @@ -4,7 +4,15 @@ import cn.hutool.http.HttpUtil; | @@ -4,7 +4,15 @@ import cn.hutool.http.HttpUtil; | ||
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | import com.aliyuncs.exceptions.ClientException; | 5 | import com.aliyuncs.exceptions.ClientException; |
| 6 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 6 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 7 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 8 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||
| 7 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 9 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 10 | +import com.trash.common.core.domain.entity.SysRole; | ||
| 11 | +import com.trash.common.core.domain.entity.SysUser; | ||
| 12 | +import com.trash.common.core.domain.model.LoginUser; | ||
| 13 | +import com.trash.common.core.redis.RedisCache; | ||
| 14 | +import com.trash.common.utils.SecurityUtils; | ||
| 15 | +import com.trash.framework.web.service.TokenService; | ||
| 8 | import com.trash.garbage.config.WxConfig; | 16 | import com.trash.garbage.config.WxConfig; |
| 9 | import com.trash.garbage.custom.BizException; | 17 | import com.trash.garbage.custom.BizException; |
| 10 | import com.trash.garbage.global.GlobalRedisProperties; | 18 | import com.trash.garbage.global.GlobalRedisProperties; |
| @@ -14,7 +22,6 @@ import com.trash.garbage.pojo.domain.GarAddress; | @@ -14,7 +22,6 @@ import com.trash.garbage.pojo.domain.GarAddress; | ||
| 14 | import com.trash.garbage.pojo.domain.GarUser; | 22 | import com.trash.garbage.pojo.domain.GarUser; |
| 15 | import com.trash.garbage.pojo.dto.AddressDto; | 23 | import com.trash.garbage.pojo.dto.AddressDto; |
| 16 | import com.trash.garbage.pojo.dto.LoginDto; | 24 | import com.trash.garbage.pojo.dto.LoginDto; |
| 17 | -import com.trash.garbage.security.UserCustom; | ||
| 18 | import com.trash.garbage.service.GarAddressService; | 25 | import com.trash.garbage.service.GarAddressService; |
| 19 | import com.trash.garbage.service.GarUserService; | 26 | import com.trash.garbage.service.GarUserService; |
| 20 | import com.trash.garbage.mapper.GarUserMapper; | 27 | import com.trash.garbage.mapper.GarUserMapper; |
| @@ -22,8 +29,7 @@ import com.trash.garbage.utils.*; | @@ -22,8 +29,7 @@ import com.trash.garbage.utils.*; | ||
| 22 | import org.apache.commons.codec.binary.Base64; | 29 | import org.apache.commons.codec.binary.Base64; |
| 23 | import org.springframework.beans.factory.annotation.Autowired; | 30 | import org.springframework.beans.factory.annotation.Autowired; |
| 24 | import org.springframework.security.authentication.AuthenticationManager; | 31 | import org.springframework.security.authentication.AuthenticationManager; |
| 25 | -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
| 26 | -import org.springframework.security.core.Authentication; | 32 | +import org.springframework.security.core.authority.SimpleGrantedAuthority; |
| 27 | import org.springframework.security.core.userdetails.UsernameNotFoundException; | 33 | import org.springframework.security.core.userdetails.UsernameNotFoundException; |
| 28 | import org.springframework.stereotype.Service; | 34 | import org.springframework.stereotype.Service; |
| 29 | import org.springframework.transaction.annotation.Transactional; | 35 | import org.springframework.transaction.annotation.Transactional; |
| @@ -33,9 +39,7 @@ import javax.crypto.Cipher; | @@ -33,9 +39,7 @@ import javax.crypto.Cipher; | ||
| 33 | import javax.crypto.spec.IvParameterSpec; | 39 | import javax.crypto.spec.IvParameterSpec; |
| 34 | import javax.crypto.spec.SecretKeySpec; | 40 | import javax.crypto.spec.SecretKeySpec; |
| 35 | import java.security.spec.AlgorithmParameterSpec; | 41 | import java.security.spec.AlgorithmParameterSpec; |
| 36 | -import java.util.Arrays; | ||
| 37 | -import java.util.List; | ||
| 38 | -import java.util.Objects; | 42 | +import java.util.*; |
| 39 | import java.util.concurrent.TimeUnit; | 43 | import java.util.concurrent.TimeUnit; |
| 40 | 44 | ||
| 41 | /** | 45 | /** |
| @@ -49,95 +53,160 @@ public class GarUserServiceImpl extends ServiceImpl<GarUserMapper, GarUser> | @@ -49,95 +53,160 @@ public class GarUserServiceImpl extends ServiceImpl<GarUserMapper, GarUser> | ||
| 49 | implements GarUserService { | 53 | implements GarUserService { |
| 50 | @Resource | 54 | @Resource |
| 51 | private WxConfig wxConfig; | 55 | private WxConfig wxConfig; |
| 52 | - @Autowired | ||
| 53 | - private AuthenticationManager authenticationManager; | ||
| 54 | 56 | ||
| 55 | @Autowired | 57 | @Autowired |
| 56 | private GarAddressService garAddressService; | 58 | private GarAddressService garAddressService; |
| 57 | 59 | ||
| 60 | + | ||
| 58 | @Resource | 61 | @Resource |
| 59 | - private RedisUtils redisUtils; | 62 | + private RedisCache redisCache; |
| 63 | + | ||
| 64 | + @Autowired | ||
| 65 | + private TokenService tokenService; | ||
| 60 | 66 | ||
| 61 | 67 | ||
| 62 | @Override | 68 | @Override |
| 63 | - public String login(LoginDto user) { | ||
| 64 | - if (Objects.isNull(user)) { | ||
| 65 | - throw new UsernameNotFoundException("当前用户不存在"); | 69 | + public String login(LoginDto loginDto) { |
| 70 | + if (Objects.isNull(loginDto)) { | ||
| 71 | + throw new UsernameNotFoundException("当前用户不存在!"); | ||
| 66 | } | 72 | } |
| 67 | // TODO 微信登录 | 73 | // TODO 微信登录 |
| 68 | - if (user.getLoginType().equals(GlobalStatus.UserStatusEnum.WX_LOGIN.getStatus())) { | ||
| 69 | - String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&js_code=" + user.getWxCode() + "&grant_type=authorization_code"; | 74 | + if (loginDto.getLoginType().equals(GlobalStatus.UserStatusEnum.WX_LOGIN.getStatus())) { |
| 75 | + String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getSecret() + "&js_code=" + loginDto.getWxCode() + "&grant_type=authorization_code"; | ||
| 70 | String body = HttpUtil.createGet(url).header("cache-control", "no-cache").execute().body(); | 76 | String body = HttpUtil.createGet(url).header("cache-control", "no-cache").execute().body(); |
| 71 | JSONObject open = JSONObject.parseObject(body); | 77 | JSONObject open = JSONObject.parseObject(body); |
| 72 | String sessionKey = open.getString("session_key"); | 78 | String sessionKey = open.getString("session_key"); |
| 73 | try { | 79 | try { |
| 74 | - user.setTel(decrypt(user.getEncryptedData(), sessionKey, user.getIv())); | 80 | + loginDto.setTel(decrypt(loginDto.getEncryptedData(), sessionKey, loginDto.getIv())); |
| 75 | } catch (Exception e) { | 81 | } catch (Exception e) { |
| 76 | throw new RuntimeException("解密失败"); | 82 | throw new RuntimeException("解密失败"); |
| 77 | } | 83 | } |
| 78 | } | 84 | } |
| 79 | // 验证码验证 | 85 | // 验证码验证 |
| 80 | - Integer code = (Integer) redisUtils.get(GlobalRedisProperties.REDIS_USER_CODE.getValue() + user.getTel()); | ||
| 81 | - if (!code.equals(user.getCode())) { | 86 | + String code = redisCache.getCacheObject(GlobalRedisProperties.REDIS_USER_CODE.getValue() + loginDto.getTel()); |
| 87 | + if (loginDto.getCode() == null || !loginDto.getCode().equals(code)) { | ||
| 82 | throw new BizException(ResultCode.CODE_400, "验证码错误!!"); | 88 | throw new BizException(ResultCode.CODE_400, "验证码错误!!"); |
| 83 | } | 89 | } |
| 84 | - // 封装成authentication对象 | ||
| 85 | - Authentication authentication = new UsernamePasswordAuthenticationToken(user.getTel(), ""); | ||
| 86 | - // 开始认证 | ||
| 87 | - Authentication authenticate = authenticationManager.authenticate(authentication); | ||
| 88 | - if (Objects.isNull(authenticate)) { | ||
| 89 | - throw new RuntimeException("用户名或密码错误"); | 90 | + // 查询用户 |
| 91 | + QueryWrapper<GarUser> qw = new QueryWrapper<>(); | ||
| 92 | + qw.lambda().eq(GarUser::getGarUserTel, loginDto.getTel()); | ||
| 93 | + GarUser nUser = this.getOne(qw); | ||
| 94 | + if (Objects.isNull(nUser)) { | ||
| 95 | + // 不存在就创建用户 | ||
| 96 | + nUser = new GarUser(); | ||
| 97 | + nUser.setGarUserTel(loginDto.getTel()); | ||
| 98 | + nUser.setGarUserDelFlag(GlobalStatus.DEL_FLAG_NO); | ||
| 99 | + nUser.setGarUserType(GlobalStatus.UserStatusEnum.NORMAL_USER.getDescription()); | ||
| 100 | + this.save(nUser); | ||
| 101 | + } | ||
| 102 | + LoginUser loginUser = new LoginUser(); | ||
| 103 | + ArrayList<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>(); | ||
| 104 | + loginUser.setAuthorities(authorities); | ||
| 105 | + Set<String> set = new HashSet<String>(); | ||
| 106 | + SysUser user = new SysUser(); | ||
| 107 | + user.setUserId(nUser.getGarUserId()); | ||
| 108 | + user.setUserName(nUser.getGarUserName()); | ||
| 109 | + user.setPhonenumber(loginDto.getTel()); | ||
| 110 | + loginUser.setUser(user); | ||
| 111 | + set.add("*:*:*"); | ||
| 112 | + SysRole role = new SysRole(); | ||
| 113 | + role.setRoleKey("admin"); | ||
| 114 | + ArrayList<SysRole> roles = new ArrayList<SysRole>(); | ||
| 115 | + roles.add(role); | ||
| 116 | + user.setRoles(roles); | ||
| 117 | + loginUser.setPermissions(set); | ||
| 118 | + String token = JwtUtils.createToken(nUser.getGarUserId(), nUser.getGarUserTel()); | ||
| 119 | + if (!token.contains("Bearer ")) { | ||
| 120 | + token = "Bearer " + token; | ||
| 90 | } | 121 | } |
| 91 | - UserCustom userCustom = (UserCustom) authenticate.getPrincipal(); | ||
| 92 | - // 存入redis | ||
| 93 | - redisUtils.set(GlobalRedisProperties.REDIS_USER_HEADER.getValue() + userCustom.getUser().getGarUserId(), userCustom); | ||
| 94 | - // 修改在线状态 | ||
| 95 | - return JwtUtils.createToken(userCustom.getUser().getTel(), userCustom.getUser().getGarUserId()); | 122 | + loginUser.setToken(token); |
| 123 | + tokenService.refreshToken(loginUser); | ||
| 124 | + return token; | ||
| 96 | } | 125 | } |
| 97 | 126 | ||
| 98 | @Override | 127 | @Override |
| 99 | public void sendVerify(String tel) throws ClientException { | 128 | public void sendVerify(String tel) throws ClientException { |
| 100 | //随机生成6位数字验证码 | 129 | //随机生成6位数字验证码 |
| 101 | - Integer validateCode = ValidateCodeUtil.generatorCode(4); | 130 | + String validateCode = ValidateCodeUtil.generatorCode(4); |
| 102 | //给用户发送验证码 | 131 | //给用户发送验证码 |
| 103 | // SMSUtils.sendMessage("", tel, validateCode.toString(), ""); | 132 | // SMSUtils.sendMessage("", tel, validateCode.toString(), ""); |
| 104 | // 保存redis | 133 | // 保存redis |
| 105 | System.out.println("code:" + validateCode); | 134 | System.out.println("code:" + validateCode); |
| 106 | - redisUtils.setEx(GlobalRedisProperties.REDIS_USER_CODE.getValue() + tel, validateCode, 60, TimeUnit.SECONDS); | 135 | + redisCache.setCacheObject(GlobalRedisProperties.REDIS_USER_CODE.getValue() + tel, validateCode, 60, TimeUnit.SECONDS); |
| 107 | } | 136 | } |
| 108 | 137 | ||
| 109 | @Override | 138 | @Override |
| 110 | public List<GarAddress> queryAddress(String type) { | 139 | public List<GarAddress> queryAddress(String type) { |
| 111 | - UserCustom userCustom = SecurityUtil.getUserCustom(); | ||
| 112 | - if (Objects.isNull(userCustom)) { | ||
| 113 | - throw new BizException(ResultCode.CODE_401, ResultCode.CODE_401.getMsg()); | ||
| 114 | - } | ||
| 115 | - String garUserId = userCustom.getUser().getGarUserId(); | 140 | + LoginUser user = SecurityUtils.getLoginUser(); |
| 141 | + String garUserId = user.getUser().getUserId(); | ||
| 116 | LambdaQueryWrapper<GarAddress> qw = new LambdaQueryWrapper<>(); | 142 | LambdaQueryWrapper<GarAddress> qw = new LambdaQueryWrapper<>(); |
| 117 | qw.eq(GarAddress::getGarUserId, garUserId); | 143 | qw.eq(GarAddress::getGarUserId, garUserId); |
| 118 | - List<GarAddress> addressList = garAddressService.list(qw); | ||
| 119 | if (GlobalStatus.QUERY_ADDRESS_TYPE_CURRENT.equals(type)) { | 144 | if (GlobalStatus.QUERY_ADDRESS_TYPE_CURRENT.equals(type)) { |
| 120 | - for (GarAddress garAddress : addressList) { | ||
| 121 | - if (GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue().equals(garAddress.getGarUserDefault())) { | ||
| 122 | - return Arrays.asList(garAddress); | ||
| 123 | - } | ||
| 124 | - } | 145 | + qw.eq(GarAddress::getGarUserDefault, GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue()); |
| 146 | + GarAddress one = garAddressService.getOne(qw); | ||
| 147 | + return Arrays.asList(one); | ||
| 125 | } | 148 | } |
| 126 | - return addressList; | 149 | + return garAddressService.list(qw); |
| 127 | } | 150 | } |
| 128 | 151 | ||
| 129 | @Override | 152 | @Override |
| 130 | public String saveAddress(AddressDto dto) { | 153 | public String saveAddress(AddressDto dto) { |
| 131 | - UserCustom userCustom = SecurityUtil.getUserCustom(); | ||
| 132 | - GarAddress garAddress = new GarAddress(); | ||
| 133 | - garAddress.setGarUserId(userCustom.getUser().getGarUserId()); | ||
| 134 | - garAddress.setGarUserAddress(dto.getAddress()); | ||
| 135 | - garAddress.setGarUserDefault(dto.getDefaultFlag()); | ||
| 136 | - garAddress.setGarUserContactName(dto.getContactName()); | ||
| 137 | - garAddress.setGarUserContactTel(dto.getContactTel()); | ||
| 138 | - garAddress.setGarRemark(dto.getDetails()); | ||
| 139 | - garAddressService.save(garAddress); | ||
| 140 | - return "新增地址成功"; | 154 | + LoginUser userCustom = SecurityUtils.getLoginUser(); |
| 155 | + // 限制地址数 | ||
| 156 | + LambdaQueryWrapper<GarAddress> qw = new LambdaQueryWrapper<>(); | ||
| 157 | + qw.eq(GarAddress::getGarUserId, userCustom.getUser().getUserId()); | ||
| 158 | + List<GarAddress> list = garAddressService.list(qw); | ||
| 159 | + if (list.size() > 19) { | ||
| 160 | + throw new BizException(ResultCode.CODE_201, "新增地址数已达上线,请删除地址后新增地址或编辑已有地址!"); | ||
| 161 | + } | ||
| 162 | + GarAddress address = new GarAddress(); | ||
| 163 | + address.setGarUserId(userCustom.getUser().getUserId()); | ||
| 164 | + address.setGarUserAddress(dto.getAddressArea()); | ||
| 165 | + address.setGarUserDefault(dto.getDefaultFlag() ? GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue() : GlobalStatus.GarAddressStatus.NORMAL_ADDRESS.getValue()); | ||
| 166 | + address.setGarUserContactName(dto.getContactPerson()); | ||
| 167 | + address.setGarUserContactTel(dto.getContactIphoneNumber()); | ||
| 168 | + address.setGarRemark(dto.getAddressDetail()); | ||
| 169 | + handleCurrentAddress(address); | ||
| 170 | + garAddressService.save(address); | ||
| 171 | + return "新增地址成功!"; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + @Override | ||
| 175 | + public String updateAddress(AddressDto dto) { | ||
| 176 | + GarAddress address = new GarAddress(); | ||
| 177 | + String userId = SecurityUtils.getLoginUser().getUser().getUserId(); | ||
| 178 | + address.setGarAddressId(dto.getGarAddressId()); | ||
| 179 | + address.setGarUserId(userId); | ||
| 180 | + address.setGarUserAddress(dto.getAddressArea()); | ||
| 181 | + address.setGarRemark(dto.getAddressDetail()); | ||
| 182 | + address.setGarUserDefault(dto.getDefaultFlag() ? GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue() : GlobalStatus.GarAddressStatus.NORMAL_ADDRESS.getValue()); | ||
| 183 | + handleCurrentAddress(address); | ||
| 184 | + address.setGarUserContactName(dto.getContactPerson()); | ||
| 185 | + address.setGarUserContactTel(dto.getContactIphoneNumber()); | ||
| 186 | + LambdaUpdateWrapper<GarAddress> up = new LambdaUpdateWrapper<>(); | ||
| 187 | + up.eq(GarAddress::getGarUserId, address.getGarUserId()) | ||
| 188 | + .eq(GarAddress::getGarAddressId, address.getGarAddressId()); | ||
| 189 | + garAddressService.update(address, up); | ||
| 190 | + return "地址修改成功!"; | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + private void handleCurrentAddress(GarAddress address) { | ||
| 194 | + if (address.getGarUserDefault().equals(GlobalStatus.GarAddressStatus.CURRENT_ADDRESS.getValue())) { | ||
| 195 | + LambdaUpdateWrapper<GarAddress> wrapper = new LambdaUpdateWrapper<>(); | ||
| 196 | + wrapper.eq(GarAddress::getGarUserId, address.getGarUserId()) | ||
| 197 | + .set(GarAddress::getGarUserDefault, GlobalStatus.GarAddressStatus.NORMAL_ADDRESS.getValue()); | ||
| 198 | + garAddressService.update(wrapper); | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + @Override | ||
| 203 | + public String deleteAddress(String addressId) { | ||
| 204 | + String garUserId = SecurityUtils.getLoginUser().getUser().getUserId(); | ||
| 205 | + LambdaQueryWrapper<GarAddress> qw = new LambdaQueryWrapper<>(); | ||
| 206 | + qw.eq(GarAddress::getGarUserId, garUserId) | ||
| 207 | + .eq(GarAddress::getGarAddressId, addressId); | ||
| 208 | + garAddressService.remove(qw); | ||
| 209 | + return "删除成功!"; | ||
| 141 | } | 210 | } |
| 142 | 211 | ||
| 143 | 212 |
trash-garbage/src/main/java/com/trash/garbage/service/impl/UserDetailServiceImpl.java deleted
100644 → 0
| 1 | -package com.trash.garbage.service.impl; | ||
| 2 | - | ||
| 3 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 4 | -import com.trash.garbage.global.GlobalStatus; | ||
| 5 | -import com.trash.garbage.pojo.domain.GarUser; | ||
| 6 | -import com.trash.garbage.security.UserCustom; | ||
| 7 | -import com.trash.garbage.service.GarUserService; | ||
| 8 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | -import org.springframework.security.core.userdetails.UserDetails; | ||
| 10 | -import org.springframework.security.core.userdetails.UserDetailsService; | ||
| 11 | -import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
| 12 | -import org.springframework.stereotype.Component; | ||
| 13 | - | ||
| 14 | -import java.util.Collections; | ||
| 15 | -import java.util.Objects; | ||
| 16 | - | ||
| 17 | -/** | ||
| 18 | - * 用户信息实现类 | ||
| 19 | - * @author 20412 | ||
| 20 | - */ | ||
| 21 | -@Component | ||
| 22 | -public class UserDetailServiceImpl implements UserDetailsService { | ||
| 23 | - | ||
| 24 | - @Autowired | ||
| 25 | - private GarUserService userService; | ||
| 26 | - | ||
| 27 | - /** 查询数据库中的数据是否配对上 */ | ||
| 28 | - @Override | ||
| 29 | - public UserDetails loadUserByUsername(String tel) throws UsernameNotFoundException { | ||
| 30 | - // 查表是否有对应的tel | ||
| 31 | - QueryWrapper<GarUser> qw = new QueryWrapper<>(); | ||
| 32 | - qw.lambda().eq(GarUser::getGarUserTel, tel); | ||
| 33 | - GarUser user = userService.getOne(qw); | ||
| 34 | - if (Objects.isNull(user)) { | ||
| 35 | - // 不存在就创建用户 | ||
| 36 | - GarUser nUser = new GarUser(); | ||
| 37 | - nUser.setGarUserTel(tel); | ||
| 38 | - nUser.setGarUserDelFlag(GlobalStatus.DEL_FLAG_NO); | ||
| 39 | - nUser.setGarUserType("iphone"); | ||
| 40 | - if (userService.save(nUser)) { | ||
| 41 | - return new UserCustom(nUser, Collections.emptyList()); | ||
| 42 | - } | ||
| 43 | - } | ||
| 44 | - // 第二参数是控制权限 普通用户无需角色认证 | ||
| 45 | - return new UserCustom(user, Collections.emptyList()); | ||
| 46 | - } | ||
| 47 | -} |
trash-garbage/src/main/java/com/trash/garbage/utils/FastJson2JsonRedisSerializer.java deleted
100644 → 0
| 1 | -package com.trash.garbage.utils; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | -import com.alibaba.fastjson.parser.ParserConfig; | ||
| 5 | -import com.alibaba.fastjson.serializer.SerializerFeature; | ||
| 6 | -import com.fasterxml.jackson.databind.JavaType; | ||
| 7 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 8 | -import com.fasterxml.jackson.databind.type.TypeFactory; | ||
| 9 | -import org.springframework.data.redis.serializer.RedisSerializer; | ||
| 10 | -import org.springframework.data.redis.serializer.SerializationException; | ||
| 11 | -import org.springframework.util.Assert; | ||
| 12 | - | ||
| 13 | -import java.nio.charset.Charset; | ||
| 14 | -/** | ||
| 15 | - * FastJson2JsonRedisSerializer | ||
| 16 | - * Redis使用FastJson序列化 | ||
| 17 | - */ | ||
| 18 | -public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> { | ||
| 19 | - private ObjectMapper objectMapper = new ObjectMapper(); | ||
| 20 | - public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); | ||
| 21 | - | ||
| 22 | - private Class<T> clazz; | ||
| 23 | - | ||
| 24 | - static { | ||
| 25 | - ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | ||
| 26 | - //如果遇到反序列化autoType is not support错误,请添加并修改一下包名到bean文件路径 | ||
| 27 | - // ParserConfig.getGlobalInstance().addAccept("com.xxxxx.xxx"); | ||
| 28 | - } | ||
| 29 | - public FastJson2JsonRedisSerializer(Class<T> clazz) { | ||
| 30 | - super(); | ||
| 31 | - this.clazz = clazz; | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - public byte[] serialize(T t) throws SerializationException { | ||
| 35 | - if (t == null) { | ||
| 36 | - return new byte[0]; | ||
| 37 | - } | ||
| 38 | - return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - public T deserialize(byte[] bytes) throws SerializationException { | ||
| 42 | - if (bytes == null || bytes.length <= 0) { | ||
| 43 | - return null; | ||
| 44 | - } | ||
| 45 | - String str = new String(bytes, DEFAULT_CHARSET); | ||
| 46 | - | ||
| 47 | - return JSON.parseObject(str, clazz); | ||
| 48 | - } | ||
| 49 | - public void setObjectMapper(ObjectMapper objectMapper) { | ||
| 50 | - Assert.notNull(objectMapper, "'objectMapper' must not be null"); | ||
| 51 | - this.objectMapper = objectMapper; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - protected JavaType getJavaType(Class<?> clazz) { | ||
| 55 | - return TypeFactory.defaultInstance().constructType(clazz); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | -} |
trash-garbage/src/main/java/com/trash/garbage/utils/JsonUtil.java deleted
100644 → 0
| 1 | -package com.trash.garbage.utils; | ||
| 2 | - | ||
| 3 | -import cn.hutool.core.bean.BeanUtil; | ||
| 4 | -import com.alibaba.fastjson.JSON; | ||
| 5 | -import com.alibaba.fastjson.JSONObject; | ||
| 6 | -import org.slf4j.Logger; | ||
| 7 | -import org.slf4j.LoggerFactory; | ||
| 8 | - | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * @Author : guzijian | ||
| 12 | - * @Description : | ||
| 13 | - **/ | ||
| 14 | -public final class JsonUtil { | ||
| 15 | - static Logger log = LoggerFactory.getLogger(JsonUtil.class) ; | ||
| 16 | - /** | ||
| 17 | - * 把Java对象转换成json字符串 | ||
| 18 | - * | ||
| 19 | - * @param object 待转化为JSON字符串的Java对象 | ||
| 20 | - * @return json 串 or null | ||
| 21 | - */ | ||
| 22 | - public static String parseObjToJson(Object object) { | ||
| 23 | - String string = null; | ||
| 24 | - try { | ||
| 25 | - string = JSONObject.toJSONString(object); | ||
| 26 | - } catch (Exception e) { | ||
| 27 | - log.info("把Java对象转换成json字符串转换异常:{}",e.getMessage()); | ||
| 28 | - } | ||
| 29 | - return string; | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - /** | ||
| 33 | - * 将Json字符串信息转换成对应的Java对象 | ||
| 34 | - * | ||
| 35 | - * @param json json字符串对象 | ||
| 36 | - * @param c 对应的类型 | ||
| 37 | - */ | ||
| 38 | - public static <T> T parseJsonToObj(String json, Class<T> c) { | ||
| 39 | - try { | ||
| 40 | - JSONObject jsonObject = JSON.parseObject(json); | ||
| 41 | - return JSON.toJavaObject(jsonObject, c); | ||
| 42 | - } catch (Exception e) { | ||
| 43 | - log.info("将Json字符串信息转换成对应的Java对象转换异常:{}",e.getMessage()); | ||
| 44 | - return null; | ||
| 45 | - } | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - public static <T> T parseObjToObj(Object obj,Class<T> clazz){ | ||
| 49 | - try { | ||
| 50 | - return BeanUtil.toBean(obj, clazz); | ||
| 51 | - }catch (Exception e){ | ||
| 52 | - log.info("将Json字符串信息转换成对应的Java对象转换异常:{}",e.getMessage()); | ||
| 53 | - } | ||
| 54 | - return null; | ||
| 55 | - } | ||
| 56 | -} | ||
| 57 | \ No newline at end of file | 0 | \ No newline at end of file |
trash-garbage/src/main/java/com/trash/garbage/utils/JwtUtils.java
| @@ -19,15 +19,15 @@ public class JwtUtils { | @@ -19,15 +19,15 @@ public class JwtUtils { | ||
| 19 | private final static String tokenSecret = "guzijian"; | 19 | private final static String tokenSecret = "guzijian"; |
| 20 | 20 | ||
| 21 | /** 创建token */ | 21 | /** 创建token */ |
| 22 | - public static String createToken(String username, String userId) { | 22 | + public static String createToken(String id, String tel) { |
| 23 | String token = Jwts.builder() | 23 | String token = Jwts.builder() |
| 24 | // 说明 | 24 | // 说明 |
| 25 | .setSubject("AUTH-USER") | 25 | .setSubject("AUTH-USER") |
| 26 | // 过期时间 | 26 | // 过期时间 |
| 27 | .setExpiration(new Date(System.currentTimeMillis() + tokenExpiration)) | 27 | .setExpiration(new Date(System.currentTimeMillis() + tokenExpiration)) |
| 28 | // 加入认证信息 | 28 | // 加入认证信息 |
| 29 | - .claim("userId",userId) | ||
| 30 | - .claim("username",username) | 29 | + .claim("tel",tel) |
| 30 | + .claim("userId",id) | ||
| 31 | // 加密方式 jwt 密钥方便解密 | 31 | // 加密方式 jwt 密钥方便解密 |
| 32 | .signWith(SignatureAlgorithm.HS256, tokenSecret) | 32 | .signWith(SignatureAlgorithm.HS256, tokenSecret) |
| 33 | // 压缩方式 | 33 | // 压缩方式 |
trash-garbage/src/main/java/com/trash/garbage/utils/RedisUtils.java
| 1 | package com.trash.garbage.utils; | 1 | package com.trash.garbage.utils; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.bean.BeanUtil; | ||
| 4 | import org.springframework.beans.factory.annotation.Autowired; | 3 | import org.springframework.beans.factory.annotation.Autowired; |
| 5 | import org.springframework.data.redis.core.RedisTemplate; | 4 | import org.springframework.data.redis.core.RedisTemplate; |
| 6 | import org.springframework.stereotype.Component; | 5 | import org.springframework.stereotype.Component; |
| @@ -25,10 +24,6 @@ public class RedisUtils { | @@ -25,10 +24,6 @@ public class RedisUtils { | ||
| 25 | return redisTemplate.opsForValue().get(key); | 24 | return redisTemplate.opsForValue().get(key); |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | - public <T> T get(String key,Class<T> clazz){ | ||
| 29 | - return BeanUtil.toBean(redisTemplate.opsForValue().get(key), clazz); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | public boolean setNxAndEx(String key,String value,long expireTime){ | 27 | public boolean setNxAndEx(String key,String value,long expireTime){ |
| 33 | return redisTemplate.opsForValue().setIfAbsent(key,value,expireTime, TimeUnit.SECONDS); | 28 | return redisTemplate.opsForValue().setIfAbsent(key,value,expireTime, TimeUnit.SECONDS); |
| 34 | } | 29 | } |
trash-garbage/src/main/java/com/trash/garbage/utils/SecurityUtil.java deleted
100644 → 0
| 1 | -package com.trash.garbage.utils; | ||
| 2 | - | ||
| 3 | -import com.trash.garbage.custom.BizException; | ||
| 4 | -import com.trash.garbage.global.ResultCode; | ||
| 5 | -import com.trash.garbage.security.UserCustom; | ||
| 6 | -import org.springframework.security.core.context.SecurityContextHolder; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * @author 20412 | ||
| 10 | - */ | ||
| 11 | -public class SecurityUtil { | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - public static UserCustom getUserCustom() { | ||
| 15 | - if (SecurityContextHolder.getContext().getAuthentication().getPrincipal() instanceof UserCustom) | ||
| 16 | - return (UserCustom) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | ||
| 17 | - throw new BizException(ResultCode.CODE_401, ResultCode.CODE_401.getMsg()); | ||
| 18 | - } | ||
| 19 | -} |
trash-garbage/src/main/java/com/trash/garbage/utils/ValidateCodeUtil.java
| @@ -3,11 +3,11 @@ package com.trash.garbage.utils; | @@ -3,11 +3,11 @@ package com.trash.garbage.utils; | ||
| 3 | import java.util.Random; | 3 | import java.util.Random; |
| 4 | 4 | ||
| 5 | public class ValidateCodeUtil { | 5 | public class ValidateCodeUtil { |
| 6 | - public static Integer generatorCode(int bit){ | ||
| 7 | - int code = 0; | 6 | + public static String generatorCode(int bit){ |
| 7 | + StringBuilder code = new StringBuilder(); | ||
| 8 | for (int i = 0; i < bit; i++) { | 8 | for (int i = 0; i < bit; i++) { |
| 9 | - code = code * 10 + new Random().nextInt(10); | 9 | + code = code.append(new Random().nextInt(10)); |
| 10 | } | 10 | } |
| 11 | - return code; | 11 | + return code.toString(); |
| 12 | } | 12 | } |
| 13 | } | 13 | } |
trash-garbage/src/main/resources/application-dev.yml deleted
100644 → 0
| 1 | -spring: | ||
| 2 | - datasource: | ||
| 3 | - type: com.alibaba.druid.pool.DruidDataSource | ||
| 4 | - driverClassName: com.mysql.cj.jdbc.Driver | ||
| 5 | - druid: | ||
| 6 | - # 主库数据源 | ||
| 7 | - url: jdbc:mysql://localhost:3306/trash?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useAffectedRows=true&allowMultiQueries=true | ||
| 8 | - username: root | ||
| 9 | - password: guzijian | ||
| 10 | - # 初始连接数 | ||
| 11 | - initialSize: 5 | ||
| 12 | - # 最小连接池数量 | ||
| 13 | - minIdle: 10 | ||
| 14 | - # 最大连接池数量 | ||
| 15 | - maxActive: 20 | ||
| 16 | - # 配置获取连接等待超时的时间 | ||
| 17 | - maxWait: 60000 | ||
| 18 | - # 配置连接超时时间 | ||
| 19 | - connectTimeout: 30000 | ||
| 20 | - # 配置网络超时时间 | ||
| 21 | - socketTimeout: 60000 | ||
| 22 | - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 | ||
| 23 | - timeBetweenEvictionRunsMillis: 60000 | ||
| 24 | - # 配置一个连接在池中最小生存的时间,单位是毫秒 | ||
| 25 | - minEvictableIdleTimeMillis: 300000 | ||
| 26 | - # 配置一个连接在池中最大生存的时间,单位是毫秒 | ||
| 27 | - maxEvictableIdleTimeMillis: 900000 | ||
| 28 | - # 配置检测连接是否有效 | ||
| 29 | - validationQuery: SELECT 1 FROM DUAL | ||
| 30 | - testWhileIdle: true | ||
| 31 | - testOnBorrow: false | ||
| 32 | - testOnReturn: false | ||
| 33 | - webStatFilter: | ||
| 34 | - enabled: true | ||
| 35 | - statViewServlet: | ||
| 36 | - enabled: true | ||
| 37 | - # 设置白名单,不填则允许所有访问 | ||
| 38 | - allow: | ||
| 39 | - url-pattern: /druid/* | ||
| 40 | - # 控制台管理用户名和密码 | ||
| 41 | - login-username: ruoyi | ||
| 42 | - login-password: 123456 | ||
| 43 | - filter: | ||
| 44 | - stat: | ||
| 45 | - enabled: true | ||
| 46 | - # 慢SQL记录 | ||
| 47 | - log-slow-sql: true | ||
| 48 | - slow-sql-millis: 1000 | ||
| 49 | - merge-sql: true | ||
| 50 | - wall: | ||
| 51 | - config: | ||
| 52 | - multi-statement-allow: true | ||
| 53 | - redis: | ||
| 54 | - # 地址 | ||
| 55 | -# host: 121.41.83.61 | ||
| 56 | -# host: 192.168.172.221 | ||
| 57 | - host: 127.0.0.1 | ||
| 58 | - database: 0 | ||
| 59 | - # password: "guzijian" | ||
| 60 | - port: 6379 | ||
| 61 | - # 连接超时时间 | ||
| 62 | - timeout: 10s | ||
| 63 | - lettuce: | ||
| 64 | - pool: | ||
| 65 | - # 连接池中的最小空闲连接 | ||
| 66 | - min-idle: 0 | ||
| 67 | - # 连接池中的最大空闲连接 | ||
| 68 | - max-idle: 8 | ||
| 69 | - # 连接池的最大数据库连接数 | ||
| 70 | - max-active: 8 | ||
| 71 | - # #连接池最大阻塞等待时间(使用负值表示没有限制) | ||
| 72 | - max-wait: -1ms | ||
| 73 | - #返回json的全局时间格式 | ||
| 74 | - jackson: | ||
| 75 | - date-format: yyyy-MM-dd HH:mm:ss | ||
| 76 | - time-zone: GMT+8 | ||
| 77 | - | ||
| 78 | -# mybaits 配置 | ||
| 79 | -mybatis-plus: | ||
| 80 | - global-config: | ||
| 81 | - # 指定逻辑删除含义 | ||
| 82 | - db-config: | ||
| 83 | - logic-delete-value: 1 | ||
| 84 | - logic-not-delete-value: 0 | ||
| 85 | - configuration: | ||
| 86 | - # 日志打印sql | ||
| 87 | - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | ||
| 88 | - | ||
| 89 | -trash: | ||
| 90 | - garbage: | ||
| 91 | - config: | ||
| 92 | - location: | ||
| 93 | - # security 放行路径 | ||
| 94 | - exclude: /user/login,/user/send/verify,/user/sendCode/**,/doc.html,/swagger-ui.html,/swagger-ui/**,/swagger-resources/**,/v2/api-docs,/v3/api-docs,/webjars/**,/ws/** | ||
| 95 | - | ||
| 96 | -wx: | ||
| 97 | - appId: 'wxc3f60667dc9d6cea' | ||
| 98 | - secret: 'd35996a9f898dff37974efba0b6f23ed' | ||
| 99 | \ No newline at end of file | 0 | \ No newline at end of file |
trash-garbage/src/main/resources/application.yml deleted
100644 → 0
trash-garbage/src/main/resources/mapper/GarAddressMapper.xml
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | <mapper namespace="com.trash.garbage.mapper.GarAddressMapper"> | 5 | <mapper namespace="com.trash.garbage.mapper.GarAddressMapper"> |
| 6 | 6 | ||
| 7 | <resultMap id="BaseResultMap" type="com.trash.garbage.pojo.domain.GarAddress"> | 7 | <resultMap id="BaseResultMap" type="com.trash.garbage.pojo.domain.GarAddress"> |
| 8 | - <id property="garAddressId" column="gar_address_id" jdbcType="BIGINT"/> | 8 | + <id property="garAddressId" column="gar_address_id" jdbcType="VARCHAR"/> |
| 9 | <result property="garUserId" column="gar_user_id" jdbcType="VARCHAR"/> | 9 | <result property="garUserId" column="gar_user_id" jdbcType="VARCHAR"/> |
| 10 | <result property="garUserAddress" column="gar_user_address" jdbcType="VARCHAR"/> | 10 | <result property="garUserAddress" column="gar_user_address" jdbcType="VARCHAR"/> |
| 11 | <result property="garUserDefault" column="gar_user_default" jdbcType="TINYINT"/> | 11 | <result property="garUserDefault" column="gar_user_default" jdbcType="TINYINT"/> |