35 lines
829 B
Go
35 lines
829 B
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
|
|
|
"36wisdom/biz/model/dto"
|
|
"36wisdom/biz/service"
|
|
)
|
|
|
|
type userCollection struct{}
|
|
|
|
var UserCollection = &userCollection{}
|
|
|
|
func (c *userCollection) ListByUser(ctx context.Context, req *dto.UserCollectionListReq) (*dto.UserCollectionListRes, error) {
|
|
recs, err := service.UserCollection.ListByUser(ctx, req.UserId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
res := &dto.UserCollectionListRes{List: make([]dto.UserCollectionItem, 0, len(recs))}
|
|
for _, r := range recs {
|
|
res.List = append(res.List, userCollectionItem(r))
|
|
}
|
|
return res, nil
|
|
}
|
|
|
|
func userCollectionItem(r gdb.Record) dto.UserCollectionItem {
|
|
return dto.UserCollectionItem{
|
|
Id: r["id"].Int64(),
|
|
UserId: r["user_id"].Int64(),
|
|
StrategyId: r["strategy_id"].Int64(),
|
|
}
|
|
}
|