d597975b42
CI / changes (push) Successful in 38s
CI / ad (push) Successful in 3m1s
CI / admin (push) Successful in 34s
CI / bff (push) Successful in 29s
CI / chore (push) Successful in 34s
CI / equipment (push) Failing after 11s
CI / express (push) Successful in 27s
CI / factory (push) Successful in 32s
CI / payment (push) Successful in 29s
CI / product (push) Successful in 30s
CI / record (push) Successful in 30s
CI / sale (push) Successful in 30s
CI / task (push) Successful in 32s
CI / user (push) Successful in 31s
CI / wecom (push) Successful in 33s
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/rpc/equipment/pb"
|
|
"lone-services/services/equipment/internal/dao"
|
|
"lone-services/services/equipment/internal/model"
|
|
"lone-services/services/equipment/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type BeansItemsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewBeansItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BeansItemsLogic {
|
|
return &BeansItemsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *BeansItemsLogic) BeansItems(in *equipment.BeansItemsRequest) (*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),
|
|
}
|
|
|
|
if len(in.Time) > utils.NumberOne {
|
|
w.Between = map[string][2]string{"created_at": {
|
|
in.Time[utils.NumberZero], in.Time[utils.NumberOne]}}
|
|
}
|
|
if in.Name != utils.StringEmpty {
|
|
key := fmt.Sprintf("(user_name LIKE '%s' OR user_nick_name LIKE ?)", "%%"+in.Name+"%%")
|
|
w.Other = map[string]string{key: "%%" + in.Name + "%%"}
|
|
}
|
|
|
|
items, err := model.BeansModel{}.Init().Page(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.Fail)
|
|
}
|
|
|
|
return l.ok(items)
|
|
}
|