From cbf3847498b9806ec774c5ad287c935599685f8d Mon Sep 17 00:00:00 2001 From: "LinskRuis.32" Date: Wed, 10 Jun 2020 17:55:54 +0800 Subject: [PATCH] sync up to exec .sql --- models/sys_file.go | 21 -------- service/sysService/file.go | 18 ------- webs/sys/main.go | 23 ++------ webs/sys/my.sql | 106 +++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 59 deletions(-) delete mode 100644 models/sys_file.go delete mode 100644 service/sysService/file.go create mode 100644 webs/sys/my.sql diff --git a/models/sys_file.go b/models/sys_file.go deleted file mode 100644 index 947fc89..0000000 --- a/models/sys_file.go +++ /dev/null @@ -1,21 +0,0 @@ -package models - -import ( - "time" -) - -type SysFile struct { - Id int64 `xorm:"pk autoincr BIGINT(20)"` - Xid string `xorm:"not null pk VARCHAR(64)"` - Types string `xorm:"comment('类型') VARCHAR(50)"` - Uid string `xorm:"VARCHAR(64)"` - Toid string `xorm:"VARCHAR(64)"` - Extion string `xorm:"VARCHAR(50)"` - Size int64 `xorm:"BIGINT(20)"` - Filename string `xorm:"VARCHAR(255)"` - Descpt string `xorm:"VARCHAR(500)"` - Status int `xorm:"INT(2)"` - Times time.Time `xorm:"default CURRENT_TIMESTAMP TIMESTAMP"` - Downtm time.Time `xorm:"comment('最近下载时间') TIMESTAMP"` - Downs int64 `xorm:"default 0 BIGINT(20)"` -} diff --git a/service/sysService/file.go b/service/sysService/file.go deleted file mode 100644 index 06db1ad..0000000 --- a/service/sysService/file.go +++ /dev/null @@ -1,18 +0,0 @@ -package sysService - -import ( - "GoClouds/core/comm" - "GoClouds/models" -) - -func FindFile(xid string) *models.SysFile { - e := new(models.SysFile) - ok, err := comm.DbSys.Where("xid=?", xid).Get(e) - if err != nil { - return nil - } - if ok { - return e - } - return nil -} diff --git a/webs/sys/main.go b/webs/sys/main.go index 9e54587..ddc18ee 100644 --- a/webs/sys/main.go +++ b/webs/sys/main.go @@ -50,26 +50,9 @@ func SyncTable() error { if comm.DbSys == nil { return nil } - err := comm.DbSys.Sync2(models.SysUser{}) - if err != nil { - println("Sync2 SysUser err:" + err.Error()) - return err - } - err = comm.DbSys.Sync2(models.SysFile{}) - if err != nil { - return err - } - err = comm.DbSys.Sync2(models.SysPermssion{}) - if err != nil { - return err - } - err = comm.DbSys.Sync2(models.SysRole{}) - if err != nil { - return err - } - err = comm.DbSys.Sync2(models.SysUserRole{}) - if err != nil { - return err + isext, err := comm.DbSys.IsTableExist(models.SysUser{}) + if err == nil && !isext { + comm.DbSys.ImportFile("my.sql") } return nil } diff --git a/webs/sys/my.sql b/webs/sys/my.sql new file mode 100644 index 0000000..0ef4e04 --- /dev/null +++ b/webs/sys/my.sql @@ -0,0 +1,106 @@ +/* + Navicat Premium Data Transfer + + Source Server : hw-test + Source Server Type : MySQL + Source Server Version : 50730 + Source Host : hw.1ydt.cn:3306 + Source Schema : test + + Target Server Type : MySQL + Target Server Version : 50730 + File Encoding : 65001 + + Date: 10/06/2020 17:47:59 +*/ + +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for sys_permssion +-- ---------------------------- +DROP TABLE IF EXISTS `sys_permssion`; +CREATE TABLE `sys_permssion` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `xid` varchar(64) NOT NULL, + `parent` varchar(64) NULL DEFAULT NULL, + `title` varchar(100) NULL DEFAULT NULL, + `value` varchar(100) NULL DEFAULT NULL, + `times` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0), + `sort` int(11) NULL DEFAULT 10, + PRIMARY KEY (`id`, `xid`) USING BTREE, + INDEX `IDX_sys_permssion_parent`(`parent`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 11 ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_permssion +-- ---------------------------- +INSERT INTO `sys_permssion` VALUES (1, 'common', NULL, '通用', 'common', '2019-10-23 11:29:32', 0); +INSERT INTO `sys_permssion` VALUES (2, 'login', 'common', '登录', 'login', '2019-10-23 11:29:40', 11); +INSERT INTO `sys_permssion` VALUES (3, 'uppass', 'common', '修改密码', 'comm:uppass', '2020-03-01 21:47:42', 12); +INSERT INTO `sys_permssion` VALUES (4, 'admin', NULL, '后台界面', 'admin', '2019-10-27 00:11:30', 2); +INSERT INTO `sys_permssion` VALUES (5, 'roles', NULL, '角色管理', 'role:list', '2019-11-03 13:48:58', 3); +INSERT INTO `sys_permssion` VALUES (6, 'role1', 'roles', '角色编辑', 'role:edit', '2019-11-03 13:49:21', 11); +INSERT INTO `sys_permssion` VALUES (7, 'role2', 'roles', '角色删除', 'role:del', '2019-11-03 13:49:22', 12); +INSERT INTO `sys_permssion` VALUES (8, 'grant', 'roles', '用户授权', 'user:grant', '2019-11-04 09:52:47', 13); +INSERT INTO `sys_permssion` VALUES (9, 'users', NULL, '用户管理', 'user:list', '2019-11-04 09:51:14', 4); +INSERT INTO `sys_permssion` VALUES (10, 'userxg', 'users', '用户编辑', 'user:edit', '2019-11-04 20:27:02', 10); + +-- ---------------------------- +-- Table structure for sys_role +-- ---------------------------- +DROP TABLE IF EXISTS `sys_role`; +CREATE TABLE `sys_role` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `xid` varchar(64) NOT NULL, + `title` varchar(100) NULL DEFAULT NULL, + `perms` text NULL, + `times` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0), + PRIMARY KEY (`id`, `xid`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_role +-- ---------------------------- +INSERT INTO `sys_role` VALUES (1, 'common', '通用权限', 'common,login,uppass', '2019-10-23 11:31:34'); +INSERT INTO `sys_role` VALUES (2, 'admin', '权限管理员', 'admin,roles,role1,role2,users,grant', '2019-11-03 13:49:35'); + +-- ---------------------------- +-- Table structure for sys_user +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user`; +CREATE TABLE `sys_user` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `xid` varchar(64) NOT NULL, + `name` varchar(50) NOT NULL, + `pass` varchar(100) NULL DEFAULT NULL, + `phone` varchar(50) NULL DEFAULT NULL COMMENT '备用电话', + `times` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间', + `logintm` timestamp(0) NULL DEFAULT NULL COMMENT '登陆时间', + `fwtm` timestamp(0) NULL DEFAULT NULL COMMENT '访问时间', + PRIMARY KEY (`id`, `xid`, `name`) USING BTREE, + INDEX `IDX_sys_user_phone`(`phone`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_user +-- ---------------------------- +INSERT INTO `sys_user` VALUES (1, 'admin', 'root', 'E10ADC3949BA59ABBE56E057F20F883E', '', '2020-03-01 23:28:35', '2020-06-10 17:34:57', '2020-06-10 17:34:51'); + +-- ---------------------------- +-- Table structure for sys_user_role +-- ---------------------------- +DROP TABLE IF EXISTS `sys_user_role`; +CREATE TABLE `sys_user_role` ( + `user_code` varchar(64) NOT NULL, + `role_codes` text NULL, + `limits` text NULL, + PRIMARY KEY (`user_code`) USING BTREE +) ENGINE = InnoDB ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_user_role +-- ---------------------------- +INSERT INTO `sys_user_role` VALUES ('admin', 'admin', NULL); + +SET FOREIGN_KEY_CHECKS = 1;