37 lines
748 B
Go
37 lines
748 B
Go
package logic
|
|
|
|
import (
|
|
"admin/validator"
|
|
"context"
|
|
|
|
"admin/admin"
|
|
"admin/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"pkg.local/utils"
|
|
validateService "pkg.local/validate"
|
|
)
|
|
|
|
type AddLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLogic {
|
|
return &AddLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *AddLogic) Add(in *admin.AddRequest) (*admin.Response, error) {
|
|
var req validator.AdminAddValidator
|
|
if resp := validateService.ValidateFromProto(in, &req); resp != utils.StringEmpty {
|
|
return &admin.Response{Code: utils.Ok.Code, Msg: resp}, nil
|
|
}
|
|
|
|
return &admin.Response{}, nil
|
|
}
|