Procházet zdrojové kódy

添加血透管理后台代码

csx před 5 roky
revize
4a85c6f766
43 změnil soubory, kde provedl 4515 přidání a 0 odebrání
  1. 146 0
      conf/app.conf
  2. 58 0
      controllers/admin_api_controllers/admin_api_base_controller.go
  3. 16 0
      controllers/admin_api_controllers/admin_api_router_register.go
  4. 466 0
      controllers/admin_api_controllers/analysis_api_controller.go
  5. 35 0
      controllers/admin_api_controllers/login_api_controller.go
  6. 135 0
      controllers/base_api_controller.go
  7. 42 0
      controllers/base_controller.go
  8. 58 0
      controllers/base_view_controller.go
  9. 2 0
      db/xt_drug_dic
  10. 21 0
      db/xt_drugway_dic
  11. 35 0
      db/xt_ef_dic
  12. binární
      db/xtdb.docx
  13. 372 0
      enums/error_code.go
  14. 16 0
      main.go
  15. 16 0
      models/admin_models/admin_models.go
  16. 69 0
      models/admin_user_models.go
  17. 62 0
      models/data_models.go
  18. 14 0
      models/db_err_models.go
  19. 486 0
      models/dialysis.go
  20. 107 0
      models/org_models.go
  21. 320 0
      models/patient_models.go
  22. 37 0
      models/purview_models.go
  23. 61 0
      models/role_models.go
  24. 130 0
      models/service_models.go
  25. 11 0
      models/subscibe_state_models.go
  26. 23 0
      routers/router.go
  27. 353 0
      service/admin_service.go
  28. 116 0
      service/db.go
  29. 75 0
      service/statistics_service.go
  30. 382 0
      service/verify_login_token_service.go
  31. binární
      static/1.jpg
  32. binární
      static/2.jpg
  33. binární
      static/5.jpg
  34. 1 0
      static/js/reload.min.js
  35. 37 0
      tests/default_test.go
  36. 13 0
      utils/ip_helper.go
  37. 66 0
      utils/log.go
  38. 191 0
      utils/paginator.go
  39. 75 0
      utils/regex_helper.go
  40. 115 0
      utils/stringtool.go
  41. 27 0
      utils/time_helper.go
  42. 231 0
      utils/tools.go
  43. 95 0
      views/index.tpl

+ 146 - 0
conf/app.conf Zobrazit soubor

@@ -0,0 +1,146 @@
1
+appname = 血透
2
+httpport = 9529
3
+runmode = dev
4
+
5
+copyrequestbody = true
6
+sessionon = true
7
+sessiongcmaxlifetime = 64800
8
+
9
+tokencookiemaxlifetime = 7200
10
+
11
+enablexsrf = false
12
+xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
13
+xsrfexpire = 3600
14
+
15
+qiniu_accesskey = -l_Pcc1YJs0gh3w0YwN2uoaZO_5fY5J9SIYnSjg0
16
+qiniu_secretkey = DmZSp_Bmnp-9aUB7xUvoyViZpzmx1Rs2RL69GvlW
17
+qiniu_domain = https://images.shengws.com/
18
+qiniu_bucket = syhclub-storage
19
+
20
+aes_key = "xuetou-201807319"
21
+
22
+wxtoken = gh_ac6cd0cdde3d
23
+wxoriId = gh_ac6cd0cdde3d
24
+wxappId = wxbb9223f20bc11612
25
+# wxappsecret = a78c793c377268db25dde2eb971a2ebb
26
+# wxEncodingAESKey = 1vRDzqltXYOc9iMqhsQT7AkIRRpUaGl8MZlUcP7x4UK
27
+
28
+sms_appId = dcabb3aa7afd402794046ebbbf652bce
29
+sms_sid = a26cb0ceb3a811ca82143972f4ef38a4
30
+sms_token = ea475ed8d3de6c54c2b3f9d78db76d1e
31
+sms_baseUrl = https://open.ucpaas.com/ol/sms/
32
+ip_max_send_count = 20
33
+moblie_max_send_count = 5
34
+sms_verification_code_templateid = 329532
35
+
36
+
37
+appid = "wx43ad410d9eef426e"
38
+mchid = "1509573721"
39
+key = "e4SHrkiZu0pQEwVoGBapDBTf9N1Q6MxV"
40
+appsecret="61ee2e6268497d5aa9de0b0187c39aea"
41
+
42
+
43
+
44
+[prod]
45
+httpdomain = https://api.xt.kuyicloud.com
46
+sso_domain = https://sso.kuyicloud.com
47
+front_end_domain = "https://xt.kuyicloud.com/#"
48
+
49
+readmysqlhost = shengws1.mysql.rds.aliyuncs.com
50
+readmysqlport = 3306
51
+readmysqluser = syh
52
+readmysqlpass = xhPECP2nFObR8aUK
53
+readmysqlname = sgj_xt
54
+
55
+writemysqlhost = shengws1.mysql.rds.aliyuncs.com
56
+writemysqlport = 3306
57
+writemysqluser = syh
58
+writemysqlpass = xhPECP2nFObR8aUK
59
+writemysqlname = sgj_xt
60
+
61
+
62
+readuserhost = shengws1.mysql.rds.aliyuncs.com
63
+readuserport = 3306
64
+readuseruser = syh
65
+readuserpass = xhPECP2nFObR8aUK
66
+readusername = sgj_users
67
+
68
+writeuserhost = shengws1.mysql.rds.aliyuncs.com
69
+writeuserport = 3306
70
+writeuseruser = syh
71
+writeuserpass = xhPECP2nFObR8aUK
72
+writeusername = sgj_users
73
+
74
+redishost = 349e580b2a524290.redis.rds.aliyuncs.com
75
+redisport = 6379
76
+redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
77
+redisdb = 0
78
+
79
+
80
+
81
+
82
+niprocart =  63
83
+jms = 58
84
+fistula_needle_set = 65
85
+fistula_needle_set_16 = 64
86
+hemoperfusion = 55
87
+dialyser_sterilised = 12
88
+filtryzer = 53
89
+dialyzers = 8
90
+injector = 81
91
+bloodlines = 42
92
+tubingHemodialysis = 30
93
+package = 82
94
+aliquid = 83
95
+
96
+
97
+
98
+[dev]
99
+httpdomain = http://api.xt.test.sgjyun.com
100
+sso_domain = https://testsso.sgjyun.com
101
+front_end_domain = "http://xt.test.sgjyun.com/#"
102
+
103
+readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
104
+readmysqlport = 3306
105
+readmysqluser = root
106
+readmysqlpass = 1Q2W3e4r!@#$
107
+readmysqlname = sgj_xt
108
+
109
+writemysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
110
+writemysqlport = 3306
111
+writemysqluser = root
112
+writemysqlpass = 1Q2W3e4r!@#$
113
+writemysqlname = sgj_xt
114
+
115
+readuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
116
+readuserport = 3306
117
+readuseruser = root
118
+readuserpass = 1Q2W3e4r!@#$
119
+readusername = sgj_users
120
+
121
+writeuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
122
+writeuserport = 3306
123
+writeuseruser = root
124
+writeuserpass = 1Q2W3e4r!@#$
125
+writeusername = sgj_users
126
+
127
+redishost = 120.77.235.13
128
+redisport = 6379
129
+redispasswrod = syh@#$%123456!
130
+redisdb = 0
131
+
132
+
133
+
134
+niprocart =  83
135
+jms = 80
136
+fistula_needle_set = 81
137
+fistula_needle_set_16 = 82
138
+hemoperfusion = 85
139
+dialyser_sterilised = 84
140
+filtryzer = 79
141
+dialyzers = 10000
142
+injector = 10001
143
+bloodlines = 10002
144
+tubingHemodialysis = 10003
145
+package = 10004
146
+aliquid = 10005

+ 58 - 0
controllers/admin_api_controllers/admin_api_base_controller.go Zobrazit soubor

@@ -0,0 +1,58 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"XT_Admin_Api/controllers"
5
+	"XT_Admin_Api/enums"
6
+	"XT_Admin_Api/models/admin_models"
7
+)
8
+
9
+type AdminBaseAPIController struct {
10
+	controllers.BaseAPIController
11
+}
12
+
13
+func (this *AdminBaseAPIController) ErrorLog(format string, a ...interface{}) {
14
+	//beego.Error(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
15
+}
16
+
17
+func (this *AdminBaseAPIController) WarnLog(format string, a ...interface{}) {
18
+	//beego.Warn(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
19
+}
20
+
21
+func (this *AdminBaseAPIController) InfoLog(format string, a ...interface{}) {
22
+	//beego.Info(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
23
+}
24
+
25
+func (this *AdminBaseAPIController) DebugLog(format string, a ...interface{}) {
26
+	//beego.Debug(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
27
+}
28
+
29
+func (this *AdminBaseAPIController) TraceLog(format string, a ...interface{}) {
30
+	//beego.Trace(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
31
+}
32
+
33
+func (this *AdminBaseAPIController) GetAdminInfo() *AdminInfo {
34
+	userInfo := this.GetSession("admin_info")
35
+	if userInfo == nil {
36
+		return nil
37
+	} else {
38
+		return userInfo.(*AdminInfo)
39
+	}
40
+}
41
+
42
+type AdminInfo struct {
43
+	Admin *admin_models.AdminAccount
44
+}
45
+
46
+type AdminBaseAPIAuthController struct {
47
+	AdminBaseAPIController
48
+}
49
+
50
+func (this *AdminBaseAPIAuthController) Prepare() {
51
+	this.AdminBaseAPIController.Prepare()
52
+
53
+	adminInfo := this.GetAdminInfo()
54
+	if adminInfo == nil {
55
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
56
+		this.StopRun()
57
+	}
58
+}

+ 16 - 0
controllers/admin_api_controllers/admin_api_router_register.go Zobrazit soubor

@@ -0,0 +1,16 @@
1
+package admin_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+// 管理员后台路由,以 /admin/api 为前缀
6
+func AdminAPIControllersRegisterRouters() {
7
+	beego.Router("/admin/api/login/pwd", &LoginAPIController{}, "post:LoginByPwd")
8
+
9
+	beego.Router("/admin/api/org/regist", &AnalysisAPIController{}, "get:RegistOrg")
10
+	beego.Router("/admin/api/org/active", &AnalysisAPIController{}, "get:ActiveOrg")
11
+	beego.Router("/admin/api/user/active", &AnalysisAPIController{}, "get:ActiveUser")
12
+	beego.Router("/admin/api/org/expiring", &AnalysisAPIController{}, "get:ExpiringOrg")
13
+	beego.Router("/admin/api/dialysis/analysis", &AnalysisAPIController{}, "get:DialysisAnalysis")
14
+	beego.Router("/admin/api/monitor/analysis", &AnalysisAPIController{}, "get:MonitorAnalysis")
15
+	beego.Router("/admin/api/patient/analysis", &AnalysisAPIController{}, "get:PatientAnalysis")
16
+}

+ 466 - 0
controllers/admin_api_controllers/analysis_api_controller.go Zobrazit soubor

@@ -0,0 +1,466 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"XT_Admin_Api/models"
5
+	"XT_Admin_Api/service"
6
+	"XT_Admin_Api/utils"
7
+	"time"
8
+)
9
+
10
+type AnalysisAPIController struct {
11
+	AdminBaseAPIAuthController
12
+	// AdminBaseAPIController
13
+}
14
+
15
+// /admin/api/org/regist [get] RegistOrg
16
+func (this *AnalysisAPIController) RegistOrg() {
17
+	totalOrg, getTotalOrgErr := service.GetTotalOrgCount()
18
+	if getTotalOrgErr != nil {
19
+		this.ErrorLog("获取总机构数失败:%v", getTotalOrgErr)
20
+	}
21
+
22
+	now := time.Now()
23
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
24
+	registOrgCountToday, getRegistOrgCountTodayErr := service.GetRegistedOrgCountFromDayToDay(zeroHourTimeOfToday, now)
25
+	if getRegistOrgCountTodayErr != nil {
26
+		this.ErrorLog("获取今日注册机构数失败:%v", getRegistOrgCountTodayErr)
27
+	}
28
+
29
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
30
+	registOrgCountThisWeek, getRegistOrgCountThisWeekErr := service.GetRegistedOrgCountFromDayToDay(monday, sunday)
31
+	if getRegistOrgCountThisWeekErr != nil {
32
+		this.ErrorLog("获取本周注册机构数失败:%v", getRegistOrgCountThisWeekErr)
33
+	}
34
+
35
+	thisYear := now.Year()
36
+	thisMonth := int(now.Month())
37
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
38
+	registOrgCountThisMonth, getRegistOrgCountThisMonthErr := service.GetRegistedOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
39
+	if getRegistOrgCountThisMonthErr != nil {
40
+		this.ErrorLog("获取本月注册机构数失败:%v", getRegistOrgCountThisMonthErr)
41
+	}
42
+
43
+	monthRegistOrgCounts := make([]map[string]interface{}, 0, 12)
44
+	for m := 1; m < 12; m++ {
45
+		if m > thisMonth {
46
+			break
47
+		}
48
+		if m == thisMonth {
49
+			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
50
+				"month": m,
51
+				"count": registOrgCountThisMonth,
52
+			})
53
+
54
+		} else {
55
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
56
+			registOrgCount, getRegistOrgCountErr := service.GetRegistedOrgCountFromDayToDay(BOM, EOM)
57
+			if getRegistOrgCountErr != nil {
58
+				this.ErrorLog("获取%v月注册机构数失败:%v", m, getRegistOrgCountErr)
59
+			}
60
+			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
61
+				"month": m,
62
+				"count": registOrgCount,
63
+			})
64
+		}
65
+	}
66
+
67
+	registOrgsThisWeek, getRegistOrgThisWeekErr := service.GetRegistedOrgsFromDayToDay(monday, sunday)
68
+	if getRegistOrgThisWeekErr != nil {
69
+		this.ErrorLog("获取本周注册机构失败:%v", getRegistOrgThisWeekErr)
70
+		registOrgsThisWeek = make([]*models.Org, 0)
71
+	}
72
+
73
+	registOrgsThisMonth, getRegistOrgThisMonthErr := service.GetRegistedOrgsFromDayToDay(beginningOfMonth, endOfMonth)
74
+	if getRegistOrgThisMonthErr != nil {
75
+		this.ErrorLog("获取本月注册机构失败:%v", getRegistOrgThisMonthErr)
76
+		registOrgsThisMonth = make([]*models.Org, 0)
77
+	}
78
+
79
+	this.ServeSuccessJSON(map[string]interface{}{
80
+		"total_org_count":         totalOrg,
81
+		"regist_org_count_today":  registOrgCountToday,
82
+		"regist_org_count_week":   registOrgCountThisWeek,
83
+		"regist_org_count_month":  registOrgCountThisMonth,
84
+		"regist_org_count_months": monthRegistOrgCounts,
85
+		"regist_orgs_week":        registOrgsThisWeek,
86
+		"regist_orgs_month":       registOrgsThisMonth,
87
+	})
88
+}
89
+
90
+// /admin/api/org/active [get] ActiveOrg
91
+func (this *AnalysisAPIController) ActiveOrg() {
92
+	now := time.Now()
93
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
94
+	activeOrgCountToday, getActiveTodayErr := service.GetActiveOrgCountFromDayToDay(zeroHourTimeOfToday, now)
95
+	if getActiveTodayErr != nil {
96
+		this.ErrorLog("获取今日活跃机构数失败:%v", getActiveTodayErr)
97
+	}
98
+
99
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
100
+	activeOrgCountThisWeek, getActiveOrgCountThisWeekErr := service.GetActiveOrgCountFromDayToDay(monday, sunday)
101
+	if getActiveOrgCountThisWeekErr != nil {
102
+		this.ErrorLog("获取本周活跃机构数失败:%v", getActiveOrgCountThisWeekErr)
103
+	}
104
+
105
+	thisYear := now.Year()
106
+	thisMonth := int(now.Month())
107
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
108
+	activeOrgCountThisMonth, getActiveOrgCountThisMonthErr := service.GetActiveOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
109
+	if getActiveOrgCountThisMonthErr != nil {
110
+		this.ErrorLog("获取本月活跃机构数失败:%v", getActiveOrgCountThisMonthErr)
111
+	}
112
+
113
+	monthActiveOrgCounts := make([]map[string]interface{}, 0, 12)
114
+	for m := 1; m < 12; m++ {
115
+		if m > thisMonth {
116
+			break
117
+		}
118
+		if m == thisMonth {
119
+			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
120
+				"month": m,
121
+				"count": activeOrgCountThisMonth,
122
+			})
123
+
124
+		} else {
125
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
126
+			activeOrgCount, getActiveOrgCountErr := service.GetActiveOrgCountFromDayToDay(BOM, EOM)
127
+			if getActiveOrgCountErr != nil {
128
+				this.ErrorLog("获取%v月活跃机构数失败:%v", m, getActiveOrgCountErr)
129
+			}
130
+			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
131
+				"month": m,
132
+				"count": activeOrgCount,
133
+			})
134
+		}
135
+	}
136
+
137
+	activeOrgsThisWeek, getActiveOrgThisWeekErr := service.GetActiveOrgsFromDayToDay(monday, sunday)
138
+	if getActiveOrgThisWeekErr != nil {
139
+		this.ErrorLog("获取本周活跃机构失败:%v", getActiveOrgThisWeekErr)
140
+		activeOrgsThisWeek = make([]*service.ActiveOrgListVM, 0)
141
+	}
142
+
143
+	activeOrgsThisMonth, getActiveOrgThisMonthErr := service.GetActiveOrgsFromDayToDay(beginningOfMonth, endOfMonth)
144
+	if getActiveOrgThisMonthErr != nil {
145
+		this.ErrorLog("获取本月活跃机构失败:%v", getActiveOrgThisMonthErr)
146
+		activeOrgsThisMonth = make([]*service.ActiveOrgListVM, 0)
147
+	}
148
+
149
+	this.ServeSuccessJSON(map[string]interface{}{
150
+		"active_org_count_today":  activeOrgCountToday,
151
+		"active_org_count_week":   activeOrgCountThisWeek,
152
+		"active_org_count_month":  activeOrgCountThisMonth,
153
+		"active_org_count_months": monthActiveOrgCounts,
154
+		"active_orgs_week":        activeOrgsThisWeek,
155
+		"active_orgs_month":       activeOrgsThisMonth,
156
+	})
157
+}
158
+
159
+// /admin/api/user/active [get] ActiveUser
160
+func (this *AnalysisAPIController) ActiveUser() {
161
+	now := time.Now()
162
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
163
+	activeAdminCountToday, getActiveTodayErr := service.GetActiveAdminUserCountFromDayToDay(zeroHourTimeOfToday, now)
164
+	if getActiveTodayErr != nil {
165
+		this.ErrorLog("获取今日活跃账户数失败:%v", getActiveTodayErr)
166
+	}
167
+
168
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
169
+	activeAdminCountThisWeek, getActiveAdminCountThisWeekErr := service.GetActiveAdminUserCountFromDayToDay(monday, sunday)
170
+	if getActiveAdminCountThisWeekErr != nil {
171
+		this.ErrorLog("获取本周活跃账户数失败:%v", getActiveAdminCountThisWeekErr)
172
+	}
173
+
174
+	thisYear := now.Year()
175
+	thisMonth := int(now.Month())
176
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
177
+	activeAdminCountThisMonth, getActiveAdminCountThisMonthErr := service.GetActiveAdminUserCountFromDayToDay(beginningOfMonth, endOfMonth)
178
+	if getActiveAdminCountThisMonthErr != nil {
179
+		this.ErrorLog("获取本月活跃账户数失败:%v", getActiveAdminCountThisMonthErr)
180
+	}
181
+
182
+	monthActiveAdminCounts := make([]map[string]interface{}, 0, 12)
183
+	for m := 1; m < 12; m++ {
184
+		if m > thisMonth {
185
+			break
186
+		}
187
+		if m == thisMonth {
188
+			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
189
+				"month": m,
190
+				"count": activeAdminCountThisMonth,
191
+			})
192
+
193
+		} else {
194
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
195
+			activeAdminCount, getActiveAdminCountErr := service.GetActiveAdminUserCountFromDayToDay(BOM, EOM)
196
+			if getActiveAdminCountErr != nil {
197
+				this.ErrorLog("获取%v月活跃账户数失败:%v", m, getActiveAdminCountErr)
198
+			}
199
+			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
200
+				"month": m,
201
+				"count": activeAdminCount,
202
+			})
203
+		}
204
+	}
205
+
206
+	activeAdminsThisWeek, getActiveAdminThisWeekErr := service.GetActiveAdminUsersFromDayToDay(monday, sunday)
207
+	if getActiveAdminThisWeekErr != nil {
208
+		this.ErrorLog("获取本周活跃账户失败:%v", getActiveAdminThisWeekErr)
209
+		activeAdminsThisWeek = make([]*service.ActiveAdminUserListVM, 0)
210
+	}
211
+
212
+	activeAdminsThisMonth, getActiveAdminThisMonthErr := service.GetActiveAdminUsersFromDayToDay(beginningOfMonth, endOfMonth)
213
+	if getActiveAdminThisMonthErr != nil {
214
+		this.ErrorLog("获取本月活跃账户失败:%v", getActiveAdminThisMonthErr)
215
+		activeAdminsThisMonth = make([]*service.ActiveAdminUserListVM, 0)
216
+	}
217
+
218
+	this.ServeSuccessJSON(map[string]interface{}{
219
+		"active_admin_count_today":  activeAdminCountToday,
220
+		"active_admin_count_week":   activeAdminCountThisWeek,
221
+		"active_admin_count_month":  activeAdminCountThisMonth,
222
+		"active_admin_count_months": monthActiveAdminCounts,
223
+		"active_admins_week":        activeAdminsThisWeek,
224
+		"active_admins_month":       activeAdminsThisMonth,
225
+	})
226
+}
227
+
228
+// /admin/api/org/expiring [get] ExpiringOrg
229
+func (this *AnalysisAPIController) ExpiringOrg() {
230
+	now := time.Now()
231
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
232
+	// endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
233
+	timeAfter15Days := zeroHourTimeOfToday.AddDate(0, 0, 15)
234
+	timeBefore15Days := zeroHourTimeOfToday.AddDate(0, 0, -15)
235
+
236
+	countOfWillExpireOrg, getWillExpireOrgCountErr := service.GetWillExpireOrgCountFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
237
+	if getWillExpireOrgCountErr != nil {
238
+		this.ErrorLog("获取即将到期机构数失败:%v", getWillExpireOrgCountErr)
239
+	}
240
+
241
+	countOfExpiredOrg, getExpiredOrgCountErr := service.GetDidExpiredOrgCountFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
242
+	if getExpiredOrgCountErr != nil {
243
+		this.ErrorLog("获取刚到期机构数失败:%v", getExpiredOrgCountErr)
244
+	}
245
+
246
+	willExpireOrgs, getWillExpireOrgsErr := service.GetWillExpireOrgsFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
247
+	if getWillExpireOrgsErr != nil {
248
+		this.ErrorLog("获取即将到期机构失败:%v", getWillExpireOrgsErr)
249
+		willExpireOrgs = make([]*service.ExpireOrgListVM, 0, 0)
250
+	}
251
+
252
+	expiredOrgs, getExpiredOrgsErr := service.GetDidExpireOrgsFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
253
+	if getExpiredOrgsErr != nil {
254
+		this.ErrorLog("获取已到期机构失败:%v", getExpiredOrgsErr)
255
+		expiredOrgs = make([]*service.ExpireOrgListVM, 0, 0)
256
+	}
257
+
258
+	this.ServeSuccessJSON(map[string]interface{}{
259
+		"will_expire_org_count": countOfWillExpireOrg,
260
+		"did_expired_org_count": countOfExpiredOrg,
261
+		"will_expire_orgs":      willExpireOrgs,
262
+		"did_expired_orgs":      expiredOrgs,
263
+	})
264
+}
265
+
266
+// /admin/api/dialysis/analysis [get] DialysisAnalysis
267
+func (this *AnalysisAPIController) DialysisAnalysis() {
268
+	now := time.Now()
269
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
270
+	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
271
+
272
+	timesToday, getTimesTodayErr := service.GetDialysisTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
273
+	if getTimesTodayErr != nil {
274
+		this.ErrorLog("获取今日透析次数失败:%v", getTimesTodayErr)
275
+	}
276
+
277
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
278
+	timesThisWeek, getTimesThisWeekErr := service.GetDialysisTimesFromDayToDay(monday, sunday)
279
+	if getTimesThisWeekErr != nil {
280
+		this.ErrorLog("获取本周透析次数失败:%v", getTimesThisWeekErr)
281
+	}
282
+
283
+	thisYear := now.Year()
284
+	thisMonth := int(now.Month())
285
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
286
+	timesThisMonth, getTimesThisMonthErr := service.GetDialysisTimesFromDayToDay(beginningOfMonth, endOfMonth)
287
+	if getTimesThisMonthErr != nil {
288
+		this.ErrorLog("获取本月透析次数失败:%v", getTimesThisMonthErr)
289
+	}
290
+
291
+	monthTimes := make([]map[string]interface{}, 0, 12)
292
+	for m := 1; m < 12; m++ {
293
+		if m > thisMonth {
294
+			break
295
+		}
296
+		if m == thisMonth {
297
+			monthTimes = append(monthTimes, map[string]interface{}{
298
+				"month": m,
299
+				"count": timesThisMonth,
300
+			})
301
+
302
+		} else {
303
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
304
+			times, getTimesErr := service.GetDialysisTimesFromDayToDay(BOM, EOM)
305
+			if getTimesErr != nil {
306
+				this.ErrorLog("获取%v月透析次数失败:%v", m, getTimesErr)
307
+			}
308
+			monthTimes = append(monthTimes, map[string]interface{}{
309
+				"month": m,
310
+				"count": times,
311
+			})
312
+		}
313
+	}
314
+
315
+	this.ServeSuccessJSON(map[string]interface{}{
316
+		"times_today":  timesToday,
317
+		"times_week":   timesThisWeek,
318
+		"times_month":  timesThisMonth,
319
+		"times_months": monthTimes,
320
+	})
321
+}
322
+
323
+// /admin/api/monitor/analysis [get] MonitorAnalysis
324
+func (this *AnalysisAPIController) MonitorAnalysis() {
325
+	now := time.Now()
326
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
327
+	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
328
+
329
+	timesToday, getTimesTodayErr := service.GetMonitoringTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
330
+	if getTimesTodayErr != nil {
331
+		this.ErrorLog("获取今日监控次数失败:%v", getTimesTodayErr)
332
+	}
333
+
334
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
335
+	timesThisWeek, getTimesThisWeekErr := service.GetMonitoringTimesFromDayToDay(monday, sunday)
336
+	if getTimesThisWeekErr != nil {
337
+		this.ErrorLog("获取本周监控次数失败:%v", getTimesThisWeekErr)
338
+	}
339
+
340
+	thisYear := now.Year()
341
+	thisMonth := int(now.Month())
342
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
343
+	timesThisMonth, getTimesThisMonthErr := service.GetMonitoringTimesFromDayToDay(beginningOfMonth, endOfMonth)
344
+	if getTimesThisMonthErr != nil {
345
+		this.ErrorLog("获取本月监控次数失败:%v", getTimesThisMonthErr)
346
+	}
347
+
348
+	monthTimes := make([]map[string]interface{}, 0, 12)
349
+	for m := 1; m < 12; m++ {
350
+		if m > thisMonth {
351
+			break
352
+		}
353
+		if m == thisMonth {
354
+			monthTimes = append(monthTimes, map[string]interface{}{
355
+				"month": m,
356
+				"count": timesThisMonth,
357
+			})
358
+
359
+		} else {
360
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
361
+			times, getTimesErr := service.GetMonitoringTimesFromDayToDay(BOM, EOM)
362
+			if getTimesErr != nil {
363
+				this.ErrorLog("获取%v月监控次数失败:%v", m, getTimesErr)
364
+			}
365
+			monthTimes = append(monthTimes, map[string]interface{}{
366
+				"month": m,
367
+				"count": times,
368
+			})
369
+		}
370
+	}
371
+
372
+	this.ServeSuccessJSON(map[string]interface{}{
373
+		"times_today":  timesToday,
374
+		"times_week":   timesThisWeek,
375
+		"times_month":  timesThisMonth,
376
+		"times_months": monthTimes,
377
+	})
378
+}
379
+
380
+// /admin/api/patient/analysis [get] PatientAnalysis
381
+func (this *AnalysisAPIController) PatientAnalysis() {
382
+	now := time.Now()
383
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
384
+	newCountToday, getNewCountTodayErr := service.GetNewPatientCountFromDayToDay(zeroHourTimeOfToday, now)
385
+	if getNewCountTodayErr != nil {
386
+		this.ErrorLog("获取今日新增病人数失败:%v", getNewCountTodayErr)
387
+	}
388
+
389
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
390
+	newCountThisWeek, getNewCountThisWeekErr := service.GetNewPatientCountFromDayToDay(monday, sunday)
391
+	if getNewCountThisWeekErr != nil {
392
+		this.ErrorLog("获取本周新增病人数失败:%v", getNewCountThisWeekErr)
393
+	}
394
+
395
+	thisYear := now.Year()
396
+	thisMonth := int(now.Month())
397
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
398
+	newCountThisMonth, getNewCountThisMonthErr := service.GetNewPatientCountFromDayToDay(beginningOfMonth, endOfMonth)
399
+	if getNewCountThisMonthErr != nil {
400
+		this.ErrorLog("获取本月新增病人数失败:%v", getNewCountThisMonthErr)
401
+	}
402
+
403
+	monthNewCounts := make([]map[string]interface{}, 0, 12)
404
+	for m := 1; m < 12; m++ {
405
+		if m > thisMonth {
406
+			break
407
+		}
408
+		if m == thisMonth {
409
+			monthNewCounts = append(monthNewCounts, map[string]interface{}{
410
+				"month": m,
411
+				"count": newCountThisMonth,
412
+			})
413
+
414
+		} else {
415
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
416
+			newCount, getNewCountErr := service.GetNewPatientCountFromDayToDay(BOM, EOM)
417
+			if getNewCountErr != nil {
418
+				this.ErrorLog("获取%v月新增病人数失败:%v", m, getNewCountErr)
419
+			}
420
+			monthNewCounts = append(monthNewCounts, map[string]interface{}{
421
+				"month": m,
422
+				"count": newCount,
423
+			})
424
+		}
425
+	}
426
+
427
+	maleCount, femaleCount, unknowGenderCount, getGenderCountErr := service.GetPatientGenderDistribution()
428
+	if getGenderCountErr != nil {
429
+		this.ErrorLog("获取病人性别分布失败:%v", getGenderCountErr)
430
+	}
431
+
432
+	// 1乙肝 2丙肝 3艾滋病 4肺结核 5梅毒
433
+	// 不写错误日志了,累了
434
+	normalPCount, _ := service.GetInfectiousDiseasePatientCount(0)
435
+	type1PCount, _ := service.GetInfectiousDiseasePatientCount(1)
436
+	type2PCount, _ := service.GetInfectiousDiseasePatientCount(2)
437
+	type3PCount, _ := service.GetInfectiousDiseasePatientCount(3)
438
+	type4PCount, _ := service.GetInfectiousDiseasePatientCount(4)
439
+	type5PCount, _ := service.GetInfectiousDiseasePatientCount(5)
440
+
441
+	ageDistribution, getAgeDistributionErr := service.GetPatientAgeDistribution()
442
+	if getAgeDistributionErr != nil {
443
+		this.ErrorLog("获取病人年龄分布失败:%v", getAgeDistributionErr)
444
+		ageDistribution = make([]*service.PatientAgeCountStruct, 0, 0)
445
+	}
446
+
447
+	this.ServeSuccessJSON(map[string]interface{}{
448
+		"new_patient_count_today":  newCountToday,
449
+		"new_patient_count_week":   newCountThisWeek,
450
+		"new_patient_count_month":  newCountThisMonth,
451
+		"new_patient_count_months": monthNewCounts,
452
+
453
+		"male_count":   maleCount,
454
+		"female_count": femaleCount,
455
+		"total_count":  maleCount + femaleCount + unknowGenderCount,
456
+
457
+		"disease_type_0_count": normalPCount,
458
+		"disease_type_1_count": type1PCount,
459
+		"disease_type_2_count": type2PCount,
460
+		"disease_type_3_count": type3PCount,
461
+		"disease_type_4_count": type4PCount,
462
+		"disease_type_5_count": type5PCount,
463
+
464
+		"age_counts": ageDistribution,
465
+	})
466
+}

