增加社区列表接口,任务相关接口修改

This commit is contained in:
lianghuanjie
2024-12-19 21:14:14 +08:00
parent 391a9d3481
commit a3c4adfa25
32 changed files with 1163 additions and 197 deletions

View File

@@ -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),
},
},

View 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)
}
}
}

View File

@@ -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