yshop-gin-2

思考并回答以下问题:

根目录

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
47
48
49
50
51
52
53
server:
run-mode: 'release'
http-port: 8000
read-timeout: 60
write-timeout: 60
app:
page-size: 10
jwt-secret: go-mall
prefix-url: 'http://127.0.0.1:8000'
runtime-root-path: 'runtime/'
image-save-path: 'upload/images/'
# MB
image-max-size: 5242880
image-allow-exts: ['.jpg','.jpeg','.png']
export-save-path: 'export/'
qrcode-save-path: 'qrcode/'
font-save-path: 'fonts/'
log-save-path: 'logs/'
Log-save-name: 'log'
Log-file-ext: 'log'
time-format: 20060102

database:
type: 'mysql'
user: 'root'
password: 'root'
host: '127.0.0.1:3306'
name: 'yshop_go'
table_prefix:

redis:
host: '127.0.0.1:6379'
password:
max_idle: 30
max_active: 30
idle_timeout: 200

zap:
log-filepath: 'runtime/logs'
log-info-filename: 'info'
log-warn-filename: 'warn'
log-fiile-ext: 'log'

wechat:
app_id:
app_secret:
token: yshop-gin
encoding_aes_key:

express:
eBusinessId: 1607734
appKey: 81f43a2e-f504-45c4-9b54-2637d59f8190

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main

import (
"fmt"
"github.com/spf13/cobra"
"os"
"yixiang.co/go-mall/app/listen"
"yixiang.co/go-mall/app/models"
"yixiang.co/go-mall/cmd"
"yixiang.co/go-mall/pkg/config"
"yixiang.co/go-mall/pkg/console"
"yixiang.co/go-mall/pkg/global"
"yixiang.co/go-mall/pkg/jwt"
"yixiang.co/go-mall/pkg/logging"
"yixiang.co/go-mall/pkg/redis"
"yixiang.co/go-mall/pkg/wechat"
)

func init() {
global.YSHOP_VP = config.Viper()
global.YSHOP_LOG = logging.SetupLogger()
models.Setup()
logging.Setup()
redis.Setup()
jwt.Setup()
listen.Setup()
wechat.InitWechat()
}

// @title gin-shop API
// @version 1.0
// @description gin-shop商城后台管理系统
// @termsOfService https://gitee.com/guchengwuyue/gin-shop
// @license.name apache2
func main() {
var rootCmd = &cobra.Command{
Use: "yshop=gin",
Short: "gin商城系统r",
Long: "will run serve command",

PersistentPreRun: func(cmd *cobra.Command, args []string) {

},
}

rootCmd.AddCommand(cmd.CmdServe)

// 配置默认运行 Web 服务
cmd.RegisterDefaultCmd(rootCmd, cmd.CmdServe)

// 注册全局参数,--env
cmd.RegisterGlobalFlags(rootCmd)

// 执行主命令
if err := rootCmd.Execute(); err != nil {
console.Exit(fmt.Sprintf("Failed to run app with %v: %s", os.Args, err.Error()))
}

}

routers

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
package routers

import (
"github.com/gin-gonic/gin"
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"net/http"
_ "yixiang.co/go-mall/docs"
"yixiang.co/go-mall/middleware"
"yixiang.co/go-mall/pkg/upload"
"yixiang.co/go-mall/routers/admin"
)

func InitRouter() *gin.Engine {
r := gin.New()
r.Use(gin.Logger())
r.Use(gin.Recovery())
r.Use(middleware.Cors())

r.StaticFS("/upload/images", http.Dir(upload.GetImageFullPath()))
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

//注册后台路由
admin.RegisterSystemRouters(r)
admin.RegisterShopRouters(r)
admin.RegisterToolsRouters(r)
admin.RegisterWeixinRouters(r)

//注册api 路由
//api.RegisterApiRouters(r)

return r
}

0%