From e2f20a0f6996c94c562314f4238955e00ec1dba9 Mon Sep 17 00:00:00 2001 From: taoshihan1991 <630892807@qq.com> Date: Thu, 25 Feb 2021 10:16:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9mysql5.5+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/go-fly.sql | 6 +++--- models/messages.go | 3 +++ models/users.go | 5 +++++ models/visitors.go | 4 ++++ readme.md | 23 +++++++++++++++++++---- static/html/index.html | 6 +++--- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/config/go-fly.sql b/config/go-fly.sql index 1f4d0f7..6946eb7 100644 --- a/config/go-fly.sql +++ b/config/go-fly.sql @@ -5,7 +5,7 @@ CREATE TABLE `user` ( `password` varchar(50) NOT NULL DEFAULT '', `nickname` varchar(50) NOT NULL DEFAULT '', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp, `deleted_at` timestamp NULL DEFAULT NULL, `avator` varchar(100) NOT NULL DEFAULT '', PRIMARY KEY (`id`), @@ -24,7 +24,7 @@ CREATE TABLE `visitor` ( `source_ip` varchar(50) NOT NULL DEFAULT '', `to_id` varchar(50) NOT NULL DEFAULT '', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp, `deleted_at` timestamp NULL DEFAULT NULL, `visitor_id` varchar(100) NOT NULL DEFAULT '', `status` tinyint(4) NOT NULL DEFAULT '0', @@ -44,7 +44,7 @@ CREATE TABLE `message` ( `visitor_id` varchar(100) NOT NULL DEFAULT '', `content` varchar(2048) NOT NULL DEFAULT '', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp, `deleted_at` timestamp NULL DEFAULT NULL, `mes_type` enum('kefu','visitor') NOT NULL DEFAULT 'visitor', `status` enum('read','unread') NOT NULL DEFAULT 'unread', diff --git a/models/messages.go b/models/messages.go index bb4b0cd..6937682 100644 --- a/models/messages.go +++ b/models/messages.go @@ -1,5 +1,7 @@ package models +import "time" + type Message struct { Model KefuId string `json:"kefu_id"` @@ -31,6 +33,7 @@ func CreateMessage(kefu_id string, visitor_id string, content string, mes_type s MesType: mes_type, Status: "unread", } + v.UpdatedAt = time.Now() DB.Create(v) } func FindMessageByVisitorId(visitor_id string) []Message { diff --git a/models/users.go b/models/users.go index 6284de7..1131ca2 100644 --- a/models/users.go +++ b/models/users.go @@ -2,6 +2,7 @@ package models import ( _ "github.com/jinzhu/gorm/dialects/mysql" + "time" ) type User struct { @@ -21,6 +22,7 @@ func CreateUser(name string, password string, avator string, nickname string) ui Avator: avator, Nickname: nickname, } + user.UpdatedAt = time.Now() DB.Create(user) return user.ID } @@ -30,6 +32,7 @@ func UpdateUser(id string, name string, password string, avator string, nickname Avator: avator, Nickname: nickname, } + user.UpdatedAt = time.Now() if password != "" { user.Password = password } @@ -39,12 +42,14 @@ func UpdateUserPass(name string, pass string) { user := &User{ Password: pass, } + user.UpdatedAt = time.Now() DB.Model(user).Where("name = ?", name).Update("Password", pass) } func UpdateUserAvator(name string, avator string) { user := &User{ Avator: avator, } + user.UpdatedAt = time.Now() DB.Model(user).Where("name = ?", name).Update("Avator", avator) } func FindUser(username string) User { diff --git a/models/visitors.go b/models/visitors.go index 3e692b9..e001d1a 100644 --- a/models/visitors.go +++ b/models/visitors.go @@ -1,5 +1,7 @@ package models +import "time" + type Visitor struct { Model Name string `json:"name"` @@ -33,6 +35,7 @@ func CreateVisitor(name, avator, sourceIp, toId, visitorId, refer, city, clientI ClientIp: clientIp, Extra: extra, } + v.UpdatedAt = time.Now() DB.Create(v) } func FindVisitorByVistorId(visitorId string) Visitor { @@ -77,6 +80,7 @@ func UpdateVisitor(name, avator, visitorId string, status uint, clientIp string, Name: name, Avator: avator, } + visitor.UpdatedAt = time.Now() DB.Model(visitor).Where("visitor_id = ?", visitorId).Update(visitor) } func UpdateVisitorKefu(visitorId string, kefuId string) { diff --git a/readme.md b/readme.md index 4f67d60..e74db5b 100644 --- a/readme.md +++ b/readme.md @@ -41,7 +41,7 @@ ### 安装使用 -#### 1. 先安装和运行mysql >=5.7版本 , 创建gofly数据库. +#### 1. 先安装和运行mysql >=5.5版本 , 创建gofly数据库. create database gofly charset utf8; @@ -181,10 +181,25 @@ server{ } ``` -### 生成文档 +### 更新日志 + +##### V0.3.1 + 1.修改在线咨询浮框样式 + + 2.修改数据库时间字段类型,兼容mysql5.5+ +##### V0.2.9 + + 1.访客开多个窗口时 , 单点登录关闭旧ws连接 + + 2.访客切换窗口时可以自动重连 + + 3.访客到来时 , http接口和ws接口同时发送给客服上线信息 + + 4.客服后台定时拉取在线访客接口 + + 5.客服后台切换tab拉取在线访客 + -1. 需要先安装swag -2. 在根目录swag init -g go-fly.go ### 感谢赞助 2021年02月20日 广西***社 1000元 diff --git a/static/html/index.html b/static/html/index.html index 843092a..bc6f869 100644 --- a/static/html/index.html +++ b/static/html/index.html @@ -18,15 +18,15 @@ - - + +