+ 35 - 0
controllers/admin_api_controllers/login_api_controller.go Zobrazit soubor

@@ -0,0 +1,35 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"XT_Admin_Api/enums"
5
+	"XT_Admin_Api/service"
6
+)
7
+
8
+type LoginAPIController struct {
9
+	AdminBaseAPIController
10
+}
11
+
12
+// /admin/api/login/pwd [post] LoginByPwd
13
+// @param account:string
14
+// @param password:string
15
+func (this *LoginAPIController) LoginByPwd() {
16
+	account := this.GetString("account")
17
+	password := this.GetString("password")
18
+
19
+	admin, getAdminErr := service.GetAdminAccount(account, password)
20
+	if getAdminErr != nil {
21
+		this.ErrorLog("获取管理员信息失败:%v", getAdminErr)
22
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
23
+		return
24
+	} else if admin == nil {
25
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
26
+		return
27
+	}
28
+
29
+	this.SetSession("admin_info", &AdminInfo{
30
+		Admin: admin,
31
+	})
32
+	this.ServeSuccessJSON(map[string]interface{}{
33
+		"admin": admin,
34
+	})
35
+}

+ 135 - 0
controllers/base_api_controller.go Zobrazit soubor

@@ -0,0 +1,135 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_Admin_Api/enums"
5
+)
6
+
7
+type BaseAPIController struct {
8
+	BaseController
9
+}
10
+
11
+// func (this *BaseAPIController) Prepare() {
12
+// 	this.BaseController.Prepare()
13
+// 	beego.Trace("============================================================")
14
+// 	beego.Trace("session ID: %v", this.Ctx.Input.Cookie("beegosessionID"))
15
+// 	beego.Trace("session : %v", this.GetSession("info"))
16
+// 	this.SetSession("info", time.Now().Format("2006/01/02 15:04:05"))
17
+// 	beego.Trace("============================================================")
18
+// }
19
+
20
+// 输出数据格式化
21
+/*
22
+	success json:
23
+	{
24
+		"state": 1,
25
+		"code": 0,
26
+		"data": json,
27
+	}
28
+
29
+	fail json:
30
+	{
31
+		"state": 0,
32
+		"code": int,
33
+		"msg": string,
34
+	}
35
+*/
36
+func (this *BaseAPIController) ServeSuccessJSON(data map[string]interface{}) {
37
+	this.Data["json"] = enums.MakeSuccessResponseJSON(data)
38
+	this.ServeJSON()
39
+}
40
+
41
+func (this *BaseAPIController) ServeFailJSONWithSGJErrorCode(code int) {
42
+	this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(code)
43
+	this.ServeJSON()
44
+}
45
+
46
+func (this *BaseAPIController) ServeFailJSONWithSGJError(err *enums.SGJError) {
47
+	this.Data["json"] = enums.MakeFailResponseJSONWithSGJError(err)
48
+	this.ServeJSON()
49
+}
50
+
51
+func (this *BaseAPIController) ServeFailJsonSend(code int, msg string) {
52
+	this.Data["json"] = enums.MakeFailResponseJSON(msg, code)
53
+	this.ServeJSON()
54
+}
55
+
56
+type BaseAuthAPIController struct {
57
+	BaseAPIController
58
+}
59
+
60
+func (this *BaseAuthAPIController) Prepare() {
61
+	this.BaseAPIController.Prepare()
62
+	if this.GetAdminUserInfo() == nil {
63
+		//var userAdmin models.AdminUser
64
+		//userAdmin.Id = 380
65
+		//userAdmin.Mobile = "13532250447"
66
+		//userAdmin.IsSuperAdmin = true
67
+		//userAdmin.Status = 1
68
+		//userAdmin.CreateTime = 1530786071
69
+		//userAdmin.ModifyTime = 1530786071
70
+		//var subscibe models.ServeSubscibe
71
+		//subscibe.ID = 1
72
+		//subscibe.OrgId = 4
73
+		//subscibe.PeriodStart = 1538035409
74
+		//subscibe.PeriodEnd = 1569571409
75
+		//subscibe.State = 1
76
+		//subscibe.Status = 1
77
+		//subscibe.CreatedTime = 1538035409
78
+		//subscibe.UpdatedTime = 1538035409
79
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
80
+		//subscibes[4] = &subscibe
81
+		//
82
+		//var template models.GobalTemplate
83
+		//template.TemplateId = 2
84
+		//
85
+		//
86
+		//var adminUserInfo service.AdminUserInfo
87
+		//adminUserInfo.CurrentOrgId = 4
88
+		//adminUserInfo.CurrentAppId = 5
89
+		//adminUserInfo.AdminUser = &userAdmin
90
+		//adminUserInfo.Subscibes = subscibes
91
+		//this.SetSession("admin_user_info", &adminUserInfo)
92
+
93
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
94
+		this.StopRun()
95
+	}
96
+
97
+
98
+}
99
+
100
+type BaseServeAPIController struct {
101
+	BaseAPIController
102
+}
103
+
104
+func (this *BaseServeAPIController) Prepare() {
105
+	this.BaseAPIController.Prepare()
106
+	if this.GetAdminUserInfo() == nil {
107
+		//var userAdmin models.AdminUser
108
+		//userAdmin.Id = 380
109
+		//userAdmin.Mobile = "13532250447"
110
+		//userAdmin.IsSuperAdmin = true
111
+		//userAdmin.Status = 1
112
+		//userAdmin.CreateTime = 1530786071
113
+		//userAdmin.ModifyTime = 1530786071
114
+		//var subscibe models.ServeSubscibe
115
+		//subscibe.ID = 1
116
+		//subscibe.OrgId = 4
117
+		//subscibe.PeriodStart = 1538035409
118
+		//subscibe.PeriodEnd = 1569571409
119
+		//subscibe.State = 1
120
+		//subscibe.Status = 1
121
+		//subscibe.CreatedTime = 1538035409
122
+		//subscibe.UpdatedTime = 1538035409
123
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
124
+		//subscibes[4] = &subscibe
125
+		//var adminUserInfo service.AdminUserInfo
126
+		//adminUserInfo.CurrentOrgId = 4
127
+		//adminUserInfo.CurrentAppId = 5
128
+		//adminUserInfo.AdminUser = &userAdmin
129
+		//adminUserInfo.Subscibes = subscibes
130
+		//this.SetSession("admin_user_info", &adminUserInfo)
131
+
132
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
133
+		this.StopRun()
134
+	}
135
+}

+ 42 - 0
controllers/base_controller.go Zobrazit soubor

@@ -0,0 +1,42 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_Admin_Api/service"
5
+
6
+	"github.com/astaxie/beego"
7
+	"fmt"
8
+)
9
+
10
+type BaseController struct {
11
+	beego.Controller
12
+}
13
+
14
+func (this *BaseController) GetAdminUserInfo() *service.AdminUserInfo {
15
+	userInfo := this.GetSession("admin_user_info")
16
+	fmt.Println("12")
17
+	if userInfo == nil {
18
+		return nil
19
+	} else {
20
+		return userInfo.(*service.AdminUserInfo)
21
+	}
22
+}
23
+
24
+func (this *BaseController) ErrorLog(format string, a ...interface{}) {
25
+	//beego.Error(fmt.Sprintf(format, a...))
26
+}
27
+
28
+func (this *BaseController) WarnLog(format string, a ...interface{}) {
29
+	//beego.Warn(fmt.Sprintf(format, a...))
30
+}
31
+
32
+func (this *BaseController) InfoLog(format string, a ...interface{}) {
33
+	//beego.Info(fmt.Sprintf(format, a...))
34
+}
35
+
36
+func (this *BaseController) DebugLog(format string, a ...interface{}) {
37
+	//beego.Debug(fmt.Sprintf(format, a...))
38
+}
39
+
40
+func (this *BaseController) TraceLog(format string, a ...interface{}) {
41
+	//beego.Trace(fmt.Sprintf(format, a...))
42
+}

+ 58 - 0
controllers/base_view_controller.go Zobrazit soubor

@@ -0,0 +1,58 @@
1
+package controllers
2
+
3
+type BaseViewController struct {
4
+	BaseController
5
+}
6
+
7
+// 设置模板
8
+// 第一个参数模板,第二个参数为layout
9
+func (this *BaseViewController) SetTpl(template ...string) {
10
+	var tplName string
11
+	layout := ""
12
+	switch {
13
+	case len(template) == 1:
14
+		tplName = template[0]
15
+	case len(template) == 2:
16
+		tplName = template[0]
17
+		layout = template[1]
18
+	default:
19
+		tplName = "index.tpl"
20
+	}
21
+	this.Layout = layout
22
+	this.TplName = tplName
23
+}
24
+
25
+// 重定向
26
+func (this *BaseViewController) Redirect302(url string) {
27
+	this.Redirect(url, 302)
28
+	this.StopRun()
29
+}
30
+
31
+// 错误页面
32
+func (this *BaseViewController) Abort404() {
33
+	this.Abort("404")
34
+}
35
+
36
+// // 微信错误页面
37
+// func (this *BaseViewController) WxAbort404(title, desc string) {
38
+// 	this.Data["Title"] = title
39
+// 	this.Data["Desc"] = desc
40
+// 	this.SetTpl("view_wx/error/404.html")
41
+// }
42
+
43
+// type BaseAuthViewController struct {
44
+// 	BaseViewController
45
+// }
46
+
47
+// func (this *BaseAuthViewController) Prepare() {
48
+// 	this.BaseController.Prepare()
49
+// 	backUrl := utils.SetThisRequestURI(this.Ctx.Request.RequestURI)
50
+// 	backUrl = base64.URLEncoding.EncodeToString([]byte(backUrl))
51
+// 	if this.GetUserInfo() == nil {
52
+// 		if strings.HasPrefix(this.Ctx.Request.RequestURI, "/web/") {
53
+// 			this.Redirect302(beego.URLFor("WebLoginViewController.Login") + "?backUrl=" + backUrl)
54
+// 		} else {
55
+// 			this.Redirect302(beego.URLFor("WxLoginViewController.Login") + "?backUrl=" + backUrl)
56
+// 		}
57
+// 	}
58
+// }

Diff nebyl zobrazen, protože je příliš veliký
+ 2 - 0
db/xt_drug_dic


+ 21 - 0
db/xt_drugway_dic Zobrazit soubor

@@ -0,0 +1,21 @@
1
+INSERT INTO xt_drugway_dic (code, name, status, created_time, updated_time) VALUES 
2
+("DGCX","导管冲洗",1,1536290447,1536290447),
3
+("PO","口服",1,1536290447,1536290447),
4
+("LNZS","瘤内注射",1,1536290447,1536290447),
5
+("IVPUMP","微泵注射",1,1536290447,1536290447),
6
+("WBZS","微泵注射",1,1536290447,1536290447),
7
+("SXHF","舌下含服",1,1536290447,1536290447),
8
+("JMFG","静脉封管",1,1536290447,1536290447),
9
+("DGNWBZS","导管内微泵注射",1,1536290447,1536290447),
10
+("GLCX","管路冲洗",1,1536290447,1536290447),
11
+("PS","皮试 ",1,1536290447,1536290447),
12
+("JMCX","静脉采血",1,1536290447,1536290447),
13
+("YLGCX","引流管冲洗",1,1536290447,1536290447),
14
+("ID","皮内注射",1,1536290447,1536290447),
15
+("IH","皮下注射",1,1536290447,1536290447),
16
+("IM","肌肉注射",1,1536290447,1536290447),
17
+("IV","静脉注射",1,1536290447,1536290447),
18
+("IVGTT","静脉输液(普通)",1,1536290447,1536290447),
19
+("IVGTT","静脉输液(特殊)",1,1536290447,1536290447),
20
+("JBMZ","局部麻醉",1,1536290447,1536290447),
21
+("DGRS","导管溶栓",1,1536290447,1536290447);

+ 35 - 0
db/xt_ef_dic Zobrazit soubor

@@ -0,0 +1,35 @@
1
+INSERT INTO xt_execution_frequency_dic (code,name,status,created_time,updated_time) VALUES
2
+("AM","上午",1,1536290447,1536290447),
3
+("QW","每周一次",1,1536290447,1536290447),
4
+("SAS","需要时",1,1536290447,1536290447),
5
+("SQ30FZ","术前30分钟",1,1536290447,1536290447),
6
+("ST","立即",1,1536290447,1536290447),
7
+("TID","每日三次",1,1536290447,1536290447),
8
+("QID","每日四次",1,1536290447,1536290447),
9
+("QIW","每周四次",1,1536290447,1536290447),
10
+("TIW","每周三次",1,1536290447,1536290447),
11
+("TXHLJ","透析后立即",1,1536290447,1536290447),
12
+("XJQ","下机前",1,1536290447,1536290447),
13
+("ONCE","临时一次",1,1536290447,1536290447),
14
+("LZYC","两周一次",1,1536290447,1536290447),
15
+("LZSC","两周三次",1,1536290447,1536290447),
16
+("AA","各",1,1536290447,1536290447),
17
+("SZYC","四周一次",1,1536290447,1536290447),
18
+("QOD","隔日一次",1,1536290447,1536290447),
19
+("QN","每晚一次",1,1536290447,1536290447),
20
+("BID","每日二次",1,1536290447,1536290447),
21
+("BIW","每周二次",1,1536290447,1536290447),
22
+("CF","长方",1,1536290447,1536290447),
23
+("CITO!","急速地",1,1536290447,1536290447),
24
+("CXSY","持续使用",1,1536290447,1536290447),
25
+("F","份",1,1536290447,1536290447),
26
+("HS","临睡前",1,1536290447,1536290447),
27
+("LSKY","临时开药",1,1536290447,1536290447),
28
+("MCYC","每晨一次",1,1536290447,1536290447),
29
+("MFZYC","每分钟一次",1,1536290447,1536290447),
30
+("QD","每日一次",1,1536290447,1536290447),
31
+("QEH","每小时",1,1536290447,1536290447),
32
+("QH","每1小时一次",1,1536290447,1536290447),
33
+("QM","每晨一次",1,1536290447,1536290447),
34
+("QN","每晚",1,1536290447,1536290447),
35
+("SJQ","上机前",1,1536290447,1536290447);

binární
db/xtdb.docx Zobrazit soubor


+ 372 - 0
enums/error_code.go Zobrazit soubor

