/
app.go
46 lines (41 loc) · 859 Bytes
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"github.com/GoodHot/TinyCMS/common/strs"
"github.com/GoodHot/TinyCMS/controller"
"github.com/GoodHot/TinyCMS/model"
"github.com/GoodHot/TinyCMS/orm"
"github.com/GoodHot/TinyCMS/spring"
"os"
)
func main() {
env := "prod"
if len(os.Args) > 1 {
env = os.Args[1]
}
fmt.Println(strs.Fmt("application running with '%s'", env))
err := spring.Load(strs.Fmt("resource/config/config_%s.json", env))
if err != nil {
panic(err)
}
spring := spring.AppCtx()
orm := &orm.ORM{}
spring.Reg(orm)
err = orm.Init(
&model.Admin{},
&model.Category{},
&model.Article{},
&model.Tag{},
&model.RelTagArticle{},
&model.Upload{},
&model.Dict{},
&model.Role{},
&model.RelRolePermission{},
&model.Permission{})
if err != nil {
panic(err)
}
ctrl := &controller.Controller{}
spring.Reg(ctrl)
ctrl.StartUp()
}