package new_mobile_api_controllers import ( "XT_New/controllers" "XT_New/enums" "XT_New/models" "XT_New/service" "encoding/json" "fmt" "time" ) type CommonApiController struct { controllers.BaseAuthAPIController } func (this *CommonApiController) GetInspectionMajor() { major, err := service.GetInspectionMajor(0) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError) return } this.ServeSuccessJSON(map[string]interface{}{ "inspection": major, }) } func (this *CommonApiController) GetInspectionMinor() { id, _ := this.GetInt64("id") fmt.Println("id----------------------------------------", id) minor, err := service.GetInspectionMinor(id) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError) return } this.ServeSuccessJSON(map[string]interface{}{ "inspection": minor, }) } func (this *CommonApiController) GetInspectionRange() { id, _ := this.GetInt64("id") fmt.Println("id", id) inspectionRange, err := service.GetInspectionRange(id) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError) return } this.ServeSuccessJSON(map[string]interface{}{ "inspectionRange": inspectionRange, }) } func (this *CommonApiController) SaveConfiguration() { adminInfo := this.GetAdminUserInfo() orgid := adminInfo.CurrentOrgId fmt.Println(orgid) fmt.Println("触发-------------------0") dataBody := make(map[string]interface{}, 0) err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody) fmt.Println("err", err) inspectionmajor := int64(dataBody["inspectionMajor"].(float64)) fmt.Println("大项", inspectionmajor) inspectionMinor := int64(dataBody["inspectionMinor"].(float64)) fmt.Println("小项", inspectionMinor) minrange := dataBody["min_range"].(string) fmt.Println("minragne", minrange) largerange := dataBody["large_range"].(string) fmt.Println("largerange", largerange) sort := dataBody["sort"].(string) fmt.Println("sort", sort) standard := models.XtQualityControlStandard{ InspectionMajor: inspectionmajor, InspectionMinor: inspectionMinor, MinRange: minrange, LargeRange: largerange, Sort: sort, UserOrgId: orgid, Status: 1, CreatedTime: time.Now().Unix(), } fmt.Println(standard) err = service.SaveInspection(&standard) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError) return } this.ServeSuccessJSON(map[string]interface{}{ "standard": standard, }) } func (this *CommonApiController) GetConfigurationlist() { adminUser := this.GetAdminUserInfo() orgid := adminUser.CurrentOrgId configurationlist, err := service.GetConfigurationlist(orgid) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError) return } this.ServeSuccessJSON(map[string]interface{}{ "configurationlist": configurationlist, }) }