Commit 6ef9be76 authored by 贾浩@五瓣科技's avatar 贾浩@五瓣科技

update groupv2 api

parent c81cd501
......@@ -46,7 +46,7 @@ type CreateGroupRequest struct {
}
type Task struct {
TaskId int `json:"taskId,omitempty"`
TaskId interface{} `json:"taskId,omitempty"`
Platform string `json:"platform" binding:"required"`
Action string `json:"action" binding:"required"`
Url string `json:"url"`
......
......@@ -42,6 +42,28 @@ func getGroup(c *gin.Context) {
c.JSON(200, withSuccess(resp))
}
func getGroupV2(c *gin.Context) {
_gid := c.Param("gid")
gid, _ := strconv.Atoi(_gid)
if gid == 0 {
c.JSON(200, withError(constant.InvalidParam))
return
}
userId := c.GetString("userId")
admin := c.GetBool("admin")
resp, err := srv.GetGroup(gid, userId, admin)
if err != nil {
c.JSON(200, withError(constant.InternalError))
return
}
for i := 0; i < len(resp.Tasks); i++ {
resp.Tasks[i].TaskId = strconv.Itoa(resp.Tasks[i].TaskId.(int))
}
c.JSON(200, withSuccess(resp))
}
func listGroup(c *gin.Context) {
_page := c.DefaultQuery("page", "1")
_pageSize := c.DefaultQuery("pageSize", "10")
......
......@@ -14,6 +14,7 @@ func initRouter(e *gin.Engine) {
{
group := v1.Group("/group")
group.GET("/:gid", middleware.JWTMiddleware(d, conf.Supabase.JWTSecret, false), getGroup) // 获取任务组任务详情
group.GET("/v2/:gid", middleware.JWTMiddleware(d, conf.Supabase.JWTSecret, false), getGroupV2) // 获取任务组任务详情,taskId 修改为string返回
group.GET("/list", middleware.JWTMiddleware(d, conf.Supabase.JWTSecret, true), listGroup) // 获取任务组任务详情
group.POST("/create", middleware.JWTMiddleware(d, conf.Supabase.JWTSecret, true), createGroup) // 创建任务组
}
......
......@@ -74,7 +74,7 @@ func (s *Service) GetGroup(gid int, userId string, admin bool) (resp *apiModel.G
Enable: task.Enable,
}
status, err := s.GetTaskResult(_task.TaskId, userId)
status, err := s.GetTaskResult(_task.TaskId.(int), userId)
if err != nil {
log.WithError(err).Error("group check task")
return nil, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment