57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/pkg/validate"
|
|
"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 UserBindLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewUserBindLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserBindLogic {
|
|
return &UserBindLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *UserBindLogic) UserBind(in *equipment.UserBindRequest) (*equipment.Response, error) {
|
|
var v validate.InfoValidator
|
|
if fail := l.checkParams(in, &v); fail != nil {
|
|
return fail, nil
|
|
}
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
w := modelbase.Params{
|
|
Eq: map[string]string{
|
|
"id": strconv.FormatInt(in.Id, utils.NumberTen),
|
|
},
|
|
}
|
|
|
|
var items []dao.BindInfo
|
|
err := model.BindModel{}.Init().Items(w, &items)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.Fail)
|
|
}
|
|
|
|
return l.ok(items)
|
|
}
|