Browse Source

Merge branch 'master' of http://git.shengws.com/csx/XT_New

csx 3 years ago
parent
commit
c92f1181ef

+ 38 - 14
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -3,8 +3,11 @@ package new_mobile_api_controllers
3 3
 import (
4 4
 	"XT_New/controllers"
5 5
 	"XT_New/enums"
6
+	"XT_New/models"
6 7
 	"XT_New/service"
8
+	"encoding/json"
7 9
 	"fmt"
10
+	"time"
8 11
 )
9 12
 
10 13
 type CommonApiController struct {
@@ -49,19 +52,40 @@ func (this *CommonApiController) GetInspectionRange() {
49 52
 	})
50 53
 }
51 54
 
52
-func (this *CommonApiController) SaveInspection() {
55
+func (this *CommonApiController) SaveInspectionTwo() {
56
+	adminInfo := this.GetAdminUserInfo()
57
+	orgid := adminInfo.CurrentOrgId
53 58
 	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)
59
+	dataBody := make(map[string]interface{}, 0)
60
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
61
+	fmt.Println("err", err)
62
+	inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
63
+	fmt.Println("大项", inspectionmajor)
64
+	inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
65
+	fmt.Println("小项", inspectionMinor)
66
+	minrange := dataBody["min_range"].(string)
67
+	fmt.Println("minragne", minrange)
68
+	largerange := dataBody["large_range"].(string)
69
+	fmt.Println("largerange", largerange)
70
+	sort := dataBody["sort"].(string)
71
+	fmt.Println("sort", sort)
72
+	standard := models.XtQualityControlStandard{
73
+		InspectionMajor: inspectionmajor,
74
+		InspectionMinor: inspectionMinor,
75
+		MinRange:        minrange,
76
+		LargeRange:      largerange,
77
+		Sort:            sort,
78
+		UserOrgId:       orgid,
79
+		Status:          1,
80
+		CreatedTime:     time.Now().Unix(),
81
+	}
82
+	fmt.Println(standard)
83
+	err = service.SaveInspection(&standard)
84
+	if err != nil {
85
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
86
+		return
87
+	}
88
+	this.ServeSuccessJSON(map[string]interface{}{
89
+		"standard": standard,
90
+	})
67 91
 }

+ 3 - 1
controllers/new_mobile_api_controllers/common_api_router.go View File

@@ -1,6 +1,7 @@
1 1
 package new_mobile_api_controllers
2 2
 
3 3
 import (
4
+	"fmt"
4 5
 	"github.com/astaxie/beego"
5 6
 )
6 7
 
@@ -9,5 +10,6 @@ func CommonApiControllersRegisterRouters() {
9 10
 	beego.Router("/com/api/getinspectionmajor", &CommonApiController{}, "Get:GetInspectionMajor")
10 11
 	beego.Router("/com/api/getinspectionminor", &CommonApiController{}, "Get:GetInspectionMinor")
11 12
 	beego.Router("/com/api/getinspectionrange", &CommonApiController{}, "Get:GetInspectionRange")
12
-	beego.Router("/com/api/saveinspction", &CommonApiController{}, "Post:SaveInspection")
13
+	beego.Router("/com/api/saveinspection", &CommonApiController{}, "Post:SaveInspectionTwo")
14
+	fmt.Println("进来没有------")
13 15
 }

+ 17 - 0
models/common_models.go View File

@@ -0,0 +1,17 @@
1
+package models
2
+
3
+type XtQualityControlStandard struct {
4
+	InspectionMajor int64  `gorm:"column:inspection_major" json:"inspection_major" form:"inspection_major"`
5
+	InspectionMinor int64  `gorm:"column:inspection_minor" json:"inspection_minor" form:"inspection_minor"`
6
+	MinRange        string `gorm:"column:min_range" json:"min_range" form:"min_range"`
7
+	Sort            string `gorm:"column:sort" json:"sort" form:"sort"`
8
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
9
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
10
+	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
11
+	UpdatedTime     int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
12
+	LargeRange      string `gorm:"column:large_range" json:"large_range" form:"large_range"`
13
+}
14
+
15
+func (XtQualityControlStandard) TableName() string {
16
+	return "xt_quality_control_standard"
17
+}

+ 6 - 0
service/common_service.go View File

@@ -19,3 +19,9 @@ func GetInspectionRange(id int64) (models.XtInspectionReference, error) {
19 19
 	err := XTReadDB().Model(&reference).Where("id=? and status = 1", id).Find(&reference).Error
20 20
 	return reference, err
21 21
 }
22
+
23
+func SaveInspection(standard *models.XtQualityControlStandard) error {
24
+
25
+	err := XTWriteDB().Create(&standard).Error
26
+	return err
27
+}