7939917ba0
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 1s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 48s
CI / chore (push) Successful in 0s
CI / equipment (push) Failing after 10s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 0s
CI / payment (push) Successful in 1s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 1s
CI / task (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 1s
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/services/equipment/internal/dao"
|
|
"lone-services/services/equipment/internal/model"
|
|
"strconv"
|
|
|
|
"lone-services/rpc/equipment/pb"
|
|
"lone-services/services/equipment/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ApiBeansItemsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewApiBeansItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiBeansItemsLogic {
|
|
return &ApiBeansItemsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *ApiBeansItemsLogic) ApiBeansItems(in *equipment.ApiBeansItemsRequest) (*equipment.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
var info []dao.BeansInfo
|
|
w := modelbase.Params{
|
|
Size: int(in.Size),
|
|
Order: "id desc",
|
|
Page: int(in.Page),
|
|
Eq: map[string]string{"user_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)},
|
|
}
|
|
|
|
items, err := model.BeansModel{}.Init().Page(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.Fail)
|
|
}
|
|
|
|
return l.ok(items)
|
|
}
|