a77fa23197
CI / changes (push) Successful in 1m31s
CI / ad (push) Successful in 26s
CI / admin (push) Successful in 15s
CI / bff (push) Successful in 14s
CI / chore (push) Successful in 15s
CI / equipment (push) Successful in 17s
CI / express (push) Successful in 13s
CI / factory (push) Successful in 13s
CI / message (push) Successful in 13s
CI / order (push) Successful in 13s
CI / payment (push) Successful in 13s
CI / percutaneous (push) Successful in 19s
CI / product (push) Successful in 17s
CI / record (push) Successful in 15s
CI / sale (push) Successful in 15s
CI / store (push) Successful in 15s
CI / support (push) Successful in 15s
CI / task (push) Successful in 14s
CI / user (push) Successful in 22s
CI / water (push) Successful in 16s
CI / wecom (push) Successful in 14s
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/utils"
|
|
pkgws "lone-services/pkg/ws"
|
|
|
|
"lone-services/rpc/percutaneous/pb"
|
|
"lone-services/services/percutaneous/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type SetPositionLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewSetPositionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetPositionLogic {
|
|
return &SetPositionLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
// 使用指南
|
|
func (l *SetPositionLogic) SetPosition(in *percutaneous.SetPositionRequest) (*percutaneous.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
|
|
if _, err := pkgws.GetSession(l.ctx, in.SessionId); err != nil {
|
|
l.Errorf("set position session: %v", err)
|
|
return l.fail(utils.ErrorQRcodeExp)
|
|
}
|
|
|
|
data := in.Position
|
|
if err := pkgws.Publish(l.ctx, in.SessionId, pkgws.Success(data)); err != nil {
|
|
l.Errorf("qrcode scan publish: %v", err)
|
|
}
|
|
|
|
return &percutaneous.Response{}, nil
|
|
}
|