mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 09:36:00 +08:00
validator
This commit is contained in:
+3
-6
@@ -22,7 +22,7 @@ import (
|
||||
var _ context.Context // 解决goland编辑器bug
|
||||
|
||||
func NewMsg(zk *openKeeper.ZkClient) *Msg {
|
||||
return &Msg{zk: zk}
|
||||
return &Msg{zk: zk, validate: validator.New()}
|
||||
}
|
||||
|
||||
type Msg struct {
|
||||
@@ -30,7 +30,7 @@ type Msg struct {
|
||||
validate *validator.Validate
|
||||
}
|
||||
|
||||
func () SetOptions(options map[string]bool, value bool) {
|
||||
func SetOptions(options map[string]bool, value bool) {
|
||||
utils.SetSwitchFromOptions(options, constant.IsHistory, value)
|
||||
utils.SetSwitchFromOptions(options, constant.IsPersistent, value)
|
||||
utils.SetSwitchFromOptions(options, constant.IsSenderSync, value)
|
||||
@@ -104,9 +104,6 @@ func newUserSendMsgReq(params *apistruct.ManagementSendMsgReq) *msg.SendMsgReq {
|
||||
}
|
||||
return &pbData
|
||||
}
|
||||
func init() {
|
||||
validate = validator.New()
|
||||
}
|
||||
|
||||
func (o *Msg) client() (msg.MsgClient, error) {
|
||||
conn, err := o.zk.GetConn(config.Config.RpcRegisterName.OpenImMsgName)
|
||||
@@ -197,7 +194,7 @@ func (o *Msg) ManagementSendMsg(c *gin.Context) {
|
||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||
apiresp.GinError(c, constant.ErrData)
|
||||
return
|
||||
} else if err := validate.Struct(data); err != nil {
|
||||
} else if err := o.validate.Struct(data); err != nil {
|
||||
apiresp.GinError(c, constant.ErrData)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user