@@ -0,0 +1,372 @@
1
+package enums
2
+
3
+import "XT_Admin_Api/utils"
4
+
5
+const ( // ErrorCode
6
+	// 登录注册错误 6000+
7
+	ErrorCodeLoginTimeout                   = 6001
8
+	ErrorCodeNotLogin                       = 6002
9
+	ErrorCodePermissionDenied               = 6003
10
+	ErrorCodeMobileRegistered               = 6004
11
+	ErrorCodePasswordEmpty                  = 6005
12
+	ErrorCodeVerificationCodeWrong          = 6006
13
+	ErrorCodeRegisterFail                   = 6007
14
+	ErrorCodeInvalidToken                   = 6008
15
+	ErrorCodeAccountOrPasswordWrong         = 6009
16
+	ErrorCodeMissingOrg                     = 6010
17
+	ErrorCodeMissingOrgApp                  = 6011
18
+	ErrorCodeAccountOrVerCodeWrong          = 6012
19
+	ErrorCodeMobileNotExit                  = 6013
20
+	ErrorCodeUserNotExist                   = 6014
21
+	ErrorCodeUserWasForbidden               = 6015
22
+	ErrorCodeNeverCreateTypeApp             = 6016
23
+	ErrorCodeContactSuperAdminCreateTypeApp = 6017
24
+
25
+	// 数据验证错误 7000+
26
+	ErrorCodeMobileFormat     = 7001
27
+	ErrorCodeTelphoneFormat   = 7002
28
+	ErrorCodeParamWrong       = 7003
29
+	ErrorCodeParamFormatWrong = 7004
30
+
31
+	// 数据库操作错误 8000+
32
+	ErrorCodeDBCreate         = 8001
33
+	ErrorCodeDBUpdate         = 8002
34
+	ErrorCodeDBDelete         = 8003
35
+	ErrorCodeDBSelectNoResult = 8004
36
+	ErrorCodeDataException    = 8005
37
+
38
+	// 业务逻辑操作错误 9000+
39
+	ErrorCodeRoleNotExist           = 9001
40
+	ErrorCodeAdminUserNotExist      = 9002
41
+	ErrorCodeMobileDidUsedInApp     = 9003
42
+	ErrorCodeMissingUserName        = 9004
43
+	ErrorCodeOldPasswordWrong       = 9005
44
+	ErrorCodeCannotRemoveRole       = 9006
45
+	ErrorCodeRoleMobileIsSuperAdmin = 9007
46
+
47
+	ErrorCodeGetQiniuUpToken                = 1001
48
+	ErrorCodeCreatePatient                  = 1002
49
+	ErrorCodeDialysisNoExist                = 1003
50
+	ErrorCodeIdCardNoExist                  = 1004
51
+	ErrorCodePatientNoExist                 = 1005
52
+	ErrorCodeUpdatePatient                  = 1006
53
+	ErrorCodeDialysisSolutionExist          = 1007
54
+	ErrorCodeDialysisSolutionCreate         = 1008
55
+	ErrorCodeDialysisSolutionUpdate         = 1009
56
+	ErrorCodeDialysisSolutionNotExist       = 1010
57
+	ErrorCodeParentDialysisSolutionNotExist = 1011
58
+	ErrorCodeAlReadyHadChildSolution        = 1012
59
+	ErrorCodeCanntCreateChildChildSolution  = 1013
60
+	ErrorCodeDialysisSolutionUsed           = 1014
61
+	ErrorCodeCreateDryWeightFail            = 1015
62
+	ErrorCodeCreateDoctorAdviceFail         = 1016
63
+	ErrorCodeDoctorAdviceNotExist           = 1017
64
+	ErrorCodeUpdateDoctorAdviceFail         = 1018
65
+	ErrorCodeLongTimeAdviceNotCanntEdit     = 1019
66
+	ErrorCodeAdviceStoped                   = 1020
67
+	ErrorCodeParentAdviceNotExist           = 1021
68
+	ErrorCodeStopAdviceFail                 = 1022
69
+	ErrorCodeDeleteAdviceFail               = 1023
70
+	ErrorCodeDialysisSolutionDelete         = 1024
71
+	ErrorCodeDeviceNumberNotTheZone         = 1025
72
+	ErrorCodeCreateScheduleFail             = 1026
73
+	ErrorCodeCantSetScheduleAgainOneDay     = 1027
74
+	ErrorCodeCantSetScheduleBeforeNow       = 1028
75
+	ErrorCodeScheduleNotExist               = 1029
76
+	ErrorCodeDeleteScheduleFail             = 1030
77
+	ErrorCodeChangeScheduleFail             = 1031
78
+	ErrorCodePatientPhoneUsed               = 1032
79
+	ErrorCodeAdviceExced                    = 1033
80
+	ErrorCodeAdviceChecked                  = 1034
81
+	ErrorCodePointScheduleExist             = 1035
82
+	ErrorCodeExceAndCheckNotOneUser         = 1036
83
+	ErrorCodeCanotEditOtherAdvice           = 1037
84
+	ErrorCodeEditLapsetoFail                = 1038
85
+	ErrorCodeAdviceCheckBeforeExce          = 1039
86
+	ErrorCodeAdviceExceBeforeStart          = 1040
87
+	ErrorCodeDelScheduleFailByDialysis      = 1041
88
+	ErrorCodeNotSelectLapsetoType           = 1042
89
+	ErrorCodeNotSelectLapsetoTime           = 1043
90
+
91
+	ErrorCodeInspectionDateExit    = 1201
92
+	ErrorCodeInspectionAddFail     = 1202
93
+	ErrorCodeInspectionEditFail    = 1204
94
+	ErrorCodeInspectionDateNotExit = 1203
95
+	ErrorCodeInspectionDeleteFail  = 1205
96
+
97
+	ErrorCodeMonitorCreate                  = 1128
98
+	ErrorCodeMonitorNotExist                = 1129
99
+	ErrorCodeMonitorUpdate                  = 1130
100
+	ErrorDialysisOrderNoStart               = 1132
101
+	ErrorDialysisOrderNoEND                 = 1133
102
+	ErrorDialysisOrderRepeatStart           = 1134
103
+	ErrorCodeDialysisPermissionDeniedModify = 1135
104
+
105
+	ErrorCodeNotSubscibe       = 4003
106
+	ErrorCodeServeNotExist     = 4004
107
+	ErrorCodeInvoiceExist      = 4005
108
+	ErrorCodeApplyInvoiceFail  = 4006
109
+	ErrorCodeHetongHad         = 4007
110
+	ErrorCodeCreateHetongFail  = 4008
111
+	ErrorCodePatientReachLimit = 4009
112
+
113
+	ErrorCodeDeviceZoneNotExist                      = 9021
114
+	ErrorCodeDeviceZoneNameRepeat                    = 9022
115
+	ErrorCodeDeviceGroupNotExist                     = 9023
116
+	ErrorCodeDeviceGroupNameRepeat                   = 9024
117
+	ErrorCodeDeviceNumberNotExist                    = 9025
118
+	ErrorCodeDeviceNumberRepeat                      = 9026
119
+	ErrorCodeDeviceNotExist                          = 9027
120
+	ErrorCodeDeviceZoneCannotDisable                 = 9028
121
+	ErrorCodeDeviceNumberCannotDisableCuzDevice      = 9029
122
+	ErrorCodeDeviceNumberCannotDisableCuzSchedule    = 9030
123
+	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate = 9031
124
+
125
+	ErrorCommitFail = 90000
126
+
127
+	ErrorCodeCreateStockInFail = 20001
128
+
129
+	ErrorCodeScheduleTemplateNotExist = 10001
130
+
131
+	ErrorCodeSystemError  = 6666
132
+	ErrorCodeProductError = 6667
133
+	ErrorCodeFieldExist   = 100001
134
+	ErrorCodeCreateConfig = 100002
135
+	ErrorCodeUpdateConfig = 100003
136
+
137
+	ErrorCodeDoubleCheckWrong     = 200003
138
+	ErrorCodeDoubleCheckUserWrong = 200004
139
+	ErrorCodeGoodNoStockInError   = 200005
140
+	ErrorCodeCancelStockFail      = 200006
141
+	ErrorCodeDeleteGoodTypeFail   = 200007
142
+	ErrorCodeDeleteGoodInfoFail   = 200008
143
+	ErrorCodeDeleteFail           = 200009
144
+
145
+	ErrorCodeKeyFail                 = 200010
146
+	ErrorCodeDeleteStockInRecordFail = 200011
147
+	ErrorCodeNameWrong               = 200012
148
+
149
+	ErrorCodeParamEmptyWrong       = 200013
150
+	ErrorCodeParamAdviceEmptyWrong = 200014
151
+
152
+	ErrorCodeParamTemplateNOEXISTWrong = 200015
153
+
154
+	ErrorCodeDeleteDealerWrong       = 200016
155
+	ErrorCodeDeleteManufacturerWrong = 200017
156
+	ErrorCodeGoodTypeNameExistError  = 200018
157
+	ErrorCodeGoodInfoNameExistError  = 200019
158
+
159
+	ErrorCodePrescriptionPermissionDeniedModify = 200020
160
+
161
+	ErrorCodeAdvicePermissionDeniedModify = 200021
162
+	ErrorCodePrescriptionException    = 200022
163
+
164
+
165
+)
166
+
167
+var ErrCodeMsgs = map[int]string{
168
+	// 登录注册错误
169
+	ErrorCodeLoginTimeout:                   "登录超时",
170
+	ErrorCodeNotLogin:                       "未登录",
171
+	ErrorCodePermissionDenied:               "权限不足",
172
+	ErrorCodeMobileRegistered:               "手机号已被注册",
173
+	ErrorCodePasswordEmpty:                  "密码为空",
174
+	ErrorCodeVerificationCodeWrong:          "验证码错误",
175
+	ErrorCodeRegisterFail:                   "注册失败",
176
+	ErrorCodeInvalidToken:                   "令牌无效",
177
+	ErrorCodeAccountOrPasswordWrong:         "账号或密码错误",
178
+	ErrorCodeMissingOrg:                     "未创建机构",
179
+	ErrorCodeMissingOrgApp:                  "未创建任何应用",
180
+	ErrorCodeAccountOrVerCodeWrong:          "账号或验证码错误",
181
+	ErrorCodeMobileNotExit:                  "手机号不存在",
182
+	ErrorCodeUserNotExist:                   "用户不存在",
183
+	ErrorCodeUserWasForbidden:               "该用户被禁用",
184
+	ErrorCodeNeverCreateTypeApp:             "未创建此种应用",
185
+	ErrorCodeContactSuperAdminCreateTypeApp: "请联系超级管理员开通此种应用",
186
+
187
+	// 数据验证错误
188
+	ErrorCodeMobileFormat:     "手机号格式错误",
189
+	ErrorCodeTelphoneFormat:   "电话格式错误",
190
+	ErrorCodeParamWrong:       "参数错误",
191
+	ErrorCodeParamFormatWrong: "参数格式错误",
192
+
193
+	// 数据库操作错误
194
+	ErrorCodeDBCreate:         "数据库创建出错",
195
+	ErrorCodeDBUpdate:         "数据库更新出错",
196
+	ErrorCodeDBDelete:         "数据库删除出错",
197
+	ErrorCodeDBSelectNoResult: "查询无结果",
198
+	ErrorCodeDataException:    "数据异常",
199
+
200
+	// 业务逻辑操作错误
201
+	ErrorCodeRoleNotExist:           "角色不存在",
202
+	ErrorCodeAdminUserNotExist:      "管理员不存在",
203
+	ErrorCodeMobileDidUsedInApp:     "该手机号已在该应用中被注册为管理员",
204
+	ErrorCodeMissingUserName:        "缺少用户名",
205
+	ErrorCodeOldPasswordWrong:       "原密码不正确",
206
+	ErrorCodeCannotRemoveRole:       "存在该角色的管理员,不能删除该角色",
207
+	ErrorCodeRoleMobileIsSuperAdmin: "该手机号已注册为超级管理员",
208
+
209
+	ErrorCodeGetQiniuUpToken: "获取七牛uptoken失败",
210
+	ErrorCodeCreatePatient:   "创建患者失败",
211
+	ErrorCodeDialysisNoExist: "患者透析号重复!",
212
+	ErrorCodeIdCardNoExist:   "身份证号重复!",
213
+	ErrorCodePatientNoExist:  "患者信息不存在!",
214
+	ErrorCodeUpdatePatient:   "修改患者信息失败",
215
+
216
+	ErrorCodeDialysisSolutionExist:          "该处方已经存在",
217
+	ErrorCodeDialysisSolutionCreate:         "创建处方失败",
218
+	ErrorCodeDialysisSolutionUpdate:         "修改处方失败",
219
+	ErrorCodeDialysisSolutionNotExist:       "该处方不存在",
220
+	ErrorCodeParentDialysisSolutionNotExist: "上级处方不存在",
221
+	ErrorCodeAlReadyHadChildSolution:        "所选处方已经存在子方案",
222
+	ErrorCodeCanntCreateChildChildSolution:  "子方案不能添加子方案",
223
+	ErrorCodeDialysisSolutionUsed:           "处方已被使用,不能删除",
224
+	ErrorCodeCreateDryWeightFail:            "添加干体重失败",
225
+	ErrorCodeCreateDoctorAdviceFail:         "添加医嘱失败",
226
+	ErrorCodeUpdateDoctorAdviceFail:         "修改医嘱信息失败",
227
+	ErrorCodeDoctorAdviceNotExist:           "医嘱不存在",
228
+	ErrorCodeLongTimeAdviceNotCanntEdit:     "长期医嘱不能修改!",
229
+	ErrorCodeAdviceStoped:                   "所选医嘱已停止",
230
+	ErrorCodeParentAdviceNotExist:           "上级医嘱不存在",
231
+	ErrorCodeDeleteAdviceFail:               "删除医嘱失败",
232
+	ErrorCodeStopAdviceFail:                 "停止医嘱失败",
233
+	ErrorCodeDialysisSolutionDelete:         "删除方案失败",
234
+	ErrorCodeDeviceNumberNotTheZone:         "所选机号不在选择分区中",
235
+	ErrorCodeCreateScheduleFail:             "添加排班失败",
236
+	ErrorCodeCantSetScheduleAgainOneDay:     "同一天不可有两次排班",
237
+	ErrorCodeCantSetScheduleBeforeNow:       "不能给今天之前的日期排班",
238
+	ErrorCodeScheduleNotExist:               "排班不存在",
239
+	ErrorCodePointScheduleExist:             "所先位置排班已经存在",
240
+	ErrorCodeDeleteScheduleFail:             "取消排班失败",
241
+	ErrorCodeChangeScheduleFail:             "修改排班失败",
242
+	ErrorCodePatientPhoneUsed:               "手机号已经存在",
243
+	ErrorCodeAdviceExced:                    "医嘱已经执行",
244
+	ErrorCodeAdviceCheckBeforeExce:          "核对医嘱不能在执行医嘱之前",
245
+	ErrorCodeAdviceExceBeforeStart:          "执行医嘱不能在开始之前",
246
+	ErrorCodeAdviceChecked:                  "医嘱已经核对",
247
+	ErrorCodeExceAndCheckNotOneUser:         "核对与执行不能是同一人",
248
+	ErrorCodeCanotEditOtherAdvice:           "不能修改非本人添加的医嘱",
249
+	ErrorCodeEditLapsetoFail:                "转归失败",
250
+	ErrorCodeDelScheduleFailByDialysis:      "已经上机透析,不能取消排班",
251
+	ErrorCodeNotSelectLapsetoType:           "请选择转归状态",
252
+	ErrorCodeNotSelectLapsetoTime:           "请选择转归时间",
253
+
254
+	ErrorCodeInspectionDateExit:    "当天已经存在检验检查记录",
255
+	ErrorCodeInspectionAddFail:     "添加记录失败",
256
+	ErrorCodeInspectionDateNotExit: "当天不存在检验检查记录",
257
+	ErrorCodeInspectionEditFail:    "修改记录失败",
258
+	ErrorCodeInspectionDeleteFail:  "删除记录失败",
259
+
260
+	ErrorCodeDeviceZoneNotExist:                      "设备分区不存在",
261
+	ErrorCodeDeviceZoneNameRepeat:                    "该分区名已存在",
262
+	ErrorCodeDeviceGroupNotExist:                     "设备分组不存在",
263
+	ErrorCodeDeviceGroupNameRepeat:                   "该分组名已存在",
264
+	ErrorCodeDeviceNumberNotExist:                    "机号不存在",
265
+	ErrorCodeDeviceNumberRepeat:                      "该机号已存在",
266
+	ErrorCodeDeviceNotExist:                          "该设备不存在",
267
+	ErrorCodeDeviceZoneCannotDisable:                 "该分区存在床位号,不能删除",
268
+	ErrorCodeDeviceNumberCannotDisableCuzDevice:      "该床位存在设备,不能删除",
269
+	ErrorCodeDeviceNumberCannotDisableCuzSchedule:    "该床位尚有排班安排,不能删除",
270
+	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate: "排班模板在该床位尚有排班安排,不能删除",
271
+
272
+	ErrorCodeNotSubscibe:       "没有订阅服务或服务已过期,请先购买服务!",
273
+	ErrorCodeServeNotExist:     "服务订单不存在!",
274
+	ErrorCodeInvoiceExist:      "已经申请了发票!",
275
+	ErrorCodeApplyInvoiceFail:  "申请发票失败!",
276
+	ErrorCodeHetongHad:         "合同已经存在!",
277
+	ErrorCodeCreateHetongFail:  "合同创建失败",
278
+	ErrorCodePatientReachLimit: "患者数已达到当前服务版本病人数,需要升级到更高的版本",
279
+
280
+	ErrorCodeMonitorCreate:                  "创建监测失败",
281
+	ErrorCodeMonitorNotExist:                "监测记录不存在",
282
+	ErrorCodeMonitorUpdate:                  "修改监测失败",
283
+	ErrorCodeDialysisPermissionDeniedModify: "您没有权限修改其他医护的数据!",
284
+
285
+	ErrorDialysisOrderNoStart:     "尚未上机,无法执行下机操作",
286
+	ErrorDialysisOrderNoEND:       "已处于下机状态",
287
+	ErrorDialysisOrderRepeatStart: "已上机",
288
+	//ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
289
+
290
+	ErrorCodeSystemError:              "系统异常",
291
+	ErrorCodeProductError:             "该服务商品已丢失",
292
+	ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
293
+
294
+	ErrorCodeCreateStockInFail: "入库失败",
295
+	//ErrorCodeSystemError:  "系统异常",
296
+	//ErrorCodeProductError: "该服务商品已丢失",
297
+	ErrorCodeFieldExist:   "配置字段已存在",
298
+	ErrorCodeCreateConfig: "创建配置失败",
299
+	ErrorCodeUpdateConfig: "修改配置失败",
300
+
301
+	ErrorCommitFail:               "提交失败",
302
+	ErrorCodeDoubleCheckWrong:     "核对已完成, 无法再次提交",
303
+	ErrorCodeDoubleCheckUserWrong: "你已完成核对,不能重复核对",
304
+	ErrorCodeGoodNoStockInError:   "该商品尚未入库",
305
+
306
+	ErrorCodeCancelStockFail:    "出库退库失败",
307
+	ErrorCodeDeleteGoodTypeFail: "该类型存在商品信息,无法删除",
308
+	ErrorCodeDeleteGoodInfoFail: "该商品已经入库无法删除",
309
+
310
+	ErrorCodeDeleteFail: "删除失败",
311
+
312
+	ErrorCodeKeyFail:                 "关键字不能为空",
313
+	ErrorCodeDeleteStockInRecordFail: "该记录已经有出库或退货操作,无法删除",
314
+	ErrorCodeNameWrong:               "该模版名字已存在",
315
+	ErrorCodeParamEmptyWrong:         "模版名称不能为空",
316
+	ErrorCodeParamAdviceEmptyWrong:   "医嘱名称不能为空",
317
+
318
+	ErrorCodeDeleteDealerWrong:       "该经销商所属商品已入库无法删除",
319
+	ErrorCodeDeleteManufacturerWrong: "该厂商所属商品已入库无法删除",
320
+	ErrorCodeGoodTypeNameExistError: "该商品类型名字已存在",
321
+	ErrorCodeGoodInfoNameExistError: "该规格名称名字已存在",
322
+
323
+	ErrorCodePrescriptionPermissionDeniedModify: "您没有权限修改透析处方数据",
324
+	ErrorCodeAdvicePermissionDeniedModify: "您没有权限添加医嘱",
325
+	ErrorCodePrescriptionException: "上机失败,请先开处方",
326
+}
327
+
328
+type SGJError struct {
329
+	Code int
330
+}
331
+
332
+func (e *SGJError) Error() string {
333
+	value, ok := ErrCodeMsgs[e.Code]
334
+	if ok {
335
+		return value
336
+	} else {
337
+		return "未知错误"
338
+	}
339
+}
340
+
341
+func MakeSuccessResponseJSON(data map[string]interface{}) map[string]interface{} {
342
+	json := make(map[string]interface{})
343
+	if data != nil {
344
+		json["data"] = data
345
+	} else {
346
+		json["data"] = make(map[string]interface{})
347
+	}
348
+	json["state"] = 1
349
+	json["code"] = 0
350
+	return json
351
+}
352
+
353
+func MakeFailResponseJSON(errMsg string, errCode int) map[string]interface{} {
354
+	json := make(map[string]interface{})
355
+	json["msg"] = errMsg
356
+	json["code"] = errCode
357
+	json["state"] = 0
358
+	return json
359
+}
360
+
361
+func MakeFailResponseJSONWithSGJError(err *SGJError) map[string]interface{} {
362
+	if err == nil {
363
+		utils.WarningLog("MakeFailResponseJSONWithSGJError 参数err 不能为空")
364
+		return nil
365
+	}
366
+	return MakeFailResponseJSON(err.Error(), err.Code)
367
+}
368
+
369
+func MakeFailResponseJSONWithSGJErrorCode(code int) map[string]interface{} {
370
+	err := &SGJError{Code: code}
371
+	return MakeFailResponseJSON(err.Error(), err.Code)
372
+}

+ 16 - 0
main.go Zobrazit soubor

@@ -0,0 +1,16 @@
1
+package main
2
+
3
+import (
4
+	_ "XT_Admin_Api/routers"
5
+	"XT_Admin_Api/service"
6
+
7
+	"github.com/astaxie/beego"
8
+)
9
+
10
+func init() {
11
+	service.ConnectDB()
12
+}
13
+
14
+func main() {
15
+	beego.Run()
16
+}

+ 16 - 0
models/admin_models/admin_models.go Zobrazit soubor

@@ -0,0 +1,16 @@
1
+// 统计后台的 models
2
+
3
+package admin_models
4
+
5
+type AdminAccount struct {
6
+	Id         int    `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
7
+	Account    string `json:"account"`
8
+	Pwd        string `json:"-"`
9
+	Status     int8   `json:"-"`                     // 状态 0.无效 1.有效
10
+	CreateTime int64  `gorm:"column:ctime" json:"-"` // 创建时间
11
+	ModifyTime int64  `gorm:"column:mtime" json:"-"` // 修改时间
12
+}
13
+
14
+func (AdminAccount) TableName() string {
15
+	return "sgj_admin"
16
+}

+ 69 - 0
models/admin_user_models.go Zobrazit soubor

@@ -0,0 +1,69 @@
1
+package models
2
+
3
+type AdminUser struct {
4
+	Id           int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // 管理员用户 ID
5
+	Mobile       string `json:"mobile"`
6
+	Password     string `json:"password"`
7
+	IsSuperAdmin bool   `gorm:"column:is_super_admin" json:"is_super_admin"` // 是否为超级管理员
8
+	Status       int8   `json:"status"`                                      // 状态 0.无效 1.有效
9
+	CreateTime   int64  `gorm:"column:ctime" json:"ctime"`                   // 创建时间
10
+	ModifyTime   int64  `gorm:"column:mtime" json:"mtime"`                   // 修改时间
11
+}
12
+
13
+func (AdminUser) TableName() string {
14
+	return "sgj_user_admin"
15
+}
16
+
17
+type AdminUserLoginLog struct {
18
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT"` // 记录 ID
19
+	AdminUserId int64  `gorm:"column:admin_user_id"`
20
+	OrgId       int64  `gorm:"column:org_id"`
21
+	AppId       int64  `gorm:"column:app_id"`
22
+	IP          string `gorm:"column:ip"`
23
+	OperateType int8   `gorm:"column:operate_type"` // 操作类型(1.登录;2.退出;3.切换机构)
24
+	AppType     int8   `gorm:"column:app_type"`     // 应用类型,与 OrgApp.AppType 一致
25
+	CreateTime  int64  `gorm:"column:ctime"`        // 创建时间
26
+}
27
+
28
+func (AdminUserLoginLog) TableName() string {
29
+	return "sgj_user_admin_login_log"
30
+}
31
+
32
+type AdminUserElectronicSignature struct {
33
+	ID      int64  `gorm:"column:id" json:"id" form:"id"`
34
+	Creator int64  `gorm:"column:creator" json:"creator" form:"creator"`
35
+	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
36
+	AppId   int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
37
+	Url     string `gorm:"column:url" json:"url" form:"url"`
38
+	Hash    string `gorm:"column:hash" json:"hash" form:"hash"`
39
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
40
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
41
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
42
+}
43
+
44
+func (AdminUserElectronicSignature) TableName() string {
45
+	return "sgj_user_admin_electronic_signature"
46
+}
47
+
48
+// 管理员用户特殊权限,详见表注释
49
+type AdminUserSpecialPermission struct {
50
+	ID          int64 `gorm:"column:id" json:"id"`
51
+	OrgID       int64 `gorm:"column:org_id" json:"org_id"`
52
+	AppID       int64 `gorm:"column:app_id" json:"app_id"`
53
+	AdminUserID int64 `gorm:"column:admin_user_id" json:"admin_user_id"`
54
+	Permission  int64 `gorm:"column:permission" json:"permission"`
55
+	Status      int64 `gorm:"column:status" json:"-"`
56
+	CreateTime  int64 `gorm:"column:ctime" json:"-"`
57
+	ModifyTime  int64 `gorm:"column:mtime" json:"-"`
58
+}
59
+
60
+func (AdminUserSpecialPermission) TableName() string {
61
+	return "xt_admin_user_special_permission"
62
+}
63
+
64
+type SpecialPermissionType int64
65
+
66
+const (
67
+	_                              SpecialPermissionType = iota
68
+	SpecialPermissionTypeHeadNurse                       // 护士长
69
+)

+ 62 - 0
models/data_models.go Zobrazit soubor

