From afb98f5e81ea45e0c12c07df3fd2f57e595712f7 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 13 Aug 2020 23:47:37 +0800 Subject: [PATCH] feat:update vue template & sql --- cmd/api/server.go | 2 + config/db.sql | 4 +- jobs/examples.go | 9 +- jobs/jobbase.go | 6 +- template/vue.go.template | 330 ++++++++++++++++++++------------------- 5 files changed, 177 insertions(+), 174 deletions(-) diff --git a/cmd/api/server.go b/cmd/api/server.go index 088fa0cb..68f49a9a 100644 --- a/cmd/api/server.go +++ b/cmd/api/server.go @@ -76,7 +76,9 @@ func run() error { Handler: r, } go func() { + jobs.InitJob() jobs.Setup() + }() diff --git a/config/db.sql b/config/db.sql index 6004ec78..ca98399e 100644 --- a/config/db.sql +++ b/config/db.sql @@ -452,8 +452,8 @@ INSERT INTO sys_user VALUES (2, 'zhangwj', '13211111111', 3, NULL, NULL, '0', 'q INSERT INTO sys_setting VALUES (1, 'go-admin管理系统', 'https://gitee.com/mydearzwj/image/raw/master/img/go-admin.png', '2020-08-05 14:27:34', '2020-08-07 10:13:31' ,NULL); -INSERT INTO sys_job VALUES (1, '接口测试', 'DEFAULT', 1, '0/5 * * * * ?', 'http://localhost:8000', 1, 1, 0, '2020-08-03 14:54:03', '2020-08-11 21:48:47', NULL, '', '', 1); -INSERT INTO sys_job VALUES (2, '函数测试', 'DEFAULT', 2, '0/5 * * * * ?', 'ExamplesNoParam', 1, 1, 0, '2020-08-11 21:41:23', '2020-08-11 21:41:31', NULL, '', '', 2); +INSERT INTO sys_job VALUES (1, '接口测试', 'DEFAULT', 1, '0/5 * * * * ?', 'http://localhost:8000', 1, 1, 2, 0, '', '', '2020-08-03 14:54:03', '2020-08-11 21:48:47', NULL); +INSERT INTO sys_job VALUES (2, '函数测试', 'DEFAULT', 2, '0/5 * * * * ?', 'ExamplesOne', 1, 1, 2, 0, '', '', '2020-08-11 21:41:23', '2020-08-11 21:41:31', NULL); COMMIT; -- 数据完成 ; \ No newline at end of file diff --git a/jobs/examples.go b/jobs/examples.go index ed0a5625..cef1996d 100644 --- a/jobs/examples.go +++ b/jobs/examples.go @@ -7,10 +7,11 @@ import ( // 需要将定义的struct 添加到字典中; // 字典 key 可以配置到 自动任务 调用目标 中; -func init() { - var mp = make(map[string]JobsExec, 10) - mp["ExamplesOne"] = ExamplesOne{} - jobList = mp +func InitJob() { + jobList = map[string]JobsExec{ + "ExamplesOne": ExamplesOne{}, + // ... + } } // 新添加的job 必须按照以下格式定义,并实现Exec函数 diff --git a/jobs/jobbase.go b/jobs/jobbase.go index 6b4ee04b..61402596 100644 --- a/jobs/jobbase.go +++ b/jobs/jobbase.go @@ -36,12 +36,8 @@ type ExecJob struct { func (e *ExecJob) Run() { startTime := time.Now() - var mp = jobList - lock.Lock() - var obj = mp[e.InvokeTarget] - lock.Unlock() + var obj = jobList[e.InvokeTarget] CallExec(obj.(JobsExec)) - //fmt.Println("CallExec exec success") // 结束时间 endTime := time.Now() diff --git a/template/vue.go.template b/template/vue.go.template index e19ee053..55f2a93c 100644 --- a/template/vue.go.template +++ b/template/vue.go.template @@ -1,139 +1,19 @@ {{$tableComment:=.TableComment}}