1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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) SaveInspectionTwo() {
- adminInfo := this.GetAdminUserInfo()
- orgid := adminInfo.CurrentOrgId
- 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,
- })
- }
|