@@ -0,0 +1,62 @@
1
+package models
2
+
3
+type Dataconfig struct {
4
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
5
+	ParentId       int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
6
+	Module         string `gorm:"column:module" json:"module" form:"module"`
7
+	OrgId          int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
8
+	Name           string `gorm:"column:name" json:"name" form:"name"`
9
+	FieldName      string `gorm:"column:field_name" json:"field_name" form:"field_name"`
10
+	Value          int    `gorm:"column:value" json:"value" form:"value"`
11
+	CreatedTime    string `gorm:"column:create_time" json:"create_time" form:"create_time"`
12
+	UpdatedTime    string `gorm:"column:update_time" json:"update_time" form:"update_time"`
13
+	CreateUserId   int64  `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
14
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
15
+	Remark         string `gorm:"column:remark" json:"remark" form:"remark"`
16
+	DeleteIdSystem int64  `gorm:"column:delete_id_system" json:"delete_id_system" form:"delete_id_system"`
17
+	Title          string `gorm:"column:title" json:"title" form:"title"`
18
+	Content        string `gorm:"column:content" json:"content" form:"content"`
19
+	Order          int64  `gorm:"column:orders" json:"orders" form:"orders"`
20
+}
21
+
22
+func (Dataconfig) TableName() string {
23
+	return "xt_data_config"
24
+}
25
+
26
+type ConfigViewModel struct {
27
+	ID           int64         `gorm:"column:id" json:"id" form:"id"`
28
+	ParentId     int64         `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
29
+	Module       string        `gorm:"column:module" json:"module" form:"module"`
30
+	OrgId        int64         `gorm:"column:org_id" json:"org_id" form:"org_id"`
31
+	Name         string        `gorm:"column:name" json:"name" form:"name"`
32
+	FieldName    string        `gorm:"column:field_name" json:"field_name" form:"field_name"`
33
+	Value        int           `gorm:"column:value" json:"value" form:"value"`
34
+	CreatedTime  string        `gorm:"column:create_time" json:"create_time" form:"create_time"`
35
+	UpdatedTime  string        `gorm:"column:update_time" json:"update_time" form:"update_time"`
36
+	CreateUserId int64         `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
37
+	Status       int64         `gorm:"column:status" json:"status" form:"status"`
38
+	Remark       string        `gorm:"column:remark" json:"remark" form:"remark"`
39
+	Title        string        `gorm:"column:title" json:"title" form:"title"`
40
+	Content      string        `gorm:"column:content" json:"content" form:"content"`
41
+	Order        int64         `gorm:"column:orders" json:"orders" form:"orders"`
42
+	Childs       []*Dataconfig `json:"childs" `
43
+}
44
+
45
+func (ConfigViewModel) TableName() string {
46
+	return "xt_data_config"
47
+}
48
+
49
+type FiledConfig struct {
50
+	ID          int64  `gorm:"column:id" json:"id"`
51
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
52
+	Module      int64  `gorm:"column:module" json:"module"`
53
+	FiledName   string `gorm:"column:filed_name" json:"filed_name"`
54
+	FiledNameCn string `gorm:"column:filed_name_cn" json:"filed_name_cn"`
55
+	IsShow      int64  `gorm:"column:is_show" json:"is_show"`
56
+	CreateTime  int64  `gorm:"column:create_time" json:"create_time"`
57
+	UpdateTime  int64  `gorm:"column:update_time" json:"update_time"`
58
+}
59
+
60
+func (FiledConfig) TableName() string {
61
+	return "xt_filed_config"
62
+}

+ 14 - 0
models/db_err_models.go Zobrazit soubor

@@ -0,0 +1,14 @@
1
+package models
2
+
3
+type DBErrorRecord struct {
4
+	ID         int64  `gorm:"column:id"`
5
+	OrgID      int64  `gorm:"column:org_id"`
6
+	ErrDesc    string `gorm:"column:err_desc"`
7
+	Status     int8   `gorm:"column:status"`
8
+	CreateTime int64  `gorm:"column:ctime"`
9
+	ModifyTime int64  `gorm:"column:mtime"`
10
+}
11
+
12
+func (DBErrorRecord) TableName() string {
13
+	return "xt_db_err_records"
14
+}

+ 486 - 0
models/dialysis.go Zobrazit soubor

@@ -0,0 +1,486 @@
1
+package models
2
+
3
+type SchedualPatient struct {
4
+	ID                      int64                   `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId               int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId                  int64                   `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	PatientType             int64                   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
8
+	Avatar                  string                  `gorm:"column:avatar" json:"avatar" form:"avatar"`
9
+	DialysisNo              string                  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
10
+	AdmissionNumber         string                  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
11
+	Source                  int64                   `gorm:"column:source" json:"source" form:"source"`
12
+	Lapseto                 int64                   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
13
+	PartitionId             int64                   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
14
+	BedId                   int64                   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
15
+	Name                    string                  `gorm:"column:name" json:"name" form:"name"`
16
+	Alias                   string                  `gorm:"column:alias" json:"alias" form:"alias"`
17
+	Gender                  int64                   `gorm:"column:gender" json:"gender" form:"gender"`
18
+	Nation                  string                  `gorm:"column:nation" json:"nation" form:"nation"`
19
+	NativePlace             string                  `gorm:"column:native_place" json:"native_place" form:"native_place"`
20
+	MaritalStatus           int64                   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
21
+	IdCardNo                string                  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
22
+	Birthday                int64                   `gorm:"column:birthday" json:"birthday" form:"birthday"`
23
+	ReimbursementWayId      int64                   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
24
+	HealthCareType          int64                   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
25
+	HealthCareNo            string                  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
26
+	HealthCareDueDate       int64                   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
27
+	Height                  int64                   `gorm:"column:height" json:"height" form:"height"`
28
+	BloodType               int64                   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
29
+	Rh                      int64                   `gorm:"column:rh" json:"rh" form:"rh"`
30
+	HealthCareDueAlertDate  int64                   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
31
+	EducationLevel          int64                   `gorm:"column:education_level" json:"education_level" form:"education_level"`
32
+	Profession              int64                   `gorm:"column:profession" json:"profession" form:"profession"`
33
+	Phone                   string                  `gorm:"column:phone" json:"phone" form:"phone"`
34
+	HomeTelephone           string                  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
35
+	RelativePhone           string                  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
36
+	RelativeRelations       string                  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
37
+	HomeAddress             string                  `gorm:"column:home_address" json:"home_address" form:"home_address"`
38
+	WorkUnit                string                  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
39
+	UnitAddress             string                  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
40
+	Children                int64                   `gorm:"column:children" json:"children" form:"children"`
41
+	ReceivingDate           int64                   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
42
+	IsHospitalFirstDialysis int64                   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
43
+	FirstDialysisDate       int64                   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
44
+	FirstDialysisHospital   string                  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
45
+	InductionPeriod         int64                   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
46
+	InitialDialysis         int64                   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
47
+	TotalDialysis           int64                   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
48
+	AttendingDoctorId       int64                   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
49
+	HeadNurseId             int64                   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
50
+	Evaluate                string                  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
51
+	Diagnose                string                  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
52
+	Remark                  string                  `gorm:"column:remark" json:"remark" form:"remark"`
53
+	RegistrarsId            int64                   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
54
+	Registrars              string                  `gorm:"column:registrars" json:"registrars" form:"registrars"`
55
+	QrCode                  string                  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
56
+	BindingState            int64                   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
57
+	PatientComplains        string                  `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
58
+	PresentHistory          string                  `gorm:"column:present_history" json:"present_history"`     // 现病史
59
+	PastHistory             string                  `gorm:"column:past_history" json:"past_history"`           // 既往史
60
+	Temperature             float64                 `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
61
+	Pulse                   int64                   `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
62
+	Respiratory             int64                   `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
63
+	SBP                     int64                   `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
64
+	DBP                     int64                   `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
65
+	Age                     int64                   `gorm:"column:age" json:"age"`
66
+	Status                  int64                   `gorm:"column:status" json:"status" form:"status"`
67
+	CreatedTime             int64                   `gorm:"column:created_time" json:"created_time" form:"created_time"`
68
+	UpdatedTime             int64                   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
69
+	PredialysisEvaluation   PredialysisEvaluation   `json:"PredialysisEvaluation" gorm:"ForeignKey:PatientId"`
70
+	AssessmentAfterDislysis AssessmentAfterDislysis `gorm:"ForeignKey:PatientId"`
71
+	MonitoringRecord        []MonitoringRecord      `gorm:"ForeignKey:PatientId"`
72
+}
73
+
74
+func (SchedualPatient) TableName() string {
75
+	return "xt_patients"
76
+}
77
+
78
+
79
+
80
+type PredialysisEvaluation struct {
81
+	ID                          int64   `gorm:"column:id" json:"id"`
82
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id"`
83
+	PatientId                   int64   `gorm:"column:patient_id" json:"patient_id"`
84
+	AssessmentDate              int64   `gorm:"column:assessment_date" json:"assessment_date"`
85
+	DialysisOrderId             int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
86
+	Temperature                 float64 `gorm:"column:temperature" json:"temperature"`
87
+	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
88
+	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
89
+	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
90
+	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
91
+	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
92
+	DryWeight                   float64 `gorm:"column:dry_weight" json:"dry_weight"`
93
+	WeightAfterLastTransparency float64 `gorm:"column:weight_after_last_transparency" json:"weight_after_last_transparency"`
94
+	WeighingWay                 string  `gorm:"column:weighing_way" json:"weighing_way"`
95
+	WeighingBefore              float64 `gorm:"column:weighing_before" json:"weighing_before"`
96
+	AdditionalWeight            float64 `gorm:"column:additional_weight" json:"additional_weight"`
97
+	WeightBefore                float64 `gorm:"column:weight_before" json:"weight_before"`
98
+	WeightGain                  float64 `gorm:"column:weight_gain" json:"weight_gain"`
99
+	PreloadedDewatering         float64 `gorm:"column:preloaded_dewatering" json:"preloaded_dewatering"`
100
+	UltrafiltrationAmount       float64 `gorm:"column:ultrafiltration_amount" json:"ultrafiltration_amount"`
101
+	DialysisInterphase          string  `gorm:"column:dialysis_interphase" json:"dialysis_interphase"`
102
+	LastPostDialysis            string  `gorm:"column:last_post_dialysis" json:"last_post_dialysis"`
103
+	SymptomBeforeDialysis       string  `gorm:"column:symptom_before_dialysis" json:"symptom_before_dialysis"`
104
+	InternalFistula             string  `gorm:"column:internal_fistula" json:"internal_fistula"`
105
+	InternalFistulaSkin         string  `gorm:"column:internal_fistula_skin" json:"internal_fistula_skin"`
106
+	Catheter                    string  `gorm:"column:catheter" json:"catheter"`
107
+	CatheterBend                int     `gorm:"column:catheter_bend" json:"catheter_bend"`
108
+	Complication                string  `gorm:"column:complication" json:"complication"`
109
+	Evaluator                   int64   `gorm:"column:evaluator" json:"evaluator"`
110
+	Creater                     int64   `gorm:"column:creater" json:"creater"`
111
+	Remark                      string  `gorm:"column:remark" json:"remark"`
112
+	Status                      int64   `gorm:"column:status" json:"status"`
113
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time"`
114
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time"`
115
+	Modifier                    int64   `gorm:"column:modifier" json:"modifier"`
116
+	BloodAccessPartId           int64   `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
117
+	BloodAccessPartOperaId      int64   `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id"`
118
+	IsHemorrhage                int64   `gorm:"column:is_hemorrhage" json:"is_hemorrhage"`
119
+	Hemorrhage                  string  `gorm:"column:hemorrhage" json:"hemorrhage"`
120
+	HemorrhageOther             string  `gorm:"column:hemorrhage_other" json:"hemorrhage_other"`
121
+	PunctureMethod              string  `gorm:"column:puncture_method" json:"puncture_method"`
122
+	BloodAccessInternalFistula  string  `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula"`
123
+	InternalFistulaOther        string  `gorm:"column:internal_fistula_other" json:"internal_fistula_other"`
124
+
125
+	BloodAccessNoise               int64   `gorm:"column:blood_access_noise" json:"blood_access_noise"`
126
+	PunctureWay                    int64   `gorm:"column:puncture_way" json:"puncture_way"`
127
+	VenousCatheterization          int64   `gorm:"column:venous_catheterization" json:"venous_catheterization"`
128
+	VenousCatheterizationPart      int64   `gorm:"column:venous_catheterization_part" json:"venous_catheterization_part"`
129
+	VenousCatheterizationPartOther string  `gorm:"column:venous_catheterization_part_other" json:"venous_catheterization_part_other"`
130
+	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
131
+	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
132
+	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
133
+	DialysisCount                  int64   `gorm:"column:dialysis_count" json:"dialysis_count"`
134
+	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
135
+	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
136
+	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`
137
+	IsInfect                       int64   `gorm:"column:is_infect" json:"is_infect"`
138
+	Exposed                        float64 `gorm:"column:exposed" json:"exposed"`
139
+	Skin                           int64   `gorm:"column:skin" json:"skin"`
140
+	SkinOther                      string  `gorm:"column:skin_other" json:"skin_other"`
141
+	InfectOther                    string  `gorm:"column:infect_other" json:"infect_other"`
142
+	DuctusArantiiOther             string  `gorm:"column:ductus_arantii_other" json:"ductus_arantii_other"`
143
+}
144
+
145
+func (PredialysisEvaluation) TableName() string {
146
+	return "xt_assessment_before_dislysis"
147
+}
148
+
149
+type DoctorAdvice struct {
150
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
151
+	GroupNo               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
152
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
153
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
154
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
155
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
156
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
157
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
158
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
159
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
160
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
161
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
162
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
163
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
164
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
165
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
166
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
167
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
168
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
169
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
170
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
171
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
172
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
173
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
174
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
175
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
176
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
177
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
178
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
179
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
180
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
181
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
182
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
183
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date"`
184
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
185
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
186
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
187
+	AdviceId              int64   `gorm:"-"`
188
+}
189
+
190
+func (DoctorAdvice) TableName() string {
191
+	return "xt_doctor_advice"
192
+}
193
+
194
+type GroupAdvice struct {
195
+	DoctorAdvice
196
+	Children []*GroupAdvice
197
+}
198
+
199
+func (GroupAdvice) TableName() string {
200
+	return "xt_doctor_advice"
201
+}
202
+
203
+type DoubleCheck struct {
204
+	ID                         int64  `gorm:"column:id" json:"id"`
205
+	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id"`
206
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id"`
207
+	DialysisOrderId            int64  `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
208
+	CheckDate                  int64  `gorm:"column:check_date" json:"check_date"`
209
+	DialysisItemCheck          int64  `gorm:"column:dialysis_item_check" json:"dialysis_item_check"`
210
+	DialysisItemDesc           string `gorm:"column:dialysis_item_desc" json:"dialysis_item_desc"`
211
+	DialysisParameterCheck     int64  `gorm:"column:dialysis_parameter_check" json:"dialysis_parameter_check"`
212
+	DialysisParameterDesc      string `gorm:"column:dialysis_parameter_desc" json:"dialysis_parameter_desc"`
213
+	VascularAccessVerification int64  `gorm:"column:vascular_access_verification" json:"vascular_access_verification"`
214
+	VascularAccessDesc         string `gorm:"column:vascular_access_desc" json:"vascular_access_desc"`
215
+	PipelineConnectionCheck    int64  `gorm:"column:pipeline_connection_check" json:"pipeline_connection_check"`
216
+	PipelineConnectionDesc     string `gorm:"column:pipeline_connection_desc" json:"pipeline_connection_desc"`
217
+	Collator                   int64  `gorm:"column:collator" json:"collator"`
218
+	Status                     int64  `gorm:"column:status" json:"status"`
219
+	CreatedTime                int64  `gorm:"column:created_time" json:"created_time"`
220
+	UpdatedTime                int64  `gorm:"column:updated_time" json:"updated_time"`
221
+	Creater                    int64  `gorm:"column:creater" json:"creater"`
222
+	Modifier                   int64  `gorm:"column:modifier" json:"modifier"`
223
+	CheckTime                  int64  `gorm:"column:check_time" json:"check_time"`
224
+	FirstCheckTime             int64  `gorm:"column:first_check_time" json:"first_check_time"`
225
+}
226
+
227
+func (DoubleCheck) TableName() string {
228
+	return "xt_double_check"
229
+}
230
+
231
+type AssessmentAfterDislysis struct {
232
+	ID                     int64   `gorm:"column:id" json:"id"`
233
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id"`
234
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id"`
235
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date"`
236
+	DialysisOrderId        int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
237
+	Temperature            float64 `gorm:"column:temperature" json:"temperature"`
238
+	PulseFrequency         float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
239
+	BreathingRate          float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
240
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
241
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
242
+	BloodPressureType      int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
243
+	ActualUltrafiltration  float64 `gorm:"column:actual_ultrafiltration" json:"actual_ultrafiltration"`
244
+	ActualDisplacement     float64 `gorm:"column:actual_displacement" json:"actual_displacement"`
245
+	ActualTreatmentHour    int64   `gorm:"column:actual_treatment_hour" json:"actual_treatment_hour"`
246
+	ActualTreatmentMinute  int64   `gorm:"column:actual_treatment_minute" json:"actual_treatment_minute"`
247
+	WeighingWay            string  `gorm:"column:weighing_way" json:"weighing_way"`
248
+	WeightAfter            float64 `gorm:"column:weight_after" json:"weight_after"`
249
+	WeightLoss             float64 `gorm:"column:weight_loss" json:"weight_loss"`
250
+	Cruor                  string  `gorm:"column:cruor" json:"cruor"`
251
+	SymptomAfterDialysis   string  `gorm:"column:symptom_after_dialysis" json:"symptom_after_dialysis"`
252
+	InternalFistula        string  `gorm:"column:internal_fistula" json:"internal_fistula"`
253
+	// InternalFistulaSkin             string  `gorm:"column:internal_fistula_skin" json:"internal_fistula_skin"`
254
+	Catheter string `gorm:"column:catheter" json:"catheter"`
255
+	// CatheterBend                    int     `gorm:"column:catheter_bend" json:"catheter_bend"`
256
+	Complication                    string  `gorm:"column:complication" json:"complication"`
257
+	Evaluator                       int64   `gorm:"column:evaluator" json:"evaluator"`
258
+	Remark                          string  `gorm:"column:remark" json:"remark"`
259
+	DialysisIntakes                 int64   `gorm:"column:dialysis_intakes" json:"dialysis_intakes"`
260
+	DialysisIntakesFeed             int64   `gorm:"column:dialysis_intakes_feed" json:"dialysis_intakes_feed"`
261
+	DialysisIntakesTransfusion      int64   `gorm:"column:dialysis_intakes_transfusion" json:"dialysis_intakes_transfusion"`
262
+	DialysisIntakesBloodTransfusion int64   `gorm:"column:dialysis_intakes_blood_transfusion" json:"dialysis_intakes_blood_transfusion"`
263
+	DialysisIntakesWashpipe         int64   `gorm:"column:dialysis_intakes_washpipe" json:"dialysis_intakes_washpipe"`
264
+	Status                          int64   `gorm:"column:status" json:"status"`
265
+	CreatedTime                     int64   `gorm:"column:created_time" json:"created_time"`
266
+	UpdatedTime                     int64   `gorm:"column:updated_time" json:"updated_time"`
267
+	Creater                         int64   `gorm:"column:creater" json:"creater"`
268
+	Modifier                        int64   `gorm:"column:modifier" json:"modifier"`
269
+	BloodAccessPartId               int64   `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
270
+	BloodAccessPartOperaId          int64   `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id"`
271
+	PuncturePointOozingBlood        int64   `gorm:"column:puncture_point_oozing_blood" json:"puncture_point_oozing_blood"`
272
+	PuncturePointHaematoma          int64   `gorm:"column:puncture_point_haematoma" json:"puncture_point_haematoma"`
273
+	InternalFistulaTremorAc         int64   `gorm:"column:internal_fistula_tremor_ac" json:"internal_fistula_tremor_ac"`
274
+	PatientGose                     int64   `gorm:"column:patient_gose" json:"patient_gose"`
275
+	InpatientDepartment             string  `gorm:"column:inpatient_department" json:"inpatient_department"`
276
+	ObservationContent              string  `gorm:"column:observation_content" json:"observation_content"`
277
+	ObservationContentOther         string  `gorm:"column:observation_content_other" json:"observation_content_other"`
278
+	DryWeight                       float64 `gorm:"column:dry_weight" json:"dry_weight"`
279
+	DialysisProcess                 int64   `gorm:"column:dialysis_process" json:"dialysis_process"`
280
+	InAdvanceMinute                 float64 `gorm:"column:in_advance_minute" json:"in_advance_minute"`
281
+	InAdvanceReason                 string  `gorm:"column:in_advance_reason" json:"in_advance_reason"`
282
+	HemostasisMinute                int64   `gorm:"column:hemostasis_minute" json:"hemostasis_minute"`
283
+	HemostasisOpera                 int64   `gorm:"column:hemostasis_opera" json:"hemostasis_opera"`
284
+	TremorNoise                     int64   `gorm:"column:tremor_noise" json:"tremor_noise"`
285
+	DisequilibriumSyndrome          int64   `gorm:"column:disequilibrium_syndrome" json:"disequilibrium_syndrome"`
286
+	DisequilibriumSyndromeOption    string  `gorm:"column:disequilibrium_syndrome_option" json:"disequilibrium_syndrome_option"`
287
+	ArterialTube                    int64   `gorm:"column:arterial_tube" json:"arterial_tube"`
288
+	IntravenousTube                 int64   `gorm:"column:intravenous_tube" json:"intravenous_tube"`
289
+	Dialyzer                        int64   `gorm:"column:dialyzer" json:"dialyzer"`
290
+	InAdvanceReasonOther            string  `gorm:"column:in_advance_reason_other" json:"in_advance_reason_other"`
291
+	AssessmentTime                  int64   `gorm:"column:assessment_time" json:"assessment_time"`
292
+	AssessmentDoctor                int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
293
+	IsEat                           int64   `gorm:"column:is_eat" json:"is_eat"`
294
+}
295
+
296
+func (AssessmentAfterDislysis) TableName() string {
297
+	return "xt_assessment_after_dislysis"
298
+}
299
+
300
+type TreatmentSummary struct {
301
+	ID                int64  `gorm:"column:id" json:"id"`
302
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id"`
303
+	PatientId         int64  `gorm:"column:patient_id" json:"patient_id"`
304
+	AssessmentDate    int64  `gorm:"column:assessment_date" json:"assessment_date"`
305
+	DialysisOrderId   int64  `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
306
+	Mission           string `gorm:"column:mission" json:"mission"`
307
+	DialysisSummary   string `gorm:"column:dialysis_summary" json:"dialysis_summary"`
308
+	Change            int64  `gorm:"column:change" json:"change"`
309
+	SjNurse           int64  `gorm:"column:sj_nurse" json:"sj_nurse"`
310
+	ZlNurse           int64  `gorm:"column:zl_nurse" json:"zl_nurse"`
311
+	HdNurse           int64  `gorm:"column:hd_nurse" json:"hd_nurse"`
312
+	XjNurse           int64  `gorm:"column:xj_nurse" json:"xj_nurse"`
313
+	ZlDoctor          int64  `gorm:"column:zl_doctor" json:"zl_doctor"`
314
+	ChannelImage      string `gorm:"column:channel_image" json:"channel_image"`
315
+	Puncture          string `gorm:"column:puncture" json:"puncture"`
316
+	PunctureNeedle    string `gorm:"column:puncture_needle" json:"puncture_needle"`
317
+	PunctureDirection string `gorm:"column:puncture_direction" json:"puncture_direction"`
318
+	Status            int64  `gorm:"column:status" json:"status"`
319
+	CreatedTime       int64  `gorm:"column:created_time" json:"created_time"`
320
+	UpdatedTime       int64  `gorm:"column:updated_time" json:"updated_time"`
321
+	Creater           int64  `gorm:"column:creater" json:"creater"`
322
+	Modifier          int64  `gorm:"column:modifier" json:"modifier"`
323
+}
324
+
325
+func (TreatmentSummary) TableName() string {
326
+	return "xt_treatment_summary"
327
+}
328
+
329
+type DryWeightAdjust struct {
330
+	ID            int64   `gorm:"column:id" json:"id" form:"id"`
331
+	UserOrgId     int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
332
+	PatientId     int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
333
+	Weight        float64 `gorm:"column:weight" json:"weight" form:"weight"`
334
+	AdjustedValue float64 `gorm:"column:adjusted_value" json:"adjusted_value" form:"adjusted_value"`
335
+	Doctor        int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
336
+	RegistrarsId  int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
337
+	Remark        string  `gorm:"column:remark" json:"remark" form:"remark"`
338
+	Status        int64   `gorm:"column:status" json:"status" form:"status"`
339
+	CreatedTime   int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
340
+	UpdatedTime   int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
341
+}
342
+
343
+func (DryWeightAdjust) TableName() string {
344
+	return "xt_dry_weight_adjust"
345
+}
346
+
347
+type MonitoringRecord struct {
348
+	ID                        int64   `gorm:"column:id" json:"id"`
349
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id"`
350
+	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id"`
351
+	DialysisOrderId           int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
352
+	MonitoringDate            int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
353
+	OperateTime               int64   `gorm:"column:operate_time" json:"operate_time"`
354
+	MonitoringTime            string  `gorm:"column:monitoring_time" json:"monitoring_time"`
355
+	PulseFrequency            float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
356
+	BreathingRate             float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
357
+	SystolicBloodPressure     float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
358
+	DiastolicBloodPressure    float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
359
+	BloodPressureType         int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
360
+	Pic                       string  `gorm:"column:pic" json:"pic"`
361
+	BloodFlowVolume           float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
362
+	VenousPressure            float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
363
+	VenousPressureUnit        string  `gorm:"column:venous_pressure_unit" json:"venous_pressure_unit"`
364
+	ArterialPressure          float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
365
+	TransmembranePressure     float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
366
+	TransmembranePressureUnit string  `gorm:"column:transmembrane_pressure_unit" json:"transmembrane_pressure_unit"`
367
+	UltrafiltrationRate       float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
368
+	UltrafiltrationVolume     float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
369
+	SodiumConcentration       float64 `gorm:"column:sodium_concentration" json:"sodium_concentration"`
370
+	DialysateTemperature      float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
371
+	Temperature               float64 `gorm:"column:temperature" json:"temperature"`
372
+	ReplacementRate           float64 `gorm:"column:replacement_rate" json:"replacement_rate"`
373
+	DisplacementQuantity      float64 `gorm:"column:displacement_quantity" json:"displacement_quantity"`
374
+	Ktv                       float64 `gorm:"column:ktv" json:"ktv"`
375
+	Symptom                   string  `gorm:"column:symptom" json:"symptom"`
376
+	Dispose                   string  `gorm:"column:dispose" json:"dispose"`
377
+	Result                    string  `gorm:"column:result" json:"result"`
378
+	MonitoringNurse           int64   `gorm:"column:monitoring_nurse" json:"monitoring_nurse"`
379
+	Status                    int64   `gorm:"column:status" json:"status"`
380
+	CreatedTime               int64   `gorm:"column:created_time" json:"created_time"`
381
+	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time"`
382
+	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
383
+	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
384
+}
385
+
386
+func (MonitoringRecord) TableName() string {
387
+	return "xt_monitoring_record"
388
+}
389
+
390
+type DialysisOrder struct {
391
+	ID             int64        `gorm:"column:id" json:"id"`
392
+	DialysisDate   int64        `gorm:"column:dialysis_date" json:"dialysis_date"`
393
+	UserOrgId      int64        `gorm:"column:user_org_id" json:"user_org_id"`
394
+	PatientId      int64        `gorm:"column:patient_id" json:"patient_id"`
395
+	PrescriptionId int64        `gorm:"column:prescription_id" json:"prescription_id"`
396
+	Stage          int64        `gorm:"column:stage" json:"stage"`
397
+	Remark         string       `gorm:"column:remark" json:"remark"`
398
+	BedID          int64        `gorm:"column:bed_id" json:"bed_id"`
399
+	StartNurse     int64        `gorm:"column:start_nurse" json:"start_nurse"`
400
+	FinishNurse    int64        `gorm:"column:finish_nurse" json:"finish_nurse"`
401
+	Status         int64        `gorm:"column:status" json:"status"`
402
+	CreatedTime    int64        `gorm:"column:created_time" json:"created_time"`
403
+	UpdatedTime    int64        `gorm:"column:updated_time" json:"updated_time"`
404
+	StartTime      int64        `gorm:"column:start_time" json:"start_time"`
405
+	EndTime        int64        `gorm:"column:end_time" json:"end_time"`
406
+	PunctureNurse  int64        `gorm:"column:puncture_nurse" json:"puncture_nurse"`
407
+	Creator        int64        `gorm:"column:creator" json:"creator"`
408
+	Modifier       int64        `gorm:"column:modifier" json:"modifier"`
409
+	FinishCreator  int64        `gorm:"column:finish_creator" json:"finish_creator"`
410
+	FinishModifier int64        `gorm:"column:finish_modifier" json:"finish_modifier"`
411
+}
412
+
413
+func (DialysisOrder) TableName() string {
414
+	return "xt_dialysis_order"
415
+}
416
+
417
+type TreatmentMode struct {
418
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
419
+	Name                string `gorm:"column:name" json:"name" form:"name"`
420
+	DialysisDuration    int64  `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
421
+	ReplacementWay      int64  `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
422
+	HemodialysisMachine int64  `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
423
+	BloodFilter         int64  `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
424
+	PerfusionApparatus  int64  `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
425
+	BloodFlowVolume     int64  `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
426
+	DialysateFlow       int64  `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
427
+	Kalium              int64  `gorm:"column:kalium" json:"kalium" form:"kalium"`
428
+	Sodium              int64  `gorm:"column:sodium" json:"sodium" form:"sodium"`
429
+	Calcium             int64  `gorm:"column:calcium" json:"calcium" form:"calcium"`
430
+	Bicarbonate         int64  `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
431
+	Remark              string `gorm:"column:remark" json:"remark" form:"remark"`
432
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
433
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
434
+	UpdatedTime         int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
435
+}
436
+
437
+func (TreatmentMode) TableName() string {
438
+	return "xt_treatment_mode"
439
+}
440
+
441
+type ReceiveTreatmentAsses struct {
442
+	ID                           int64  `gorm:"column:id" json:"id"`
443
+	Way                          int64  `gorm:"column:way" json:"way"`
444
+	Consciousness                int64  `gorm:"column:consciousness" json:"consciousness"`
445
+	Appetite                     int64  `gorm:"column:appetite" json:"appetite"`
446
+	Condition                    int64  `gorm:"column:condition" json:"condition"`
447
+	Creater                      int64  `gorm:"column:creater" json:"creater"`
448
+	Posture                      int64  `gorm:"column:posture" json:"posture"`
449
+	CreatedTime                  int64  `gorm:"column:created_time" json:"created_time"`
450
+	UpdateTime                   int64  `gorm:"column:update_time" json:"update_time"`
451
+	RecordId                     int64  `gorm:"column:record_id" json:"record_id"`
452
+	RecordDate                   int64  `gorm:"column:record_date" json:"record_date"`
453
+	Modifier                     int64  `gorm:"column:modifier" json:"modifier"`
454
+	Status                       int64  `gorm:"column:status" json:"status"`
455
+	UserOrgId                    int64  `gorm:"column:user_org_id" json:"user_org_id"`
456
+	PatientId                    int64  `gorm:"column:patient_id" json:"patient_id"`
457
+	SickCondition                int64  `gorm:"column:sick_condition" json:"sick_condition"`
458
+	DangerLevel                  int64  `gorm:"column:danger_level" json:"danger_level"`
459
+	Intake                       int64  `gorm:"column:intake" json:"intake"`
460
+	Nutrition                    int64  `gorm:"column:nutrition" json:"nutrition"`
461
+	PsychologicalAssessment      int64  `gorm:"column:psychological_assessment" json:"psychological_assessment"`
462
+	PsychologicalAssessmentOther string `gorm:"column:psychological_assessment_other" json:"psychological_assessment_other"`
463
+	Score                        string `gorm:"column:score" json:"score"`
464
+	SickConditionOther           string `gorm:"column:sick_condition_other" json:"sick_condition_other"`
465
+	Precaution                   int64  `gorm:"column:precaution" json:"precaution"`
466
+	PrecautionOther              string `gorm:"column:precaution_other" json:"precaution_other"`
467
+	PsychologicalOther           string `gorm:"column:psychological_other" json:"psychological_other"`
468
+	IsPrecaution                 int64  `gorm:"column:is_precaution" json:"is_precaution"`
469
+}
470
+
471
+func (ReceiveTreatmentAsses) TableName() string {
472
+	return "xt_receive_treatment_asses"
473
+}
474
+
475
+type GobalTemplate struct {
476
+	ID         int64 `gorm:"column:id" json:"id"`
477
+	OrgId      int64 `gorm:"column:org_id" json:"org_id"`
478
+	TemplateId int64 `gorm:"column:template_id" json:"template_id"`
479
+	Status     int64 `gorm:"column:status" json:"status"`
480
+	Ctime      int64 `gorm:"column:ctime" json:"ctime"`
481
+	Mtime      int64 `gorm:"column:mtime" json:"mtime"`
482
+}
483
+
484
+func (GobalTemplate) TableName() string {
485
+	return "xt_gobal_template"
486
+}

