增加社区列表接口,任务相关接口修改
This commit is contained in:
@@ -15,6 +15,12 @@ import (
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// 获取社区列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/community",
|
||||
Handler: task.GetCommunityListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 获取任务列表
|
||||
Method: http.MethodGet,
|
||||
@@ -36,7 +42,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
{
|
||||
// 校验任务结果
|
||||
Method: http.MethodGet,
|
||||
Path: "/task/:id",
|
||||
Path: "/task",
|
||||
Handler: task.VerifyTaskResultHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
|
||||
22
internal/handler/task/get_community_list_handler.go
Normal file
22
internal/handler/task/get_community_list_handler.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"nova_task/internal/logic/task"
|
||||
"nova_task/internal/svc"
|
||||
)
|
||||
|
||||
// 获取社区列表
|
||||
func GetCommunityListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := task.NewGetCommunityListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetCommunityList()
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// 校验任务结果
|
||||
func VerifyTaskResultHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.TaskIdPath
|
||||
var req types.VerifyTaskResultReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user