-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.go
80 lines (73 loc) · 2.06 KB
/
init.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import (
"github.com/gin-gonic/gin"
"network/controller/department"
"network/controller/session"
"network/controller/transaction"
"network/controller/user"
"network/middleware"
)
func routerRegister(router *gin.Engine) {
authorized := router.Group("/")
{
authorized.Use(middleware.Authorized)
groupUser := authorized.Group("/user")
{
groupUser.POST("/type", user.ListWithType)
{
groupUser.Use(middleware.AdminAuthorized)
// 添加用户
groupUser.POST("", user.Add)
// 删除用户
groupUser.DELETE("/:id", user.Delete)
// 修改用户
groupUser.PUT("", user.Modify)
// 获取用户详细信息
groupUser.GET("/:id", user.Info)
// 获取用户列表
groupUser.GET("", user.List)
}
}
groupDepartment := authorized.Group("/department")
{
// 获取部门列表
groupDepartment.GET("", department.List)
groupDepartment.POST("/type", department.ListWithType)
{
groupDepartment.Use(middleware.AdminAuthorized)
// 添加部门
groupDepartment.POST("", department.Add)
// 修改部门
groupDepartment.PUT("", department.Modify)
// 删除部门
groupDepartment.DELETE("/:id", department.Delete)
// 获取部门详细信息
groupDepartment.GET("/:id", department.Info)
}
}
groupTransaction := authorized.Group("/transaction")
{
// 获取事件信息
groupTransaction.GET("", transaction.List)
// 修改事件
groupTransaction.PUT("", transaction.Modified)
{
groupTransaction.Use(middleware.CityAndDistrictAuthorized)
// 添加事件
groupTransaction.POST("", transaction.Add)
// 事件统计
groupTransaction.GET("/statistic", transaction.Statistic)
groupTransaction.GET("/statistic/array", transaction.StatisticArray)
}
}
// 注销登录
authorized.DELETE("/session", session.Logout)
//查看登录日志
authorized.GET("/session/log", middleware.AdminAuthorized, session.LoginLog)
}
unauthorized := router.Group("/")
{
// 用户登录
unauthorized.POST("/session", middleware.UserLoginLog, session.Login)
}
}