zhangqian
2024-02-29 0f7dbc99a9e0c0678d458e2f8f60df52f7fdb3d1
添加纤度登记接口支持修改纤度登记
7个文件已修改
377 ■■■■ 已修改文件
controllers/fineness.go 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/request/fineness.go 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/fineness.go 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/fineness_item.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/fineness.go
@@ -2,6 +2,7 @@
import (
    "github.com/gin-gonic/gin"
    "gorm.io/gorm"
    "silkserver/controllers/request"
    "silkserver/extend/code"
    "silkserver/extend/util"
@@ -35,12 +36,23 @@
        util.ResponseFormat(c, code.RequestParamError, err.Error())
        return
    }
    if err := models.NewFinenessRegisterSearch().Create(&params); err != nil {
        util.ResponseFormat(c, code.SaveFail, "插入失败")
        return
    err := models.WithTransaction(func(db *gorm.DB) error {
        search := models.NewFinenessRegisterSearch().SetOrm(db)
        if params.ID != 0 {
            if err := models.NewFinenessItemSearch().SetOrm(db).SetFinenessRegisterID(params.ID).Delete(); err != nil {
                return err
            }
            return search.Save(&params)
        } else {
            return search.Create(&params)
        }
    })
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "保存失败")
    }
    util.ResponseFormat(c, code.Success, "添加成功")
    util.ResponseFormat(c, code.Success, "保存成功")
}
func (slf FinenessController) ParamsCheck(params models.FinenessRegister) (err error) {
controllers/request/fineness.go
@@ -1,18 +1,22 @@
package request
import "github.com/shopspring/decimal"
import (
    "github.com/shopspring/decimal"
)
type AddFinenessRegister struct {
    Number        string         `gorm:"type:varchar(255);not null;comment:编号" json:"number"`        //编号
    FinishDate    string         `gorm:"type:varchar(255);not null;comment:落丝时间" json:"finishDate"`  //落丝时间
    Workshop      string         `gorm:"type:varchar(255);not null;comment:车间" json:"name"`          //车间
    WorkshopGroup string         `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"` //车组
    Market        string         `gorm:"type:varchar(255);not null;comment:庄口" json:"market"`        //庄口
    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 `json:"finenessList"`
    Sum           FinenessItem   `json:"sum"`
    ID            uint            `json:"id"`                                                             //id 添加时传0
    Number        string          `gorm:"type:varchar(255);not null;comment:编号" json:"number"`          //编号
    FinishDate    string          `gorm:"type:varchar(255);not null;comment:落丝时间" json:"finishDate"`  //落丝时间
    Workshop      string          `gorm:"type:varchar(255);not null;comment:车间" json:"name"`            //车间
    WorkshopGroup string          `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"`   //车组
    Market        string          `gorm:"type:varchar(255);not null;comment:庄口" json:"market"`          //庄口
    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  `json:"finenessList"`
    SumFineness   decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计纤度" json:"sumFineness"`
    SumQuantity   decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计数量" json:"sumQuantity"`
}
type FinenessItem struct {
docs/docs.go
@@ -313,6 +313,66 @@
                    }
                }
            }
        },
        "/api-jl/v1/system/getPriceStandardList": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "系统设置/生丝定价标准"
                ],
                "summary": "获取生丝定价标准",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.RawSilkPriceStandard"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-jl/v1/system/savePriceStandard": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "系统设置/生丝定价标准"
                ],
                "summary": "保存生丝定价标准",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.RawSilkPriceStandard"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
@@ -464,11 +524,49 @@
                    "description": "开始回数",
                    "type": "integer"
                },
                "sumFineness": {
                    "type": "number"
                },
                "sumQuantity": {
                    "type": "number"
                },
                "updatedAt": {
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "string"
                }
            }
        },
        "models.RawSilkPriceStandard": {
            "type": "object",
            "properties": {
                "createdAt": {
                    "type": "string"
                },
                "deletedAt": {
                    "$ref": "#/definitions/gorm.DeletedAt"
                },
                "id": {
                    "type": "integer"
                },
                "marketNumber": {
                    "type": "string"
                },
                "notes": {
                    "type": "string"
                },
                "payStandard": {
                    "type": "number"
                },
                "rawSilkGradeNumber": {
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                },
                "updatedAt": {
                    "type": "string"
                }
            }
@@ -515,6 +613,10 @@
                    "description": "落丝时间",
                    "type": "string"
                },
                "id": {
                    "description": "id 添加时传0",
                    "type": "integer"
                },
                "market": {
                    "description": "庄口",
                    "type": "string"
@@ -535,8 +637,11 @@
                    "description": "开始回数",
                    "type": "integer"
                },
                "sum": {
                    "$ref": "#/definitions/request.FinenessItem"
                "sumFineness": {
                    "type": "number"
                },
                "sumQuantity": {
                    "type": "number"
                },
                "workshopGroup": {
                    "description": "车组",
@@ -617,9 +722,7 @@
                "pageSize": {
                    "type": "integer"
                },
                "total": {
                    "type": "integer"
                }
                "total": {}
            }
        }
    }
docs/swagger.json
@@ -301,6 +301,66 @@
                    }
                }
            }
        },
        "/api-jl/v1/system/getPriceStandardList": {
            "get": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "系统设置/生丝定价标准"
                ],
                "summary": "获取生丝定价标准",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.RawSilkPriceStandard"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-jl/v1/system/savePriceStandard": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "系统设置/生丝定价标准"
                ],
                "summary": "保存生丝定价标准",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.RawSilkPriceStandard"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
