/
main.go
42 lines (40 loc) · 1.21 KB
/
main.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
package main
import (
"github.com/Biubiubiuuuu/orderingSystem/db/mysql"
"github.com/Biubiubiuuuu/orderingSystem/db/redis"
"github.com/Biubiubiuuuu/orderingSystem/helper/configHelper"
"github.com/Biubiubiuuuu/orderingSystem/helper/encryptHelper"
"github.com/Biubiubiuuuu/orderingSystem/model/businessModel"
"github.com/Biubiubiuuuu/orderingSystem/model/systemModel"
"github.com/Biubiubiuuuu/orderingSystem/router"
)
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
//初始化mysql
mysql.DB.InitConn()
db := mysql.GetMysqlDB()
//自动迁移模型
db.AutoMigrate(
&systemModel.SystemAdmin{},
&businessModel.BusinessAdmin{},
&businessModel.Goods{},
&businessModel.GoodsType{},
&businessModel.Store{},
&businessModel.InStorePhoto{},
&businessModel.Table{},
&businessModel.TableType{},
)
// 添加默认管理员 username:Admin,password:123456
a := systemModel.SystemAdmin{Username: "admin", Password: encryptHelper.EncryptMD5To32Bit("123456"), Manager: "Y"}
if err := a.QuerySystemAdminByUsername(); err != nil {
a.AddSystemAdmin()
}
//初始化redis
redis.DB.InitConn()
//初始化路由
router := router.Init()
//启动
router.Run(configHelper.HTTPPort)
}