Browse Source

需求更改

XMLWAN 3 years ago
parent
commit
189a96daaa

+ 67 - 0
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -0,0 +1,67 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/controllers"
5
+	"XT_New/enums"
6
+	"XT_New/service"
7
+	"fmt"
8
+)
9
+
10
+type CommonApiController struct {
11
+	controllers.BaseAuthAPIController
12
+}
13
+
14
+func (this *CommonApiController) GetInspectionMajor() {
15
+
16
+	major, err := service.GetInspectionMajor(0)
17
+	if err != nil {
18
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
19
+		return
20
+	}
21
+	this.ServeSuccessJSON(map[string]interface{}{
22
+		"inspection": major,
23
+	})
24
+}
25
+
26
+func (this *CommonApiController) GetInspectionMinor() {
27
+	id, _ := this.GetInt64("id")
28
+	fmt.Println("id", id)
29
+	minor, err := service.GetInspectionMinor(id)
30
+	if err != nil {
31
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
32
+		return
33
+	}
34
+	this.ServeSuccessJSON(map[string]interface{}{
35
+		"inspection": minor,
36
+	})
37
+}
38
+
39
+func (this *CommonApiController) GetInspectionRange() {
40
+	id, _ := this.GetInt64("id")
41
+	fmt.Println("id", id)
42
+	inspectionRange, err := service.GetInspectionRange(id)
43
+	if err != nil {
44
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
45
+		return
46
+	}
47
+	this.ServeSuccessJSON(map[string]interface{}{
48
+		"inspectionRange": inspectionRange,
49
+	})
50
+}
51
+
52
+func (this *CommonApiController) SaveInspection() {
53
+	fmt.Println("触发-------------------0")
54
+	//dataBody := make(map[string]interface{}, 0)
55
+	//err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
56
+	//fmt.Println("err",err)
57
+	//inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
58
+	//fmt.Println("大项",inspectionmajor)
59
+	//inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
60
+	//fmt.Println("小项",inspectionMinor)
61
+	//minrange := dataBody["min_range"].(string)
62
+	//fmt.Println("minragne",minrange)
63
+	//largerange := dataBody["large_range"].(string)
64
+	//fmt.Println("largerange",largerange)
65
+	//sort := dataBody["sort"].(string)
66
+	//fmt.Println("sort",sort)
67
+}

+ 13 - 0
controllers/new_mobile_api_controllers/common_api_router.go View File

@@ -0,0 +1,13 @@
1
+package new_mobile_api_controllers
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+)
6
+
7
+func CommonApiControllersRegisterRouters() {
8
+
9
+	beego.Router("/com/api/getinspectionmajor", &CommonApiController{}, "Get:GetInspectionMajor")
10
+	beego.Router("/com/api/getinspectionminor", &CommonApiController{}, "Get:GetInspectionMinor")
11
+	beego.Router("/com/api/getinspectionrange", &CommonApiController{}, "Get:GetInspectionRange")
12
+	beego.Router("/com/api/saveinspction", &CommonApiController{}, "Post:SaveInspection")
13
+}

+ 2 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go View File

@@ -288,6 +288,7 @@ func (this *NewDialysisApiController) SavePatient() {
288 288
 			Avatar:            avatar,
289 289
 			IdCardNo:          idCard,
290 290
 			IsInfectious:      is_infectious,
291
+			RegistrarsId:      adminInfo.AdminUser.Id,
291 292
 		}
292 293
 		err = service.CreateOldPatient(&patients)
293 294
 		fmt.Print("报错", err)
@@ -318,6 +319,7 @@ func (this *NewDialysisApiController) SavePatient() {
318 319
 			BloodId:           patient.ID,
319 320
 			IsInfectious:      is_infectious,
320 321
 			IdCardNo:          idCard,
322
+			RegistrarsId:      adminInfo.AdminUser.Id,
321 323
 		}
322 324
 		err = service.CreateNewPatient(&patientsNew)
323 325
 		fmt.Print("报错", err)

+ 1 - 1
routers/router.go View File

@@ -54,7 +54,7 @@ func init() {
54 54
 	m_api.MobileAPIControllersRegisterRouters()
55 55
 	new_m_api.NewMobileAPIControllersRegisterRouters()
56 56
 	//admin_api.AdminAPIControllersRegisterRouters()
57
-
57
+	new_m_api.CommonApiControllersRegisterRouters()
58 58
 	controllers.ManageRouters()
59 59
 	//controllers.PatientRouters()
60 60
 }

+ 21 - 0
service/common_service.go View File

@@ -0,0 +1,21 @@
1
+package service
2
+
3
+import "XT_New/models"
4
+
5
+func GetInspectionMajor(orgid int64) (inspection []*models.XtInspectionReference, err error) {
6
+
7
+	err = XTReadDB().Model(&inspection).Where("org_id = ? and status = 1", orgid).Group("project_name").Order("id asc").Find(&inspection).Error
8
+	return inspection, err
9
+}
10
+
11
+func GetInspectionMinor(projectid int64) (inspection []*models.XtInspectionReference, err error) {
12
+
13
+	err = XTReadDB().Model(&inspection).Where("project_id = ? and status = 1", projectid).Find(&inspection).Error
14
+	return inspection, err
15
+}
16
+
17
+func GetInspectionRange(id int64) (models.XtInspectionReference, error) {
18
+	reference := models.XtInspectionReference{}
19
+	err := XTReadDB().Model(&reference).Where("id=? and status = 1", id).Find(&reference).Error
20
+	return reference, err
21
+}