mirror of
https://github.com/m5stack/StackChan.git
synced 2026-04-27 19:12:40 +00:00
server code 4/27
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
|
||||
"stackChan/api/dance/v1"
|
||||
"stackChan/api/dance/v2"
|
||||
)
|
||||
|
||||
type IDanceV1 interface {
|
||||
@@ -15,4 +16,14 @@ type IDanceV1 interface {
|
||||
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
|
||||
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error)
|
||||
GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error)
|
||||
GetDanceInfo(ctx context.Context, req *v1.GetDanceInfoReq) (res *v1.GetDanceInfoRes, err error)
|
||||
GetMusicList(ctx context.Context, req *v1.GetMusicListReq) (res *v1.GetMusicListRes, err error)
|
||||
}
|
||||
|
||||
type IDanceV2 interface {
|
||||
GetList(ctx context.Context, req *v2.GetListReq) (res *v2.GetListRes, err error)
|
||||
Create(ctx context.Context, req *v2.CreateReq) (res *v2.CreateRes, err error)
|
||||
Delete(ctx context.Context, req *v2.DeleteReq) (res *v2.DeleteRes, err error)
|
||||
Update(ctx context.Context, req *v2.UpdateReq) (res *v2.UpdateRes, err error)
|
||||
GetDanceInfo(ctx context.Context, req *v2.GetDanceInfoReq) (res *v2.GetDanceInfoRes, err error)
|
||||
}
|
||||
|
||||
@@ -6,40 +6,53 @@ SPDX-License-Identifier: MIT
|
||||
package v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type CreateReq struct {
|
||||
g.Meta `path:"/dance" method:"post" tags:"Dance" summary:"Dance create request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
Index int `json:"index" v:"required"`
|
||||
List []model.DanceData `json:"list" v:"required"`
|
||||
g.Meta `path:"/dance" method:"post" tags:"Dance" summary:"Dance create request"`
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName" v:"required"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type CreateRes string
|
||||
|
||||
type DeleteReq struct {
|
||||
g.Meta `path:"/dance" method:"delete" tags:"Dance" summary:"Dance delete request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
Index int `json:"index" v:"required"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type DeleteRes string
|
||||
|
||||
type UpdateReq struct {
|
||||
g.Meta `path:"/dance" method:"put" tags:"Dance" summary:"Dance put request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
Index int `json:"index" v:"required"`
|
||||
Data []model.DanceData `json:"list" v:"required"`
|
||||
g.Meta `path:"/dance" method:"put" tags:"Dance" summary:"Dance put request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type UpdateRes string
|
||||
|
||||
type GetListReq struct {
|
||||
g.Meta `path:"/dance" method:"get" tags:"Dance" summary:"Dance get request"`
|
||||
Mac string `json:"mac" v:"required"`
|
||||
}
|
||||
|
||||
type GetListRes map[string][]model.DanceData
|
||||
type GetListRes []model.Dance
|
||||
|
||||
type GetDanceInfoReq struct {
|
||||
g.Meta `path:"/danceData" method:"get" tags:"Dance get request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type GetDanceInfoRes model.Dance
|
||||
|
||||
type GetMusicListReq struct {
|
||||
g.Meta `path:"/musicList" method:"get" tags:"Dance get request"`
|
||||
}
|
||||
|
||||
type GetMusicListRes []string
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
package v2
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"stackChan/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type GetListReq struct {
|
||||
g.Meta `path:"/dance" method:"get" tags:"Dance" summary:"Dance get request"`
|
||||
Mac string `json:"mac" v:"required"` // mac address
|
||||
}
|
||||
|
||||
type GetListRes []model.Dance
|
||||
|
||||
type CreateReq struct {
|
||||
g.Meta `path:"/dance" method:"post" tags:"Dance" summary:"Dance create request"`
|
||||
Mac string `json:"mac" v:"required"` // mac address
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName" v:"required"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type CreateRes string
|
||||
|
||||
type DeleteReq struct {
|
||||
g.Meta `path:"/dance" method:"delete" tags:"Dance" summary:"Dance delete request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type DeleteRes string
|
||||
|
||||
type UpdateReq struct {
|
||||
g.Meta `path:"/dance" method:"put" tags:"Dance" summary:"Dance put request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
DanceData json.RawMessage `json:"danceData"` // Dance motion data
|
||||
DanceName string `json:"danceName"` // Dance name
|
||||
MusicUrl string `json:"musicUrl"` // Dance background music URL
|
||||
}
|
||||
|
||||
type UpdateRes string
|
||||
|
||||
type GetDanceInfoReq struct {
|
||||
g.Meta `path:"/danceData" method:"get" tags:"Dance get request"`
|
||||
Id int64 `json:"id" v:"required"`
|
||||
}
|
||||
|
||||
type GetDanceInfoRes model.Dance
|
||||
Reference in New Issue
Block a user