增加任务接口逻辑
This commit is contained in:
@@ -10,9 +10,13 @@ service novatask {
|
||||
@handler GetTaskList
|
||||
get /tasks (GetTaskListReq) returns (GetTaskListResp)
|
||||
|
||||
@doc "校验任务结果"
|
||||
@handler VerifyTaskResult
|
||||
get /task/:id (TaskIdPath) returns (VerifyTaskResultResp)
|
||||
|
||||
@doc "领取任务奖励"
|
||||
@handler GetTaskReward
|
||||
get /reward/:id (GetTaskRewardReq) returns (GetTaskRewardResp)
|
||||
get /reward/:id (TaskIdPath) returns (GetTaskRewardResp)
|
||||
}
|
||||
|
||||
type GetTaskListReq {
|
||||
@@ -21,25 +25,32 @@ type GetTaskListReq {
|
||||
|
||||
type Task {
|
||||
Id uint `json:"id"`
|
||||
CommunityId uint `json:"community_id"`
|
||||
Title string `json:"title"`
|
||||
SubTitle string `json:"sub_title"`
|
||||
Description string `json:"description"`
|
||||
Points int `json:"points"`
|
||||
ButtonText string `json:"button_text"`
|
||||
Type int8 `json:"type"`
|
||||
Url string `json:"url"`
|
||||
Status int8 `json:"status"`
|
||||
StartAt string `json:"start_at"`
|
||||
EndAt string `json:"end_at"`
|
||||
Status int8 `json:"status"`
|
||||
FinishState int8 `json:"finish_state"` // 0:未完成 1:待校验 2:已完成未领取 3:已领取
|
||||
}
|
||||
|
||||
type GetTaskListResp {
|
||||
Tasks []Task `json:"tasks"`
|
||||
}
|
||||
|
||||
type GetTaskRewardReq {
|
||||
type TaskIdPath {
|
||||
ID uint `path:"id"`
|
||||
}
|
||||
|
||||
type VerifyTaskResultResp {
|
||||
Finish bool `json:"finish"`
|
||||
}
|
||||
|
||||
type GetTaskRewardResp {
|
||||
Points int `json:"points"`
|
||||
}
|
||||
|
||||
12
doc/sql/novatask.sql
Normal file
12
doc/sql/novatask.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE `nh_task_progress`
|
||||
(
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`uid` int(11) NOT NULL,
|
||||
`task_id` int(11) unsigned NOT NULL COMMENT '任务id',
|
||||
`task_seq` int(11) NOT NULL COMMENT '用于可重复任务的序列号',
|
||||
`stage` tinyint NOT NULL DEFAULT 0 COMMENT '任务的阶段, 0:未完成 1:待校验 2:已完成未领取 3:已领取',
|
||||
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `uid_task_id_seq` (`uid`, `task_id`, `task_seq`)
|
||||
) COMMENT='用户任务节点';
|
||||
@@ -45,6 +45,36 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/task/v1/task/{id}": {
|
||||
"get": {
|
||||
"summary": "校验任务结果",
|
||||
"operationId": "VerifyTaskResult",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/VerifyTaskResultResp"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"task"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"apiKey": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/task/v1/tasks": {
|
||||
"get": {
|
||||
"summary": "获取任务列表",
|
||||
@@ -109,10 +139,6 @@
|
||||
"tasks"
|
||||
]
|
||||
},
|
||||
"GetTaskRewardReq": {
|
||||
"type": "object",
|
||||
"title": "GetTaskRewardReq"
|
||||
},
|
||||
"GetTaskRewardResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -133,6 +159,10 @@
|
||||
"type": "integer",
|
||||
"format": "uint32"
|
||||
},
|
||||
"community_id": {
|
||||
"type": "integer",
|
||||
"format": "uint32"
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -153,29 +183,57 @@
|
||||
"type": "integer",
|
||||
"format": "int8"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"type": "integer",
|
||||
"format": "int8"
|
||||
},
|
||||
"start_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"end_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"finish_state": {
|
||||
"type": "integer",
|
||||
"format": "int8"
|
||||
"format": "int8",
|
||||
"description": " 0:未完成 1:待校验 2:已完成未领取 3:已领取"
|
||||
}
|
||||
},
|
||||
"title": "Task",
|
||||
"required": [
|
||||
"id",
|
||||
"community_id",
|
||||
"title",
|
||||
"sub_title",
|
||||
"description",
|
||||
"points",
|
||||
"button_text",
|
||||
"type",
|
||||
"url",
|
||||
"status",
|
||||
"start_at",
|
||||
"end_at",
|
||||
"status"
|
||||
"finish_state"
|
||||
]
|
||||
},
|
||||
"TaskIdPath": {
|
||||
"type": "object",
|
||||
"title": "TaskIdPath"
|
||||
},
|
||||
"VerifyTaskResultResp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"finish": {
|
||||
"type": "boolean",
|
||||
"format": "boolean"
|
||||
}
|
||||
},
|
||||
"title": "VerifyTaskResultResp",
|
||||
"required": [
|
||||
"finish"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user