feat: device info and bind
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 24s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 23s
CI / factory (push) Successful in 21s
CI / message (push) Successful in 21s
CI / order (push) Successful in 22s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 20s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 21s
CI / wecom (push) Successful in 22s
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 24s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 23s
CI / factory (push) Successful in 21s
CI / message (push) Successful in 21s
CI / order (push) Successful in 22s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 20s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 21s
CI / wecom (push) Successful in 22s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.2
|
||||
// goctl 1.10.1
|
||||
// Source: equipment.proto
|
||||
|
||||
package equipmentClient
|
||||
@@ -19,6 +19,8 @@ type (
|
||||
ApiBindAddRequest = equipment.ApiBindAddRequest
|
||||
ApiBindExpiryGetRequest = equipment.ApiBindExpiryGetRequest
|
||||
ApiBindExpiryRequest = equipment.ApiBindExpiryRequest
|
||||
ApiBindInfoRequest = equipment.ApiBindInfoRequest
|
||||
ApiBindUpdateRequest = equipment.ApiBindUpdateRequest
|
||||
ApiMaskAddRequest = equipment.ApiMaskAddRequest
|
||||
ApiMaskUseRequest = equipment.ApiMaskUseRequest
|
||||
ApiMaskUsedItemsRequest = equipment.ApiMaskUsedItemsRequest
|
||||
@@ -30,6 +32,8 @@ type (
|
||||
EditRequest = equipment.EditRequest
|
||||
EmptyRequest = equipment.EmptyRequest
|
||||
IdRequest = equipment.IdRequest
|
||||
InternalBindAddRequest = equipment.InternalBindAddRequest
|
||||
InternalBindInfoRequest = equipment.InternalBindInfoRequest
|
||||
ItemsRequest = equipment.ItemsRequest
|
||||
MaskItemsRequest = equipment.MaskItemsRequest
|
||||
Response = equipment.Response
|
||||
@@ -62,6 +66,10 @@ type (
|
||||
ApiMaskStoreUse(ctx context.Context, in *ApiMaskUseRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
ApiMaskStoreUseItems(ctx context.Context, in *ApiMaskUsedItemsRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
ApiVersion(ctx context.Context, in *ApiVersionRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
ApiBindInfo(ctx context.Context, in *ApiBindInfoRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
ApiBindUpdate(ctx context.Context, in *ApiBindUpdateRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
InternalBindAdd(ctx context.Context, in *InternalBindAddRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
InternalBindInfo(ctx context.Context, in *InternalBindInfoRequest, opts ...grpc.CallOption) (*Response, error)
|
||||
}
|
||||
|
||||
defaultEquipment struct {
|
||||
@@ -190,3 +198,23 @@ func (m *defaultEquipment) ApiVersion(ctx context.Context, in *ApiVersionRequest
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.ApiVersion(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultEquipment) ApiBindInfo(ctx context.Context, in *ApiBindInfoRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.ApiBindInfo(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultEquipment) ApiBindUpdate(ctx context.Context, in *ApiBindUpdateRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.ApiBindUpdate(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultEquipment) InternalBindAdd(ctx context.Context, in *InternalBindAddRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.InternalBindAdd(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultEquipment) InternalBindInfo(ctx context.Context, in *InternalBindInfoRequest, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := equipment.NewEquipmentClient(m.cli.Conn())
|
||||
return client.InternalBindInfo(ctx, in, opts...)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ type BindCreate struct {
|
||||
HostNickname string `gorm:"column:host_nickname;type:varchar(128);comment:主机昵称;NOT NULL" json:"host_nickname"`
|
||||
UserId int64 `gorm:"column:user_id;type:int(11);comment:用户ID;NOT NULL" json:"user_id"`
|
||||
UserNickname string `gorm:"column:user_nickname;type:varchar(128);comment:用户昵称;NOT NULL" json:"user_nickname"`
|
||||
Type int32 `json:"type" gorm:"type"` // 类型。1为圆屏,2为卵型屏,3为皮肤分析仪,4为经皮湿水仪,5为AI化妆盒,6为软水机,7为制氧机
|
||||
Type int32 `json:"type" gorm:"type"` // 类型。1为圆屏,2为卵型屏,3为皮肤分析仪,4为经皮湿水仪,5为AI化妆盒,6为软水机,7为制氧机
|
||||
SkinType int32 `gorm:"column:skin_type" json:"skin_type"` // 1用户 2门店
|
||||
Image string `gorm:"column:image;type:varchar(128);comment:图片地址;NOT NULL" json:"image"`
|
||||
IsSpeciality int32 `gorm:"column:is_speciality;type:tinyint(1);default:0;comment:1是专业版;NOT NULL" json:"is_speciality"`
|
||||
Status int32 `gorm:"column:status;type:tinyint(1);default:1;comment:状态,1为正常,2为禁用" json:"status"`
|
||||
@@ -24,7 +25,8 @@ type BindInfo struct {
|
||||
UserId int64 `gorm:"column:user_id;type:int(11);comment:用户ID;NOT NULL" json:"user_id"`
|
||||
UserNickname string `gorm:"column:user_nickname;type:varchar(128);comment:用户昵称;NOT NULL" json:"user_nickname"`
|
||||
Image string `gorm:"column:image;type:varchar(128);comment:图片地址;NOT NULL" json:"image"`
|
||||
Type int32 `json:"type" gorm:"type"` // 类型。1为圆屏,2为卵型屏,3为皮肤分析仪,4为经皮湿水仪,5为AI化妆盒,6为软水机,7为制氧机
|
||||
Type int32 `json:"type" gorm:"type"` // 类型。1为圆屏,2为卵型屏,3为皮肤分析仪,4为经皮湿水仪,5为AI化妆盒,6为软水机,7为制氧机
|
||||
SkinType int32 `gorm:"column:skin_type" json:"skin_type"` // 1用户 2门店
|
||||
IsSpeciality int32 `gorm:"column:is_speciality;type:tinyint(1);default:0;comment:1是专业版;NOT NULL" json:"is_speciality"`
|
||||
ExpiryTime string `gorm:"column:expiry_time;type:char(11);comment:过期时间" json:"expiry_time"`
|
||||
Status uint8 `gorm:"column:status;type:tinyint(1);default:1;comment:状态,1为正常,2为禁用" json:"status"`
|
||||
@@ -32,6 +34,15 @@ type BindInfo struct {
|
||||
UpdatedTime utils.CustomTime `gorm:"column:updated_time;type:timestamp;default:CURRENT_TIMESTAMP;NOT NULL" json:"updated_time"`
|
||||
}
|
||||
|
||||
type DeviceInfo struct {
|
||||
Id int64 `json:"id"`
|
||||
DeviceNo string `json:"device_no"`
|
||||
DeviceName string `json:"device_name"`
|
||||
Status uint8 `json:"status"`
|
||||
CreatedAt utils.CustomTime `json:"created_at"`
|
||||
UpdatedAt utils.CustomTime `json:"updated_at"`
|
||||
}
|
||||
|
||||
type BindExpiry struct {
|
||||
Id int64 `gorm:"column:id;type:bigint(20);primary_key;AUTO_INCREMENT" json:"id"`
|
||||
HostCode string `gorm:"column:host_code;type:varchar(64);comment:主机编号;NOT NULL" json:"host_code"`
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"lone-services/services/equipment/validator"
|
||||
"strconv"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
equipment "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
equipment "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
"lone-services/services/equipment/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApiBindInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewApiBindInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiBindInfoLogic {
|
||||
return &ApiBindInfoLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ApiBindInfoLogic) ApiBindInfo(in *equipment.ApiBindInfoRequest) (*equipment.Response, error) {
|
||||
var v validator.ApiBindInfoValidator
|
||||
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)
|
||||
}
|
||||
|
||||
eq := map[string]string{
|
||||
"user_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen),
|
||||
"status": utils.StringStatusOk,
|
||||
}
|
||||
if v.Id > utils.NumberZero {
|
||||
eq["id"] = strconv.FormatInt(v.Id, utils.NumberTen)
|
||||
}
|
||||
if v.HostCode != utils.StringEmpty {
|
||||
eq["host_code"] = v.HostCode
|
||||
}
|
||||
if v.Type > utils.NumberZero {
|
||||
eq["type"] = strconv.Itoa(int(v.Type))
|
||||
}
|
||||
|
||||
var info dao.BindInfo
|
||||
err := model.BindModel{}.Init().GetOne(modelbase.Params{
|
||||
Eq: eq,
|
||||
Order: "id desc",
|
||||
}, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.ok(nil)
|
||||
}
|
||||
return l.ok(info)
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
equipment "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
"lone-services/services/equipment/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ApiBindUpdateLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewApiBindUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiBindUpdateLogic {
|
||||
return &ApiBindUpdateLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ApiBindUpdateLogic) ApiBindUpdate(in *equipment.ApiBindUpdateRequest) (*equipment.Response, error) {
|
||||
var v validator.ApiBindUpdateValidator
|
||||
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)
|
||||
}
|
||||
|
||||
affected, err := model.BindModel{}.Init().Edit(modelbase.Params{
|
||||
Eq: map[string]string{
|
||||
"id": strconv.FormatInt(v.Id, utils.NumberTen),
|
||||
"user_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen),
|
||||
"status": utils.StringStatusOk,
|
||||
},
|
||||
}, map[string]interface{}{
|
||||
"host_nickname": v.HostNickname,
|
||||
})
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if affected < utils.NumberOne {
|
||||
return l.fail(utils.ErrorNotFund)
|
||||
}
|
||||
return l.ok(nil)
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"lone-services/pkg/utils"
|
||||
|
||||
"lone-services/rpc/equipment/pb"
|
||||
equipment "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
equipment "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
"lone-services/services/equipment/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type InternalBindAddLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewInternalBindAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalBindAddLogic {
|
||||
return &InternalBindAddLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *InternalBindAddLogic) InternalBindAdd(in *equipment.InternalBindAddRequest) (*equipment.Response, error) {
|
||||
var v validator.InternalBindAddValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
w := modelbase.Params{
|
||||
Eq: map[string]string{
|
||||
"host_code": v.HostCode,
|
||||
"status": utils.StringStatusOk,
|
||||
"type": strconv.Itoa(int(v.Type)),
|
||||
},
|
||||
}
|
||||
var info dao.BindCreate
|
||||
modelObj := model.BindModel{}.Init()
|
||||
err := modelObj.GetOne(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id > utils.NumberZero {
|
||||
if info.UserId == v.UserId {
|
||||
return l.fail(utils.ErrorBindError)
|
||||
}
|
||||
return l.fail(utils.ErrorBindOtherError)
|
||||
}
|
||||
|
||||
w = modelbase.Params{Eq: map[string]string{
|
||||
"host_code": v.HostCode,
|
||||
"user_id": strconv.FormatInt(v.UserId, utils.NumberTen),
|
||||
"type": strconv.Itoa(int(v.Type)),
|
||||
}}
|
||||
err = modelObj.GetOne(w, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
|
||||
info.Status = utils.StatusOk
|
||||
info.UserId = v.UserId
|
||||
info.UserNickname = v.UserNickname
|
||||
info.HostCode = v.HostCode
|
||||
info.HostNickname = v.HostNickname
|
||||
info.BindTime = utils.Now()
|
||||
info.Type = v.Type
|
||||
info.SkinType = v.SkinType
|
||||
|
||||
w = modelbase.Params{
|
||||
Eq: map[string]string{"id": strconv.FormatInt(info.Id, utils.NumberTen)},
|
||||
}
|
||||
|
||||
modelObj.Begin()
|
||||
if info.Id < utils.NumberOne {
|
||||
err = modelObj.Create(&info)
|
||||
} else {
|
||||
_, err = modelObj.Edit(w, &info)
|
||||
}
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
modelObj.Rollback()
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
|
||||
err = model.BindHistoryModel{}.Init().Create(&dao.BindHistoryCreate{
|
||||
HostCode: v.HostCode,
|
||||
UserId: v.UserId,
|
||||
Status: utils.StatusOk,
|
||||
Type: v.Type,
|
||||
})
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
modelObj.Rollback()
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
modelObj.Commit()
|
||||
return l.ok(utils.NumberOne)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
equipment "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/equipment/internal/dao"
|
||||
"lone-services/services/equipment/internal/model"
|
||||
"lone-services/services/equipment/internal/svc"
|
||||
"lone-services/services/equipment/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type InternalBindInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
BaseLogic
|
||||
}
|
||||
|
||||
func NewInternalBindInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalBindInfoLogic {
|
||||
return &InternalBindInfoLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *InternalBindInfoLogic) InternalBindInfo(in *equipment.InternalBindInfoRequest) (*equipment.Response, error) {
|
||||
var v validator.InternalBindInfoValidator
|
||||
if fail := l.checkParams(in, &v); fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
eq := map[string]string{
|
||||
"status": utils.StringStatusOk,
|
||||
}
|
||||
if v.UserId > utils.NumberZero {
|
||||
eq["user_id"] = strconv.FormatInt(v.UserId, utils.NumberTen)
|
||||
}
|
||||
if v.SkinType > utils.NumberZero {
|
||||
eq["skin_type"] = strconv.Itoa(int(v.SkinType))
|
||||
}
|
||||
if v.HostCode != utils.StringEmpty {
|
||||
eq["host_code"] = v.HostCode
|
||||
}
|
||||
if v.Type > utils.NumberZero {
|
||||
eq["type"] = strconv.Itoa(int(v.Type))
|
||||
}
|
||||
if v.Id > utils.NumberZero {
|
||||
eq["id"] = strconv.FormatInt(v.Id, utils.NumberTen)
|
||||
}
|
||||
if len(eq) == utils.NumberOne {
|
||||
return l.out(utils.ErrorParams, "缺少查询条件")
|
||||
}
|
||||
|
||||
var info dao.BindInfo
|
||||
err := model.BindModel{}.Init().GetOne(modelbase.Params{
|
||||
Eq: eq,
|
||||
Order: "id desc",
|
||||
}, &info)
|
||||
if err != nil {
|
||||
l.Logger.Error(err)
|
||||
return l.fail(utils.Fail)
|
||||
}
|
||||
if info.Id < utils.NumberOne {
|
||||
return l.ok(nil)
|
||||
}
|
||||
return l.ok(info)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.10.2
|
||||
// goctl 1.10.1
|
||||
// Source: equipment.proto
|
||||
|
||||
package server
|
||||
@@ -138,3 +138,23 @@ func (s *EquipmentServer) ApiVersion(ctx context.Context, in *equipment.ApiVersi
|
||||
l := logic.NewApiVersionLogic(ctx, s.svcCtx)
|
||||
return l.ApiVersion(in)
|
||||
}
|
||||
|
||||
func (s *EquipmentServer) ApiBindInfo(ctx context.Context, in *equipment.ApiBindInfoRequest) (*equipment.Response, error) {
|
||||
l := logic.NewApiBindInfoLogic(ctx, s.svcCtx)
|
||||
return l.ApiBindInfo(in)
|
||||
}
|
||||
|
||||
func (s *EquipmentServer) ApiBindUpdate(ctx context.Context, in *equipment.ApiBindUpdateRequest) (*equipment.Response, error) {
|
||||
l := logic.NewApiBindUpdateLogic(ctx, s.svcCtx)
|
||||
return l.ApiBindUpdate(in)
|
||||
}
|
||||
|
||||
func (s *EquipmentServer) InternalBindAdd(ctx context.Context, in *equipment.InternalBindAddRequest) (*equipment.Response, error) {
|
||||
l := logic.NewInternalBindAddLogic(ctx, s.svcCtx)
|
||||
return l.InternalBindAdd(in)
|
||||
}
|
||||
|
||||
func (s *EquipmentServer) InternalBindInfo(ctx context.Context, in *equipment.InternalBindInfoRequest) (*equipment.Response, error) {
|
||||
l := logic.NewInternalBindInfoLogic(ctx, s.svcCtx)
|
||||
return l.InternalBindInfo(in)
|
||||
}
|
||||
|
||||
@@ -31,8 +31,71 @@ func (p BindSetExpiryValidator) GetMessage() validate.ValidatorMessages {
|
||||
}
|
||||
}
|
||||
|
||||
type InternalBindAddValidator struct {
|
||||
UserId int64 `validate:"required,gt=0"`
|
||||
UserNickname string `validate:"omitempty,max=128"`
|
||||
HostNickname string `validate:"omitempty,max=128"`
|
||||
HostCode string `validate:"required,max=64"`
|
||||
Type int32 `validate:"required,gt=0"`
|
||||
SkinType int32 `validate:"required,oneof=1 2"`
|
||||
}
|
||||
|
||||
func (p InternalBindAddValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"UserId.required": "缺少用户",
|
||||
"UserId.gt": "缺少用户",
|
||||
"HostCode.required": "缺少设备编码",
|
||||
"HostCode.max": "设备编码过长",
|
||||
"Type.required": "缺少设备类型",
|
||||
"Type.gt": "缺少设备类型",
|
||||
"SkinType.required": "缺少绑定类型",
|
||||
"SkinType.oneof": "绑定类型只能是1或2",
|
||||
}
|
||||
}
|
||||
|
||||
type InternalBindInfoValidator struct {
|
||||
UserId int64 `validate:"omitempty,gte=0"`
|
||||
SkinType int32 `validate:"omitempty,oneof=1 2"`
|
||||
HostCode string `validate:"omitempty,max=64"`
|
||||
Type int32 `validate:"omitempty,gte=0"`
|
||||
Id int64 `validate:"omitempty,gte=0"`
|
||||
}
|
||||
|
||||
func (p InternalBindInfoValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"SkinType.oneof": "绑定类型只能是1或2",
|
||||
"HostCode.max": "设备编码过长",
|
||||
}
|
||||
}
|
||||
|
||||
type ApiBindInfoValidator struct {
|
||||
Id int64 `validate:"omitempty,gte=0"`
|
||||
HostCode string `validate:"omitempty,max=64"`
|
||||
Type int32 `validate:"omitempty,gte=0"`
|
||||
}
|
||||
|
||||
func (p ApiBindInfoValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"HostCode.max": "设备编码过长",
|
||||
}
|
||||
}
|
||||
|
||||
type ApiBindUpdateValidator struct {
|
||||
Id int64 `validate:"required,gt=0"`
|
||||
HostNickname string `validate:"required,max=128"`
|
||||
}
|
||||
|
||||
func (p ApiBindUpdateValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"Id.required": "id 必传",
|
||||
"Id.gt": "id 必传",
|
||||
"HostNickname.required": "缺少设备名称",
|
||||
"HostNickname.max": "设备名称过长",
|
||||
}
|
||||
}
|
||||
|
||||
type BindValidator struct {
|
||||
HostNickname string `form:"host_nickname" json:"host_nickname" validate:"required"`
|
||||
HostNickname string `form:"host_nickname" json:"host_nickname"`
|
||||
HostCode string `form:"host_code" json:"host_code" validate:"required"`
|
||||
Type int32 `form:"type" json:"type"`
|
||||
}
|
||||
@@ -40,8 +103,7 @@ type BindValidator struct {
|
||||
// GetMessage 提示消息
|
||||
func (p BindValidator) GetMessage() validate.ValidatorMessages {
|
||||
return validate.ValidatorMessages{
|
||||
"HostNickname.required": "缺少设备名称",
|
||||
"HostCode.required": "缺少设备编码",
|
||||
"HostCode.required": "缺少设备编码",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user