@@ -452,11 +512,49 @@
                    "description": "开始回数",
                    "type": "integer"
                },
                "sumFineness": {
                    "type": "number"
                },
                "sumQuantity": {
                    "type": "number"
                },
                "updatedAt": {
                    "type": "string"
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "string"
                }
            }
        },
        "models.RawSilkPriceStandard": {
            "type": "object",
            "properties": {
                "createdAt": {
                    "type": "string"
                },
                "deletedAt": {
                    "$ref": "#/definitions/gorm.DeletedAt"
                },
                "id": {
                    "type": "integer"
                },
                "marketNumber": {
                    "type": "string"
                },
                "notes": {
                    "type": "string"
                },
                "payStandard": {
                    "type": "number"
                },
                "rawSilkGradeNumber": {
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                },
                "updatedAt": {
                    "type": "string"
                }
            }
@@ -503,6 +601,10 @@
                    "description": "落丝时间",
                    "type": "string"
                },
                "id": {
                    "description": "id 添加时传0",
                    "type": "integer"
                },
                "market": {
                    "description": "庄口",
                    "type": "string"
@@ -523,8 +625,11 @@
                    "description": "开始回数",
                    "type": "integer"
                },
                "sum": {
                    "$ref": "#/definitions/request.FinenessItem"
                "sumFineness": {
                    "type": "number"
                },
                "sumQuantity": {
                    "type": "number"
                },
                "workshopGroup": {
                    "description": "车组",
@@ -605,9 +710,7 @@
                "pageSize": {
                    "type": "integer"
                },
                "total": {
                    "type": "integer"
                }
                "total": {}
            }
        }
    }
docs/swagger.yaml
@@ -102,10 +102,35 @@
      startCircle:
        description: 开始回数
        type: integer
      sumFineness:
        type: number
      sumQuantity:
        type: number
      updatedAt:
        type: string
      workshopGroup:
        description: 车组
        type: string
    type: object
  models.RawSilkPriceStandard:
    properties:
      createdAt:
        type: string
      deletedAt:
        $ref: '#/definitions/gorm.DeletedAt'
      id:
        type: integer
      marketNumber:
        type: string
      notes:
        type: string
      payStandard:
        type: number
      rawSilkGradeNumber:
        type: string
      unit:
        type: string
      updatedAt:
        type: string
    type: object
  request.AddDict:
@@ -136,6 +161,9 @@
      finishDate:
        description: 落丝时间
        type: string
      id:
        description: id 添加时传0
        type: integer
      market:
        description: 庄口
        type: string
@@ -151,8 +179,10 @@
      startCircle:
        description: 开始回数
        type: integer
      sum:
        $ref: '#/definitions/request.FinenessItem'
      sumFineness:
        type: number
      sumQuantity:
        type: number
      workshopGroup:
        description: 车组
        type: string
@@ -205,8 +235,7 @@
        type: integer
      pageSize:
        type: integer
      total:
        type: integer
      total: {}
    type: object
info:
  contact: {}
@@ -398,4 +427,42 @@
      summary: 删除字典
      tags:
      - 系统设置/字典
  /api-jl/v1/system/getPriceStandardList:
    get:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/models.RawSilkPriceStandard'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 获取生丝定价标准
      tags:
      - 系统设置/生丝定价标准
  /api-jl/v1/system/savePriceStandard:
    post:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/models.RawSilkPriceStandard'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 保存生丝定价标准
      tags:
      - 系统设置/生丝定价标准
swagger: "2.0"
models/fineness.go
@@ -2,6 +2,7 @@
import (
    "fmt"
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
    "silkserver/pkg/mysqlx"
)
@@ -10,15 +11,17 @@
    // FinenessRegister 纤度登记
    FinenessRegister struct {
        gorm.Model
        Number        string         `gorm:"type:varchar(255);not null;comment:编号" json:"number"`        //编号
        FinishDate    string         `gorm:"type:varchar(255);not null;comment:落丝时间" json:"finishDate"`  //落丝时间
        Workshop      string         `gorm:"type:varchar(255);not null;comment:车间" json:"name"`          //车间
        WorkshopGroup string         `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"` //车组
        Market        string         `gorm:"type:varchar(255);not null;comment:庄口" json:"market"`        //庄口
        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;references:ID" json:"finenessList"`
        Number        string          `gorm:"type:varchar(255);not null;comment:编号" json:"number"`        //编号
        FinishDate    string          `gorm:"type:varchar(255);not null;comment:落丝时间" json:"finishDate"`  //落丝时间
        Workshop      string          `gorm:"type:varchar(255);not null;comment:车间" json:"name"`          //车间
        WorkshopGroup string          `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"` //车组
        Market        string          `gorm:"type:varchar(255);not null;comment:庄口" json:"market"`        //庄口
        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;references:ID" json:"finenessList"`
        SumFineness   decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计纤度" json:"sumFineness"`
        SumQuantity   decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计数量" json:"sumQuantity"`
    }
    FinenessRegisterSearch struct {
        FinenessRegister
models/fineness_item.go
@@ -55,6 +55,11 @@
    return slf
}
func (slf *FinenessItemSearch) SetFinenessRegisterID(id uint) *FinenessItemSearch {
    slf.FinenessRegisterID = id
    return slf
}
func (slf *FinenessItemSearch) build() *gorm.DB {
    var db = slf.Orm.Table(slf.TableName())
@@ -66,6 +71,10 @@
        db = db.Order(slf.Order)
    }
    if slf.FinenessRegisterID != 0 {
        db = db.Where("fineness_register_id = ?", slf.FinenessRegisterID)
    }
    return db
}