fix: ci dir error
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/log"
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
ad "lone-services/rpc/ad/pb"
|
||||
"lone-services/services/ad/internal/dao"
|
||||
"lone-services/services/ad/internal/model"
|
||||
"lone-services/services/ad/internal/svc"
|
||||
"lone-services/services/ad/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ItemsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemsLogic {
|
||||
return &ItemsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ItemsLogic) Items(in *ad.ItemsReq) (*ad.Response, error) {
|
||||
var req validator.AdItemsValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return outResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
page := int(req.Page)
|
||||
size := int(req.PageSize)
|
||||
if page < modelbase.DefaultPage {
|
||||
page = modelbase.DefaultPage
|
||||
}
|
||||
if size < modelbase.DefaultPage {
|
||||
size = modelbase.DefaultSize
|
||||
}
|
||||
|
||||
w := modelbase.Params{
|
||||
Page: page,
|
||||
Size: size,
|
||||
Order: "id desc",
|
||||
}
|
||||
|
||||
var info []dao.AdInfo
|
||||
result, err := model.AdModel{}.Init().Page(w, &info)
|
||||
if err != nil {
|
||||
log.Errorf("ad items: %v", err)
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
items := make([]*ad.Item, 0, len(info))
|
||||
for _, row := range info {
|
||||
items = append(items, toAdItem(row))
|
||||
}
|
||||
|
||||
return okResponse(utils.StructToJson(&ad.ItemsData{
|
||||
Count: result.Count,
|
||||
Items: items,
|
||||
})), nil
|
||||
}
|
||||
Reference in New Issue
Block a user