Amog_ 2 years ago
parent d8f9d45e45
commit 0963fc433c

@ -0,0 +1 @@
miniprogram

@ -1,71 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>miniprogram</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>miniprogram</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>20</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!--parent-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<groupId>com.example</groupId>
<artifactId>miniprogram</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>miniprogram</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>20</java.version>
</properties>
<dependencies>
<!--jdbc-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<!--jpa-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!--thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--mysql-->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!--test-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--tomcat-->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>9.0.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -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;
}

@ -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;
}

@ -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 <K>
* @param <V>
*/
public abstract class Repository<K, V> {
private final Map<K, V> map = new ConcurrentHashMap<>();
/**
*
*/
private final Function<V, K> getPrimaryKey;
public Repository(Function<V, K> 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<V> findAll() {
return map.values();
}
public void clear() {
map.clear();
}
}

@ -0,0 +1,7 @@
package com.example.miniprogram.service;
import org.springframework.stereotype.Service;
@Service
public class UserService {
}

@ -1,2 +1,12 @@
server:
port: 8080
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
Loading…
Cancel
Save