+ 107 - 0
models/org_models.go Zobrazit soubor

@@ -0,0 +1,107 @@
1
+package models
2
+
3
+type Org struct {
4
+	Id              int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // 机构 ID
5
+	Creator         int64  `json:"creator"`                              // 创建者,即管理员用户的 id
6
+	OrgName         string `gorm:"column:org_name" json:"org_name"`
7
+	OrgShortName    string `gorm:"column:org_short_name" json:"org_short_name"` // 简称
8
+	OrgLogo         string `gorm:"column:org_logo" json:"org_logo"`
9
+	OrgIntroduction string `gorm:"column:org_introduction" json:"org_introduction"`
10
+	Province        int64  `json:"province"` // 省,代号,下面的市、区也一样
11
+	City            int64  `json:"city"`
12
+	District        int64  `json:"district"`
13
+	Address         string `json:"address"`                   // 详细地址
14
+	Illness         string `json:"illness"`                   // 服务病种 多个并用“,”隔开
15
+	Status          int8   `json:"status"`                    // 状态 0.无效 1.有效 2.禁用
16
+	CreateTime      int64  `gorm:"column:ctime" json:"ctime"` // 创建时间
17
+	ModifyTime      int64  `gorm:"column:mtime" json:"mtime"` // 修改时间
18
+
19
+	OrgType        int64         `gorm:"column:org_type" json:"org_type"`
20
+	Evaluate       float64       `gorm:"column:evaluate" json:"evaluate"`
21
+	Comments       int64         `gorm:"column:comments" json:"comments"`
22
+	OperatingState int64         `gorm:"column:operating_state" json:"operating_state"`
23
+	Claim          int64         `gorm:"column:claim" json:"claim"`
24
+	Telephone      string        `gorm:"column:telephone" json:"telephone"`
25
+	BusinessWeek   string        `gorm:"column:business_week" json:"business_week"`
26
+	BusinessTime   string        `gorm:"column:business_time" json:"business_time"`
27
+	Gallery        string        `gorm:"column:gallery" json:"gallery"`
28
+	ContactName    string        `gorm:"column:contact_name" json:"contact_name"`
29
+	OrgGallery     []*OrgGallery `gorm:"ForeignKey:OrgId" json:"org_gallery"`
30
+}
31
+
32
+func (Org) TableName() string {
33
+	return "sgj_user_org"
34
+}
35
+
36
+type OrgGallery struct {
37
+	ID     int64  `gorm:"column:id" json:"id" form:"id"`
38
+	Url    string `gorm:"column:url" json:"url" form:"url"`
39
+	Type   int64  `gorm:"column:type" json:"type" form:"type"`
40
+	OrgId  int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
41
+	UserId int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
42
+	Status int64  `gorm:"column:status" json:"status" form:"status"`
43
+	Ctime  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
44
+	Mtime  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
45
+}
46
+
47
+func (OrgGallery) TableName() string {
48
+	return "sgj_user_org_gallery"
49
+}
50
+
51
+type OrgApp struct {
52
+	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // ID
53
+	AppType    int   `gorm:"column:app_type" json:"app_type"`      // 应用类型 1.病友经营;2.科普号;3.血透经营;4.慢病管理
54
+	Creator    int   `json:"creator"`                              // 创建者,即管理员用户的 id
55
+	OrgId      int   `gorm:"column:org_id" json:"org_id"`
56
+	OpenStatus int   `gorm:"column:open_status" json:"open_status"`
57
+	Status     int8  `json:"status"`                    // 状态 0.无效 1.有效 2.禁用
58
+	CreateTime int64 `gorm:"column:ctime" json:"ctime"` // 创建时间
59
+	ModifyTime int64 `gorm:"column:mtime" json:"mtime"` // 修改时间
60
+}
61
+
62
+func (OrgApp) TableName() string {
63
+	return "sgj_user_org_app"
64
+}
65
+
66
+type OrgBan struct {
67
+	ID      int64  `gorm:"column:id" json:"id"`
68
+	OrgId   int64  `gorm:"column:org_id" json:"org_id"`
69
+	Reason  string `gorm:"column:reason" json:"reason"`
70
+	Ctime   int64  `gorm:"column:ctime" json:"ctime"`
71
+	BanTime int64  `gorm:"column:ban_time" json:"ban_time"`
72
+	Status  int64  `gorm:"column:status" json:"status"`
73
+	Mtime   int64  `gorm:"column:mtime" json:"mtime"`
74
+}
75
+
76
+func (OrgBan) TableName() string {
77
+	return "sgj_user_admin_org_ban"
78
+}
79
+
80
+type OrgType struct {
81
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
82
+	Name        string `gorm:"column:name" json:"name" form:"name"`
83
+	ShortName   string `gorm:"column:short_name" json:"short_name" form:"short_name"`
84
+	Pid         int64  `gorm:"column:pid" json:"pid" form:"pid"`
85
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
86
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
87
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
88
+	SortNo      int64  `gorm:"column:sort_no" json:"sort_no" form:"sort_no"`
89
+}
90
+
91
+func (OrgType) TableName() string {
92
+	return "sgj_user_org_type"
93
+}
94
+
95
+type Illness struct {
96
+	ID          int64  `gorm:"column:id" json:"id"`
97
+	IllnessName string `gorm:"column:illness_name" json:"illness_name"`
98
+	Status      int64  `gorm:"column:status" json:"status"`
99
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time"`
100
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time"`
101
+}
102
+
103
+func (Illness) TableName() string {
104
+	return "sgj_user_illness"
105
+}
106
+
107
+

+ 320 - 0
models/patient_models.go Zobrazit soubor

@@ -0,0 +1,320 @@
1
+package models
2
+
3
+type Patients struct {
4
+	ID                           int64                `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId                    int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId                       int64                `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	Avatar                       string               `gorm:"column:avatar" json:"avatar" form:"avatar"`
8
+	PatientType                  int64                `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
9
+	DialysisNo                   string               `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
10
+	AdmissionNumber              string               `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
11
+	Source                       int64                `gorm:"column:source" json:"source" form:"source"`
12
+	Lapseto                      int64                `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
13
+	PartitionId                  int64                `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
14
+	BedId                        int64                `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
15
+	Name                         string               `gorm:"column:name" json:"name" form:"name"`
16
+	Alias                        string               `gorm:"column:alias" json:"alias" form:"alias"`
17
+	Gender                       int64                `gorm:"column:gender" json:"gender" form:"gender"`
18
+	Nation                       string               `gorm:"column:nation" json:"nation" form:"nation"`
19
+	NativePlace                  string               `gorm:"column:native_place" json:"native_place" form:"native_place"`
20
+	MaritalStatus                int64                `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
21
+	IdCardNo                     string               `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
22
+	Birthday                     int64                `gorm:"column:birthday" json:"birthday" form:"birthday"`
23
+	ReimbursementWayId           int64                `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
24
+	HealthCareType               int64                `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
25
+	HealthCareNo                 string               `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
26
+	HealthCareDueDate            int64                `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
27
+	Height                       int64                `gorm:"column:height" json:"height" form:"height"`
28
+	BloodType                    int64                `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
29
+	Rh                           int64                `gorm:"column:rh" json:"rh" form:"rh"`
30
+	HealthCareDueAlertDate       int64                `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
31
+	EducationLevel               int64                `gorm:"column:education_level" json:"education_level" form:"education_level"`
32
+	Profession                   int64                `gorm:"column:profession" json:"profession" form:"profession"`
33
+	Phone                        string               `gorm:"column:phone" json:"phone" form:"phone"`
34
+	HomeTelephone                string               `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
35
+	RelativePhone                string               `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
36
+	RelativeRelations            string               `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
37
+	HomeAddress                  string               `gorm:"column:home_address" json:"home_address" form:"home_address"`
38
+	WorkUnit                     string               `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
39
+	UnitAddress                  string               `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
40
+	Children                     int64                `gorm:"column:children" json:"children" form:"children"`
41
+	ReceivingDate                int64                `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
42
+	IsHospitalFirstDialysis      int64                `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
43
+	FirstDialysisDate            int64                `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
44
+	FirstDialysisHospital        string               `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
45
+	PredialysisCondition         string               `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
46
+	PreHospitalDialysisFrequency string               `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
47
+	PreHospitalDialysisTimes     int64                `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
48
+	HospitalFirstDialysisDate    int64                `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
49
+	InductionPeriod              int64                `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
50
+	InitialDialysis              int64                `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
51
+	TotalDialysis                int64                `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
52
+	AttendingDoctorId            int64                `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
53
+	HeadNurseId                  int64                `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
54
+	Evaluate                     string               `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
55
+	Diagnose                     string               `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
56
+	Remark                       string               `gorm:"column:remark" json:"remark" form:"remark"`
57
+	RegistrarsId                 int64                `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
58
+	Registrars                   string               `gorm:"column:registrars" json:"registrars" form:"registrars"`
59
+	QrCode                       string               `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
60
+	BindingState                 int64                `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
61
+	PatientComplains             string               `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
62
+	PresentHistory               string               `gorm:"column:present_history" json:"present_history"`     // 现病史
63
+	PastHistory                  string               `gorm:"column:past_history" json:"past_history"`           // 既往史
64
+	Temperature                  float64              `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
65
+	Pulse                        int64                `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
66
+	Respiratory                  int64                `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
67
+	SBP                          int64                `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
68
+	DBP                          int64                `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
69
+	Status                       int64                `gorm:"column:status" json:"status" form:"status"`
70
+	CreatedTime                  int64                `gorm:"column:created_time" json:"created_time" form:"created_time"`
71
+	UpdatedTime                  int64                `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
72
+	DialysisSolutions            []DialysisSolution   `json:"solutions" gorm:"foreignkey:PatientId"`
73
+	Age                          int64                `gorm:"column:age" json:"age"`
74
+	Contagions                   []InfectiousDiseases `json:"contagions" gorm:"foreignkey:PatientId"`
75
+	Diseases                     []ChronicDiseases    `json:"diseases" gorm:"foreignkey:PatientId"`
76
+}
77
+
78
+func (Patients) TableName() string {
79
+	return "xt_patients"
80
+}
81
+
82
+type ChronicDiseases struct {
83
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
84
+	PatientId   int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
85
+	DiseaseId   int64 `gorm:"column:disease_id" json:"disease_id" form:"disease_id"`
86
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
87
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
88
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
89
+}
90
+
91
+func (ChronicDiseases) TableName() string {
92
+	return "xt_patients_chronic_diseases"
93
+}
94
+
95
+type InfectiousDiseases struct {
96
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
97
+	PatientId   int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
98
+	DiseaseId   int64 `gorm:"column:disease_id" json:"disease_id" form:"disease_id"`
99
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
100
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
101
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
102
+}
103
+
104
+func (InfectiousDiseases) TableName() string {
105
+	return "xt_patients_infectious_diseases"
106
+}
107
+
108
+type DialysisPrescription struct {
109
+	ID                        int64   `gorm:"column:id" json:"id"`
110
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id"`
111
+	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id"`
112
+	Dialyzer                  int64   `gorm:"column:dialyzer" json:"dialyzer"`
113
+	MachineType               string  `gorm:"column:machine_type" json:"machine_type"`
114
+	DewaterAmount             float64 `gorm:"column:dewater_amount" json:"dewater_amount"`
115
+	PrescriptionDewatering    float64 `gorm:"column:prescription_dewatering" json:"prescription_dewatering"`
116
+	Anticoagulant             int64   `gorm:"column:anticoagulant" json:"anticoagulant"`
117
+	AnticoagulantShouji       float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji"`
118
+	AnticoagulantWeichi       float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi"`
119
+	AnticoagulantZongliang    float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang"`
120
+	AnticoagulantGaimingcheng string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng"`
121
+	AnticoagulantGaijiliang   string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang"`
122
+	ModeId                    int64   `gorm:"column:mode_id" json:"mode_id"`
123
+	DialysisDuration          float64 `gorm:"column:dialysis_duration" json:"dialysis_duration"`
124
+	ReplacementTotal          float64 `gorm:"column:replacement_total" json:"replacement_total"`
125
+	ReplacementWay            int64   `gorm:"column:replacement_way" json:"replacement_way"`
126
+	HemodialysisMachine       int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine"`
127
+	BloodFilter               int64   `gorm:"column:blood_filter" json:"blood_filter"`
128
+	PerfusionApparatus        int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus"`
129
+	// DryWeight                 float64 `gorm:"column:dry_weight" json:"dry_weight"`
130
+	VascularAccessMode         int64   `gorm:"column:vascular_access_mode" json:"vascular_access_mode"`
131
+	VascularAccess             int64   `gorm:"column:vascular_access" json:"vascular_access"`
132
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
133
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow"`
134
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui"`
135
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium"`
136
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium"`
137
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium"`
138
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate"`
139
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose"`
140
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
141
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity"`
142
+	PrescriptionDoctor         int64   `gorm:"column:prescription_doctor" json:"prescription_doctor"`
143
+	Remark                     string  `gorm:"column:remark" json:"remark"`
144
+	Status                     int64   `gorm:"column:status" json:"status"`
145
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time"`
146
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time"`
147
+	RecordDate                 int64   `gorm:"column:record_date" json:"record_date"`
148
+	RecordId                   int64   `gorm:"column:record_id" json:"record_id"`
149
+	Creater                    int64   `gorm:"column:creater" json:"creater"`
150
+	Modifier                   int64   `gorm:"column:modifier" json:"modifier"`
151
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour"`
152
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute"`
153
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation"`
154
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration"`
155
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
156
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid"`
157
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine"`
158
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other"`
159
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part"`
160
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value"`
161
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access"`
162
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration"`
163
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other"`
164
+	Niprocart                  int64   `gorm:"column:niprocart" json:"niprocart"`
165
+	Jms                        int64   `gorm:"column:jms" json:"jms"`
166
+	FistulaNeedleSet           int64   `gorm:"column:fistula_needle_set" json:"fistula_needle_set"`
167
+	FistulaNeedleSet16         int64   `gorm:"column:fistula_needle_set_16" json:"fistula_needle_set_16"`
168
+	Hemoperfusion              int64   `gorm:"column:hemoperfusion" json:"hemoperfusion"`
169
+	DialyserSterilised         int64   `gorm:"column:dialyser_sterilised" json:"dialyser_sterilised"`
170
+	Filtryzer                  int64   `gorm:"column:filtryzer" json:"filtryzer"`
171
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv"`
172
+	Dialyzers int64 `gorm:"column:dialyzers" json:"dialyzers"`
173
+	Injector int64 `gorm:"column:injector" json:"injector"`
174
+	Bloodlines int64 `gorm:"column:bloodlines" json:"bloodlines"`
175
+	TubingHemodialysis int64 `gorm:"column:tubing_hemodialysis" json:"tubing_hemodialysis"`
176
+	Package int64 `gorm:"column:package" json:"package"`
177
+	ALiquid int64 `gorm:"column:a_liquid" json:"a_liquid"`
178
+}
179
+
180
+func (DialysisPrescription) TableName() string {
181
+	return "xt_dialysis_prescription"
182
+}
183
+
184
+type DialysisSolution struct {
185
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
186
+	Name                       string  `gorm:"column:name" json:"name" form:"name"`
187
+	SubName                    string  `gorm:"column:sub_name" json:"sub_name" form:"sub_name"`
188
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
189
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
190
+	ParentId                   int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
191
+	Type                       int64   `gorm:"column:type" json:"type" form:"type"`
192
+	Period                     string  `gorm:"column:period" json:"period" form:"period"`
193
+	Times                      string  `gorm:"column:times" json:"times" form:"times"`
194
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
195
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
196
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
197
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
198
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
199
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
200
+	ModeName                   string  `gorm:"column:mode_name" json:"mode_name" form:"mode_name"`
201
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
202
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
203
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
204
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
205
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
206
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
207
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
208
+	Dewater                    float64 `gorm:"column:dewater" json:"dewater" form:"dewater"`
209
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
210
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
211
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
212
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
213
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
214
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
215
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
216
+	Doctor                     int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
217
+	FirstDialysis              int64   `gorm:"column:first_dialysis" json:"first_dialysis" form:"first_dialysis"`
218
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
219
+	InitiateMode               int64   `gorm:"column:initiate_mode" json:"initiate_mode" form:"initiate_mode"`
220
+	AffirmState                int64   `gorm:"column:affirm_state" json:"affirm_state" form:"affirm_state"`
221
+	UseState                   int64   `gorm:"column:use_state" json:"use_state" form:"use_state"`
222
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
223
+	RegistrarsId               int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
224
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
225
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
226
+	SolutionType               int64   `gorm:"column:solution_type" json:"solution_type" form:"solution_type"`
227
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
228
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
229
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid"`
230
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine"`
231
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other"`
232
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part"`
233
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value"`
234
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access"`
235
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration"`
236
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
237
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
238
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
239
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
240
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialysate_formulation"`
241
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total"`
242
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
243
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other"`
244
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv"`
245
+}
246
+
247
+func (DialysisSolution) TableName() string {
248
+	return "xt_dialysis_solution"
249
+}
250
+
251
+type PatientDialysisRecord struct {
252
+	DialysisOrder
253
+
254
+	ScheduleType  int64  `gorm:"-" json:"schedule_type" form:"schedule_type"`
255
+	PartitionId   int64  `gorm:"-" json:"partition_id" form:"partition_id"`
256
+	PartitionName string `gorm:"-" json:"partition_name" form:"partition_name"`
257
+	DeviceNumber  string `gorm:"-" json:"device_number" form:"device_number"`
258
+
259
+	// DialysisPrescription    DialysisPrescription    `json:"prescription" gorm:"foreignkey:RecordId"`
260
+	// PredialysisEvaluation   PredialysisEvaluation   `json:"predialysis_evaluation" gorm:"foreignkey:DialysisOrderId"`
261
+	// AssessmentAfterDislysis AssessmentAfterDislysis `json:"assessment_after_dislysis" gorm:"foreignkey:DialysisOrderId"`
262
+	// TreatmentSummary        TreatmentSummary        `json:"treatment_summary" gorm:"foreignkey:DialysisOrderId"`
263
+
264
+	DialysisPrescription    DialysisPrescription    `json:"prescription" gorm:"foreignkey:RecordDate;AssociationForeignKey:DialysisDate;"`
265
+	PredialysisEvaluation   PredialysisEvaluation   `json:"predialysis_evaluation" gorm:"foreignkey:AssessmentDate;AssociationForeignKey:DialysisDate;"`
266
+	AssessmentAfterDislysis AssessmentAfterDislysis `json:"assessment_after_dislysis" gorm:"foreignkey:AssessmentDate;AssociationForeignKey:DialysisDate;"`
267
+	TreatmentSummary        TreatmentSummary        `json:"treatment_summary" gorm:"foreignkey:AssessmentDate;AssociationForeignKey:DialysisDate;"`
268
+}
269
+
270
+type DialysisPrescriptionAddtional struct {
271
+	DialysisPrescription
272
+
273
+}
274
+
275
+type PatientDiseaseCourse struct {
276
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
277
+	OrgID      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
278
+	PatientID  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
279
+	Recorder   int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
280
+	RecordTime int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
281
+	Content    string `gorm:"column:content" json:"content" form:"content"`
282
+	Status     int64  `gorm:"column:status" json:"-" form:"-"`
283
+	CreateTime int64  `gorm:"column:ctime" json:"-" form:"-"`
284
+	ModifyTime int64  `gorm:"column:mtime" json:"-" form:"-"`
285
+	Title      string `gorm:"column:title" json:"title"`
286
+}
287
+
288
+func (PatientDiseaseCourse) TableName() string {
289
+	return "xt_patient_course_of_disease"
290
+}
291
+
292
+type PatientRescueRecord struct {
293
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
294
+	OrgID      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
295
+	PatientID  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
296
+	Recorder   int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
297
+	RecordTime int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
298
+	Content    string `gorm:"column:content" json:"content" form:"content"`
299
+	Status     int64  `gorm:"column:status" json:"-" form:"-"`
300
+	CreateTime int64  `gorm:"column:ctime" json:"-" form:"-"`
301
+	ModifyTime int64  `gorm:"column:mtime" json:"-" form:"-"`
302
+}
303
+
304
+func (PatientRescueRecord) TableName() string {
305
+	return "xt_patient_rescue_record"
306
+}
307
+
308
+type PatientLapseto struct {
309
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
310
+	PatientId   int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
311
+	LapsetoType int64 `gorm:"column:lapseto_type" json:"lapseto_type" form:"lapseto_type"`
312
+	LapsetoTime int64 `gorm:"column:lapseto_time" json:"lapseto_time" form:"lapseto_time"`
313
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
314
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
315
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
316
+}
317
+
318
+func (PatientLapseto) TableName() string {
319
+	return "xt_patient_lapseto"
320
+}

+ 37 - 0
models/purview_models.go Zobrazit soubor

@@ -0,0 +1,37 @@
1
+package models
2
+
3
+type Purview struct {
4
+	Id                  int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
5
+	Parentid            int64  `json:"pid"`                                                // 父级ID
6
+	Module              int8   `json:"module"`                                             // 所属应用类型 1.病友经营;2.科普号;3.血透经营;4.慢病管理;
7
+	Name                string `json:"name"`                                               // 规则名称(也是菜单名)
8
+	Urlfor              string `json:"urlfor"`                                             // 规则唯一英文标识,(Controller.Method)
9
+	MenuIconClass       string `gorm:"menu_icon_class" json:"menu_icon_class"`             // 菜单图标的 css 样式
10
+	SuperAdminExclusive int8   `gorm:"super_admin_exclusive" json:"super_admin_exclusive"` // 是否为超级管理员专属 0否1是
11
+	Listorder           int    `json:"-"`                                                  // 排序ID
12
+	Status              int8   `json:"status"`                                             // 状态 0.无效 1.有效 2.禁用
13
+	CreateTime          int64  `gorm:"column:ctime" json:"-"`                              // 创建时间
14
+	ModifyTime          int64  `gorm:"column:mtime" json:"-"`                              // 修改时间
15
+
16
+	Link   string     `gorm:"-" json:"link"`   // urlfor 解析后的链接
17
+	Childs []*Purview `gorm:"-" json:"childs"` // 子节点
18
+}
19
+
20
+func (Purview) TableName() string {
21
+	return "sgj_user_purview"
22
+}
23
+
24
+type RolePurview struct {
25
+	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT"`
26
+	RoleId     int64
27
+	OrgId      int64
28
+	AppId      int64
29
+	PurviewIds string
30
+	Status     int8  // 状态 0.无效 1.有效 2.禁用
31
+	CreateTime int64 `gorm:"column:ctime"` // 创建时间
32
+	ModifyTime int64 `gorm:"column:mtime"` // 修改时间
33
+}
34
+
35
+func (RolePurview) TableName() string {
36
+	return "sgj_user_role_purview"
37
+}

+ 61 - 0
models/role_models.go Zobrazit soubor

@@ -0,0 +1,61 @@
1
+package models
2
+
3
+type Role struct {
4
+	Id           int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
5
+	RoleName     string `gorm:"column:role_name" json:"name"`
6
+	RoleIntro    string `gorm:"column:role_introduction" json:"intro"`
7
+	Creator      int64  `json:"-"`
8
+	OrgId        int64  `gorm:"column:org_id" json:"-"`
9
+	AppId        int64  `gorm:"column:app_id" json:"-"`
10
+	IsSuperAdmin bool   `gorm:"column:is_super_admin" json:"-"`
11
+	Status       int8   `json:"status"`                // 状态 0.无效 1.有效 2.禁用
12
+	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
13
+	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
14
+}
15
+
16
+func (Role) TableName() string {
17
+	return "sgj_user_role"
18
+}
19
+
20
+type App_Role struct {
21
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
22
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id"`
23
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
24
+	AppId       int64  `gorm:"column:app_id" json:"app_id"`
25
+	RoleId      int64  `gorm:"column:role_id" json:"role_id"`
26
+	Avatar      string `json:"avatar" json:"avatar"`
27
+	UserName    string `gorm:"column:user_name" json:"user_name"`   // 用户名称
28
+	Intro       string `json:"intro"`                               // 简介
29
+	UserType    int8   `gorm:"column:user_type" json:"user_type"`   // 用户类型(1.管理员;2.医生;3.护士;4.运营)
30
+	UserTitle   int8   `gorm:"column:user_title" json:"user_title"` // 用户职称(1.医士;2.医师;3.住院医师;4.主治医师;5.副主任医师;6.主任医师;7.护士;8.护师;9.主管护师;10.副主任护师;11.主任护师;12.运营专员;13.运营主管)
31
+	Status      int8   `json:"status"`                              // 状态 0.无效 1.有效
32
+	CreateTime  int64  `gorm:"column:ctime" json:"ctime"`           // 创建时间
33
+	ModifyTime  int64  `gorm:"column:mtime" json:"mtime"`           // 修改时间
34
+}
35
+
36
+func (App_Role) TableName() string {
37
+	return "sgj_user_admin_role"
38
+}
39
+
40
+var UserType = map[int]string{
41
+	1: "管理员",
42
+	2: "医生",
43
+	3: "护士",
44
+	4: "运营",
45
+}
46
+
47
+var UserTitle = map[int]string{
48
+	1:  "医士",
49
+	2:  "医师",
50
+	3:  "住院医师",
51
+	4:  "主治医师",
52
+	5:  "副主任医师",
53
+	6:  "主任医师",
54
+	7:  "护士",
55
+	8:  "护师",
56
+	9:  "主管护师",
57
+	10: "副主任护师",
58
+	11: "主任护师",
59
+	12: "运营专员",
60
+	13: "运营主管",
61
+}

+ 130 - 0
models/service_models.go Zobrazit soubor

