增加欢迎表

pull/30/head
taoshihan1991 4 years ago
parent b29614b4b3
commit 688cff136b

@ -64,3 +64,13 @@ CREATE TABLE `role` (
`name` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
DROP TABLE IF EXISTS `welcome`;
CREATE TABLE `welcome` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` varchar(100) NOT NULL DEFAULT '',
`content` varchar(500) NOT NULL DEFAULT '',
`is_default` tinyint(3) unsigned NOT NULL DEFAULT '0',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

@ -15,18 +15,25 @@ func GetNotice(c *gin.Context) {
kefuId:=c.Query("kefu_id")
lang,_:=c.Get("lang")
language:=config.CreateLanguage(lang.(string))
welcome:=models.FindWelcomeByUserId(kefuId)
user:=models.FindUser(kefuId)
info:=make(map[string]interface{})
info["nickname"]=user.Nickname
info["avator"]=user.Avator
info["name"]=user.Name
info["content"]=language.Notice
info["time"]=time.Now().Format("2006-01-02 15:04:05")
var content string
log.Println(welcome)
if welcome.Content!=""{
content=welcome.Content
}else {
content=language.Notice
}
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
"result":info,
"result":gin.H{
"nickname":user.Nickname,
"avator":user.Avator,
"name":user.Name,
"content":content,
"time":time.Now().Format("2006-01-02 15:04:05"),
},
})
}
var upgrader = websocket.Upgrader{}

@ -60,6 +60,7 @@ func main() {
engine.GET("/login", tmpl.PageLogin)
//咨询界面
engine.GET("/chat_page",middleware.SetLanguage, tmpl.PageChat)
engine.GET("/chatIndex",middleware.SetLanguage, tmpl.PageChat)
//登陆验证
engine.POST("/check", controller.LoginCheckPass)
//框架界面

@ -0,0 +1,16 @@
package models
import "time"
type Welcome struct {
ID uint `gorm:"primary_key" json:"id"`
UserId string `json:"user_id"`
Content string `json:"content"`
IsDefault uint `json:"is_default"`
Ctime time.Time `json:"ctime"`
}
func FindWelcomeByUserId(userId interface{})Welcome{
var w Welcome
DB.Where("user_id = ? and is_default=?", userId,1).First(&w)
return w
}

@ -186,7 +186,7 @@
if (redata.type == "kfOnline") {
let msg = redata.data
guest.to_id=msg.id;
this.chatTitle=msg.name+",为您服务!"
this.chatTitle=msg.name+",正在与您沟通!"
$(".chatBox").append("<div class=\"chatTime\">"+this.chatTitle+"</div>");
this.scrollBottom();
}
@ -374,7 +374,7 @@
setTimeout(function () {
_this.msgList.push(content);
_this.scrollBottom();
}, 2000);
}, 4000);
;
}
});

Loading…
Cancel
Save