diff --git a/app/controllers/agent.go b/app/controllers/agent.go index 3778802..89123b4 100644 --- a/app/controllers/agent.go +++ b/app/controllers/agent.go @@ -1,13 +1,13 @@ package controllers import ( + "../entity" + "../libs" + "../service" "errors" "fmt" "github.com/astaxie/beego" "github.com/astaxie/beego/validation" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" - "github.com/lisijie/gopub/app/service" "strconv" ) diff --git a/app/controllers/base.go b/app/controllers/base.go index 4538e67..866698f 100644 --- a/app/controllers/base.go +++ b/app/controllers/base.go @@ -1,10 +1,11 @@ package controllers import ( + "../service" "encoding/json" "github.com/astaxie/beego" + "github.com/astaxie/beego/orm" "github.com/beego/i18n" - "github.com/lisijie/gopub/app/service" "io/ioutil" "strings" ) @@ -185,7 +186,7 @@ func (this *BaseController) jsonResult(out interface{}) { // 错误检查 func (this *BaseController) checkError(err error) { - if err != nil { + if err != nil && err != orm.ErrNoRows { this.showMsg(err.Error(), MSG_ERR) } } diff --git a/app/controllers/env.go b/app/controllers/env.go index 1a6e63a..a9c2d01 100644 --- a/app/controllers/env.go +++ b/app/controllers/env.go @@ -3,8 +3,8 @@ package controllers import ( "encoding/json" "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/service" + "../entity" + "../service" "strconv" ) diff --git a/app/controllers/mailtpl.go b/app/controllers/mailtpl.go index 8410378..8d31760 100644 --- a/app/controllers/mailtpl.go +++ b/app/controllers/mailtpl.go @@ -2,8 +2,8 @@ package controllers import ( "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/service" + "../entity" + "../service" ) type MailTplController struct { diff --git a/app/controllers/main.go b/app/controllers/main.go index 7f43dc9..be175ab 100644 --- a/app/controllers/main.go +++ b/app/controllers/main.go @@ -3,7 +3,7 @@ package controllers import ( "fmt" "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/service" + "../service" "os" "runtime" "time" diff --git a/app/controllers/project.go b/app/controllers/project.go index eeb611f..8aa0f79 100644 --- a/app/controllers/project.go +++ b/app/controllers/project.go @@ -3,9 +3,9 @@ package controllers import ( "fmt" "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" - "github.com/lisijie/gopub/app/service" + "../entity" + "../libs" + "../service" "strconv" "strings" ) diff --git a/app/controllers/review.go b/app/controllers/review.go index 7ca4fa3..2cb9573 100644 --- a/app/controllers/review.go +++ b/app/controllers/review.go @@ -2,9 +2,9 @@ package controllers import ( "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" - "github.com/lisijie/gopub/app/service" + "../entity" + "../libs" + "../service" ) type ReviewController struct { diff --git a/app/controllers/role.go b/app/controllers/role.go index 4afdbc2..a8c037b 100644 --- a/app/controllers/role.go +++ b/app/controllers/role.go @@ -2,8 +2,8 @@ package controllers import ( "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/service" + "../entity" + "../service" "strings" ) diff --git a/app/controllers/server.go b/app/controllers/server.go index 3a0cb9b..c491868 100644 --- a/app/controllers/server.go +++ b/app/controllers/server.go @@ -2,10 +2,11 @@ package controllers import ( "github.com/astaxie/beego" + "github.com/astaxie/beego/orm" "github.com/astaxie/beego/validation" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" - "github.com/lisijie/gopub/app/service" + "../entity" + "../libs" + "../service" "strconv" ) @@ -20,9 +21,13 @@ func (this *ServerController) List() { page = 1 } count, err := service.ServerService.GetTotal(service.SERVER_TYPE_NORMAL) - this.checkError(err) + if err != orm.ErrNoRows { + this.checkError(err) + } serverList, err := service.ServerService.GetServerList(page, this.pageSize) - this.checkError(err) + if err != orm.ErrNoRows { + this.checkError(err) + } this.Data["count"] = count this.Data["list"] = serverList diff --git a/app/controllers/task.go b/app/controllers/task.go index 32186d7..bfbd1bf 100644 --- a/app/controllers/task.go +++ b/app/controllers/task.go @@ -3,9 +3,9 @@ package controllers import ( "fmt" "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" - "github.com/lisijie/gopub/app/service" + "../entity" + "../libs" + "../service" ) type TaskController struct { diff --git a/app/controllers/user.go b/app/controllers/user.go index 9d02441..f861aec 100644 --- a/app/controllers/user.go +++ b/app/controllers/user.go @@ -6,8 +6,8 @@ import ( "fmt" "github.com/astaxie/beego" "github.com/astaxie/beego/validation" - "github.com/lisijie/gopub/app/libs" - "github.com/lisijie/gopub/app/service" + "../libs" + "../service" "regexp" "strconv" ) diff --git a/app/mail/mail.go b/app/mail/mail.go index 0d86646..fd89ef4 100644 --- a/app/mail/mail.go +++ b/app/mail/mail.go @@ -1,9 +1,9 @@ package mail import ( + "../libs" "github.com/astaxie/beego" - "github.com/lisijie/gomail" - "github.com/lisijie/gopub/app/libs" + "gopkg.in/gomail.v2" "strings" ) diff --git a/app/service/action.go b/app/service/action.go index 03d0a56..cb7ff67 100644 --- a/app/service/action.go +++ b/app/service/action.go @@ -2,7 +2,7 @@ package service import ( "fmt" - "github.com/lisijie/gopub/app/entity" + "../entity" ) // 系统动态 diff --git a/app/service/auth.go b/app/service/auth.go index 90d7205..42e6a8c 100644 --- a/app/service/auth.go +++ b/app/service/auth.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/astaxie/beego" "github.com/astaxie/beego/orm" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" + "../entity" + "../libs" "strconv" "strings" "time" diff --git a/app/service/deploy.go b/app/service/deploy.go index d9872d6..b1ad6b1 100644 --- a/app/service/deploy.go +++ b/app/service/deploy.go @@ -4,9 +4,9 @@ import ( "fmt" "github.com/astaxie/beego" "github.com/astaxie/beego/utils" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" - "github.com/lisijie/gopub/app/mail" + "../entity" + "../libs" + "../mail" "html" "os" "path/filepath" diff --git a/app/service/deploy_job.go b/app/service/deploy_job.go index 836ff41..5d6b9b2 100644 --- a/app/service/deploy_job.go +++ b/app/service/deploy_job.go @@ -3,8 +3,8 @@ package service import ( "fmt" "github.com/astaxie/beego" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" + "../entity" + "../libs" "os" "path/filepath" "strings" diff --git a/app/service/env.go b/app/service/env.go index 56bf4e3..827d8a0 100644 --- a/app/service/env.go +++ b/app/service/env.go @@ -2,7 +2,7 @@ package service import ( "github.com/astaxie/beego/orm" - "github.com/lisijie/gopub/app/entity" + "../entity" ) type envService struct{} diff --git a/app/service/init.go b/app/service/init.go index c0ba6ef..da2af3b 100644 --- a/app/service/init.go +++ b/app/service/init.go @@ -5,7 +5,7 @@ import ( "github.com/astaxie/beego" "github.com/astaxie/beego/orm" _ "github.com/go-sql-driver/mysql" - "github.com/lisijie/gopub/app/entity" + "../entity" "net/url" "os" ) diff --git a/app/service/mail.go b/app/service/mail.go index 7fe2abb..9865393 100644 --- a/app/service/mail.go +++ b/app/service/mail.go @@ -1,7 +1,7 @@ package service import ( - "github.com/lisijie/gopub/app/entity" + "../entity" ) type mailService struct{} diff --git a/app/service/project.go b/app/service/project.go index e3fe9c3..f93f8b5 100644 --- a/app/service/project.go +++ b/app/service/project.go @@ -1,7 +1,7 @@ package service import ( - "github.com/lisijie/gopub/app/entity" + "../entity" "os" ) diff --git a/app/service/repository.go b/app/service/repository.go index 45bea54..33d49c1 100644 --- a/app/service/repository.go +++ b/app/service/repository.go @@ -2,7 +2,7 @@ package service import ( "errors" - "github.com/lisijie/gopub/app/libs" + "../libs" "path/filepath" "sort" "strconv" diff --git a/app/service/role.go b/app/service/role.go index 09d1c87..9bae60b 100644 --- a/app/service/role.go +++ b/app/service/role.go @@ -2,7 +2,7 @@ package service import ( "errors" - "github.com/lisijie/gopub/app/entity" + "../entity" ) type roleService struct{} diff --git a/app/service/server.go b/app/service/server.go index d2f8288..01ae2bc 100644 --- a/app/service/server.go +++ b/app/service/server.go @@ -2,7 +2,7 @@ package service import ( "errors" - "github.com/lisijie/gopub/app/entity" + "../entity" ) const ( diff --git a/app/service/system.go b/app/service/system.go index ef78de4..07da730 100644 --- a/app/service/system.go +++ b/app/service/system.go @@ -1,7 +1,7 @@ package service import ( - "github.com/lisijie/gopub/app/entity" + "../entity" ) type systemService struct{} diff --git a/app/service/task.go b/app/service/task.go index 7666ee2..446a4cf 100644 --- a/app/service/task.go +++ b/app/service/task.go @@ -3,7 +3,7 @@ package service import ( "fmt" "github.com/astaxie/beego/orm" - "github.com/lisijie/gopub/app/entity" + "../entity" "os" "strconv" "time" diff --git a/app/service/user.go b/app/service/user.go index 20cdc48..7d3becb 100644 --- a/app/service/user.go +++ b/app/service/user.go @@ -3,8 +3,8 @@ package service import ( "errors" "github.com/astaxie/beego/utils" - "github.com/lisijie/gopub/app/entity" - "github.com/lisijie/gopub/app/libs" + "../entity" + "../libs" ) type userService struct{} diff --git a/conf/app.conf b/conf/app.conf index 95eb4a2..694d491 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -4,8 +4,8 @@ runmode = dev # 数据库配置 db.host = 127.0.0.1 -db.user = root -db.password = "" +db.user = gopub +db.password = "gopub" db.port = 3306 db.name = gopub db.prefix = "t_" @@ -22,4 +22,4 @@ mail.password = your password data_dir = /data/golang/src/gopub/data # 日志文件 -log_file = logs/error.log \ No newline at end of file +log_file = logs/error.log diff --git a/install.sql b/install.sql index f11937c..142787a 100644 --- a/install.sql +++ b/install.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS `t_action`; CREATE TABLE `t_action` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `action` varchar(20) NOT NULL DEFAULT '', @@ -10,6 +11,7 @@ CREATE TABLE `t_action` ( KEY `create_time` (`create_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_env`; CREATE TABLE `t_env` ( `id` int(11) NOT NULL AUTO_INCREMENT, `project_id` int(11) NOT NULL DEFAULT '0', @@ -25,12 +27,13 @@ CREATE TABLE `t_env` ( `mail_tpl_id` int(11) NOT NULL DEFAULT '0', `mail_to` varchar(1000) NOT NULL DEFAULT '', `mail_cc` varchar(1000) NOT NULL DEFAULT '', - `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `t_env_project_id` (`project_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_env_server`; CREATE TABLE `t_env_server` ( `id` int(11) NOT NULL AUTO_INCREMENT, `project_id` int(11) NOT NULL DEFAULT '0', @@ -40,6 +43,7 @@ CREATE TABLE `t_env_server` ( KEY `t_env_server_env_id` (`env_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_mail_tpl`; CREATE TABLE `t_mail_tpl` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL DEFAULT '0', @@ -48,23 +52,25 @@ CREATE TABLE `t_mail_tpl` ( `content` longtext NOT NULL, `mail_to` varchar(1000) NOT NULL DEFAULT '', `mail_cc` varchar(1000) NOT NULL DEFAULT '', - `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_perm`; CREATE TABLE `t_perm` ( `module` varchar(20) NOT NULL DEFAULT '' COMMENT '模块名', `action` varchar(20) NOT NULL DEFAULT '' COMMENT '操作名', UNIQUE KEY `module` (`module`,`action`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_project`; CREATE TABLE `t_project` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(100) NOT NULL DEFAULT '', `domain` varchar(100) NOT NULL DEFAULT '', `version` varchar(20) NOT NULL DEFAULT '', - `version_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `version_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `repo_url` varchar(100) NOT NULL DEFAULT '', `status` int(11) NOT NULL DEFAULT '0', `error_msg` longtext NOT NULL, @@ -75,27 +81,30 @@ CREATE TABLE `t_project` ( `create_verfile` int(11) NOT NULL DEFAULT '0', `verfile_path` varchar(50) NOT NULL DEFAULT '', `task_review` tinyint(4) NOT NULL DEFAULT '0' COMMENT '发布是否需要审批', - `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_role`; CREATE TABLE `t_role` ( `id` int(11) NOT NULL AUTO_INCREMENT, `role_name` varchar(20) NOT NULL DEFAULT '', `project_ids` varchar(1000) NOT NULL DEFAULT '', `description` varchar(200) NOT NULL DEFAULT '', - `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_role_perm`; CREATE TABLE `t_role_perm` ( `role_id` int(11) unsigned NOT NULL, `perm` varchar(50) NOT NULL DEFAULT '', PRIMARY KEY (`role_id`,`perm`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_server`; CREATE TABLE `t_server` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type_id` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:普通服务器, 1:跳板机', @@ -107,11 +116,12 @@ CREATE TABLE `t_server` ( `ssh_pwd` varchar(100) NOT NULL DEFAULT '' COMMENT 'ssh密码', `ssh_key` varchar(100) NOT NULL DEFAULT '' COMMENT 'sshkey路径', `work_dir` varchar(100) NOT NULL DEFAULT '' COMMENT '工作目录', - `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_task`; CREATE TABLE `t_task` ( `id` int(11) NOT NULL AUTO_INCREMENT, `project_id` int(11) NOT NULL DEFAULT '0' COMMENT '项目ID', @@ -130,7 +140,7 @@ CREATE TABLE `t_task` ( `pub_log` longtext NOT NULL COMMENT '发布日志', `pub_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '发布状态', `review_status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '审批状态', - `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `t_task_project_id` (`project_id`), @@ -138,6 +148,7 @@ CREATE TABLE `t_task` ( KEY `pub_time` (`pub_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_task_review`; CREATE TABLE `t_task_review` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `task_id` int(11) NOT NULL COMMENT '任务ID', @@ -150,6 +161,7 @@ CREATE TABLE `t_task_review` ( KEY `task_id` (`task_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_user`; CREATE TABLE `t_user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(20) NOT NULL DEFAULT '', @@ -160,12 +172,13 @@ CREATE TABLE `t_user` ( `last_login` datetime DEFAULT NULL, `last_ip` varchar(15) NOT NULL DEFAULT '', `status` int(11) NOT NULL DEFAULT '0', - `create_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `user_name` (`user_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +DROP TABLE IF EXISTS `t_user_role`; CREATE TABLE `t_user_role` ( `user_id` int(11) unsigned NOT NULL, `role_id` int(11) unsigned NOT NULL, @@ -275,4 +288,4 @@ VALUES INSERT INTO `t_user` (`id`, `user_name`, `password`, `salt`, `sex`, `email`, `last_login`, `last_ip`, `status`, `create_time`, `update_time`) VALUES - (1,'admin','7fef6171469e80d32c0559f88b377245','',1,'admin@admin.com','2016-05-11 10:33:49','127.0.0.1',0,'0000-00-00 00:00:00','2016-05-11 10:33:49'); \ No newline at end of file + (1,'admin','7fef6171469e80d32c0559f88b377245','',1,'admin@admin.com','2016-05-11 10:33:49','127.0.0.1',0,NOW(),'2016-05-11 10:33:49'); diff --git a/main.go b/main.go index 60bbdd8..ec1dbeb 100644 --- a/main.go +++ b/main.go @@ -1,12 +1,12 @@ package main import ( + "./app/controllers" + _ "./app/mail" + "./app/service" "fmt" "github.com/astaxie/beego" "github.com/beego/i18n" - "github.com/lisijie/gopub/app/controllers" - _ "github.com/lisijie/gopub/app/mail" - "github.com/lisijie/gopub/app/service" "time" ) diff --git a/pack.sh b/pack.sh old mode 100644 new mode 100755 diff --git a/service.sh b/service.sh old mode 100644 new mode 100755