-
Notifications
You must be signed in to change notification settings - Fork 0
api
steiner edited this page Jan 29, 2024
·
1 revision
sealed class Response {
@Serializable
data class Ok<T: Any>(val message: String, val data: T): Response()
@Serializable
data class Err(val message: String): Response()
}
转换成 JSON 格式, Ok 类就是
{
"message": "message",
"data": ...
}Err 类就是只有一个 message 字段
用户模型
@Serializable
class User(
val id: Int,
val name: String,
val roles: List<Role>,
val enabled: Boolean,
val email: String,
@Transient
val passwordHash: String? = null
)
在序列化 User 对象时,passwordHash 是不会生成到 json 中去的
角色模型
@Serializable
class Role(
val id: Int,
val name: String
)
| 方法 | 路径 | 说明 | query | body | 返回类型 |
|---|---|---|---|---|---|
| POST | /authenticate | 登录 | LoginRequest | Response.Ok<{token: string}> | |
| POST | /register | 注册用户 | PostUserRequest | Response.Ok<User> | |
| GET | /user | 查找当前用户信息,需要携带 jwttoken | Response.Ok<User> | ||
| PUT | /user | 更改当前用户信息,需要携带 jwttoken | UpdateUserRequest | Response.Ok<User> |
@Serializable
class Priority(
val id: Int,
val name: String,
val order: Int,
val parentid: Int
)
添加优先级请求 PostPriorityRequest
@Serializable
class PostPriorityRequest(
val name: String,
val order: Int,
val parentid: Int
)
更新优先级请求 UpdatePriorityRequest
@Serializable
class UpdatePriorityRequest(
val id: Int,
val name: String?,
val order: Int?
)
/todolist/priority
| 方法 | 路径 | 说明 | query | body | 返回类型 |
|---|---|---|---|---|---|
| POST | / | 添加优先级 | PostPriorityRequest | Response.Ok<Priority> | |
| DELETE | /{id} | 删除优先级 | Response.Ok<Unit> | ||
| PUT | / | 更新优先级 | UpdatePriorityRequest | Response.Ok<Priority> | |
| GET | /{id} | 查找优先级 | Response.Ok<Priority> | ||
| GET | / | 查找 | taskid: number | Response.Ok<List<Priority>> |
@Serializable
class Tag(
val id: Int,
val name: String,
val parentid: Int,
val color: String
)
添加标签请求 PostTagRequest
@Serializable
class PostTagRequest(
val name: String,
val parentid: Int,
val color: String
)
更新标签请求 UpdateTagRequest
@Serializable
class UpdateTagRequest(
val id: Int,
val name: String
)
/todolist/tag
| 方法 | 路径 | 说明 | query | body | 返回类型 |
|---|---|---|---|---|---|
| POST | / | 添加标签 | PostTagRequest | Response.Ok<Tag> | |
| DELETE | /{id} | 删除标签 | Response.Ok<Unit> | ||
| PUT | / | 更新标签 | UpdateTagRequest | Response.Ok<Tag> | |
| GET | / | 获取匹配 parentid 的标签 | parentid | Response.Ok<Tag> |
@Serializable
class SubTask(
val id: Int,
val index: Int,
val name: String,
val isdone: Boolean,
val parentid: Int
)
添加子任务请求 PostSubTaskRequest
@Serializable
class PostSubTaskRequest(
val parentid: Int,
val name: String
)
更新子任务请求 UpdateSubTaskRequest
@Serializable
class UpdateSubTaskRequest(
val id: Int,
val name: String?,
val isdone: Boolean?,
)
/todolist/subtask/
| 方法 | 路径 | 说明 | query | body | 返回类型 |
|---|---|---|---|---|---|
| POST | / | 添加子任务 | PostSUbTaskRequest | Response.Ok<SubTask> | |
| DELETE | /{id} | 删除子任务 | Response.Ok<Unit> | ||
| PUT | / | 更新子任务 | UpdateSubTaskREquest | Response.Ok<SubTask> |
@Serializable
class Task(
val id: Int,
val index: Int,
val name: String,
val isdone: Boolean,
val priority: Priority,
val note: String?,
val subtasks: List<SubTask>,
val expectTime: Int,
val finishTime: Int,
val deadline: LocalDateTime?,
val notifyTime: LocalDateTime?,
val tags: List<Tag>,
val parentid: Int,
val createTime: LocalDateTime,
val updateTime: LocalDateTime
)
注意 json中可以通过转换 iso8601 格式的 string 来得到 LocalDateTime
添加任务请求 PostTaskRequest
@Serializable
class PostTaskRequest(
val name: String,
val parentid: Int,
val note: String?,
val priority: Priority,
val tags: List<Tag>?,
val deadline: LocalDateTime?,
val notifyTime: LocalDateTime?,
val expectTime: Int
)
添加任务标签请求 PostTaskTagRequest
@Serializable
class PostTaskTagRequest(
val taskid: Int,
val tagid: Int
)
更新任务请求 UpdateTaskRequest
@Serializable
class UpdateTaskRequest(
val id: Int,
val name: String?,
val isdone: Boolean?,
val deadline: LocalDateTime?,
val notifyTime: LocalDateTime?,
val note: String?,
val priority: Priority?,
val expectTime: Int?,
val finishTime: Int?,
val parentid: Int?
)
/todolist/task/
| 方法 | 路径 | 说明 | query | body | 返回类型 |
|---|---|---|---|---|---|
| POST | / | 添加任务 | PostTaskRequest | Response.Ok<Task> | |
| POST | /tag | 给任务添加标签 | PostTaskTagRequest | Response.Ok<Unit> | |
| DELETE | /{id} | 删除任务 | Response.Ok<Unit> | ||
| DELETE | /deadline/{id} | 删除任务的截止时间 | Response.Ok<Unit> | ||
| DELETE | /tag | 删除匹配 tagid 的标签 | taskid: number, tagid: number | Response.Ok<Unit> | |
| DELETE | /notify-time/{id} | 删除匹配id的任务的提醒时间 | Response.Ok<Unit> | ||
| PUT | / | 更新任务 | UpdateTaskRequest | Response.Ok<Task> | |
| GET | /{id} | 查找任务 | Response.Ok<Task> |
@Serializable
class TaskGroup(
val id: Int,
val index: Int,
val name: String,
val tasks: List<Task>,
val createTime: LocalDateTime,
val updateTime: LocalDateTime,
val parentid: Int
)
添加任务列表请求 PostTaskGroupRequest
@Serializable
class PostTaskGroupRequest(
val parentid: Int,
val name: String,
val after: Int?
)
更新任务列表请求 UpdateTaskGroupRequest
@Serializable
class UpdateTaskGroupRequest(
val id: Int,
val name: String
)
/todolist/taskgroup/
| 方法 | 路径 | 说明 | query | body | 返回类型 |
|---|---|---|---|---|---|
| POST | / | 添加任务列表 | PostTaskGroupRequest | Response.Ok<TaskGroup> | |
| DELETE | /{id} | 删除任务列表 | Response.Ok<Unit> | ||
| PUT | / | 更新任务列表 | UpdateTaskGroupRequest | Response.Ok<TaskGroup> | |
| GET | / | 获取匹配 parentid 的所有任务列表 | parentid | Response.Ok<List<TaskGroup>> | |
| GET | /{id} | 获取匹配 id 的任务列表 | Response.Ok<TaskGroup> |
@Serializable
class TaskProject(
val id: Int,
val index: Int,
val name: String,
val avatarid: Int?,
val userid: Int,
val profile: String?,
val createTime: LocalDateTime,
val updateTime: LocalDateTime
)
添加任务项目请求 PostTaskProjectRequest
@Serializable
class PostTaskProjectRequest(
val userid: Int,
val name: String,
val avatarid: Int?,
val profile: String?
)
更新任务项目请求 UpdateTaskProjectRequest
@Serializable
class UpdateTaskProjectRequest(
val id: Int,
val name: String?,
val avatarid: Int?,
val profile: String?
)
/todolist/taskproject
| 方法 | 路径 | 说明 | query | body | 返回类型 |
|---|---|---|---|---|---|
| POST | / | 添加任务项目 | PostTaskProjectRequest | Response.Ok<TaskProject> | |
| DELETE | /{id} | 删除任务项目 | Response.Ok<Unit> | ||
| PUT | / | 更新任务项目 | UpdateTaskProjectRequest | Response.Ok<TaskProject> | |
| GET | / | 查找此用户下的所有任务项目 | Response.Ok<List<TaskProject>> | ||
| GET | /{id} | 查找匹配id的任务项目 | Response.Ok<TaskProject> |