admin add edit status password items info
This commit is contained in:
@@ -2,6 +2,8 @@ package logic
|
||||
|
||||
import (
|
||||
"admin/admin"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
|
||||
"pkg.local/utils"
|
||||
validateService "pkg.local/validate"
|
||||
@@ -10,22 +12,34 @@ import (
|
||||
type BaseLogic struct {
|
||||
}
|
||||
|
||||
func (l *BaseLogic) checkParams(in *admin.AdminEditRequest, v validateService.IValidator) *admin.Response {
|
||||
func (l *BaseLogic) checkParams(in interface{}, v validateService.IValidator) *admin.Response {
|
||||
rv := reflect.ValueOf(in)
|
||||
if rv.Kind() != reflect.Ptr || rv.IsNil() {
|
||||
return &admin.Response{
|
||||
Code: utils.ErrorParams.Code,
|
||||
Msg: "request must be non‑nil proto pointer",
|
||||
}
|
||||
}
|
||||
|
||||
if resp := validateService.ValidateFromProto(in, v); resp != utils.StringEmpty {
|
||||
return &admin.Response{Code: utils.ErrorParams.Code, Msg: resp}
|
||||
resp := validateService.ValidateFromProto(in, v)
|
||||
if resp != utils.StringEmpty {
|
||||
return &admin.Response{
|
||||
Code: utils.ErrorParams.Code,
|
||||
Msg: resp,
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *AdminAddLogic) fail(status utils.Status) *admin.Response {
|
||||
func (l *BaseLogic) fail(status utils.Status) *admin.Response {
|
||||
return &admin.Response{Code: status.Code, Msg: status.Msg}
|
||||
}
|
||||
|
||||
func (l *AdminAddLogic) out(status utils.Status, msg string) *admin.Response {
|
||||
func (l *BaseLogic) out(status utils.Status, msg string) *admin.Response {
|
||||
return &admin.Response{Code: status.Code, Msg: msg}
|
||||
}
|
||||
|
||||
func (l *AdminAddLogic) ok(data any) *admin.Response {
|
||||
return &admin.Response{Code: utils.Ok.Code, Msg: utils.Ok.Msg}
|
||||
func (l *BaseLogic) ok(data any) *admin.Response {
|
||||
buf, _ := json.Marshal(data)
|
||||
return &admin.Response{Code: utils.Ok.Code, Msg: utils.Ok.Msg, Data: string(buf)}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user