diff --git a/README.me b/README.me new file mode 100644 index 0000000..a87e341 --- /dev/null +++ b/README.me @@ -0,0 +1 @@ +miniprogram \ No newline at end of file diff --git a/pom.xml b/pom.xml index cdebc21..f9db138 100644 --- a/pom.xml +++ b/pom.xml @@ -1,71 +1,95 @@ - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.1.3 - - - com.example - miniprogram - 0.0.1-SNAPSHOT - miniprogram - Demo project for Spring Boot - - 20 - - - - org.springframework.boot - spring-boot-starter-data-jdbc - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-web - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - com.mysql - mysql-connector-j - runtime - - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - + + + org.springframework.boot + spring-boot-starter-parent + 3.1.3 + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.projectlombok - lombok - - - - - - + com.example + miniprogram + 0.0.1-SNAPSHOT + miniprogram + Demo project for Spring Boot + + 20 + + + + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + org.springframework.boot + spring-boot-starter-web + + + + + com.mysql + mysql-connector-j + runtime + + + + + org.projectlombok + lombok + true + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.apache.tomcat + tomcat-servlet-api + 9.0.12 + provided + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + diff --git a/src/main/java/com/example/miniprogram/entity/Swiper.java b/src/main/java/com/example/miniprogram/entity/Swiper.java new file mode 100644 index 0000000..80b3d18 --- /dev/null +++ b/src/main/java/com/example/miniprogram/entity/Swiper.java @@ -0,0 +1,16 @@ +package com.example.miniprogram.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Table(name = "`swiper`") +@Data +@AllArgsConstructor +public class Swiper { + @Id + @Column(name = "`swiper_id`") + private Integer swiperId; + + @Column(name = "`swiper_image_url`") + private String swiperImageUrl; +} diff --git a/src/main/java/com/example/miniprogram/entity/User.java b/src/main/java/com/example/miniprogram/entity/User.java new file mode 100644 index 0000000..635587c --- /dev/null +++ b/src/main/java/com/example/miniprogram/entity/User.java @@ -0,0 +1,30 @@ +package com.example.miniprogram.entity; + +import jakarta.persistence.*; +import lombok.*; + +import java.util.Date; + +@Table(name = "`user`") +@Data +@AllArgsConstructor +public class User { + @Id + @Column(name = "`user_id`") + private Integer userId; + + @Column(name = "`user_gender`") + private Integer userGender; + + @Column(name = "`user_nickname`") + private String userNickname; + + @Column(name = "`user_is_admin`") + private Integer userIsAdmin; + + @Column(name = "`user_allow`") + private Integer userAllow; + + @Column(name = "`user_create_time`") + private Date userCreatTime; +} diff --git a/src/main/java/com/example/miniprogram/repository/Repository.java b/src/main/java/com/example/miniprogram/repository/Repository.java new file mode 100644 index 0000000..19d5244 --- /dev/null +++ b/src/main/java/com/example/miniprogram/repository/Repository.java @@ -0,0 +1,46 @@ +package com.example.miniprogram.repository; + +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * 通用的仓库类 + * 提供基础的增删改查和主键映射 + * + * @param 主键类型 + * @param 值类型 + */ +public abstract class Repository { + private final Map map = new ConcurrentHashMap<>(); + /** + * 将值映射为主键的函数 + */ + private final Function getPrimaryKey; + + public Repository(Function getPrimaryKey) { + this.getPrimaryKey = getPrimaryKey; + } + + public void update(V value) { + map.put(getPrimaryKey.apply(value), value); + } + + public V find(K key) { + if (key == null) return null; + return map.get(key); + } + + public void delete(K key) { + map.remove(key); + } + + public Collection findAll() { + return map.values(); + } + + public void clear() { + map.clear(); + } +} diff --git a/src/main/java/com/example/miniprogram/service/UserService.java b/src/main/java/com/example/miniprogram/service/UserService.java new file mode 100644 index 0000000..e34a689 --- /dev/null +++ b/src/main/java/com/example/miniprogram/service/UserService.java @@ -0,0 +1,7 @@ +package com.example.miniprogram.service; + +import org.springframework.stereotype.Service; + +@Service +public class UserService { +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 47fbb02..2ce0911 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,2 +1,12 @@ server: - port: 8080 \ No newline at end of file + port: 8080 + +spring: + datasource: + url: jdbc:mysql://localhost:3306/db + username: root + password: root + +spring.jackson.date-format: yyyy-MM-dd HH:mm + +spring.jackson.time-zone: GMT+8 \ No newline at end of file