1个文件已删除
1个文件已添加
2 文件已重命名
6个文件已修改
| | |
| | | package constvar |
| | | |
| | | type BaseJobType int |
| | | type BaseOperationType int |
| | | |
| | | const ( |
| | | BaseJobTypeIncoming BaseJobType = iota + 1 //收货 |
| | | BaseJobTypeOutgoing //交货 |
| | | BaseJobTypeInternal //内部调拨 |
| | | BaseOperationTypeIncoming BaseOperationType = iota + 1 //收货 |
| | | BaseOperationTypeOutgoing //交货 |
| | | BaseOperationTypeInternal //内部调拨 |
| | | ) |
| | | |
| | | func (slf BaseJobType) IsValid() bool { |
| | | return slf == BaseJobTypeIncoming || |
| | | slf == BaseJobTypeOutgoing || |
| | | slf == BaseJobTypeInternal |
| | | func (slf BaseOperationType) IsValid() bool { |
| | | return slf == BaseOperationTypeIncoming || |
| | | slf == BaseOperationTypeOutgoing || |
| | | slf == BaseOperationTypeInternal |
| | | } |
| | | |
| | | type ReservationMethod int |
File was renamed from controllers/job_type.go |
| | |
| | | "wms/request" |
| | | ) |
| | | |
| | | type JobTypeController struct{} |
| | | type OperationTypeController struct{} |
| | | |
| | | // Add |
| | | // @Tags 作业类型 |
| | | // @Summary 添加作业类型 |
| | | // @Produce application/json |
| | | // @Param object body request.AddJobType true "作业类型信息" |
| | | // @Param object body request.AddOperationType true "作业类型信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/warehouse/jobType [post] |
| | | func (slf JobTypeController) Add(c *gin.Context) { |
| | | var reqParams request.AddJobType |
| | | var params models.JobType |
| | | // @Router /api-wms/v1/warehouse/operationType [post] |
| | | func (slf OperationTypeController) Add(c *gin.Context) { |
| | | var reqParams request.AddOperationType |
| | | var params models.OperationType |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | if err := models.NewJobTypeSearch().Create(¶ms); err != nil { |
| | | logx.Errorf("JobType create err: %v", err) |
| | | if err := models.NewOperationTypeSearch().Create(¶ms); err != nil { |
| | | logx.Errorf("OperationType create err: %v", err) |
| | | util.ResponseFormat(c, code.SaveFail, "插入失败") |
| | | return |
| | | } |
| | |
| | | // @Tags 作业类型 |
| | | // @Summary 编辑作业类型 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateJobType true "作业类型信息" |
| | | // @Param object body request.UpdateOperationType true "作业类型信息" |
| | | // @Param id path string true "作业类型id" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/warehouse/jobType/{id} [put] |
| | | func (slf JobTypeController) Update(c *gin.Context) { |
| | | // @Router /api-wms/v1/warehouse/operationType/{id} [put] |
| | | func (slf OperationTypeController) Update(c *gin.Context) { |
| | | id := cast.ToUint(c.Param("id")) |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | var ( |
| | | reqParams request.UpdateJobType |
| | | params models.JobType |
| | | reqParams request.UpdateOperationType |
| | | params models.OperationType |
| | | ) |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("参数解析失败: %v"+err.Error())) |
| | |
| | | return |
| | | } |
| | | |
| | | err := models.NewJobTypeSearch().SetID(params.ID).Update(¶ms) |
| | | err := models.NewOperationTypeSearch().SetID(params.ID).Update(¶ms) |
| | | |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "修改失败") |
| | |
| | | util.ResponseFormat(c, code.UpdateSuccess, "更新成功") |
| | | } |
| | | |
| | | func (slf JobTypeController) ParamsCheck(params models.JobType) (err error) { |
| | | func (slf OperationTypeController) ParamsCheck(params models.OperationType) (err error) { |
| | | if params.ID != 0 { |
| | | _, err = models.NewJobTypeSearch().SetID(params.ID).First() |
| | | _, err = models.NewOperationTypeSearch().SetID(params.ID).First() |
| | | if err == gorm.ErrRecordNotFound { |
| | | return errors.New("记录不存在") |
| | | } |
| | |
| | | // @Tags 作业类型 |
| | | // @Summary 查询作业类型列表 |
| | | // @Produce application/json |
| | | // @Param object query request.GetJobTypeList true "查询参数" |
| | | // @Success 200 {object} util.ResponseList{data=[]models.JobType} "成功" |
| | | // @Router /api-wms/v1/warehouse/jobType [get] |
| | | func (slf JobTypeController) List(c *gin.Context) { |
| | | var params request.GetJobTypeList |
| | | // @Param object query request.GetOperationTypeList true "查询参数" |
| | | // @Success 200 {object} util.ResponseList{data=[]models.OperationType} "成功" |
| | | // @Router /api-wms/v1/warehouse/operationType [get] |
| | | func (slf OperationTypeController) List(c *gin.Context) { |
| | | var params request.GetOperationTypeList |
| | | if err := c.ShouldBindQuery(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | list, total, err := models.NewJobTypeSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetOrder("id desc").SetPreload(true).Find() |
| | | list, total, err := models.NewOperationTypeSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetOrder("id desc").SetPreload(true).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | |
| | | // @Produce application/json |
| | | // @Param id path string true "作业类型id" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/warehouse/jobType/{id} [delete] |
| | | func (slf JobTypeController) Delete(c *gin.Context) { |
| | | // @Router /api-wms/v1/warehouse/operationType/{id} [delete] |
| | | func (slf OperationTypeController) Delete(c *gin.Context) { |
| | | id := cast.ToUint(c.Param("id")) |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | |
| | | err := models.NewJobTypeSearch().SetID(id).Delete() |
| | | err := models.NewOperationTypeSearch().SetID(id).Delete() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除失败") |
| | | return |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/jobType": { |
| | | "/api-wms/v1/warehouse/operationType": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.JobType" |
| | | "$ref": "#/definitions/models.OperationType" |
| | | } |
| | | } |
| | | } |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddJobType" |
| | | "$ref": "#/definitions/request.AddOperationType" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/jobType/{id}": { |
| | | "/api-wms/v1/warehouse/operationType/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateJobType" |
| | | "$ref": "#/definitions/request.UpdateOperationType" |
| | | } |
| | | }, |
| | | { |
| | |
| | | } |
| | | }, |
| | | "definitions": { |
| | | "constvar.BaseJobType": { |
| | | "constvar.BaseOperationType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "BaseJobTypeIncoming": "收货", |
| | | "BaseJobTypeInternal": "内部调拨", |
| | | "BaseJobTypeOutgoing": "交货" |
| | | "BaseOperationTypeIncoming": "收货", |
| | | "BaseOperationTypeInternal": "内部调拨", |
| | | "BaseOperationTypeOutgoing": "交货" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "BaseJobTypeIncoming", |
| | | "BaseJobTypeOutgoing", |
| | | "BaseJobTypeInternal" |
| | | "BaseOperationTypeIncoming", |
| | | "BaseOperationTypeOutgoing", |
| | | "BaseOperationTypeInternal" |
| | | ] |
| | | }, |
| | | "constvar.ReservationMethod": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "models.JobType": { |
| | | "models.Location": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createTime": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "位置名称", |
| | | "type": "string" |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "models.OperationType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ReservationDaysBeforePriority": { |
| | | "description": "在优先级的前几天", |
| | | "type": "integer" |
| | | }, |
| | | "baseJobType": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseJobType" |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "returnJobType": { |
| | | "returnOperationType": { |
| | | "description": "退货类型名称", |
| | | "type": "string" |
| | | }, |
| | | "returnJobTypeID": { |
| | | "returnOperationTypeID": { |
| | | "description": "退货类型ID", |
| | | "type": "integer" |
| | | }, |
| | |
| | | "warehouseId": { |
| | | "description": "仓库id", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "models.Location": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createTime": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "位置名称", |
| | | "type": "string" |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddJobType": { |
| | | "request.AddOperationType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ReservationDaysBeforePriority": { |
| | | "description": "在优先级的前几天", |
| | | "type": "integer" |
| | | }, |
| | | "baseJobType": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseJobType" |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "returnJobTypeID": { |
| | | "returnOperationTypeID": { |
| | | "description": "退货类型ID", |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateJobType": { |
| | | "request.UpdateOperationType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ReservationDaysBeforePriority": { |
| | | "description": "在优先级的前几天", |
| | | "type": "integer" |
| | | }, |
| | | "baseJobType": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseJobType" |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "returnJobTypeID": { |
| | | "returnOperationTypeID": { |
| | | "description": "退货类型ID", |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/jobType": { |
| | | "/api-wms/v1/warehouse/operationType": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.JobType" |
| | | "$ref": "#/definitions/models.OperationType" |
| | | } |
| | | } |
| | | } |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddJobType" |
| | | "$ref": "#/definitions/request.AddOperationType" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/jobType/{id}": { |
| | | "/api-wms/v1/warehouse/operationType/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateJobType" |
| | | "$ref": "#/definitions/request.UpdateOperationType" |
| | | } |
| | | }, |
| | | { |
| | |
| | | } |
| | | }, |
| | | "definitions": { |
| | | "constvar.BaseJobType": { |
| | | "constvar.BaseOperationType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "BaseJobTypeIncoming": "收货", |
| | | "BaseJobTypeInternal": "内部调拨", |
| | | "BaseJobTypeOutgoing": "交货" |
| | | "BaseOperationTypeIncoming": "收货", |
| | | "BaseOperationTypeInternal": "内部调拨", |
| | | "BaseOperationTypeOutgoing": "交货" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "BaseJobTypeIncoming", |
| | | "BaseJobTypeOutgoing", |
| | | "BaseJobTypeInternal" |
| | | "BaseOperationTypeIncoming", |
| | | "BaseOperationTypeOutgoing", |
| | | "BaseOperationTypeInternal" |
| | | ] |
| | | }, |
| | | "constvar.ReservationMethod": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "models.JobType": { |
| | | "models.Location": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createTime": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "位置名称", |
| | | "type": "string" |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "models.OperationType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ReservationDaysBeforePriority": { |
| | | "description": "在优先级的前几天", |
| | | "type": "integer" |
| | | }, |
| | | "baseJobType": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseJobType" |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "returnJobType": { |
| | | "returnOperationType": { |
| | | "description": "退货类型名称", |
| | | "type": "string" |
| | | }, |
| | | "returnJobTypeID": { |
| | | "returnOperationTypeID": { |
| | | "description": "退货类型ID", |
| | | "type": "integer" |
| | | }, |
| | |
| | | "warehouseId": { |
| | | "description": "仓库id", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "models.Location": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createTime": { |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "位置名称", |
| | | "type": "string" |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddJobType": { |
| | | "request.AddOperationType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ReservationDaysBeforePriority": { |
| | | "description": "在优先级的前几天", |
| | | "type": "integer" |
| | | }, |
| | | "baseJobType": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseJobType" |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "returnJobTypeID": { |
| | | "returnOperationTypeID": { |
| | | "description": "退货类型ID", |
| | | "type": "integer" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateJobType": { |
| | | "request.UpdateOperationType": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ReservationDaysBeforePriority": { |
| | | "description": "在优先级的前几天", |
| | | "type": "integer" |
| | | }, |
| | | "baseJobType": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseJobType" |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | |
| | | } |
| | | ] |
| | | }, |
| | | "returnJobTypeID": { |
| | | "returnOperationTypeID": { |
| | | "description": "退货类型ID", |
| | | "type": "integer" |
| | | }, |
| | |
| | | definitions: |
| | | constvar.BaseJobType: |
| | | constvar.BaseOperationType: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | type: integer |
| | | x-enum-comments: |
| | | BaseJobTypeIncoming: 收货 |
| | | BaseJobTypeInternal: 内部调拨 |
| | | BaseJobTypeOutgoing: 交货 |
| | | BaseOperationTypeIncoming: 收货 |
| | | BaseOperationTypeInternal: 内部调拨 |
| | | BaseOperationTypeOutgoing: 交货 |
| | | x-enum-varnames: |
| | | - BaseJobTypeIncoming |
| | | - BaseJobTypeOutgoing |
| | | - BaseJobTypeInternal |
| | | - BaseOperationTypeIncoming |
| | | - BaseOperationTypeOutgoing |
| | | - BaseOperationTypeInternal |
| | | constvar.ReservationMethod: |
| | | enum: |
| | | - 1 |
| | |
| | | description: 排序 |
| | | type: integer |
| | | type: object |
| | | models.JobType: |
| | | models.Location: |
| | | properties: |
| | | createTime: |
| | | type: string |
| | | id: |
| | | type: integer |
| | | name: |
| | | description: 位置名称 |
| | | type: string |
| | | updateTime: |
| | | type: string |
| | | type: object |
| | | models.OperationType: |
| | | properties: |
| | | ReservationDaysBeforePriority: |
| | | description: 在优先级的前几天 |
| | | type: integer |
| | | baseJobType: |
| | | baseOperationType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.BaseJobType' |
| | | - $ref: '#/definitions/constvar.BaseOperationType' |
| | | description: 基础作业类型 |
| | | company: |
| | | allOf: |
| | |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.ReservationMethod' |
| | | description: 保留方式 |
| | | returnJobType: |
| | | returnOperationType: |
| | | description: 退货类型名称 |
| | | type: string |
| | | returnJobTypeID: |
| | | returnOperationTypeID: |
| | | description: 退货类型ID |
| | | type: integer |
| | | showOperations: |
| | |
| | | warehouseId: |
| | | description: 仓库id |
| | | type: integer |
| | | type: object |
| | | models.Location: |
| | | properties: |
| | | createTime: |
| | | type: string |
| | | id: |
| | | type: integer |
| | | name: |
| | | description: 位置名称 |
| | | type: string |
| | | updateTime: |
| | | type: string |
| | | type: object |
| | | models.Warehouse: |
| | | properties: |
| | |
| | | description: 备注 |
| | | type: string |
| | | type: object |
| | | request.AddJobType: |
| | | request.AddOperationType: |
| | | properties: |
| | | ReservationDaysBeforePriority: |
| | | description: 在优先级的前几天 |
| | | type: integer |
| | | baseJobType: |
| | | baseOperationType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.BaseJobType' |
| | | - $ref: '#/definitions/constvar.BaseOperationType' |
| | | description: 基础作业类型 |
| | | companyId: |
| | | description: 公司id |
| | |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.ReservationMethod' |
| | | description: 保留方式 |
| | | returnJobTypeID: |
| | | returnOperationTypeID: |
| | | description: 退货类型ID |
| | | type: integer |
| | | showOperations: |
| | |
| | | description: 备注 |
| | | type: string |
| | | type: object |
| | | request.UpdateJobType: |
| | | request.UpdateOperationType: |
| | | properties: |
| | | ReservationDaysBeforePriority: |
| | | description: 在优先级的前几天 |
| | | type: integer |
| | | baseJobType: |
| | | baseOperationType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.BaseJobType' |
| | | - $ref: '#/definitions/constvar.BaseOperationType' |
| | | description: 基础作业类型 |
| | | companyId: |
| | | description: 公司id |
| | |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.ReservationMethod' |
| | | description: 保留方式 |
| | | returnJobTypeID: |
| | | returnOperationTypeID: |
| | | description: 退货类型ID |
| | | type: integer |
| | | showOperations: |
| | |
| | | summary: 编辑公司 |
| | | tags: |
| | | - 公司 |
| | | /api-wms/v1/warehouse/jobType: |
| | | /api-wms/v1/warehouse/operationType: |
| | | get: |
| | | parameters: |
| | | - in: query |
| | |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/models.JobType' |
| | | $ref: '#/definitions/models.OperationType' |
| | | type: array |
| | | type: object |
| | | summary: 查询作业类型列表 |
| | |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddJobType' |
| | | $ref: '#/definitions/request.AddOperationType' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | summary: 添加作业类型 |
| | | tags: |
| | | - 作业类型 |
| | | /api-wms/v1/warehouse/jobType/{id}: |
| | | /api-wms/v1/warehouse/operationType/{id}: |
| | | delete: |
| | | parameters: |
| | | - description: 作业类型id |
| | |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateJobType' |
| | | $ref: '#/definitions/request.UpdateOperationType' |
| | | - description: 作业类型id |
| | | in: path |
| | | name: id |
| | |
| | | err := db.AutoMigrate( |
| | | Company{}, |
| | | Warehouse{}, |
| | | JobType{}, |
| | | OperationType{}, |
| | | Location{}, |
| | | ) |
| | | return err |
File was renamed from models/job_type.go |
| | |
| | | ) |
| | | |
| | | type ( |
| | | // JobType 作业类型 |
| | | JobType struct { |
| | | // OperationType 作业类型 |
| | | OperationType struct { |
| | | WmsModel |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:仓库名称"` //仓库名称 |
| | | BaseJobType constvar.BaseJobType `json:"baseJobType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型 |
| | | CompanyId int `json:"companyId" gorm:"type:int;not null;comment:公司id"` //公司id |
| | | Company Company `json:"company" gorm:"foreignKey:CompanyId"` //公司 |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` //仓库id |
| | | Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"` //仓库 |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:仓库名称"` //仓库名称 |
| | | BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型 |
| | | CompanyId int `json:"companyId" gorm:"type:int;not null;comment:公司id"` //公司id |
| | | Company Company `json:"company" gorm:"foreignKey:CompanyId"` //公司 |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` //仓库id |
| | | Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"` //仓库 |
| | | |
| | | DefaultLocationSrcId int `json:"defaultLocationSrcId" gorm:"type:int;not null;comment:默认源位置id"` //默认源位置id |
| | | DefaultLocationSrc Location `json:"defaultLocationSrc" gorm:"foreignKey:DefaultLocationSrcId"` //默认源位置 |
| | |
| | | ReservationDaysBeforePriority int `json:"ReservationDaysBeforePriority" gorm:"type:int;"` //在优先级的前几天 |
| | | ShowOperations bool `json:"showOperations" gorm:"column:show_operations;type:int"` //显示作业详情 |
| | | CreateBackorder constvar.WhetherType `json:"createBackorder" gorm:"column:create_backorder"` //创建欠单 |
| | | ReturnJobTypeID int `json:"returnJobTypeID" gorm:"column:return_job_type_id"` //退货类型ID |
| | | ReturnJobType string `json:"returnJobType" gorm:"-"` //退货类型名称 |
| | | ReturnOperationTypeID int `json:"returnOperationTypeID" gorm:"column:return_job_type_id"` //退货类型ID |
| | | ReturnOperationType string `json:"returnOperationType" gorm:"-"` //退货类型名称 |
| | | } |
| | | |
| | | JobTypeSearch struct { |
| | | JobType |
| | | OperationTypeSearch struct { |
| | | OperationType |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | |
| | | } |
| | | ) |
| | | |
| | | func (slf *JobType) TableName() string { |
| | | func (slf *OperationType) TableName() string { |
| | | return "job_type" |
| | | } |
| | | |
| | | func NewJobTypeSearch() *JobTypeSearch { |
| | | return &JobTypeSearch{Orm: mysqlx.GetDB()} |
| | | func NewOperationTypeSearch() *OperationTypeSearch { |
| | | return &OperationTypeSearch{Orm: mysqlx.GetDB()} |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) SetOrm(tx *gorm.DB) *JobTypeSearch { |
| | | func (slf *OperationTypeSearch) SetOrm(tx *gorm.DB) *OperationTypeSearch { |
| | | slf.Orm = tx |
| | | return slf |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) SetPage(page, size int) *JobTypeSearch { |
| | | func (slf *OperationTypeSearch) SetPage(page, size int) *OperationTypeSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) SetOrder(order string) *JobTypeSearch { |
| | | func (slf *OperationTypeSearch) SetOrder(order string) *OperationTypeSearch { |
| | | slf.Order = order |
| | | return slf |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) SetID(id uint) *JobTypeSearch { |
| | | func (slf *OperationTypeSearch) SetID(id uint) *OperationTypeSearch { |
| | | slf.ID = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) SetName(name string) *JobTypeSearch { |
| | | func (slf *OperationTypeSearch) SetName(name string) *OperationTypeSearch { |
| | | slf.Name = name |
| | | return slf |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) SetKeyword(keyword string) *JobTypeSearch { |
| | | func (slf *OperationTypeSearch) SetKeyword(keyword string) *OperationTypeSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) SetPreload(preload bool) *JobTypeSearch { |
| | | func (slf *OperationTypeSearch) SetPreload(preload bool) *OperationTypeSearch { |
| | | slf.Preload = preload |
| | | return slf |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&JobType{}) |
| | | func (slf *OperationTypeSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&OperationType{}) |
| | | |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | |
| | | } |
| | | |
| | | // Create 单条插入 |
| | | func (slf *JobTypeSearch) Create(record *JobType) error { |
| | | func (slf *OperationTypeSearch) Create(record *OperationType) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Create(record).Error; err != nil { |
| | |
| | | } |
| | | |
| | | // CreateBatch 批量插入 |
| | | func (slf *JobTypeSearch) CreateBatch(records []*JobType) error { |
| | | func (slf *OperationTypeSearch) CreateBatch(records []*OperationType) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Create(&records).Error; err != nil { |
| | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) Update(record *JobType) error { |
| | | func (slf *OperationTypeSearch) Update(record *OperationType) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { |
| | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | func (slf *OperationTypeSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.build() |
| | | ) |
| | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error { |
| | | func (slf *OperationTypeSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()).Where(query, args...) |
| | | ) |
| | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) Delete() error { |
| | | func (slf *OperationTypeSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&JobType{}).Error |
| | | return db.Delete(&OperationType{}).Error |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) First() (*JobType, error) { |
| | | func (slf *OperationTypeSearch) First() (*OperationType, error) { |
| | | var ( |
| | | record = new(JobType) |
| | | record = new(OperationType) |
| | | db = slf.build() |
| | | ) |
| | | |
| | |
| | | return record, nil |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) Find() ([]*JobType, int64, error) { |
| | | func (slf *OperationTypeSearch) Find() ([]*OperationType, int64, error) { |
| | | var ( |
| | | records = make([]*JobType, 0) |
| | | records = make([]*OperationType, 0) |
| | | total int64 |
| | | db = slf.build() |
| | | ) |
| | |
| | | return records, total, nil |
| | | } |
| | | |
| | | func (slf *JobTypeSearch) FindNotTotal() ([]*JobType, error) { |
| | | func (slf *OperationTypeSearch) FindNotTotal() ([]*OperationType, error) { |
| | | var ( |
| | | records = make([]*JobType, 0) |
| | | records = make([]*OperationType, 0) |
| | | db = slf.build() |
| | | ) |
| | | |
| | |
| | | } |
| | | |
| | | // FindByQuery 指定条件查询. |
| | | func (slf *JobTypeSearch) FindByQuery(query string, args []interface{}) ([]*JobType, int64, error) { |
| | | func (slf *OperationTypeSearch) FindByQuery(query string, args []interface{}) ([]*OperationType, int64, error) { |
| | | var ( |
| | | records = make([]*JobType, 0) |
| | | records = make([]*OperationType, 0) |
| | | total int64 |
| | | db = slf.Orm.Table(slf.TableName()).Where(query, args...) |
| | | ) |
| | |
| | | } |
| | | |
| | | // FindByQueryNotTotal 指定条件查询&不查询总条数. |
| | | func (slf *JobTypeSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*JobType, error) { |
| | | func (slf *OperationTypeSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*OperationType, error) { |
| | | var ( |
| | | records = make([]*JobType, 0) |
| | | records = make([]*OperationType, 0) |
| | | db = slf.Orm.Table(slf.TableName()).Where(query, args...) |
| | | ) |
| | | |
New file |
| | |
| | | package request |
| | | |
| | | import "wms/constvar" |
| | | |
| | | type GetOperationTypeList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | | |
| | | type AddOperationType struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:仓库名称"` //仓库名称 |
| | | BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型 |
| | | CompanyId int `json:"companyId" gorm:"type:int;not null;comment:公司id"` //公司id |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` //仓库id |
| | | |
| | | DefaultLocationSrcId int `json:"defaultLocationSrcId" gorm:"type:int;not null;comment:默认源位置id"` //默认源位置id |
| | | DefaultLocationDestId int `json:"defaultLocationDestId" gorm:"type:int;not null;comment:默认目标位置id"` //默认目标位置id |
| | | |
| | | PrintLabel bool `json:"printLabel" gorm:"column:print_label;type:tinyint;comment:打印标签"` //是否打印标签 |
| | | ReservationMethod constvar.ReservationMethod `json:"reservationMethod" gorm:"column:reservation_method"` //保留方式 |
| | | ReservationDaysBefore int `json:"reservationDaysBefore" gorm:"type:int;"` //收货前几天 |
| | | ReservationDaysBeforePriority int `json:"ReservationDaysBeforePriority" gorm:"type:int;"` //在优先级的前几天 |
| | | ShowOperations bool `json:"showOperations" gorm:"column:show_operations;type:int"` //显示作业详情 |
| | | CreateBackorder constvar.WhetherType `json:"createBackorder" gorm:"column:create_backorder"` //创建欠单 |
| | | ReturnOperationTypeID int `json:"returnOperationTypeID" gorm:"column:return_job_type_id"` //退货类型ID |
| | | } |
| | | |
| | | type UpdateOperationType struct { |
| | | ID uint `gorm:"comment:主键ID;primaryKey;" json:"id"` |
| | | AddOperationType |
| | | } |
| | |
| | | } |
| | | |
| | | // 作业类型 |
| | | jobTypeController := new(controllers.JobTypeController) |
| | | jobTypeAPI := r.Group(urlPrefix + "/warehouse") |
| | | operationTypeController := new(controllers.OperationTypeController) |
| | | operationTypeAPI := r.Group(urlPrefix + "/warehouse") |
| | | { |
| | | jobTypeAPI.GET("jobType", jobTypeController.List) // 获取作业类型列表 |
| | | jobTypeAPI.POST("jobType", jobTypeController.Add) // 新增作业类型 |
| | | jobTypeAPI.PUT("jobType/:id", jobTypeController.Update) // 修改作业类型 |
| | | jobTypeAPI.DELETE("jobType/:id", jobTypeController.Delete) // 删除作业类型 |
| | | operationTypeAPI.GET("operationType", operationTypeController.List) // 获取作业类型列表 |
| | | operationTypeAPI.POST("operationType", operationTypeController.Add) // 新增作业类型 |
| | | operationTypeAPI.PUT("operationType/:id", operationTypeController.Update) // 修改作业类型 |
| | | operationTypeAPI.DELETE("operationType/:id", operationTypeController.Delete) // 删除作业类型 |
| | | } |
| | | |
| | | return r |