| | |
| | | } |
| | | } |
| | | |
| | | // GetSupplierByNumber 用编码查询Supplier |
| | | // @Tags Supplier |
| | | // @Summary 用编码查询Supplier |
| | | // @Security ApiKeyAuth |
| | | // @accept application/json |
| | | // @Produce application/json |
| | | // @Param number path string true "供应商编码" |
| | | // @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}" |
| | | // @Router /s/getSupplierByNumber/{number} [get] |
| | | func (sApi *SupplierApi) GetSupplierByNumber(c *gin.Context) { |
| | | number := c.Param("number") |
| | | if number == "" { |
| | | response.FailWithMessage("编码参数不能为空", c) |
| | | return |
| | | } |
| | | if res, err := sService.GetSupplierByNumber(number); err != nil { |
| | | global.GVA_LOG.Error("查询失败!", zap.Error(err)) |
| | | response.FailWithMessage("查询失败", c) |
| | | } else { |
| | | response.OkWithData(gin.H{"res": res}, c) |
| | | } |
| | | } |
| | | |
| | | // GetSupplierList 分页获取Supplier列表 |
| | | // @Tags Supplier |
| | | // @Summary 分页获取Supplier列表 |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/s/getSupplierByNumber/{number}": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Supplier" |
| | | ], |
| | | "summary": "用编码查询Supplier", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "供应商编码", |
| | | "name": "number", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", |
| | | "schema": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/s/getSupplierList": { |
| | | "get": { |
| | | "security": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/s/getSupplierByNumber/{number}": { |
| | | "get": { |
| | | "security": [ |
| | | { |
| | | "ApiKeyAuth": [] |
| | | } |
| | | ], |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "Supplier" |
| | | ], |
| | | "summary": "用编码查询Supplier", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "供应商编码", |
| | | "name": "number", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "{\"success\":true,\"data\":{},\"msg\":\"查询成功\"}", |
| | | "schema": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/s/getSupplierList": { |
| | | "get": { |
| | | "security": [ |
| | |
| | | summary: 用id查询Supplier |
| | | tags: |
| | | - Supplier |
| | | /s/getSupplierByNumber/{number}: |
| | | get: |
| | | consumes: |
| | | - application/json |
| | | parameters: |
| | | - description: 供应商编码 |
| | | in: path |
| | | name: number |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: '{"success":true,"data":{},"msg":"查询成功"}' |
| | | schema: |
| | | type: string |
| | | security: |
| | | - ApiKeyAuth: [] |
| | | summary: 用编码查询Supplier |
| | | tags: |
| | | - Supplier |
| | | /s/getSupplierList: |
| | | get: |
| | | consumes: |
| | |
| | | sRouter.POST("changeSupplierStatus", sApi.ChangeSupplierStatus) // 更新Supplier状态 |
| | | } |
| | | { |
| | | sRouterWithoutRecord.GET("findSupplier", sApi.FindSupplier) // 根据ID获取Supplier |
| | | sRouterWithoutRecord.GET("getSupplierList", sApi.GetSupplierList) // 获取Supplier列表 |
| | | sRouterWithoutRecord.GET("findSupplier", sApi.FindSupplier) // 根据ID获取Supplier |
| | | sRouterWithoutRecord.GET("getSupplierByNumber/:number", sApi.GetSupplierByNumber) // 用编码查询Supplier |
| | | sRouterWithoutRecord.GET("getSupplierList", sApi.GetSupplierList) // 获取Supplier列表 |
| | | } |
| | | } |
| | |
| | | |
| | | // GetSupplier 根据id获取Supplier记录 |
| | | func (sService *SupplierService) GetSupplier(id uint) (s test.Supplier, err error) { |
| | | err = global.GVA_DB.Where("id = ?", id).First(&s).Error |
| | | err = global.GVA_DB.Model(&test.Supplier{}).Where("id = ?", id).First(&s).Error |
| | | return |
| | | } |
| | | |
| | | // GetSupplierByNumber 根据编码获取Supplier记录 |
| | | func (sService *SupplierService) GetSupplierByNumber(number string) (s test.Supplier, err error) { |
| | | err = global.GVA_DB.Where("number = ?", number).First(&s).Error |
| | | err = global.GVA_DB.Model(&test.Supplier{}).Where("number = ?", number).Preload("Contract").First(&s).Error |
| | | return |
| | | } |
| | | |