From f2c2a344c17f0bfa89eb6a73804717872c73cebd Mon Sep 17 00:00:00 2001 From: taoshihan <630892807@qq.com> Date: Wed, 12 Apr 2023 15:22:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=A2=E6=9C=8D=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=90=8C=E6=AD=A5=E4=BF=AE=E6=94=B9=E8=AE=BF=E5=AE=A2?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/kefu.go | 16 +++++++++++++++- static/templates/setting_config.html | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/controller/kefu.go b/controller/kefu.go index a4d74b7..4442dc1 100644 --- a/controller/kefu.go +++ b/controller/kefu.go @@ -237,6 +237,13 @@ func PostKefuInfo(c *gin.Context) { password := c.PostForm("password") avator := c.PostForm("avator") nickname := c.PostForm("nickname") + if name == "" { + c.JSON(200, gin.H{ + "code": 400, + "msg": "客服账号不能为空", + }) + return + } //插入新用户 if id == "" { uid := models.CreateUser(name, tools.Md5(password), avator, nickname) @@ -253,7 +260,14 @@ func PostKefuInfo(c *gin.Context) { if password != "" { password = tools.Md5(password) } - models.UpdateUser(id, name, password, avator, nickname) + message := &models.Message{ + KefuId: name, + } + models.DB.Model(&models.Message{}).Update(message) + visitor := &models.Visitor{ + ToId: name, + } + models.DB.Model(&models.Visitor{}).Update(visitor) } c.JSON(200, gin.H{ diff --git a/static/templates/setting_config.html b/static/templates/setting_config.html index 0e854c4..c51576a 100644 --- a/static/templates/setting_config.html +++ b/static/templates/setting_config.html @@ -2,6 +2,7 @@