@@ -0,0 +1,130 @@
1
+package models
2
+
3
+import "time"
4
+
5
+type ServeOrder struct {
6
+	ID                    int64     `gorm:"column:id" json:"id"`
7
+	OrgId                 int64     `gorm:"column:org_id" json:"org_id"`
8
+	Period                int64     `gorm:"column:period" json:"period"`
9
+	PeriodStart           int64     `gorm:"column:period_start" json:"period_start"`
10
+	PeriodEnd             int64     `gorm:"column:period_end" json:"period_end"`
11
+	PeriodStartTime       time.Time `gorm:"column:period_start_time" json:"period_start_time"`
12
+	PeriodEndTime         time.Time `gorm:"column:period_end_time" json:"period_end_time"`
13
+	Status                int64     `gorm:"column:status" json:"status"`
14
+	CreatedTime           int64     `gorm:"column:created_time" json:"created_time"`
15
+	UpdatedTime           int64     `gorm:"column:updated_time" json:"updated_time"`
16
+	OrderNumber           string    `gorm:"column:order_number" json:"order_number"`
17
+	OrderStatus           int64     `gorm:"column:order_status" json:"order_status"`
18
+	PayType               int64     `gorm:"column:pay_type" json:"pay_type"`
19
+	PayTime               int64     `gorm:"column:pay_time" json:"pay_time"`
20
+	PaymentAmount         float64   `gorm:"column:payment_amount" json:"payment_amount"`
21
+	PayableAmount         float64   `gorm:"column:payable_amount" json:"payable_amount"`
22
+	DiscountableAmount    float64   `gorm:"column:discountable_amount" json:"discountable_amount"`
23
+	PaymentTransactionId  string    `gorm:"column:payment_transaction_id" json:"payment_transaction_id"`
24
+	ServeName             string    `gorm:"column:serve_name" json:"serve_name"`
25
+	ServeDesc             string    `gorm:"column:serve_desc" json:"serve_desc"`
26
+	ServeDuration         string    `gorm:"column:serve_duration" json:"serve_duration"`
27
+	OrderExpireTime       int64     `gorm:"column:order_expire_time" json:"order_expire_time"`
28
+	Price                 float64   `gorm:"column:price" json:"price"`
29
+	Quantity              int64     `gorm:"column:quantity" json:"quantity"`
30
+	ServeId              int64     `gorm:"column:serve_id" json:"serve_id"`
31
+	OrderExpireTimeFormat string    `gorm:"-"`
32
+}
33
+
34
+func (ServeOrder) TableName() string {
35
+	return "sgj_serve_order"
36
+}
37
+
38
+type ServeOrderInfomation struct {
39
+	ID          int64   `gorm:"column:id" json:"id"`
40
+	OrgId       int64   `gorm:"column:org_id" json:"org_id"`
41
+	OrderNumber string  `gorm:"column:order_number" json:"order_number"`
42
+	ProductId   int64   `gorm:"column:product_id" json:"product_id"`
43
+	ProductName string  `gorm:"column:product_name" json:"product_name"`
44
+	ProductDesc string  `gorm:"column:product_desc" json:"product_desc"`
45
+	Price       float64 `gorm:"column:price" json:"price"`
46
+	Quantity    int64   `gorm:"column:quantity" json:"quantity"`
47
+	MarketPrice float64 `gorm:"column:market_price" json:"market_price"`
48
+	Status      int64   `gorm:"column:status" json:"status"`
49
+}
50
+
51
+func (ServeOrderInfomation) TableName() string {
52
+	return "sgj_serve_order_infomation"
53
+}
54
+
55
+type ServeProduct struct {
56
+	ID            int64   `gorm:"column:id" json:"id"`
57
+	ServeName     string  `gorm:"column:serve_name" json:"serve_name"`
58
+	ServeDesc     string  `gorm:"column:serve_desc" json:"serve_desc"`
59
+	OriginalPrice float64 `gorm:"column:original_price" json:"original_price"`
60
+	Price         float64 `gorm:"column:price" json:"price"`
61
+	Status        int64   `gorm:"column:status" json:"status"`
62
+	CreatedTime   int64   `gorm:"column:created_time" json:"created_time"`
63
+	UpdatedTime   int64   `gorm:"column:updated_time" json:"updated_time"`
64
+	ServeDuration int64   `gorm:"column:serve_duration" json:"serve_duration"`
65
+	Edition int64   `gorm:"column:edition" json:"edition"`
66
+}
67
+
68
+func (ServeProduct) TableName() string {
69
+	return "sgj_serve_product"
70
+}
71
+
72
+type ServeSubscibe struct {
73
+	ID              int64     `gorm:"column:id" json:"id"`
74
+	OrgId           int64     `gorm:"column:org_id" json:"org_id"`
75
+	PeriodStart     int64     `gorm:"column:period_start" json:"period_start"`
76
+	PeriodEnd       int64     `gorm:"column:period_end" json:"period_end"`
77
+	PeriodStartTime time.Time `gorm:"column:period_start_time" json:"period_start_time"`
78
+	PeriodEndTime   time.Time `gorm:"column:period_end_time" json:"period_end_time"`
79
+	Status          int64     `gorm:"column:status" json:"status"`
80
+	CreatedTime     int64     `gorm:"column:created_time" json:"created_time"`
81
+	UpdatedTime     int64     `gorm:"column:updated_time" json:"updated_time"`
82
+	State           int64     `gorm:"column:state" json:"state" form:"statstateus"`
83
+	Org				Org       `gorm:"ForeignKey:OrgId"`
84
+
85
+	Patients        int64     `gorm:"-" json:"patients"`
86
+}
87
+
88
+func (ServeSubscibe) TableName() string {
89
+	return "sgj_serve_subscibe"
90
+}
91
+
92
+type ServeInvoice struct {
93
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
94
+	InvoiceType             int64   `gorm:"column:invoice_type" json:"invoice_type" form:"invoice_type"`
95
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
96
+	InvoiceTitle            string  `gorm:"column:invoice_title" json:"invoice_title" form:"invoice_title"`
97
+	InvoiceAmountGross      float64 `gorm:"column:invoice_amount_gross" json:"invoice_amount_gross" form:"invoice_amount_gross"`
98
+	Recipient               string  `gorm:"column:recipient" json:"recipient" form:"recipient"`
99
+	ContactPhone            string  `gorm:"column:contact_phone" json:"contact_phone" form:"contact_phone"`
100
+	Address                 string  `gorm:"column:address" json:"address" form:"address"`
101
+	TaxIdentificationNumber string  `gorm:"column:tax_identification_number" json:"tax_identification_number" form:"tax_identification_number"`
102
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
103
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
104
+	CreatedTime             int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
105
+	UpdatedTime             int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
106
+	Orders                  string  `gorm:"column:orders" json:"orders" form:"orders"`
107
+	InvoiceStatus int64 `gorm:"column:invoice_status" json:"invoice_status" form:"invoice_status"`
108
+}
109
+
110
+func (ServeInvoice) TableName() string {
111
+	return "sgj_serve_invoice"
112
+}
113
+
114
+
115
+type ServeOrderContract struct {
116
+	ID int64 `gorm:"column:id" json:"id" form:"id"`
117
+	OrgId int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
118
+	OrderId int64 `gorm:"column:order_id" json:"order_id" form:"order_id"`
119
+	OrderNumber string `gorm:"column:order_number" json:"order_number" form:"order_number"`
120
+	CompanyTitle string `gorm:"column:company_title" json:"company_title" form:"company_title"`
121
+	CompanyAddress string `gorm:"column:company_address" json:"company_address" form:"company_address"`
122
+	ContactPhone string `gorm:"column:contact_phone" json:"contact_phone" form:"contact_phone"`
123
+	Contact string `gorm:"column:contact" json:"contact" form:"contact"`
124
+	Status int64 `gorm:"column:status" json:"status" form:"status"`
125
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
126
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
127
+}
128
+func (ServeOrderContract) TableName() string {
129
+	return "sgj_serve_order_contract"
130
+}

+ 11 - 0
models/subscibe_state_models.go Zobrazit soubor

@@ -0,0 +1,11 @@
1
+package models
2
+
3
+
4
+type ServeSubscibeState struct {
5
+	ServeSubscibe
6
+
7
+	State int64 `gorm:"-" json:"state"`
8
+}
9
+func (ServeSubscibeState) TableName() string {
10
+	return "sgj_serve_subscibe"
11
+}

+ 23 - 0
routers/router.go Zobrazit soubor

@@ -0,0 +1,23 @@
1
+package routers
2
+
3
+import (
4
+	admin_api "XT_Admin_Api/controllers/admin_api_controllers"
5
+	"github.com/astaxie/beego"
6
+	"github.com/astaxie/beego/plugins/cors"
7
+)
8
+
9
+func init() {
10
+	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
11
+		// AllowAllOrigins:  true,
12
+		AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com"},
13
+		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
14
+		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
15
+		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
16
+		AllowCredentials: true,
17
+	}))
18
+
19
+	// beego.Router("/", &controllers.MainController{})
20
+
21
+
22
+	admin_api.AdminAPIControllersRegisterRouters()
23
+}

+ 353 - 0
service/admin_service.go Zobrazit soubor

@@ -0,0 +1,353 @@
1
+// 统计后台的 service
2
+
3
+package service
4
+
5
+import (
6
+	"XT_Admin_Api/models"
7
+	"XT_Admin_Api/models/admin_models"
8
+	"time"
9
+
10
+	"github.com/jinzhu/gorm"
11
+)
12
+
13
+func GetAdminAccount(account string, password string) (*admin_models.AdminAccount, error) {
14
+	var model admin_models.AdminAccount
15
+	err := readUserDb.Where("account = ? AND pwd = ? AND status = 1", account, password).First(&model).Error
16
+	if err != nil {
17
+		if err == gorm.ErrRecordNotFound {
18
+			return nil, nil
19
+		}
20
+		return nil, err
21
+	}
22
+	return &model, nil
23
+}
24
+
25
+// 获取总机构数
26
+func GetTotalOrgCount() (int, error) {
27
+	var count int
28
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0").Count(&count).Error
29
+	if err != nil {
30
+		return 0, err
31
+	}
32
+	return count, nil
33
+}
34
+
35
+// 获取一段时间内注册的机构数量
36
+func GetRegistedOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
37
+	var count int
38
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND ctime >= ? AND ctime <= ?", from.Unix(), to.Unix()).Count(&count).Error
39
+	if err != nil {
40
+		return 0, err
41
+	}
42
+	return count, nil
43
+}
44
+
45
+// 获取一段时间内注册的机构
46
+func GetRegistedOrgsFromDayToDay(from time.Time, to time.Time) ([]*models.Org, error) {
47
+	var orgs []*models.Org
48
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND ctime >= ? AND ctime <= ?", from.Unix(), to.Unix()).Find(&orgs).Error
49
+	if err != nil {
50
+		return nil, err
51
+	}
52
+	return orgs, nil
53
+}
54
+
55
+// 获取一段时间内的活跃机构数
56
+func GetActiveOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
57
+	var count int
58
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_user_admin_login_log WHERE ctime >= ? AND ctime <= ?", from.Unix(), to.Unix()).Rows()
59
+	if err != nil {
60
+		return 0, err
61
+	}
62
+	if rows.Next() {
63
+		rows.Scan(&count)
64
+	}
65
+	return count, nil
66
+}
67
+
68
+type ActiveOrgListVM struct {
69
+	models.Org
70
+	ActiveTime int64 `gorm:"column:active_time" json:"active_time"`
71
+}
72
+
73
+// 获取一段时间内的活跃机构
74
+func GetActiveOrgsFromDayToDay(from time.Time, to time.Time) ([]*ActiveOrgListVM, error) {
75
+	var orgs []*ActiveOrgListVM
76
+	err := readUserDb.Raw("select * from (select log.org_id, org.*, log.ctime as active_time from sgj_user_admin_login_log as log left join sgj_user_org as org on log.org_id = org.id where log.ctime >= ? AND log.ctime <= ? AND org.status <> 0 order by log.ctime desc) as t group by t.org_id;", from.Unix(), to.Unix()).Scan(&orgs).Error
77
+	if err != nil {
78
+		return nil, err
79
+	}
80
+	return orgs, nil
81
+}
82
+
83
+// 获取一段时间内的活跃账户数
84
+func GetActiveAdminUserCountFromDayToDay(from time.Time, to time.Time) (int, error) {
85
+	var count int
86
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT admin_user_id) AS count FROM sgj_user_admin_login_log WHERE ctime >= ? AND ctime <= ? AND operate_type = 1", from.Unix(), to.Unix()).Rows()
87
+	if err != nil {
88
+		return 0, err
89
+	}
90
+	if rows.Next() {
91
+		rows.Scan(&count)
92
+	}
93
+	return count, nil
94
+}
95
+
96
+type ActiveAdminUserListVM struct {
97
+	models.App_Role
98
+	OrgName    string `gorm:"column:org_name" json:"org_name"`
99
+	ActiveTime int64  `gorm:"column:active_time" json:"active_time"`
100
+}
101
+
102
+// 获取一段时间内的活跃账户
103
+func GetActiveAdminUsersFromDayToDay(from time.Time, to time.Time) ([]*ActiveAdminUserListVM, error) {
104
+	var users []*ActiveAdminUserListVM
105
+	err := readUserDb.Raw("select * from (select log.admin_user_id as uid, admin.*, org.org_name, log.ctime as active_time from sgj_user_admin_login_log as log left join sgj_user_admin_role as admin on log.admin_user_id = admin.admin_user_id left join sgj_user_org as org on log.org_id = org.id where log.ctime >= ? AND log.ctime <= ? AND log.operate_type = 1 AND admin.status > 0 order by log.ctime desc) as t group by t.uid;", from.Unix(), to.Unix()).Scan(&users).Error
106
+	if err != nil {
107
+		return nil, err
108
+	}
109
+	return users, nil
110
+}
111
+
112
+// 获取即将到期机构数
113
+func GetWillExpireOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
114
+	var count int
115
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_serve_subscibe WHERE period_end >= ? AND period_end <= ? AND state <> 9 GROUP BY org_id;", from.Unix(), to.Unix()).Rows()
116
+	if err != nil {
117
+		return 0, err
118
+	}
119
+	if rows.Next() {
120
+		rows.Scan(&count)
121
+	}
122
+	return count, nil
123
+}
124
+
125
+// 获取已到期机构数
126
+func GetDidExpiredOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
127
+	var count int
128
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_serve_subscibe WHERE period_end >= ? AND period_end <= ? AND state <> 9 GROUP BY org_id;", from.Unix(), to.Unix()).Rows()
129
+	if err != nil {
130
+		return 0, err
131
+	}
132
+	if rows.Next() {
133
+		rows.Scan(&count)
134
+	}
135
+	return count, nil
136
+}
137
+
138
+type ExpireOrgListVM struct {
139
+	OrgID      int64  `gorm:"column:org_id" json:"org_id"`
140
+	OrgName    string `gorm:"column:org_name" json:"org_name"`
141
+	PeriodEnd  int64  `gorm:"column:period_end" json:"period_end"`
142
+	Telephone  string `gorm:"column:telephone" json:"telephone"`
143
+	ExpireDays int    `gorm:"-" json:"expire_days"`
144
+}
145
+
146
+// 获取即将到期机构
147
+func GetWillExpireOrgsFromDayToDay(from time.Time, to time.Time) ([]*ExpireOrgListVM, error) {
148
+	var vms []*ExpireOrgListVM
149
+	err := readUserDb.Raw("select s_o.org_id, s_o.period_end, o.org_name, o.telephone from (select ss.* from (select s.org_id as org_id, s.id as sid, s.period_end from sgj_serve_subscibe as s where s.period_end <= ? AND s.period_end >= ? AND s.state <> 9 order by s.id desc) as ss group by ss.org_id) as s_o left join sgj_user_org as o on o.id = s_o.org_id", to.Unix(), from.Unix()).Scan(&vms).Error
150
+	if err != nil {
151
+		return nil, err
152
+	}
153
+	for _, vm := range vms {
154
+		vm.ExpireDays = time.Unix(vm.PeriodEnd, 0).Day() - from.Day()
155
+	}
156
+	return vms, nil
157
+}
158
+
159
+// 获取已到期机构
160
+func GetDidExpireOrgsFromDayToDay(from time.Time, to time.Time) ([]*ExpireOrgListVM, error) {
161
+	var vms []*ExpireOrgListVM
162
+	err := readUserDb.Raw("select s_o.org_id, s_o.period_end, o.org_name, o.telephone from (select ss.* from (select s.org_id as org_id, s.id as sid, s.period_end from sgj_serve_subscibe as s where s.period_end >= ? AND s.period_end <= ? AND s.state <> 9 order by s.id desc) as ss group by ss.org_id) as s_o left join sgj_user_org as o on o.id = s_o.org_id", from.Unix(), to.Unix()).Scan(&vms).Error
163
+	if err != nil {
164
+		return nil, err
165
+	}
166
+	for _, vm := range vms {
167
+		vm.ExpireDays = to.Day() - time.Unix(vm.PeriodEnd, 0).Day()
168
+	}
169
+	return vms, nil
170
+}
171
+
172
+// 获取一段时间内的透析次数
173
+func GetDialysisTimesFromDayToDay(from time.Time, to time.Time) (int, error) {
174
+	var count int
175
+	err := readDb.Model(&models.DialysisOrder{}).Where("status > 0 AND dialysis_date >= ? AND dialysis_date <= ?", from.Unix(), to.Unix()).Count(&count).Error
176
+	if err != nil {
177
+		return 0, err
178
+	}
179
+	return count, nil
180
+}
181
+
182
+// 获取一段时间内的监控次数
183
+func GetMonitoringTimesFromDayToDay(from time.Time, to time.Time) (int, error) {
184
+	var count int
185
+	err := readDb.Model(&models.MonitoringRecord{}).Where("status > 0 AND monitoring_date >= ? AND monitoring_date <= ?", from.Unix(), to.Unix()).Count(&count).Error
186
+	if err != nil {
187
+		return 0, err
188
+	}
189
+	return count, nil
190
+}
191
+
192
+// 获取一段时间内新增病人数量
193
+func GetNewPatientCountFromDayToDay(from time.Time, to time.Time) (int, error) {
194
+	var count int
195
+	err := readDb.Model(&models.Patients{}).Where("status > 0 AND created_time >= ? AND created_time <= ?", from.Unix(), to.Unix()).Count(&count).Error
196
+	if err != nil {
197
+		return 0, err
198
+	}
199
+	return count, nil
200
+}
201
+
202
+// 获取病人性别分布
203
+func GetPatientGenderDistribution() (int, int, int, error) {
204
+	var maleCount, femaleCount, unknowGenderCount int
205
+	rows, err := readDb.Raw("SELECT count(id), gender FROM xt_patients WHERE (status > 0) group by gender;").Rows()
206
+	if err != nil {
207
+		return 0, 0, 0, err
208
+	}
209
+	for rows.Next() {
210
+		var gender, count int
211
+		rows.Scan(&count, &gender)
212
+		if gender == 1 {
213
+			maleCount = count
214
+		} else if gender == 2 {
215
+			femaleCount = count
216
+		} else {
217
+			unknowGenderCount = count
218
+		}
219
+	}
220
+	return maleCount, femaleCount, unknowGenderCount, nil
221
+}
222
+
223
+// 获取某种传染病的病人数,diseaseType = 0时为没有传染病
224
+// 1乙肝 2丙肝 3艾滋病 4肺结核 5梅毒
225
+func GetInfectiousDiseasePatientCount(diseaseType int) (int, error) {
226
+	if diseaseType == 0 {
227
+		var count int
228
+		rows, err := readDb.Raw("select count(p.id) from xt_patients as p where id not in (select p_d.patient_id from xt_patients_infectious_diseases as p_d where status = 1 group by p_d.patient_id) and status = 1;").Rows()
229
+		if err != nil {
230
+			return 0, err
231
+		}
232
+		if rows.Next() {
233
+			rows.Scan(&count)
234
+		}
235
+		return count, nil
236
+
237
+	} else {
238
+		var count int
239
+		rows, err := readDb.Raw("select count(distinct patient_id) from xt_patients_infectious_diseases where status = 1 and disease_id = ?;", diseaseType).Rows()
240
+		if err != nil {
241
+			return 0, err
242
+		}
243
+		if rows.Next() {
244
+			rows.Scan(&count)
245
+		}
246
+		return count, nil
247
+	}
248
+}
249
+
250
+// 获取患者年龄分布
251
+func GetPatientAgeDistribution() ([]*PatientAgeCountStruct, error) {
252
+	var counts []*PatientAgeCountStruct
253
+	err := readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM (
254
+		SELECT
255
+			CASE
256
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d'))<10 THEN '10'
257
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=10 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<20 THEN '20'
258
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=20 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<30 THEN '30'
259
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=30 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<40 THEN '40'
260
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=40 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<50 THEN '50'
261
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=50 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<60 THEN '60'
262
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=60 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<70 THEN '70'
263
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=70 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<80 THEN '80'
264
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=80 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<90 THEN '90'
265
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=90 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<100 THEN '100'
266
+				ELSE '-1'
267
+			END
268
+		AS nnd FROM xt_patients where status=1
269
+	) a GROUP BY nnd;`).Scan(&counts).Error
270
+	if err != nil {
271
+		return nil, err
272
+	}
273
+	return counts, nil
274
+}
275
+
276
+func GetAdminUserElectronicSignature(orgID int64, appID int64, userID int64) (*models.AdminUserElectronicSignature, error) {
277
+	var es models.AdminUserElectronicSignature
278
+	err := readUserDb.Model(&models.AdminUserElectronicSignature{}).Where("org_id=? and app_id=? and creator=? and status=1", orgID, appID, userID).First(&es).Error
279
+
280
+	if err == gorm.ErrRecordNotFound {
281
+		return nil, nil
282
+	}
283
+	if err != nil {
284
+		return nil, err
285
+	}
286
+	return &es, nil
287
+}
288
+
289
+func CreateAdminUserElectronicSignature(es *models.AdminUserElectronicSignature) error {
290
+	err := writeUserDb.Create(es).Error
291
+	return err
292
+}
293
+
294
+func SaveAdminUserElectronicSignature(es *models.AdminUserElectronicSignature) error {
295
+	err := writeUserDb.Save(es).Error
296
+	return err
297
+}
298
+
299
+func GetAdminUserSpecialPermission(orgID int64, appID int64, adminUserID int64, permissionType models.SpecialPermissionType) (*models.AdminUserSpecialPermission, error) {
300
+	var record models.AdminUserSpecialPermission
301
+	err := readDb.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND admin_user_id = ? AND permission = ? AND status = 1", orgID, appID, adminUserID, permissionType).First(&record).Error
302
+	if err != nil {
303
+		if err == gorm.ErrRecordNotFound {
304
+			return nil, nil
305
+		} else {
306
+			return nil, err
307
+		}
308
+	}
309
+	return &record, nil
310
+}
311
+
312
+func SaveAdminUserSpecialPermission(permission *models.AdminUserSpecialPermission) error {
313
+	err := writeDb.Save(permission).Error
314
+	return err
315
+}
316
+
317
+func GetAllValidAdminUsersWithSpecialPermission(orgID int64, appID int64, permissionType models.SpecialPermissionType) ([]*models.AdminUserSpecialPermission, error) {
318
+	var records []*models.AdminUserSpecialPermission
319
+	err := readDb.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND permission = ? AND status = 1", orgID, appID, permissionType).Find(&records).Error
320
+	if err != nil {
321
+		return nil, err
322
+	}
323
+	return records, nil
324
+}
325
+
326
+func GetAllSpecialPermissionAdminUsersWithoutStatus(orgID int64, appID int64, permissionType models.SpecialPermissionType) ([]*models.AdminUserSpecialPermission, error) {
327
+	var records []*models.AdminUserSpecialPermission
328
+	err := readDb.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND permission = ?", orgID, appID, permissionType).Find(&records).Error
329
+	if err != nil {
330
+		return nil, err
331
+	}
332
+	return records, nil
333
+}
334
+
335
+func CancelAllSpecialPermissionAdminUsers(orgID int64, appID int64, permissionType models.SpecialPermissionType) error {
336
+	tx := writeDb.Begin()
337
+	updateTime := time.Now().Unix()
338
+	err := tx.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND status = 1 AND permission = ?", orgID, appID, permissionType).Updates(map[string]interface{}{"status": 0, "mtime": updateTime}).Error
339
+	if err != nil {
340
+		tx.Rollback()
341
+		return err
342
+	}
343
+	tx.Commit()
344
+	return nil
345
+}
346
+
347
+func BatchSaveSpecialPermissionAdminUsers(users []*models.AdminUserSpecialPermission) error {
348
+	tx := writeDb.Begin()
349
+	for _, user := range users {
350
+		tx.Save(user)
351
+	}
352
+	return tx.Commit().Error
353
+}

+ 116 - 0
service/db.go Zobrazit soubor

@@ -0,0 +1,116 @@
1
+// Pipe - A small and beautiful blogging platform written in golang.
2
+// Copyright (C) 2017-2018, b3log.org
3
+//
4
+// This program is free software: you can redistribute it and/or modify
5
+// it under the terms of the GNU General Public License as published by
6
+// the Free Software Foundation, either version 3 of the License, or
7
+// (at your option) any later version.
8
+//
9
+// This program is distributed in the hope that it will be useful,
10
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+// GNU General Public License for more details.
13
+//
14
+// You should have received a copy of the GNU General Public License
15
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
+
17
+package service
18
+
19
+import (
20
+	"fmt"
21
+
22
+	"github.com/astaxie/beego"
23
+	"github.com/jinzhu/gorm"
24
+	_ "github.com/jinzhu/gorm/dialects/mysql" // mysql
25
+)
26
+
27
+var readDb *gorm.DB
28
+var writeDb *gorm.DB
29
+var readUserDb *gorm.DB
30
+var writeUserDb *gorm.DB
31
+
32
+var err error
33
+
34
+func ConnectDB() {
35
+	readHost := beego.AppConfig.String("readmysqlhost")
36
+	readPort := beego.AppConfig.String("readmysqlport")
37
+	readUser := beego.AppConfig.String("readmysqluser")
38
+	readPass := beego.AppConfig.String("readmysqlpass")
39
+	readName := beego.AppConfig.String("readmysqlname")
40
+
41
+	writeHost := beego.AppConfig.String("writemysqlhost")
42
+	writePort := beego.AppConfig.String("writemysqlport")
43
+	writeUser := beego.AppConfig.String("writemysqluser")
44
+	writePass := beego.AppConfig.String("writemysqlpass")
45
+	writeName := beego.AppConfig.String("writemysqlname")
46
+
47
+	readUserHost := beego.AppConfig.String("readuserhost")
48
+	readUserPort := beego.AppConfig.String("readuserport")
49
+	readUserUser := beego.AppConfig.String("readuseruser")
50
+	readUserPass := beego.AppConfig.String("readuserpass")
51
+	readUserName := beego.AppConfig.String("readusername")
52
+
53
+	writeUserHost := beego.AppConfig.String("writeuserhost")
54
+	writeUserPort := beego.AppConfig.String("writeuserport")
55
+	writeUserUser := beego.AppConfig.String("writeuseruser")
56
+	writeUserPass := beego.AppConfig.String("writeuserpass")
57
+	writeUserName := beego.AppConfig.String("writeusername")
58
+
59
+	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
60
+	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
61
+
62
+	rudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUser, readUserPass, readUserHost, readUserPort, readUserName)
63
+	wudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUser, writeUserPass, writeUserHost, writeUserPort, writeUserName)
64
+
65
+	readDb, err = gorm.Open("mysql", rdsn)
66
+	if err != nil {
67
+		//beego.Error(err)
68
+	}
69
+	readDb.DB().SetMaxIdleConns(10)
70
+	readDb.DB().SetMaxOpenConns(100)
71
+	readDb.LogMode(true)
72
+
73
+	writeDb, err = gorm.Open("mysql", wdsn)
74
+	if err != nil {
75
+		//beego.Error(err)
76
+	}
77
+	writeDb.DB().SetMaxIdleConns(10)
78
+	writeDb.DB().SetMaxOpenConns(100)
79
+	writeDb.LogMode(true)
80
+
81
+	readUserDb, err = gorm.Open("mysql", rudsn)
82
+	if err != nil {
83
+		//beego.Error(err)
84
+	}
85
+	readUserDb.DB().SetMaxIdleConns(10)
86
+	readUserDb.DB().SetMaxOpenConns(100)
87
+	readUserDb.LogMode(true)
88
+
89
+	writeUserDb, err = gorm.Open("mysql", wudsn)
90
+	if err != nil {
91
+		//beego.Error(err)
92
+	}
93
+	writeUserDb.DB().SetMaxIdleConns(10)
94
+	writeUserDb.DB().SetMaxOpenConns(100)
95
+	writeUserDb.LogMode(true)
96
+
97
+}
98
+
99
+//func DisconnectDB() {
100
+//	if err := readDb.Close(); nil != err {
101
+//		beego.Error("Disconnect from database failed: " + err.Error())
102
+//	}
103
+//}
104
+
105
+func XTReadDB() *gorm.DB {
106
+	return readDb
107
+}
108
+func XTWriteDB() *gorm.DB {
109
+	return writeDb
110
+}
111
+func UserReadDB() *gorm.DB {
112
+	return readUserDb
113
+}
114
+func UserWriteDB() *gorm.DB {
115
+	return writeUserDb
116
+}

+ 75 - 0
service/statistics_service.go Zobrazit soubor

@@ -0,0 +1,75 @@
1
+package service
2
+
3
+import (
4
+	"XT_Admin_Api/models"
5
+)
6
+
7
+func GetDayDialysisCount(orgID, date int64) (total int64) {
8
+	readDb.Model(&models.DialysisOrder{}).Where("user_org_id=? and dialysis_date=? and status=1", orgID, date).Count(&total)
9
+	return
10
+}
11
+
12
+func GetTimebetweenDialysisCount(orgID, start, end int64) (total int64) {
13
+	readDb.Model(&models.DialysisOrder{}).Where("user_org_id=? and dialysis_date>=? and dialysis_date<=? and status=1", orgID, start, end).Count(&total)
14
+	return
15
+}
16
+
17
+type PatientContagionsCountStruct struct {
18
+	DiseaseId int64 `json:"disease_id"`
19
+	Count int64 `json:"count"`
20
+}
21
+
22
+func GetPatientContagionCounts(orgID int64) (counts []*PatientContagionsCountStruct) {
23
+	readDb.Table("xt_patients_infectious_diseases AS pid").Joins("JOIN xt_patients AS p ON p.id=pid.patient_id").Where("p.user_org_id=? and p.status=1 and pid.status=1", orgID).Select("pid.disease_id, count(pid.disease_id) as count").Group("pid.disease_id").Scan(&counts)
24
+	return
25
+}
26
+
27
+type PatientGenderCountStruct struct {
28
+	Gender int64 `json:"gender"`
29
+	Count int64 `json:"count"`
30
+}
31
+
32
+func GetPatientGenderCounts(orgID int64) (counts []*PatientGenderCountStruct) {
33
+	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1", orgID).Select("gender, count(gender) as count").Group("gender").Scan(&counts)
34
+	return
35
+}
36
+
37
+type PatientAgeCountStruct struct {
38
+	Age int64 `json:"age"`
39
+	Count int64 `json:"count"`
40
+}
41
+
42
+func GetPatiendAgeBetweenCount(orgID int64) (counts []*PatientAgeCountStruct) {
43
+	readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
44
+	 SELECT
45
+	 CASE
46
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<10 THEN '10'
47
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=10 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<20 THEN '20'
48
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=20 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<30 THEN '30'
49
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=30 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<40 THEN '40'
50
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=40 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<50 THEN '50'
51
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=50 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<60 THEN '60'
52
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=60 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<70 THEN '70'
53
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=70 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<80 THEN '80'
54
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=80 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<90 THEN '90'
55
+	  WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=90 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + ( FROM_UNIXTIME(birthday, '%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<100 THEN '100'
56
+	  ELSE '-1'
57
+	 END
58
+	 AS nnd FROM xt_patients where user_org_id=? and status=1
59
+	 )a GROUP BY nnd`, orgID).Scan(&counts)
60
+	return
61
+}
62
+
63
+
64
+type DialysisModeCountStruct struct {
65
+	Date int64 `json:"date"`
66
+	Mode int64 `json:"mode"`
67
+	Count int64 `json:"count"`
68
+	DateMonth string `json:"date_month"`
69
+}
70
+
71
+
72
+func GetPatientDialysisModeBetweenCount(orgID int64, start,end int64) (counts []*DialysisModeCountStruct) {
73
+	readDb.Raw(`SELECT o.dialysis_date as date, p.mode_id as mode, count(p.mode_id) as count, FROM_UNIXTIME(o.dialysis_date, '%Y-%m') as date_month from xt_dialysis_order as o JOIN xt_dialysis_prescription as p ON p.record_date=o.dialysis_date WHERE o.user_org_id=? and p.user_org_id=? and o.status=1 and p.status=1 and o.dialysis_date>=? and o.dialysis_date<? group by FROM_UNIXTIME(o.dialysis_date, '%Y%m'), p.mode_id`, orgID, orgID, start, end).Scan(&counts)
74
+	return
75
+}

