| | |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormatList(c, code.Success, list, int(total)) |
| | | util.ResponseFormatList(c, code.Success, list, total) |
| | | } |
| | | |
| | | // Info |
| | | // @Tags 纤度登记 |
| | | // @Summary 纤度登记详情 |
| | | // @Produce application/json |
| | | // @Param id path string true "字典信息" |
| | | // @Success 200 {object} util.ResponseList{data=models.FinenessRegister} "成功" |
| | | // @Router /api-jl/v1/fineness/register/{id} [get] |
| | | func (slf FinenessController) Info(c *gin.Context) { |
| | | idStr := c.Param("id") |
| | | if idStr == "0" || idStr == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | |
| | | id := convertx.StringToUInt(idStr) |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | |
| | | info, err := models.NewFinenessRegisterSearch().SetID(id).SetPreload().First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, info) |
| | | } |
| | | |
| | | // Delete |
| | |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/register/{id}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度登记" |
| | | ], |
| | | "summary": "纤度登记详情", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "字典信息", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/models.FinenessRegister" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/register/{id}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度登记" |
| | | ], |
| | | "summary": "纤度登记详情", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "字典信息", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/models.FinenessRegister" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | summary: 纤度登记删除 |
| | | tags: |
| | | - 纤度登记 |
| | | get: |
| | | parameters: |
| | | - description: 字典信息 |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/models.FinenessRegister' |
| | | type: object |
| | | summary: 纤度登记详情 |
| | | tags: |
| | | - 纤度登记 |
| | | /api-jl/v1/system/dict: |
| | | get: |
| | | parameters: |
| | |
| | | Spec string `gorm:"type:varchar(255);not null;comment:规格" json:"spec"` //规格 |
| | | StartCircle uint8 `gorm:"type:varchar(255);not null;comment:开始回数" json:"startCircle"` //开始回数 |
| | | EndCircle uint8 `gorm:"type:varchar(255);not null;comment:结束回数" json:"endCircle"` //结束回数 |
| | | FinenessList []FinenessItem `gorm:"foreignkey:FinenessRegisterID" json:"finenessList"` |
| | | FinenessList []FinenessItem `gorm:"foreignkey:FinenessRegisterID;references:ID" json:"finenessList"` |
| | | } |
| | | FinenessRegisterSearch struct { |
| | | FinenessRegister |
| | |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetPreload() *FinenessRegisterSearch { |
| | | slf.Preload = true |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetID(id uint) *FinenessRegisterSearch { |
| | | slf.ID = id |
| | | return slf |
| | |
| | | db = db.Where("number = ?", slf.Number) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Model(&FinenessRegister{}).Preload("FinenessList") |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | finenessApi.GET("register", FinenessController.List) // 获取纤度登记列表 |
| | | finenessApi.DELETE("register/:id", FinenessController.Delete) // 删除纤度登记 |
| | | finenessApi.POST("register", FinenessController.Add) // 新增纤度登记 |
| | | finenessApi.GET("register/:id", FinenessController.Info) // 获取纤度登记详情 |
| | | } |
| | | |
| | | return r |