Files
arenax-server/internal/controller/reward/reward_v1_list.go

33 lines
768 B
Go

package reward
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"server/internal/model"
"server/internal/service"
"server/api/reward/v1"
)
func (c *ControllerV1) List(ctx context.Context, req *v1.ListReq) (res *v1.ListRes, err error) {
fromCtx := g.RequestFromCtx(ctx)
operatorId := fromCtx.GetCtxVar("id").Int64()
operatorRole := fromCtx.GetCtxVar("role").String()
out, err := service.Reward().List(ctx, &model.RewardListIn{Page: req.Page,
Size: req.Size,
OperatorId: operatorId,
OperatorRole: operatorRole,
StoreId: req.StoreId,
Name: req.Name,
Status: req.Status,
RewardTypeId: req.RewardTypeId,
})
if err != nil {
return nil, err
}
return &v1.ListRes{
List: out.List,
Total: out.Total,
}, nil
}