+ 382 - 0
service/verify_login_token_service.go Zobrazit soubor

@@ -0,0 +1,382 @@
1
+package service
2
+
3
+import (
4
+	"encoding/json"
5
+	"io/ioutil"
6
+	"net/http"
7
+	"net/url"
8
+	"strconv"
9
+	"time"
10
+
11
+	"XT_Admin_Api/models"
12
+	"XT_Admin_Api/utils"
13
+
14
+	"github.com/astaxie/beego"
15
+)
16
+
17
+type AdminUserInfo struct {
18
+	AdminUser    *models.AdminUser                    `json:"user"`
19
+	CurrentOrgId int64                                `json:"current_org_id"`
20
+	CurrentAppId int64                                `json:"current_app_id"`
21
+	OrgIds       []int64                              `json:"org_ids"`
22
+	Orgs         map[int64]*models.Org                `json:"orgs"`
23
+	OrgAppIds    map[int64][]int64                    `json:"org_app_ids"`
24
+	OrgApps      map[int64](map[int64]*models.OrgApp) `json:"org_apps"`
25
+	App2OrgIds   map[int64]int64                      `json:"app_to_org_ids"`
26
+	AppRoles     map[int64]*models.App_Role           `json:"app_roles"`
27
+	AppPurviews  map[int64][]*models.Purview          `json:"app_purviews"`
28
+	AppUrlfors   map[int64][]string                   `json:"app_urlfors"`
29
+	Subscibes    map[int64]*models.ServeSubscibe      `json:"org_subscibes"`
30
+
31
+}
32
+
33
+type verifyTokenError struct {
34
+	Msg string
35
+}
36
+
37
+func (e *verifyTokenError) Error() string {
38
+	return e.Msg
39
+}
40
+
41
+// 验证 token 成功后返回的管理员用户的所有信息,包括:基本用户信息,所属的所有机构,机构下的所有应用,应用的用户权限
42
+// map 的数据格式为
43
+/*
44
+"admin_user": { AdminUser's json },
45
+current_org_id: 1,
46
+current_app_id: 11,
47
+"org_ids": [1, 2, 3],
48
+"orgs": { (org_id: Org_Obj)
49
+	1: { Org's json },
50
+	2: { Org's json },
51
+},
52
+"org_app_ids": { (org_id: org_app_ids)
53
+	1: [11, 12, 13],
54
+	2: [21, 22, 23],
55
+},
56
+"org_apps": { (org_id: {app_id: OrgApp_Obj})
57
+	1: {
58
+		11: { OrgApp's json },
59
+		12: { OrgApp's json },
60
+	},
61
+	2: {
62
+		21: { OrgApp's json },
63
+		22: { OrgApp's json },
64
+	},
65
+},
66
+"app_to_org_ids": { (app_id: org_id)
67
+	11: 1,
68
+	12: 1,
69
+	21: 2,
70
+	22: 2,
71
+},
72
+"app_roles": { (app_id: App_Role Obj)
73
+	11: {App_Role's json},
74
+	12: {App_Role's json},
75
+	21: {App_Role's json},
76
+},
77
+"purviews": { (app_id: [processed Purviews' json])
78
+	11: [
79
+		{Purview's json .childs[
80
+			{Purview's json},
81
+			{Purview's json},
82
+		]},
83
+		{Purview's json},
84
+	],
85
+	12: [
86
+		{Purview's json},
87
+		{Purview's json},
88
+	],
89
+},
90
+"purview_urlfors": { (app_id: [url_for])
91
+	11: [
92
+		"Controller1.Action1",
93
+		"Controller1.Action2",
94
+		"Controller2.Action1",
95
+		"Controller2.Action2",
96
+	],
97
+}
98
+应当注意的是,屈服于 Golang 令人恶心的类型机制,这里将所有数值型的 key 或 value 全部转成了 string
99
+*/
100
+// 解析用户信息,并返回
101
+func VerifyToken(token string, ip string, sessionID string) (*AdminUserInfo, error, int) {
102
+	// if len(sessionID) == 0 {
103
+	// 	return nil, &verifyTokenError{"sessionID 为空"}
104
+	// }
105
+	ssoDomain := beego.AppConfig.String("sso_domain")
106
+	api := ssoDomain + "/verifytoken"
107
+	values := make(url.Values)
108
+	values.Set("token", token)
109
+	values.Set("app_type", "3")
110
+	values.Set("ip", ip)
111
+	values.Set("session_id", sessionID)
112
+	resp, requestErr := http.PostForm(api, values)
113
+
114
+	if requestErr != nil {
115
+		utils.ErrorLog("请求验证 sso token 接口失败: %v", requestErr)
116
+		return nil, requestErr, 0
117
+	}
118
+	defer resp.Body.Close()
119
+	body, ioErr := ioutil.ReadAll(resp.Body)
120
+	if ioErr != nil {
121
+		utils.ErrorLog("验证 sso token 接口返回数据读取失败: %v", ioErr)
122
+		return nil, ioErr, 0
123
+	}
124
+	var respJSON map[string]interface{}
125
+	utils.InfoLog(string(body))
126
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
127
+		utils.ErrorLog("验证 sso token 接口返回数据解析JSON失败: %v", err)
128
+		return nil, err, 0
129
+	}
130
+
131
+	if respJSON["state"].(float64) != 1 {
132
+		msg := respJSON["msg"].(string)
133
+		utils.ErrorLog("验证 sso token 接口请求失败: %v", msg)
134
+		return nil, &verifyTokenError{"验证 sso token 接口请求失败"}, int(respJSON["code"].(float64))
135
+	} else {
136
+		utils.SuccessLog("验证 sso token 成功")
137
+		return processAdminUserInfo(respJSON["data"].(map[string]interface{})), nil, 0
138
+	}
139
+}
140
+
141
+func processAdminUserInfo(data map[string]interface{}) *AdminUserInfo {
142
+	adminUser := processAdminUser(data)
143
+	currentOrgId, currentAppId := processCurrentOrgIDAndAppID(data)
144
+	orgIds := processOrgIds(data)
145
+	orgs := processOrgs(data)
146
+	orgAppIds := processOrgAppIds(data)
147
+	orgApps := processOrgApps(data)
148
+	app2OrgIds := processApp2OrgIds(data)
149
+	appRoles := processAppRoles(data)
150
+	appPurviews := processPurviews(data)
151
+	appUrlfors := processPurviewUrlfors(data)
152
+	orgSubscibes := processOrgSubscibes(data)
153
+	sessionAdminUserInfo := &AdminUserInfo{
154
+		AdminUser:    adminUser,
155
+		CurrentOrgId: currentOrgId,
156
+		CurrentAppId: currentAppId,
157
+		OrgIds:       orgIds,
158
+		Orgs:         orgs,
159
+		OrgAppIds:    orgAppIds,
160
+		OrgApps:      orgApps,
161
+		App2OrgIds:   app2OrgIds,
162
+		AppRoles:     appRoles,
163
+		AppPurviews:  appPurviews,
164
+		AppUrlfors:   appUrlfors,
165
+		Subscibes:    orgSubscibes,
166
+	}
167
+	return sessionAdminUserInfo
168
+}
169
+
170
+// "admin_user": { AdminUser's json },
171
+func processAdminUser(data map[string]interface{}) *models.AdminUser {
172
+	userJSONStr := data["admin_user"].(string)
173
+	var adminUser models.AdminUser
174
+	if err := json.Unmarshal([]byte(userJSONStr), &adminUser); err != nil {
175
+		utils.ErrorLog("解析用户信息失败:%v", err)
176
+		return nil
177
+	} else {
178
+		return &adminUser
179
+	}
180
+}
181
+
182
+// current_org_id: 1,
183
+// current_app_id: 11,
184
+func processCurrentOrgIDAndAppID(data map[string]interface{}) (int64, int64) {
185
+	orgIDStr := data["current_org_id"].(string)
186
+	appIDStr := data["current_app_id"].(string)
187
+	orgID, _ := strconv.Atoi(orgIDStr)
188
+	appID, _ := strconv.Atoi(appIDStr)
189
+	return int64(orgID), int64(appID)
190
+}
191
+
192
+// "org_ids": [1, 2, 3],
193
+func processOrgIds(data map[string]interface{}) []int64 {
194
+	orgIdStrs := data["org_ids"].([]interface{})
195
+	orgIds := make([]int64, 0, len(orgIdStrs))
196
+	for _, idstr := range orgIdStrs {
197
+		id, _ := strconv.Atoi(idstr.(string))
198
+		orgIds = append(orgIds, int64(id))
199
+	}
200
+	return orgIds
201
+}
202
+
203
+// "orgs": { (org_id: Org_Obj)
204
+// 	1: { Org's json },
205
+// 	2: { Org's json },
206
+// },
207
+func processOrgs(data map[string]interface{}) map[int64]*models.Org {
208
+	orgJSONs := data["orgs"].(map[string]interface{})
209
+	orgs := make(map[int64]*models.Org)
210
+	for orgIdStr, orgJSON := range orgJSONs {
211
+		orgId, _ := strconv.Atoi(orgIdStr)
212
+		var org models.Org
213
+		json.Unmarshal([]byte(orgJSON.(string)), &org)
214
+		orgs[int64(orgId)] = &org
215
+	}
216
+	return orgs
217
+}
218
+
219
+// "org_app_ids": { (org_id: org_app_ids)
220
+// 	1: [11, 12, 13],
221
+// 	2: [21, 22, 23],
222
+// },
223
+func processOrgAppIds(data map[string]interface{}) map[int64][]int64 {
224
+	orgAppIdStrs := data["org_app_ids"].(map[string]interface{})
225
+	orgAppIds := make(map[int64][]int64)
226
+	for orgIdStr, appIdStrs := range orgAppIdStrs {
227
+		orgId, _ := strconv.Atoi(orgIdStr)
228
+		appIds := make([]int64, 0, len(appIdStrs.([]interface{})))
229
+		for _, appIdStr := range appIdStrs.([]interface{}) {
230
+			appId, _ := strconv.Atoi(appIdStr.(string))
231
+			appIds = append(appIds, int64(appId))
232
+		}
233
+		orgAppIds[int64(orgId)] = appIds
234
+	}
235
+	return orgAppIds
236
+}
237
+
238
+// "org_apps": { (org_id: {app_id: OrgApp_Obj})
239
+// 	1: {
240
+// 		11: { OrgApp's json },
241
+// 		12: { OrgApp's json },
242
+// 	},
243
+// 	2: {
244
+// 		21: { OrgApp's json },
245
+// 		22: { OrgApp's json },
246
+// 	},
247
+// },
248
+func processOrgApps(data map[string]interface{}) map[int64]map[int64]*models.OrgApp {
249
+	orgAppJSONs := data["org_apps"].(map[string]interface{})
250
+	orgApps := make(map[int64]map[int64]*models.OrgApp)
251
+	for orgIdStr, appJSONStrMap := range orgAppJSONs {
252
+		orgId, _ := strconv.Atoi(orgIdStr)
253
+
254
+		apps := make(map[int64]*models.OrgApp)
255
+		for appIdStr, appJSONStr := range appJSONStrMap.(map[string]interface{}) {
256
+			appId, _ := strconv.Atoi(appIdStr)
257
+
258
+			var app models.OrgApp
259
+			json.Unmarshal([]byte(appJSONStr.(string)), &app)
260
+			apps[int64(appId)] = &app
261
+		}
262
+
263
+		orgApps[int64(orgId)] = apps
264
+	}
265
+	return orgApps
266
+}
267
+
268
+// "app_to_org_ids": { (app_id: org_id)
269
+// 	11: 1,
270
+// 	12: 1,
271
+// 	21: 2,
272
+// 	22: 2,
273
+// },
274
+func processApp2OrgIds(data map[string]interface{}) map[int64]int64 {
275
+	app2OrgIdStrs := data["app_to_org_ids"].(map[string]interface{})
276
+	app2OrgIds := make(map[int64]int64)
277
+	for appIdStr, orgIdStr := range app2OrgIdStrs {
278
+		orgId, _ := strconv.Atoi(orgIdStr.(string))
279
+		appId, _ := strconv.Atoi(appIdStr)
280
+		app2OrgIds[int64(appId)] = int64(orgId)
281
+	}
282
+	return app2OrgIds
283
+}
284
+
285
+// "app_roles": { (app_id: App_Role Obj)
286
+// 	11: {App_Role's json},
287
+// 	12: {App_Role's json},
288
+// 	21: {App_Role's json},
289
+// },
290
+func processAppRoles(data map[string]interface{}) map[int64]*models.App_Role {
291
+	appRoleJSONs := data["app_roles"].(map[string]interface{})
292
+	appRoles := make(map[int64]*models.App_Role)
293
+	for appIDStr, appRoleJSON := range appRoleJSONs {
294
+		appID, _ := strconv.Atoi(appIDStr)
295
+		var appRole models.App_Role
296
+		json.Unmarshal([]byte(appRoleJSON.(string)), &appRole)
297
+		appRoles[int64(appID)] = &appRole
298
+	}
299
+	return appRoles
300
+}
301
+
302
+// "purviews": { (app_id: [processed Purviews' json])
303
+// 	11: [
304
+// 		{Purview's json .childs[
305
+// 			{Purview's json},
306
+// 			{Purview's json},
307
+// 		]},
308
+// 		{Purview's json},
309
+// 	],
310
+// 	12: [
311
+// 		{Purview's json},
312
+// 		{Purview's json},
313
+// 	],
314
+// },
315
+func processPurviews(data map[string]interface{}) map[int64][]*models.Purview {
316
+	appPurviewJSONsStrs := data["purviews"].(map[string]interface{})
317
+	appPurviews := make(map[int64][]*models.Purview)
318
+	for appIdStr, purviewJSONsStr := range appPurviewJSONsStrs {
319
+		appId, _ := strconv.Atoi(appIdStr)
320
+		var purviews []*models.Purview
321
+		json.Unmarshal([]byte(purviewJSONsStr.(string)), &purviews)
322
+		// setLinkForPurviews(purviews)
323
+		appPurviews[int64(appId)] = purviews
324
+	}
325
+	return appPurviews
326
+}
327
+
328
+// func setLinkForPurviews(purviews []*models.Purview) {
329
+// 	for _, purview := range purviews {
330
+// 		if len(purview.Urlfor) == 0 {
331
+// 			purview.Link = ""
332
+// 		} else {
333
+// 			purview.Link = beego.URLFor(purview.Urlfor)
334
+// 		}
335
+// 		if purview.Childs == nil {
336
+// 			purview.Childs = make([]*models.Purview, 0)
337
+// 		} else {
338
+// 			setLinkForPurviews(purview.Childs)
339
+// 		}
340
+// 		// utils.TraceLog("%+v", purview)
341
+// 	}
342
+// }
343
+
344
+// "purview_urlfors": { (app_id: [url_for])
345
+// 	11: [
346
+// 		"Controller1.Action1",
347
+// 		"Controller1.Action2",
348
+// 		"Controller2.Action1",
349
+// 		"Controller2.Action2",
350
+// 	],
351
+// }
352
+func processPurviewUrlfors(data map[string]interface{}) map[int64][]string {
353
+	appUrlforsStrs := data["purview_urlfors"].(map[string]interface{})
354
+	appUrlfors := make(map[int64][]string)
355
+	for appIdStr, urlforsStr := range appUrlforsStrs {
356
+		appId, _ := strconv.Atoi(appIdStr)
357
+		var urlfors []string
358
+		json.Unmarshal([]byte(urlforsStr.(string)), &urlfors)
359
+		appUrlfors[int64(appId)] = urlfors
360
+	}
361
+	return appUrlfors
362
+}
363
+
364
+// "org_subscibes": { (org_id: ServeSubscibe)
365
+//  11: {ServeSubscibe's json}
366
+// },
367
+func processOrgSubscibes(data map[string]interface{}) map[int64]*models.ServeSubscibe {
368
+	subscibeJSONs := data["org_subscibes"].(map[string]interface{})
369
+	subscibes := make(map[int64]*models.ServeSubscibe)
370
+	for orgIDStr, subscibeJSON := range subscibeJSONs {
371
+		orgID, _ := strconv.Atoi(orgIDStr)
372
+		var subscibe models.ServeSubscibe
373
+		json.Unmarshal([]byte(subscibeJSON.(string)), &subscibe)
374
+		subscibes[int64(orgID)] = &subscibe
375
+	}
376
+	return subscibes
377
+}
378
+
379
+func ModifyPassword(adminID int64, password string) error {
380
+	err := writeUserDb.Model(&models.AdminUser{}).Where("id = ? AND status = 1", adminID).Updates(map[string]interface{}{"password": password, "mtime": time.Now().Unix()}).Error
381
+	return err
382
+}

binární
static/1.jpg Zobrazit soubor


binární
static/2.jpg Zobrazit soubor


binární
static/5.jpg Zobrazit soubor


+ 1 - 0
static/js/reload.min.js Zobrazit soubor

@@ -0,0 +1 @@
1
+function b(a){var c=new WebSocket(a);c.onclose=function(){setTimeout(function(){b(a)},2E3)};c.onmessage=function(){location.reload()}}try{if(window.WebSocket)try{b("ws://localhost:12450/reload")}catch(a){console.error(a)}else console.log("Your browser does not support WebSockets.")}catch(a){console.error("Exception during connecting to Reload:",a)};

+ 37 - 0
tests/default_test.go Zobrazit soubor

@@ -0,0 +1,37 @@
1
+package test
2
+
3
+import (
4
+	_ "XT/routers"
5
+	"net/http"
6
+	"net/http/httptest"
7
+	"path/filepath"
8
+	"runtime"
9
+	"testing"
10
+
11
+	"github.com/astaxie/beego"
12
+	. "github.com/smartystreets/goconvey/convey"
13
+)
14
+
15
+func init() {
16
+	_, file, _, _ := runtime.Caller(1)
17
+	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
18
+	beego.TestBeegoInit(apppath)
19
+}
20
+
21
+// TestBeego is a sample to run an endpoint test
22
+func TestBeego(t *testing.T) {
23
+	r, _ := http.NewRequest("GET", "/", nil)
24
+	w := httptest.NewRecorder()
25
+	beego.BeeApp.Handlers.ServeHTTP(w, r)
26
+
27
+	beego.Trace("testing", "TestBeego", "Code[%d]\n%s", w.Code, w.Body.String())
28
+
29
+	Convey("Subject: Test Station Endpoint\n", t, func() {
30
+		Convey("Status Code Should Be 200", func() {
31
+			So(w.Code, ShouldEqual, 200)
32
+		})
33
+		Convey("The Result Should Not Be Empty", func() {
34
+			So(w.Body.Len(), ShouldBeGreaterThan, 0)
35
+		})
36
+	})
37
+}

+ 13 - 0
utils/ip_helper.go Zobrazit soubor

@@ -0,0 +1,13 @@
1
+package utils
2
+
3
+import (
4
+	"net/http"
5
+)
6
+
7
+func GetIP(r *http.Request) string {
8
+	ip := r.Header.Get("X-Forwarded-For")
9
+	if ip == "" {
10
+		ip = r.RemoteAddr
11
+	}
12
+	return ip
13
+}

+ 66 - 0
utils/log.go Zobrazit soubor

