-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (56 loc) · 1.8 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"gitee.com/CQU-2022CurriculumProject/HospitalOutpatientSystem_Server/controller"
"gitee.com/CQU-2022CurriculumProject/HospitalOutpatientSystem_Server/infra/dal/client_db"
"gitee.com/CQU-2022CurriculumProject/HospitalOutpatientSystem_Server/middleware"
"github.com/gin-gonic/gin"
)
func Init() {
client_db.InitDB()
}
func main() {
Init()
r := gin.New()
r.Use(gin.Recovery(), gin.Logger())
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.POST("/login", controller.Login)
r.POST("/register", controller.Register)
r.POST("/wx/login", controller.WXLogin)
r.Use(middleware.Authorize())
r.GET("/auth", func(c *gin.Context) {
userID, _ := middleware.GetUserID(c)
c.JSON(200, gin.H{
"userID": userID,
})
})
// 科室
departmentRouter := r.Group("/department")
{
departmentRouter.POST("/get_all_department", controller.GetAllDepartment)
}
// 病人
patientRouter := r.Group("/patient")
{
patientRouter.POST("get_place", controller.GetPlace)
patientRouter.POST("get_payment", controller.GetPayment)
patientRouter.POST("get_register_order", controller.GetRegisterOrder)
// 根据挂号ID获得处方
patientRouter.POST("get_prescription_order", controller.GetPrescriptionOrder)
patientRouter.POST("to_appoint", controller.ToAppoint)
patientRouter.POST("get_check_order", controller.GetCheckOrder)
//patientRouter.POST("cancel_medication", controller.CancelMedication)
patientRouter.POST("pay_all", controller.PayAll)
patientRouter.POST("cancel_all", controller.CancelAll)
}
// 医生
doctorRouter := r.Group("/doctor")
{
doctorRouter.POST("/get_from_department", controller.GetDocFromDepartment)
doctorRouter.POST("/get_appoint_order", controller.GetAppointOrder)
}
r.Run() // 监听并在 0.0.0.0:8080 上启动服务
}