基础实体类搭建
This commit is contained in:
parent
6c98936a30
commit
026cd4b800
20
pom.xml
20
pom.xml
|
@ -9,10 +9,10 @@
|
|||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>project-04</artifactId>
|
||||
<artifactId>catch-the-letters</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>project-04</name>
|
||||
<description>project-04</description>
|
||||
<name>catch-the-letters</name>
|
||||
<description>catch-the-letters</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<fastjson.version>2.0.34</fastjson.version>
|
||||
|
@ -54,13 +54,6 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--mybatis-plus-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>${mybatis-plus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--fastjson-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.fastjson2</groupId>
|
||||
|
@ -75,11 +68,10 @@
|
|||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--mysql-connector-->
|
||||
<!--MongoDB-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--junit-->
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.example.project04;
|
||||
package com.example.catchTheLetters;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Project04Application {
|
||||
public class CatchTheLettersApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Project04Application.class, args);
|
||||
SpringApplication.run(CatchTheLettersApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
spring.application.name=project-04
|
|
@ -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
|
|
@ -1,10 +1,10 @@
|
|||
package com.example.project04;
|
||||
package com.example.catchTheLetters;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Project04ApplicationTests {
|
||||
class CatchTheLettersApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
Loading…
Reference in New Issue