@@ -0,0 +1,66 @@
1
+package utils
2
+
3
+import (
4
+	"fmt"
5
+	"time"
6
+)
7
+
8
+const (
9
+	color_red = uint8(iota + 91)
10
+	color_green
11
+	color_yellow
12
+	color_blue
13
+	color_magenta //洋红
14
+
15
+	// info = "[INFO]"
16
+	// trac = "[TRAC]"
17
+	// erro = "[ERRO]"
18
+	// warn = "[WARN]"
19
+	// succ = "[SUCC]"
20
+)
21
+
22
+// 根据 https://github.com/liyu4/chill 修改的
23
+// see complete color rules in document in https://en.wikipedia.org/wiki/ANSI_escape_code#cite_note-ecma48-13
24
+func TraceLog(format string, a ...interface{}) {
25
+	fmt.Println(formatLog(yellow(fmt.Sprintf(format, a...))))
26
+}
27
+
28
+func InfoLog(format string, a ...interface{}) {
29
+	fmt.Println(formatLog(blue(fmt.Sprintf(format, a...))))
30
+}
31
+
32
+func SuccessLog(format string, a ...interface{}) {
33
+	fmt.Println(formatLog(green(fmt.Sprintf(format, a...))))
34
+}
35
+
36
+func WarningLog(format string, a ...interface{}) {
37
+	fmt.Println(formatLog(magenta(fmt.Sprintf(format, a...))))
38
+}
39
+
40
+func ErrorLog(format string, a ...interface{}) {
41
+	fmt.Println(formatLog(red(fmt.Sprintf(format, a...))))
42
+}
43
+
44
+func red(s string) string {
45
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_red, s)
46
+}
47
+
48
+func green(s string) string {
49
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_green, s)
50
+}
51
+
52
+func yellow(s string) string {
53
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_yellow, s)
54
+}
55
+
56
+func blue(s string) string {
57
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_blue, s)
58
+}
59
+
60
+func magenta(s string) string {
61
+	return fmt.Sprintf("\x1b[%dm%s\x1b[0m", color_magenta, s)
62
+}
63
+
64
+func formatLog(prefix string) string {
65
+	return time.Now().Format("[2006/01/02 15:04:05]") + " " + prefix + " "
66
+}

+ 191 - 0
utils/paginator.go Zobrazit soubor

@@ -0,0 +1,191 @@
1
+// Copyright 2013 wetalk authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License"): you may
4
+// not use this file except in compliance with the License. You may obtain
5
+// a copy of the License at
6
+//
7
+//     http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+// License for the specific language governing permissions and limitations
13
+// under the License.
14
+
15
+package utils
16
+
17
+import (
18
+	"math"
19
+	"net/http"
20
+	"net/url"
21
+	"strconv"
22
+)
23
+
24
+type Paginator struct {
25
+	Request     *http.Request
26
+	PerPageNums int
27
+	MaxPages    int
28
+
29
+	nums      int64
30
+	pageRange []int
31
+	pageNums  int
32
+	page      int
33
+}
34
+
35
+func (p *Paginator) PageNums() int {
36
+	if p.pageNums != 0 {
37
+		return p.pageNums
38
+	}
39
+	pageNums := math.Ceil(float64(p.nums) / float64(p.PerPageNums))
40
+	if p.MaxPages > 0 {
41
+		pageNums = math.Min(pageNums, float64(p.MaxPages))
42
+	}
43
+	p.pageNums = int(pageNums)
44
+	return p.pageNums
45
+}
46
+
47
+func (p *Paginator) Nums() int64 {
48
+	return p.nums
49
+}
50
+
51
+func (p *Paginator) SetNums(nums int64) {
52
+	p.nums = nums
53
+}
54
+
55
+func (p *Paginator) Page() int {
56
+	if p.page != 0 {
57
+		return p.page
58
+	}
59
+	if p.Request.Form == nil {
60
+		p.Request.ParseForm()
61
+	}
62
+	p.page, _ = strconv.Atoi(p.Request.Form.Get("page"))
63
+	if p.page > p.PageNums() {
64
+		p.page = p.PageNums()
65
+	}
66
+	if p.page <= 0 {
67
+		p.page = 1
68
+	}
69
+	return p.page
70
+}
71
+
72
+func (p *Paginator) Pages() []int {
73
+	if p.pageRange == nil && p.nums > 0 {
74
+		var pages []int
75
+		pageNums := p.PageNums()
76
+		page := p.Page()
77
+		switch {
78
+		case page >= pageNums-4 && pageNums > 9:
79
+			start := pageNums - 9 + 1
80
+			pages = make([]int, 9)
81
+			for i, _ := range pages {
82
+				pages[i] = start + i
83
+			}
84
+		case page >= 5 && pageNums > 9:
85
+			start := page - 5 + 1
86
+			pages = make([]int, int(math.Min(9, float64(page+4+1))))
87
+			for i, _ := range pages {
88
+				pages[i] = start + i
89
+			}
90
+		default:
91
+			pages = make([]int, int(math.Min(9, float64(pageNums))))
92
+			for i, _ := range pages {
93
+				pages[i] = i + 1
94
+			}
95
+		}
96
+		p.pageRange = pages
97
+	}
98
+	return p.pageRange
99
+}
100
+
101
+func (p *Paginator) PageLink(page int) string {
102
+	link, _ := url.ParseRequestURI(p.Request.RequestURI)
103
+	values := link.Query()
104
+	if page == 1 {
105
+		values.Del("page")
106
+	} else {
107
+		values.Set("page", strconv.Itoa(page))
108
+	}
109
+	link.RawQuery = values.Encode()
110
+	return link.String()
111
+}
112
+
113
+func (p *Paginator) PageParams() url.Values {
114
+	link, _ := url.ParseRequestURI(p.Request.RequestURI)
115
+	values := link.Query()
116
+	values.Del("page")
117
+	return values
118
+}
119
+
120
+func (p *Paginator) BasePageLink() string {
121
+	link, _ := url.ParseRequestURI(p.Request.RequestURI)
122
+	values := link.Query()
123
+	values.Del("page")
124
+	link.RawQuery = values.Encode()
125
+	return link.String()
126
+}
127
+
128
+func (p *Paginator) PageLinkPrev() (link string) {
129
+	if p.HasPrev() {
130
+		link = p.PageLink(p.Page() - 1)
131
+	}
132
+	return
133
+}
134
+
135
+func (p *Paginator) PageLinkNext() (link string) {
136
+	if p.HasNext() {
137
+		link = p.PageLink(p.Page() + 1)
138
+	}
139
+	return
140
+}
141
+
142
+func (p *Paginator) PageLinkFirst() (link string) {
143
+	return p.PageLink(1)
144
+}
145
+
146
+func (p *Paginator) PageLinkLast() (link string) {
147
+	return p.PageLink(p.PageNums())
148
+}
149
+
150
+func (p *Paginator) HasPrev() bool {
151
+	return p.Page() > 1
152
+}
153
+
154
+func (p *Paginator) HasNext() bool {
155
+	return p.Page() < p.PageNums()
156
+}
157
+
158
+func (p *Paginator) IsActive(page int) bool {
159
+	return p.Page() == page
160
+}
161
+
162
+func (p *Paginator) Offset() int {
163
+	return (p.Page() - 1) * p.PerPageNums
164
+}
165
+
166
+func (p *Paginator) HasPages() bool {
167
+	return p.PageNums() > 1
168
+}
169
+
170
+func (p *Paginator) Total() int {
171
+	return p.PageNums()
172
+}
173
+func (p *Paginator) TotalSubOne() int {
174
+	return p.PageNums() - 1
175
+}
176
+
177
+func NewPaginator(req *http.Request, per int, nums int64) *Paginator {
178
+	p := Paginator{}
179
+	p.Request = req
180
+	if per <= 0 {
181
+		per = 10
182
+	}
183
+	p.PerPageNums = per
184
+	p.SetNums(nums)
185
+	return &p
186
+}
187
+
188
+func FakePaginator(currentPage int, per int, nums int64) *Paginator {
189
+	fakeReq, _ := http.NewRequest("GET", "/?page="+strconv.Itoa(currentPage), nil)
190
+	return NewPaginator(fakeReq, per, nums)
191
+}

+ 75 - 0
utils/regex_helper.go Zobrazit soubor

@@ -0,0 +1,75 @@
1
+package utils
2
+
3
+import (
4
+	"fmt"
5
+	"regexp"
6
+)
7
+
8
+// 正整数正则
9
+func PositiveIntegerRegexp() *regexp.Regexp {
10
+	reg, _ := regexp.Compile("^[1-9][0-9]*$")
11
+	return reg
12
+}
13
+
14
+// 手机号正则 不那么严谨的
15
+func CellPhoneRegexp() *regexp.Regexp {
16
+	reg, _ := regexp.Compile("^1\\d{10}$")
17
+	return reg
18
+}
19
+
20
+// 固话正则
21
+func TelPhoneRegexp() *regexp.Regexp {
22
+	// reg, _ := regexp.Compile("^0\\d{2,3}-?\\d{7,8}$")
23
+	reg, _ := regexp.Compile("^0\\d{2,3}-?\\d{7,8}$")
24
+	return reg
25
+}
26
+
27
+// 手机号或固话正则
28
+func PhoneRegexp() *regexp.Regexp {
29
+	reg, _ := regexp.Compile("^(0\\d{2,3}-?\\d{7,8}$)|(1\\d{10}$)")
30
+	return reg
31
+}
32
+
33
+// tests
34
+func PositiveIntegerRegexpTest() {
35
+	reg := PositiveIntegerRegexp()
36
+	fmt.Println("12 是否匹配:", reg.MatchString("12"))
37
+	fmt.Println("1 是否匹配:", reg.MatchString("1"))
38
+	fmt.Println("980030 是否匹配:", reg.MatchString("980030"))
39
+	fmt.Println("01 是否匹配:", reg.MatchString("01"))
40
+	fmt.Println("asd1asd 是否匹配:", reg.MatchString("asd1asd"))
41
+	fmt.Println("a12 是否匹配:", reg.MatchString("a12"))
42
+	fmt.Println("12a 是否匹配:", reg.MatchString("12a"))
43
+	fmt.Println("-12 是否匹配:", reg.MatchString("-12"))
44
+	fmt.Println("12.1 是否匹配:", reg.MatchString("12.1"))
45
+	fmt.Println("14j2a 是否匹配:", reg.MatchString("14j2a"))
46
+}
47
+
48
+func CellPhoneRegexpTest() {
49
+	reg := CellPhoneRegexp()
50
+	fmt.Println("13632250447 是否匹配:", reg.MatchString("13632250447"))
51
+	fmt.Println("12000000000 是否匹配:", reg.MatchString("12000000000"))
52
+	fmt.Println("30001212325 是否匹配:", reg.MatchString("30001212325"))
53
+	fmt.Println("1233123 是否匹配:", reg.MatchString("1233123"))
54
+	fmt.Println("123312312344 是否匹配:", reg.MatchString("123312312344"))
55
+	fmt.Println("13345678a12 是否匹配:", reg.MatchString("13345678a12"))
56
+	fmt.Println("a13345678a1 是否匹配:", reg.MatchString("a13345678a1"))
57
+	fmt.Println("1334a678a12 是否匹配:", reg.MatchString("1334a678a12"))
58
+	fmt.Println("1345678a12a 是否匹配:", reg.MatchString("1345678a12a"))
59
+	fmt.Println("aqwertyuioo 是否匹配:", reg.MatchString("aqwertyuioo"))
60
+}
61
+
62
+func TelPhoneRegexpTest() {
63
+	reg := TelPhoneRegexp()
64
+	fmt.Println("020-39006917 是否匹配:", reg.MatchString("020-39006917"))
65
+	fmt.Println("02039006917 是否匹配:", reg.MatchString("02039006917"))
66
+	fmt.Println("0754-5916612 是否匹配:", reg.MatchString("0754-5916612"))
67
+	fmt.Println("07545916612 是否匹配:", reg.MatchString("07545916612"))
68
+	fmt.Println("123-39006917 是否匹配:", reg.MatchString("123-39006917"))
69
+	fmt.Println("1754-5916612 是否匹配:", reg.MatchString("1754-5916612"))
70
+	fmt.Println("0a0-39006917 是否匹配:", reg.MatchString("0a0-39006917"))
71
+	fmt.Println("0a039006917 是否匹配:", reg.MatchString("0a039006917"))
72
+	fmt.Println("010-39s06917 是否匹配:", reg.MatchString("010-39s06917"))
73
+	fmt.Println("020-390069171 是否匹配:", reg.MatchString("020-390069171"))
74
+	fmt.Println("020-3900691 是否匹配:", reg.MatchString("020-3900691"))
75
+}

+ 115 - 0
utils/stringtool.go Zobrazit soubor

@@ -0,0 +1,115 @@
1
+package utils
2
+
3
+import (
4
+	"bytes"
5
+	"crypto/aes"
6
+	"crypto/cipher"
7
+	"crypto/md5"
8
+	"encoding/base64"
9
+	"fmt"
10
+	"math/rand"
11
+	"strconv"
12
+	"strings"
13
+	"time"
14
+
15
+	"github.com/astaxie/beego"
16
+)
17
+
18
+// 将字符串加密成 md5
19
+func String2md5(str string) string {
20
+	data := []byte(str)
21
+	has := md5.Sum(data)
22
+	return fmt.Sprintf("%x", has) //将[]byte转成16进制
23
+}
24
+
25
+// RandomString 在数字、大写字母、小写字母范围内生成num位的随机字符串
26
+func RandomString(length int) string {
27
+	// 48 ~ 57 数字
28
+	// 65 ~ 90 A ~ Z
29
+	// 97 ~ 122 a ~ z
30
+	// 一共62个字符,在0~61进行随机,小于10时,在数字范围随机,
31
+	// 小于36在大写范围内随机,其他在小写范围随机
32
+	rand.Seed(time.Now().UnixNano())
33
+	result := make([]string, 0, length)
34
+	for i := 0; i < length; i++ {
35
+		t := rand.Intn(62)
36
+		if t < 10 {
37
+			result = append(result, strconv.Itoa(rand.Intn(10)))
38
+		} else if t < 36 {
39
+			result = append(result, string(rand.Intn(26)+65))
40
+		} else {
41
+			result = append(result, string(rand.Intn(26)+97))
42
+		}
43
+	}
44
+	return strings.Join(result, "")
45
+}
46
+
47
+func RandomNumberString(length int) string {
48
+	var str string
49
+	for i := 0; i < length; i++ {
50
+		rand.Seed(time.Now().UnixNano())
51
+		str += strconv.Itoa(rand.Intn(10))
52
+	}
53
+	return str
54
+}
55
+
56
+// AES加密
57
+func AESEncrypt(origin string) string {
58
+	aes_key := beego.AppConfig.String("aes_key")
59
+	fmt.Println(aes_key)
60
+	xpass, _ := _aesEncrypt([]byte(origin), []byte(aes_key))
61
+	fmt.Println(_aesEncrypt([]byte(origin), []byte(aes_key)))
62
+	fmt.Println(xpass)
63
+	pass64 := base64.StdEncoding.EncodeToString(xpass)
64
+	fmt.Println(pass64)
65
+	return pass64
66
+}
67
+
68
+func AESDecrypt(crypted []byte) string {
69
+	aes_key := beego.AppConfig.String("aes_key")
70
+	origData, err := _aesDecrypt(crypted, []byte(aes_key))
71
+	if err != nil {
72
+		return ""
73
+	}
74
+	return string(origData)
75
+}
76
+
77
+func _PKCS5Padding(ciphertext []byte, blockSize int) []byte {
78
+	padding := blockSize - len(ciphertext)%blockSize
79
+	padtext := bytes.Repeat([]byte{byte(padding)}, padding)
80
+	return append(ciphertext, padtext...)
81
+}
82
+
83
+func _PKCS5UnPadding(origData []byte) []byte {
84
+	length := len(origData)
85
+	unpadding := int(origData[length-1])
86
+	return origData[:(length - unpadding)]
87
+}
88
+
89
+func _aesEncrypt(origData, key []byte) ([]byte, error) {
90
+	block, err := aes.NewCipher(key)
91
+	if err != nil {
92
+		return nil, err
93
+	}
94
+
95
+	blockSize := block.BlockSize()
96
+	origData = _PKCS5Padding(origData, blockSize)
97
+	blockMode := cipher.NewCBCEncrypter(block, key[:blockSize])
98
+	crypted := make([]byte, len(origData))
99
+	blockMode.CryptBlocks(crypted, origData)
100
+	return crypted, nil
101
+}
102
+
103
+func _aesDecrypt(crypted, key []byte) ([]byte, error) {
104
+	block, err := aes.NewCipher(key)
105
+	if err != nil {
106
+		return nil, err
107
+	}
108
+
109
+	blockSize := block.BlockSize()
110
+	blockMode := cipher.NewCBCDecrypter(block, key[:blockSize])
111
+	origData := make([]byte, len(crypted))
112
+	blockMode.CryptBlocks(origData, crypted)
113
+	origData = _PKCS5UnPadding(origData)
114
+	return origData, nil
115
+}

+ 27 - 0
utils/time_helper.go Zobrazit soubor

@@ -0,0 +1,27 @@
1
+package utils
2
+
3
+import (
4
+	"time"
5
+)
6
+
7
+// day 当天凌晨0点
8
+func ZeroHourTimeOfDay(day time.Time) time.Time {
9
+	dayStr := day.Format("2006-01-02")
10
+	zeroHourTime, _ := ParseTimeStringToTime("2006-01-02", dayStr)
11
+	return *zeroHourTime
12
+}
13
+
14
+// day 当月一号凌晨0点
15
+func BeginningOfMonth(day time.Time) time.Time {
16
+	dayStr := day.Format("2006-01")
17
+	monthTime, _ := ParseTimeStringToTime("2006-01", dayStr)
18
+	return *monthTime
19
+}
20
+
21
+// 指定年月的月份的月初凌晨0点和月末23点59分59秒
22
+func MonthBeginningToEnd(year int, month int) (time.Time, time.Time) {
23
+	beginningOfMonth := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Local)
24
+	beginningOfNextMonth := beginningOfMonth.AddDate(0, 1, 0)
25
+	endOfMonth := beginningOfNextMonth.Add(time.Duration(-1))
26
+	return beginningOfMonth, endOfMonth
27
+}

+ 231 - 0
utils/tools.go Zobrazit soubor

@@ -0,0 +1,231 @@
1
+package utils
2
+
3
+import (
4
+	"crypto/sha1"
5
+	"encoding/base64"
6
+	"errors"
7
+	"fmt"
8
+	"io"
9
+	"math/rand"
10
+	"regexp"
11
+	"sort"
12
+	"strconv"
13
+	"strings"
14
+	"time"
15
+
16
+	"github.com/astaxie/beego"
17
+)
18
+
19
+func TimeSub(t1, t2 time.Time) int {
20
+	t1 = time.Date(t1.Year(), t1.Month(), t1.Day(), 0, 0, 0, 0, time.Local)
21
+	t2 = time.Date(t2.Year(), t2.Month(), t2.Day(), 0, 0, 0, 0, time.Local)
22
+
23
+	return int(t1.Sub(t2).Hours() / 24)
24
+}
25
+
26
+func MarkBackUrl(backUrl, defaultUrl string) string {
27
+	if len(backUrl) == 0 {
28
+		backUrl = defaultUrl
29
+	} else {
30
+		backURLByte, err := base64.URLEncoding.DecodeString(backUrl)
31
+		if err != nil {
32
+			backUrl = backUrl
33
+		} else {
34
+			backUrl = string(backURLByte)
35
+		}
36
+	}
37
+	return backUrl
38
+}
39
+
40
+func CheckMobile(mobile string) (match bool) {
41
+
42
+	//过滤手机
43
+	match, _ = regexp.MatchString("^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$", mobile)
44
+	return
45
+}
46
+
47
+func RandCode(min, max int64) string {
48
+	if min >= max || min == 0 || max == 0 {
49
+		return strconv.FormatInt(max, 10)
50
+	}
51
+	rand.Seed(time.Now().UnixNano())
52
+	randNum := rand.Int63n(max-min) + min
53
+	return strconv.FormatInt(randNum, 10)
54
+}
55
+
56
+func TimeAgo(timeUnix int64) string {
57
+	timeUnixS := time.Unix(timeUnix, 0)
58
+	timeNow := time.Now()
59
+	timeSub := timeNow.Sub(timeUnixS)
60
+
61
+	if timeSub < time.Minute*1 {
62
+		return "刚刚"
63
+	} else if timeSub < time.Hour*1 {
64
+		return strconv.Itoa(int(timeSub.Minutes())) + "分钟前"
65
+	} else if timeSub < time.Hour*24 {
66
+		return strconv.Itoa(int(timeSub.Hours())) + "小时前"
67
+	} else if timeSub < time.Hour*24*7 {
68
+		return strconv.Itoa(int(timeSub.Hours()/24)) + "天前"
69
+	} else {
70
+		return timeUnixS.Format("2006-01-02 15:04")
71
+	}
72
+	return ""
73
+}
74
+
75
+//Signature sha1签名
76
+func Signature(params ...string) string {
77
+	sort.Strings(params)
78
+	h := sha1.New()
79
+	for _, s := range params {
80
+		io.WriteString(h, s)
81
+	}
82
+	return fmt.Sprintf("%x", h.Sum(nil))
83
+}
84
+
85
+//RandomStr 随机生成字符串
86
+func RandomStr(length int) string {
87
+	str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
88
+	bytes := []byte(str)
89
+	result := []byte{}
90
+	r := rand.New(rand.NewSource(time.Now().UnixNano()))
91
+	for i := 0; i < length; i++ {
92
+		result = append(result, bytes[r.Intn(len(bytes))])
93
+	}
94
+	return string(result)
95
+}
96
+
97
+//GetCurrTs return current timestamps
98
+func GetCurrTs() int64 {
99
+	return time.Now().Unix()
100
+}
101
+
102
+func SetThisRequestURI(uri string) string {
103
+	return fmt.Sprintf("%v%v", beego.AppConfig.String("httpdomain"), uri)
104
+}
105
+
106
+func SetThisBasr64RequestURI(uri string) string {
107
+	backUrl := fmt.Sprintf("%v%v", beego.AppConfig.String("httpdomain"), uri)
108
+	backUrl = base64.URLEncoding.EncodeToString([]byte(backUrl))
109
+
110
+	return backUrl
111
+}
112
+
113
+func TransNum2Str(read int64) (transRead string) {
114
+	if read < 0 {
115
+		transRead = "0"
116
+	} else if read < 10000 {
117
+		transRead = fmt.Sprintf("%v", read)
118
+	} else {
119
+		var c float64 = 10000
120
+		var rc float64 = float64(read)
121
+		transRead = fmt.Sprintf("%.2f万", rc/c)
122
+	}
123
+
124
+	return
125
+}
126
+
127
+func GenMobileToken(mobile string) (token string) {
128
+	st := strings.Split(mobile, "")
129
+
130
+	s := fmt.Sprintf("%s%v%v%v%v%v%v", mobile, st[0], st[1], st[3], st[7], st[6], st[9])
131
+
132
+	h := sha1.New()
133
+	h.Write([]byte(s))
134
+	bs := h.Sum(nil)
135
+
136
+	token = fmt.Sprintf("%x", bs)
137
+
138
+	return
139
+}
140
+
141
+func CheckMobileToken(mobile, token string) bool {
142
+	o := GenMobileToken(mobile)
143
+	if token == o {
144
+		return true
145
+	}
146
+
147
+	return false
148
+}
149
+
150
+type jSapiConfig struct {
151
+	AppID     string `json:"app_id"`
152
+	Timestamp int64  `json:"timestamp"`
153
+	NonceStr  string `json:"nonce_str"`
154
+	Signature string `json:"signature"`
155
+}
156
+
157
+//GetAJTConfig jsapi_ticket config
158
+func GetAJTConfig(jsapiTicket, uri string) (jSapiConfig, error) {
159
+	var config jSapiConfig
160
+	nonceStr := RandomStr(16)
161
+	timestamp := GetCurrTs()
162
+	str := fmt.Sprintf("jsapi_ticket=%s&noncestr=%s&timestamp=%d&url=%s", jsapiTicket, nonceStr, timestamp, uri)
163
+	sigStr := Signature(str)
164
+
165
+	config.AppID = beego.AppConfig.String("wxappId")
166
+	config.NonceStr = nonceStr
167
+	config.Timestamp = timestamp
168
+	config.Signature = sigStr
169
+	return config, nil
170
+}
171
+
172
+func TrimHtml(src string) string {
173
+	//将HTML标签全转换成小写
174
+	re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
175
+	src = re.ReplaceAllStringFunc(src, strings.ToLower)
176
+	//去除STYLE
177
+	re, _ = regexp.Compile("\\<style[\\S\\s]+?\\</style\\>")
178
+	src = re.ReplaceAllString(src, "")
179
+	//去除SCRIPT
180
+	re, _ = regexp.Compile("\\<script[\\S\\s]+?\\</script\\>")
181
+	src = re.ReplaceAllString(src, "")
182
+	//去除所有尖括号内的HTML代码,并换成换行符
183
+	re, _ = regexp.Compile("\\<[\\S\\s]+?\\>")
184
+	src = re.ReplaceAllString(src, "\n")
185
+	//去除连续的换行符
186
+	re, _ = regexp.Compile("\\s{2,}")
187
+	src = re.ReplaceAllString(src, "\n")
188
+	return strings.TrimSpace(src)
189
+}
190
+
191
+func SubString(str string, begin, length int) string {
192
+	rs := []rune(str)
193
+	lth := len(rs)
194
+	if begin < 0 {
195
+		begin = 0
196
+	}
197
+	if begin >= lth {
198
+		begin = lth
199
+	}
200
+	end := begin + length
201
+
202
+	if end > lth {
203
+		end = lth
204
+	}
205
+	return string(rs[begin:end])
206
+}
207
+
208
+func ParseTimeStringToTime(layout string, timeStr string) (*time.Time, error) {
209
+	if len(layout) == 0 || len(timeStr) == 0 {
210
+		return nil, errors.New("layout 或 日期字符串 为空,无法解析")
211
+	}
212
+	loc, _ := time.LoadLocation("Local")
213
+	date, parseDateErr := time.ParseInLocation(layout, timeStr, loc)
214
+	return &date, parseDateErr
215
+}
216
+
217
+// 获取 date 所在周的周一和周日,以周一0点为一周的开始,周日24点为一周的结束
218
+func GetMondayAndSundayOfWeekDate(date *time.Time) (time.Time, time.Time) {
219
+	if date == nil {
220
+		now := time.Now()
221
+		date = &now
222
+	}
223
+	weekday := int(date.Weekday())
224
+	if weekday == 0 {
225
+		weekday = 7
226
+	}
227
+	loc, _ := time.LoadLocation("Local")
228
+	monday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 1-weekday).Format("2006-01-02")+" 00:00:00", loc)
229
+	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 7-weekday).Format("2006-01-02")+" 23:59:59", loc)
230
+	return monday, sunday
231
+}

Diff nebyl zobrazen, protože je příliš veliký
+ 95 - 0
views/index.tpl