修改资料功能

master
taoshihan 2 years ago
parent 3b02835941
commit 7a8cc9ab40

@ -7,7 +7,6 @@ import (
"github.com/taoshihan1991/imaptool/models"
"github.com/taoshihan1991/imaptool/tools"
"github.com/taoshihan1991/imaptool/ws"
"strconv"
)
func PostKefuAvator(c *gin.Context) {
@ -83,6 +82,9 @@ func GetKefuInfo(c *gin.Context) {
info["name"] = user.Nickname
info["id"] = user.Name
info["avator"] = user.Avator
info["username"] = user.Name
info["nickname"] = user.Nickname
info["uid"] = user.ID
c.JSON(200, gin.H{
"code": 200,
"msg": "ok",
@ -235,14 +237,6 @@ func PostKefuInfo(c *gin.Context) {
password := c.PostForm("password")
avator := c.PostForm("avator")
nickname := c.PostForm("nickname")
roleId := c.PostForm("role_id")
if roleId == "" {
c.JSON(200, gin.H{
"code": 400,
"msg": "请选择角色!",
})
return
}
//插入新用户
if id == "" {
uid := models.CreateUser(name, tools.Md5(password), avator, nickname)
@ -254,18 +248,12 @@ func PostKefuInfo(c *gin.Context) {
})
return
}
roleIdInt, _ := strconv.Atoi(roleId)
models.CreateUserRole(uid, uint(roleIdInt))
} else {
//更新用户
if password != "" {
password = tools.Md5(password)
}
models.UpdateUser(id, name, password, avator, nickname)
roleIdInt, _ := strconv.Atoi(roleId)
uid, _ := strconv.Atoi(id)
models.DeleteRoleByUserId(uid)
models.CreateUserRole(uint(uid), uint(roleIdInt))
}
c.JSON(200, gin.H{

@ -0,0 +1,185 @@
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
`password` varchar(50) NOT NULL DEFAULT '',
`nickname` varchar(50) NOT NULL DEFAULT '',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
`avator` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
TRUNCATE TABLE `user`;
INSERT INTO `user` (`id`, `name`, `password`, `nickname`, `created_at`, `updated_at`, `deleted_at`, `avator`) VALUE
(1, 'kefu2', '202cb962ac59075b964b07152d234b70', '智能客服系统', '2020-06-27 19:32:41', '2020-07-04 09:32:20', NULL, '/static/images/4.jpg');
DROP TABLE IF EXISTS `visitor`;
CREATE TABLE `visitor` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
`avator` varchar(500) NOT NULL DEFAULT '',
`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 NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
`visitor_id` varchar(100) NOT NULL DEFAULT '',
`status` tinyint(4) NOT NULL DEFAULT '0',
`refer` varchar(500) NOT NULL DEFAULT '',
`city` varchar(100) NOT NULL DEFAULT '',
`client_ip` varchar(100) NOT NULL DEFAULT '',
`extra` varchar(2048) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `visitor_id` (`visitor_id`),
KEY `to_id` (`to_id`),
KEY `idx_update` (`updated_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `message`;
CREATE TABLE `message` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kefu_id` varchar(100) NOT NULL DEFAULT '',
`visitor_id` varchar(100) NOT NULL DEFAULT '',
`content` varchar(2048) NOT NULL DEFAULT '',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
`mes_type` enum('kefu','visitor') NOT NULL DEFAULT 'visitor',
`status` enum('read','unread') NOT NULL DEFAULT 'unread',
PRIMARY KEY (`id`),
KEY `kefu_id` (`kefu_id`),
KEY `visitor_id` (`visitor_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL DEFAULT '0',
`role_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `user_role` (`id`, `user_id`, `role_id`) VALUE
(1, 1, 1);
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '',
`method` varchar(100) NOT NULL DEFAULT '',
`path` varchar(2048) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `role` (`id`, `name`, `method`, `path`) VALUES
(1, '普通客服', '*', '*');
DROP TABLE IF EXISTS `welcome`;
CREATE TABLE `welcome` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` varchar(100) NOT NULL DEFAULT '',
`keyword` 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`),
KEY `keyword` (`keyword`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `welcome` (`id`, `user_id`, `content`, `is_default`, `ctime`, `keyword`) VALUES
(NULL, 'kefu2', '我暂时离线,留言已转发到我的邮箱,稍后回复~', 1, '2020-08-24 02:57:49','offline');
INSERT INTO `welcome` (`id`, `user_id`, `content`, `is_default`, `ctime`, `keyword`) VALUES
(NULL, 'kefu2', '请问有什么可以帮您?', 0, '2020-08-24 02:57:49','welcome');
DROP TABLE IF EXISTS `ipblack`;
CREATE TABLE `ipblack` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(100) NOT NULL DEFAULT '',
`create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`kefu_id` varchar(100) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `config`;
CREATE TABLE `config` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`conf_name` varchar(255) NOT NULL DEFAULT '',
`conf_key` varchar(255) NOT NULL DEFAULT '',
`conf_value` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `conf_key` (`conf_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '公告信息', 'AllNotice', '开源智能客服系统为您服务');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '离线消息', 'OfflineMessage', '我现在离线,稍后回复您!');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '欢迎消息', 'WelcomeMessage', '有什么可以帮您?');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '邮箱地址(SMTP地址)', 'NoticeEmailSmtp', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '邮箱账户', 'NoticeEmailAddress', '');
INSERT INTO `config` (`id`, `conf_name`, `conf_key`, `conf_value`) VALUES (NULL, '邮箱密码(SMTP密码)', 'NoticeEmailPassword', '');
DROP TABLE IF EXISTS `about`;
CREATE TABLE `about` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`title_cn` varchar(255) NOT NULL DEFAULT '',
`title_en` varchar(255) NOT NULL DEFAULT '',
`keywords_cn` varchar(255) NOT NULL DEFAULT '',
`keywords_en` varchar(255) NOT NULL DEFAULT '',
`desc_cn` varchar(1024) NOT NULL DEFAULT '',
`desc_en` varchar(1024) NOT NULL DEFAULT '',
`css_js` text NOT NULL,
`html_cn` text NOT NULL,
`html_en` text NOT NULL,
`page` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE KEY `page` (`page`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `reply_group`;
CREATE TABLE `reply_group` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_name` varchar(50) NOT NULL DEFAULT '',
`user_id` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `reply_group` (`id`, `group_name`, `user_id`) VALUES (NULL, '常见问题', 'kefu2');
DROP TABLE IF EXISTS `reply_item`;
CREATE TABLE `reply_item` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`content` varchar(1024) NOT NULL DEFAULT '',
`group_id` int(11) NOT NULL DEFAULT '0',
`user_id` varchar(50) NOT NULL DEFAULT '',
`item_name` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `reply_item` (`id`, `content`, `group_id`, `user_id`, `item_name`) VALUES (NULL, '在这里[官网]link[https://gofly.sopans.com]!','1','kefu2', '官方地址在哪?');
DROP TABLE IF EXISTS `land_page`;
CREATE TABLE `land_page` (
`id` int(11) NOT NULL,
`title` varchar(125) NOT NULL DEFAULT '',
`keyword` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL,
`language` varchar(50) NOT NULL DEFAULT '',
`page_id` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
DROP TABLE IF EXISTS `language`;
CREATE TABLE `language` (
`id` int(11) NOT NULL,
`country` varchar(100) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
`short_key` varchar(100) COLLATE utf8mb4_general_ci NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
INSERT INTO `language` (`id`, `country`, `short_key`) VALUES (1, '中文简体', 'zh-cn');
INSERT INTO `language` (`id`, `country`, `short_key`) VALUES (2, '正體中文', 'zh-tw');
INSERT INTO `language` (`id`, `country`, `short_key`) VALUES (3, 'English', 'en_us');
INSERT INTO `language` (`id`, `country`, `short_key`) VALUES (4, '日本語', 'ja_jp');
DROP TABLE IF EXISTS `user_client`;
CREATE TABLE `user_client` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kefu` varchar(100) NOT NULL DEFAULT '',
`client_id` varchar(100) NOT NULL DEFAULT '',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `idx_user` (`kefu`,`client_id`),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

@ -29,9 +29,15 @@
<el-container>
<el-main class="mainMain">
<el-form :model="modifyPass" label-width="100px">
<el-form :model="modifyPass" label-width="80px">
<el-form-item label="账户">
<el-input v-model="kefuInfo.username"></el-input>
</el-form-item>
<el-form-item label="昵称">
<el-input v-model="kefuInfo.nickname"></el-input>
</el-form-item>
<el-form-item label="原头像">
<el-avatar :size="120" :src="avatarUrl"></el-avatar>
<el-avatar :size="120" :src="kefuInfo.avator"></el-avatar>
</el-form-item>
<el-form-item label="新头像">
<el-upload

@ -9,6 +9,7 @@
data: {
iframeUrl:"/setting_statistics",
fullscreenLoading:false,
kefuInfo:{},
openIndex:[1],
account: {
username: "",
@ -239,7 +240,7 @@
}
if(ACTION=="setting_avator"){
this.sendAjax("/kefuinfo","get",{},function(result){
_this.avatarUrl=result.avator;
_this.kefuInfo=result;
});
}
},
@ -439,9 +440,14 @@
//修改密码
setModifyAvatar(){
let _this=this;
this.sendAjax("/modifyavator","POST",{avator:_this.avatarUrl},function(result){
this.sendAjax("/kefuinfo","POST",{
id:_this.kefuInfo.uid,
name:_this.kefuInfo.username,
nickname:_this.kefuInfo.nickname,
avator:_this.kefuInfo.avator,
},function(result){
_this.$message({
message: "修改成功",
message: "操作成功:注意,如果修改账户名,后台需重新登录",
type: 'success'
});
});
@ -455,7 +461,7 @@
});
return;
}
this.avatarUrl = '/'+res.result.path;
this.kefuInfo.avator = '/'+res.result.path;
},
beforeAvatarUpload(file) {
var isLt2M = file.size / 1024 / 1024 < 1;

@ -10,7 +10,7 @@
style="width: 100%">
<el-table-column
prop="ip"
label="IP">
label="IP地址">
</el-table-column>
<el-table-column
prop="create_at"

@ -11,7 +11,7 @@
<el-menu-item-group>
<el-menu-item index="1-1" v-on:click="openUrl('/setting_statistics')">统计信息</el-menu-item>
<el-menu-item index="1-3" v-on:click="openUrl('/setting_modifypass')">修改密码</el-menu-item>
<el-menu-item index="1-4" v-on:click="openUrl('/setting_avator')">修改头像</el-menu-item>
<el-menu-item index="1-4" v-on:click="openUrl('/setting_avator')">修改资料</el-menu-item>
</el-menu-item-group>
</el-submenu>
<el-submenu index="2">

Loading…
Cancel
Save