基础实体类搭建

This commit is contained in:
石皮幼鸟 2024-04-08 18:51:09 +08:00
parent 6c98936a30
commit 026cd4b800
16 changed files with 213 additions and 20 deletions

20
pom.xml
View File

@ -9,10 +9,10 @@
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>com.example</groupId> <groupId>com.example</groupId>
<artifactId>project-04</artifactId> <artifactId>catch-the-letters</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>project-04</name> <name>catch-the-letters</name>
<description>project-04</description> <description>catch-the-letters</description>
<properties> <properties>
<java.version>17</java.version> <java.version>17</java.version>
<fastjson.version>2.0.34</fastjson.version> <fastjson.version>2.0.34</fastjson.version>
@ -54,13 +54,6 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--mybatis-plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<!--fastjson--> <!--fastjson-->
<dependency> <dependency>
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.alibaba.fastjson2</groupId>
@ -75,11 +68,10 @@
<version>${lombok.version}</version> <version>${lombok.version}</version>
</dependency> </dependency>
<!--mysql-connector--> <!--MongoDB-->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${mysql.version}</version>
</dependency> </dependency>
<!--junit--> <!--junit-->

View File

@ -1,13 +1,13 @@
package com.example.project04; package com.example.catchTheLetters;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class Project04Application { public class CatchTheLettersApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Project04Application.class, args); SpringApplication.run(CatchTheLettersApplication.class, args);
} }
} }

View File

@ -0,0 +1,52 @@
package com.example.catchTheLetters.entity;
import java.io.Serializable;
import java.util.List;
/**
* 关卡类
* @author spyn
*/
public class Level implements Serializable {
/**
* 关卡ID
*/
private Long id;
/**
* 关卡名称
*/
private String name;
/**
* 关卡描述
*/
private String description;
/**
* 关卡难度
* -0简单
* -1普通
* -2困难
*/
private Integer difficulty;
/**
* 关卡内容
*/
private String content;
/**
* 关卡类型
* -0拼完题设单词
* -1达成目标分数
*/
private Integer type;
/**
* 限时可选毫秒数
*/
private Long timeLimit;
/**
* 目标分数type=1时有效
*/
private Integer targetScore;
/**
* 单词列表
*/
private List<String> words;
}

View File

@ -0,0 +1,26 @@
package com.example.catchTheLetters.entity;
import java.io.Serializable;
/**
* 关卡结算信息类
* @author spyn
*/
public class ScoreInfo implements Serializable {
/**
* 用户ID
*/
private Long id;
/**
* 用户名
*/
private String username;
/**
* 分数
*/
private Integer score;
/**
* 时间UNIX时间戳
*/
private Long time;
}

View File

@ -0,0 +1,69 @@
package com.example.catchTheLetters.entity;
import lombok.Data;
import java.io.Serializable;
/**
* 用户类
* @author spyn
*/
@Data
public class User implements Serializable {
/**
* 用户ID
*/
private Long id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 性别
* -0未知
* -1
* -2
*/
private int sex;
/**
* 头像
*/
private String avatar;
/**
* 邮箱
*/
private String email;
/**
* 手机号
*/
private String phone;
/**
* 状态
* -0已注销逻辑删除
* -1在线
* -2离线
* -3封禁
* -4未激活未验证邮箱或手机号
*/
private Integer status;
/**
* 创建时间UNIX时间戳
*/
private Long createTime;
/**
* 更新时间UNIX时间戳
*/
private Long updateTime;
/**
* 个人介绍
*/
private String introduction;
/**
* 当前游戏进度关卡ID
*/
private Integer progress;
}

View File

@ -0,0 +1,45 @@
package com.example.catchTheLetters.utils;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* 对象池防止频繁创建对象触发GC必须继承
* @param <T> 对象类型
* @author spyn
*/
public abstract class ObjectPool<T> {
private final ConcurrentLinkedQueue<T> pool;
public ObjectPool() {
this.pool = new ConcurrentLinkedQueue<>();
}
/**
* 取出一个对象
* @return 对象
*/
public T borrowObject() {
T object;
if ((object = pool.poll()) == null) {
object = createObject();
}
return object;
}
/**
* 存入一个对象
* @param object 对象
*/
public void returnObject(T object) {
if (object == null) {
return;
}
this.pool.offer(object);
}
/**
* 创建一个对象
* @return 新建的对象
*/
protected abstract T createObject();
}

View File

@ -1 +0,0 @@
spring.application.name=project-04

View File

@ -0,0 +1,10 @@
spring:
application:
name: catch-the-letters
data:
mongodb:
host: 1.14.105.160
port: 27017
database: catch-the-letters
username: main
password: spynsql

View File

@ -1,10 +1,10 @@
package com.example.project04; package com.example.catchTheLetters;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest @SpringBootTest
class Project04ApplicationTests { class CatchTheLettersApplicationTests {
@Test @Test
void contextLoads() { void contextLoads() {