day10日考
commit
9249a20847
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AnalysisProjectProfileManager">
|
||||
<option name="PROJECT_PROFILE" />
|
||||
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
|
||||
<list size="0" />
|
||||
</component>
|
||||
<component name="SuppressionsComponent">
|
||||
<option name="suppComments" value="[]" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
|
||||
<file url="file://$PROJECT_DIR$/common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/common/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/user/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/user/src/main/resources" charset="UTF-8" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8 (2)" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SuppressionsComponent">
|
||||
<option name="suppComments" value="[]" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AnalysisProjectProfileManager">
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
|
||||
<scopes />
|
||||
<profiles>
|
||||
<profile profile_name="Project Default" version="1.0" is_locked="false" />
|
||||
</profiles>
|
||||
<list size="0" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.bw</groupId>
|
||||
<artifactId>daytenRikao</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- json-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.79</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
|
||||
<!--druid-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.bw</groupId>
|
||||
<artifactId>daytenRikao</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>common</module>
|
||||
<module>user</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.2.2.RELEASE</spring-boot.version>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</properties>
|
||||
|
||||
<!-- 规定SpringBoot版本 -->
|
||||
<parent>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<version>2.6.2</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,7 @@
|
|||
package com.bw;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.bw</groupId>
|
||||
<artifactId>daytenRikao</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>user</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- 引入公共模块-->
|
||||
<dependency>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>3.16.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<!-- poi导入导出依赖 -->
|
||||
<!-- excel2003使用的包 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>3.17</version>
|
||||
</dependency>
|
||||
<!-- excel2007+使用的包 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>3.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- 测试 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Druid -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.2.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- servlet 依赖. -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.11</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- Mybatis 依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
<!-- PageHelper mybatis分页插件 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<!-- json-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.79</version>
|
||||
</dependency>
|
||||
<!-- 邮件发送 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- oss sdk-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.10.2</version>
|
||||
</dependency>
|
||||
<!--knife4j-->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>2.0.9</version>
|
||||
</dependency>
|
||||
<!-- jwt-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- quartz定时任务-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.tobato</groupId>
|
||||
<artifactId>fastdfs-client</artifactId>
|
||||
<version>1.26.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 布隆过滤器依赖-->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>27.0.1-jre</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
|
@ -0,0 +1,17 @@
|
|||
package com.bw;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @ClassName Application
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/7/29 9:00
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.bw.config;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
/**
|
||||
* @BelongsProject: month-10a
|
||||
* @BelongsPackage: com.bw.config
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2023-03-09 14:44
|
||||
*/
|
||||
@Component
|
||||
public class BloomFilterUtil {
|
||||
private static final int DEFAULT_SIZE = 2 << 24; // 布隆过滤器的比特长度
|
||||
private static final int[] seeds = new int[] {7, 11, 13, 31,37, 61}; // 这里要选取质数,能很好的降低错误率
|
||||
|
||||
private BitSet bits = new BitSet(DEFAULT_SIZE);
|
||||
private SimpleHash[] func = new SimpleHash[seeds.length];
|
||||
|
||||
public static void main(String[] args) {
|
||||
String value = "crankzcool@gmail.com";
|
||||
BloomFilterUtil filter = new BloomFilterUtil();
|
||||
// System.out.println(filter.contains(value));
|
||||
// filter.add(value);
|
||||
// System.out.println(filter.contains(value));
|
||||
|
||||
filter.add("1");
|
||||
filter.add("2");
|
||||
filter.remove("1");
|
||||
System.out.println(filter.contains("1"));
|
||||
}
|
||||
|
||||
public void remove(String value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
for (SimpleHash f : func) {
|
||||
bits.set(f.hash(value), false);
|
||||
}
|
||||
}
|
||||
|
||||
public BloomFilterUtil() {
|
||||
for (int i = 0; i < seeds.length; i++) {
|
||||
func[i] = new SimpleHash(DEFAULT_SIZE, seeds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String value) {
|
||||
for (SimpleHash f: func) {
|
||||
bits.set(f.hash(value), true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (SimpleHash f : func) {
|
||||
ret = ret && bits.get(f.hash(value));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public static class SimpleHash {
|
||||
private int cap;
|
||||
private int seed;
|
||||
|
||||
public SimpleHash(int cap, int seed) {
|
||||
this.cap = cap;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
public int hash(String value) {
|
||||
int result = 0;
|
||||
int len = value.length();
|
||||
for (int i = 0; i < len; i++) {
|
||||
result = seed * result + value.charAt(i);
|
||||
}
|
||||
return (cap - 1) & result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.bw.config;
|
||||
|
||||
import com.github.tobato.fastdfs.FdfsClientConfig;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.EnableMBeanExport;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.jmx.support.RegistrationPolicy;
|
||||
|
||||
/**
|
||||
* @BelongsProject: demo02
|
||||
* @BelongsPackage: com.bw.config
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2022-12-16 14:37
|
||||
*/
|
||||
@Configuration
|
||||
// 解决 jmx 重复注册 bean 的问题
|
||||
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
|
||||
public class FastConfig {
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.bw.config;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @BelongsProject: 0107day02
|
||||
* @BelongsPackage: com.bw.config
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2023-02-01 08:52
|
||||
*/
|
||||
@Component
|
||||
public class FastUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(FastUtil.class);
|
||||
|
||||
@Resource
|
||||
private FastFileStorageClient storageClient ;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
public String upload(MultipartFile multipartFile) throws Exception{
|
||||
String originalFilename = multipartFile.getOriginalFilename().
|
||||
substring(multipartFile.getOriginalFilename().
|
||||
lastIndexOf(".") + 1);
|
||||
StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage(
|
||||
multipartFile.getInputStream(),
|
||||
multipartFile.getSize(),originalFilename , null);
|
||||
return storePath.getFullPath() ;
|
||||
}
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
public String deleteFile(String fileUrl) {
|
||||
if (StringUtils.isEmpty(fileUrl)) {
|
||||
log.info("fileUrl == >>文件路径为空...");
|
||||
return "文件路径不能为空";
|
||||
}
|
||||
try {
|
||||
StorePath storePath = StorePath.parseFromUrl(fileUrl);
|
||||
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return "删除成功";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.bw.config;
|
||||
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||
|
||||
/**
|
||||
* @BelongsProject: demo02
|
||||
* @BelongsPackage: com.bw.handler
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2022-12-11 14:17
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2WebMvc
|
||||
public class Knife4jConfiguration {
|
||||
|
||||
@Bean(value = "defaultApi2")
|
||||
public Docket defaultApi2() {
|
||||
Docket docket = new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("测试==demo")
|
||||
.description("# swagger-bootstrap-ui-demo RESTful APIs")
|
||||
.termsOfServiceUrl("http://www.xx.com/")
|
||||
.contact(new Contact("玉面小白龙", "", "123@qq.com"))
|
||||
.version("1.0")
|
||||
.build())
|
||||
//分组名称
|
||||
.groupName("2.X版本")
|
||||
.select()
|
||||
//这里指定文档Controller层扫描包路径
|
||||
.apis(RequestHandlerSelectors.basePackage("com.bw.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
return docket;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
//package com.bw.config;
|
||||
//
|
||||
//import com.bw.job.MyJob;
|
||||
//import com.bw.job.MyJob2;
|
||||
//import org.quartz.*;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
///**
|
||||
// * @BelongsProject: demo02
|
||||
// * @BelongsPackage: com.bw.config
|
||||
// * @Author: zhupengfei
|
||||
// * @CreateTime: 2022-12-22 14:59
|
||||
// */
|
||||
////把当前类定义为 一个配置文件类
|
||||
//@Configuration
|
||||
//public class QuartzConfig {
|
||||
// @Bean
|
||||
// public JobDetail downloadDetail() {
|
||||
// return JobBuilder.newJob(MyJob.class) //具体任务类
|
||||
// .withIdentity("downloadJobDetail")
|
||||
// .usingJobData("job_download","download movie")
|
||||
// .storeDurably()
|
||||
// .build();
|
||||
// }
|
||||
// //构建 Trigger 及 Scheduler
|
||||
// @Bean
|
||||
// public Trigger downloadTrigger() {
|
||||
// return TriggerBuilder.newTrigger()
|
||||
// .forJob(downloadDetail()) //关联上面的 jobDetail
|
||||
// .withIdentity("downloadTrigger")
|
||||
// .usingJobData("trigger_download","download")
|
||||
// //cron 表达式设置每隔 15 秒执行一次
|
||||
// .withSchedule(CronScheduleBuilder.cronSchedule("*/15 * * * * ?"))
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -0,0 +1,38 @@
|
|||
//package com.bw.config;
|
||||
//
|
||||
//import com.bw.job.MyJob;
|
||||
//import com.bw.job.MyJob2;
|
||||
//import org.quartz.*;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
///**
|
||||
// * @BelongsProject: demo02
|
||||
// * @BelongsPackage: com.bw.config
|
||||
// * @Author: zhupengfei
|
||||
// * @CreateTime: 2022-12-22 14:59
|
||||
// */
|
||||
////把当前类定义为 一个配置文件类
|
||||
//@Configuration
|
||||
//public class QuartzConfig2 {
|
||||
// @Bean
|
||||
// public JobDetail downloadDetail2() {
|
||||
// return JobBuilder.newJob(MyJob2.class) //具体任务类
|
||||
// .withIdentity("downloadJobDetail2")
|
||||
// .usingJobData("job_download","download movie")
|
||||
// .storeDurably()
|
||||
// .build();
|
||||
// }
|
||||
// //构建 Trigger 及 Scheduler
|
||||
// @Bean
|
||||
// public Trigger downloadTrigger2() {
|
||||
// return TriggerBuilder.newTrigger()
|
||||
// .forJob(downloadDetail2()) //关联上面的 jobDetail
|
||||
// .withIdentity("downloadTrigger2")
|
||||
// .usingJobData("trigger_download","download")
|
||||
// //cron 表达式设置每隔 5 秒执行一次
|
||||
// .withSchedule(CronScheduleBuilder.cronSchedule("*/30 * * * * ?"))
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -0,0 +1,43 @@
|
|||
//package com.bw.config;
|
||||
//
|
||||
//import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
//import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
//import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
//import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
//
|
||||
//@Configuration
|
||||
//public class RedisConfig {
|
||||
//
|
||||
// @Bean
|
||||
// public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||
//
|
||||
//
|
||||
// RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
// template.setConnectionFactory(factory);
|
||||
// Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new
|
||||
// Jackson2JsonRedisSerializer(Object.class);
|
||||
//
|
||||
// ObjectMapper om = new ObjectMapper();
|
||||
// om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
// om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
// jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
//
|
||||
// StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
// // key采用String的序列化方式
|
||||
// template.setKeySerializer(stringRedisSerializer);
|
||||
// // hash的key也采用String的序列化方式
|
||||
// template.setHashKeySerializer(stringRedisSerializer);
|
||||
// // value序列化方式采用jackson
|
||||
// template.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
// // hash的value序列化方式采用jackson
|
||||
// template.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
// template.afterPropertiesSet();
|
||||
//
|
||||
// return template;
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,33 @@
|
|||
//package com.bw.config;
|
||||
//
|
||||
//import org.redisson.Redisson;
|
||||
//import org.redisson.api.RedissonClient;
|
||||
//import org.redisson.config.Config;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
///**
|
||||
// * @BelongsProject: demo02
|
||||
// * @BelongsPackage: com.bw.config
|
||||
// * @Author: zhupengfei
|
||||
// * @CreateTime: 2022-12-24 09:26
|
||||
// */
|
||||
//
|
||||
//@Configuration
|
||||
//public class RedissonConfig {
|
||||
//
|
||||
// @Bean(destroyMethod="shutdown") // 服务停止后调用 shutdown 方法。
|
||||
// public RedissonClient redisson() throws IOException {
|
||||
// System.out.println("配置类初始加载......");
|
||||
// // 1.创建配置
|
||||
// Config config = new Config();
|
||||
// // 集群模式
|
||||
// // config.useClusterServers().addNodeAddress("127.0.0.1:6379", "127.0.0.1:6378");
|
||||
// // 2.根据 Config 创建出 RedissonClient 实例。
|
||||
// config.useSingleServer().setAddress("redis://106.54.193.225:6379");
|
||||
// return Redisson.create(config);
|
||||
// }
|
||||
//
|
||||
//}
|
|
@ -0,0 +1,68 @@
|
|||
package com.bw.config;
|
||||
|
||||
//import com.bw.interceptor.MyInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @BelongsProject: 0107day02
|
||||
* @BelongsPackage: com.bw.config
|
||||
* @Author: zhupengfei
|
||||
* @CreateTime: 2023-02-01 08:51
|
||||
*/
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
// @Autowired
|
||||
// private MyInterceptor myIntercepter;
|
||||
// //全局路由
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
//.allowedOrigins("*") //注意这个变动项,这个是旧版
|
||||
.allowedOriginPatterns("*")//这个才是新版的要求
|
||||
.allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600)
|
||||
.allowedHeaders("*");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 静态资源
|
||||
* @author: zhupengfei
|
||||
* @param: [registry]
|
||||
* @return: void
|
||||
**/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry
|
||||
.addResourceHandler("/static/**")
|
||||
.addResourceLocations("classpath:/static/");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截器
|
||||
* @author: zhupengfei
|
||||
* @param: [registry]
|
||||
* @return: void
|
||||
**/
|
||||
|
||||
// @Override
|
||||
// public void addInterceptors(InterceptorRegistry registry) {
|
||||
// registry.addInterceptor(myIntercepter)
|
||||
// .addPathPatterns("/**")
|
||||
// .excludePathPatterns("/user/*","/user/*/*"
|
||||
// ,"/doc.html","/swagger-resources","/webjars/*/*","/webjars/*","/favicon.ico","/error",
|
||||
// "/student/fastDfsUpLoad"
|
||||
// );
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.bw.controller;
|
||||
|
||||
import com.bw.pojo.User;
|
||||
import com.bw.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName UserController
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/7/29 8:49
|
||||
*/
|
||||
@RestController
|
||||
public class UserController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
//列表
|
||||
@PostMapping("list")
|
||||
public List<User> list(){
|
||||
return userService.list();
|
||||
}
|
||||
//删除
|
||||
@PostMapping("/del")
|
||||
public Integer del(@RequestParam("uid") Integer uid){
|
||||
return userService.del(uid);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.bw.mapper;
|
||||
|
||||
import com.bw.pojo.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
List<User> list();
|
||||
|
||||
Integer del(@RequestParam("uid")Integer uid);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bw.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName User
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/7/29 8:49
|
||||
*/
|
||||
@Data
|
||||
public class User {
|
||||
private Integer uid;
|
||||
private String userNmae;
|
||||
private String pwd;
|
||||
private Integer sex;
|
||||
private String birthday;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.bw.service;
|
||||
|
||||
import com.bw.pojo.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
List<User> list();
|
||||
|
||||
Integer del(Integer uid);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.bw.service.impl;
|
||||
|
||||
import com.bw.mapper.UserMapper;
|
||||
import com.bw.pojo.User;
|
||||
import com.bw.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName UserServiceImpl
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/7/29 8:51
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
@Override
|
||||
public List<User> list() {
|
||||
return userMapper.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer del(Integer uid) {
|
||||
return userMapper.del(uid);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
# 服务器相关
|
||||
|
||||
server:
|
||||
port: 10001
|
||||
|
||||
spring:
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
datasource:
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
url: jdbc:mysql://106.54.193.225:3306/day10rik?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false
|
||||
username: root
|
||||
password: cts@123
|
||||
druid:
|
||||
# 下面为连接池的补充设置,应用到上面所有数据源中
|
||||
# 初始化大小,最小,最大
|
||||
initial-size: 5
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
max-wait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: SELECT 1 FROM DUAL
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
pool-prepared-statements: true
|
||||
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
filters: stat,wall
|
||||
use-global-data-source-stat: true
|
||||
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connect-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
application:
|
||||
name: shop-server
|
||||
redis:
|
||||
host: 106.54.193.225
|
||||
port: 6379
|
||||
mail:
|
||||
host: smtp.qq.com
|
||||
username: 358795815@qq.com
|
||||
password: uuyemjigqlhvbgcj
|
||||
port: 587 # 这个端口根据实际情况配置,一般都是465
|
||||
protocol: smtp # 这里应该是不用改的,我没试过其他的配置
|
||||
test-connection: false
|
||||
default-encoding: UTF-8
|
||||
properties:
|
||||
mail:
|
||||
debug: true
|
||||
smtp:
|
||||
auth: true
|
||||
connectiontimeout: 10000
|
||||
timeout: 10000
|
||||
writetimeout: 10000
|
||||
socketFactory:
|
||||
class: javax.net.ssl.SSLSocketFactory
|
||||
port: 587
|
||||
starttls:
|
||||
enable: true
|
||||
required: true
|
||||
select:
|
||||
multipart:
|
||||
max-file-size: 100MB # 最大支持文件大小
|
||||
max-request-size: 100MB # 最大请求大小
|
||||
enabled: true
|
||||
|
||||
|
||||
# mybatis
|
||||
mybatis:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath*:mapper/*Mapper.xml
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto
|
||||
|
||||
|
||||
aliyun:
|
||||
end-point: oss-cn-shanghai.aliyuncs.com
|
||||
access-key-id: LTAI5tSFAGrms29r1xwEFtRM
|
||||
access-key-secret: rztMfqxdYlsMUtIoy9bIOSGEKCWQT7
|
||||
access-pre: https://dongxiaojie.oss-cn-shanghai.aliyuncs.com
|
||||
bucket-name: dongxiaojie
|
||||
|
||||
fdfs:
|
||||
so-timeout: 1500 # socket 连接时长
|
||||
connect-timeout: 600 # 连接 tracker 服务器超时时长
|
||||
# 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
|
||||
tracker-list: 106.54.193.225:22122
|
||||
web-server-url: 106.54.193.225:8888
|
||||
pool:
|
||||
jmx-enabled: false
|
||||
# 生成缩略图
|
||||
thumb-image:
|
||||
height: 500
|
||||
width: 500
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<!--
|
||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||
-->
|
||||
<mapper namespace="com.bw.mapper.UserMapper">
|
||||
<delete id="del">
|
||||
delete from t_user where uid =#{uid}
|
||||
</delete>
|
||||
<!-- 添加 -->
|
||||
|
||||
|
||||
<select id="list" resultType="com.bw.pojo.User">
|
||||
select * from t_user limit 0,12
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue