diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..a35811d --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1,6 @@ +target/ +*.iml +.idea/ +.vscode/ +.DS_Store +*.log diff --git a/backend/pom.xml b/backend/pom.xml new file mode 100644 index 0000000..b529cc8 --- /dev/null +++ b/backend/pom.xml @@ -0,0 +1,165 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 3.3.5 + + + + com.xly + test4-backend + 0.0.1-SNAPSHOT + test4-backend + 小羚羊 ERP 后端 + + + 21 + UTF-8 + 3.5.7 + 1.5.5.Final + 1.18.32 + 0.2.0 + 0.12.5 + 2.6.0 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-validation + + + + com.baomidou + mybatis-plus-spring-boot3-starter + ${mybatis-plus.version} + + + + org.flywaydb + flyway-core + + + org.flywaydb + flyway-mysql + + + + com.mysql + mysql-connector-j + + + + io.jsonwebtoken + jjwt-api + ${jjwt.version} + + + io.jsonwebtoken + jjwt-impl + ${jjwt.version} + runtime + + + io.jsonwebtoken + jjwt-jackson + ${jjwt.version} + runtime + + + + org.mapstruct + mapstruct + ${mapstruct.version} + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + test4-backend + + + org.apache.maven.plugins + maven-compiler-plugin + + 21 + 21 + + + org.projectlombok + lombok + ${lombok.version} + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + org.projectlombok + lombok-mapstruct-binding + ${lombok-mapstruct-binding.version} + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*Test.java + **/*IT.java + + + + + + diff --git a/backend/src/main/java/com/xly/test4/Application.java b/backend/src/main/java/com/xly/test4/Application.java new file mode 100644 index 0000000..8b91511 --- /dev/null +++ b/backend/src/main/java/com/xly/test4/Application.java @@ -0,0 +1,13 @@ +package com.xly.test4; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@MapperScan("com.xly.test4.module.*.mapper") +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml new file mode 100644 index 0000000..89503c4 --- /dev/null +++ b/backend/src/main/resources/application-dev.yml @@ -0,0 +1,4 @@ +logging: + level: + com.xly.test4: DEBUG + org.flywaydb: INFO diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml new file mode 100644 index 0000000..91e40a0 --- /dev/null +++ b/backend/src/main/resources/application.yml @@ -0,0 +1,42 @@ +spring: + application: + name: test4-backend + profiles: + active: dev + config: + import: optional:file:../.env.local[.properties] + datasource: + url: jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_SCHEMA}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useSSL=false + username: ${DB_USER} + password: ${DB_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + flyway: + enabled: true + locations: filesystem:../sql/migrations + baseline-on-migrate: false + +server: + port: 8080 + +mybatis-plus: + mapper-locations: classpath:mapper/**/*.xml + global-config: + db-config: + id-type: AUTO + configuration: + map-underscore-to-camel-case: false + +app: + security: + default-password: "666666" + max-login-fail: 5 + lock-minutes: 30 + jwt: + secret: ${JWT_SECRET} + access-ttl-hours: 24 + +springdoc: + api-docs: + path: /v3/api-docs + swagger-ui: + path: /swagger-ui.html diff --git a/backend/src/test/java/com/xly/test4/ApplicationContextIT.java b/backend/src/test/java/com/xly/test4/ApplicationContextIT.java new file mode 100644 index 0000000..513c284 --- /dev/null +++ b/backend/src/test/java/com/xly/test4/ApplicationContextIT.java @@ -0,0 +1,21 @@ +package com.xly.test4; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest +class ApplicationContextIT { + + @Autowired + private ApplicationContext context; + + @Test + void contextLoads() { + assertThat(context).isNotNull(); + assertThat(context.getBean(Application.class)).isNotNull(); + } +}