From ccc4c924d81c3f8201e7a6c783a9a7148b21670d Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 12 九月 2023 17:43:42 +0800 Subject: [PATCH] 公司增删改查,业务类型增删改查 --- models/warehouse.go | 18 docs/swagger.yaml | 430 ++++++++ docs/docs.go | 666 +++++++++++++ models/company.go | 232 ++++ controllers/company.go | 153 +++ docs/swagger.json | 666 +++++++++++++ controllers/job_type.go | 146 ++ request/job_type.go | 32 request/company.go | 15 router/router.go | 20 constvar/const.go | 42 models/db.go | 3 models/job_type.go | 263 +++++ models/location.go | 239 ++++ 14 files changed, 2,923 insertions(+), 2 deletions(-) diff --git a/constvar/const.go b/constvar/const.go index c2ae672..f5a9589 100644 --- a/constvar/const.go +++ b/constvar/const.go @@ -1 +1,43 @@ package constvar + +type BaseJobType int + +const ( + BaseJobTypeIncoming BaseJobType = iota + 1 //鏀惰揣 + BaseJobTypeOutgoing //浜よ揣 + BaseJobTypeInternal //鍐呴儴璋冩嫧 +) + +func (slf BaseJobType) IsValid() bool { + return slf == BaseJobTypeIncoming || + slf == BaseJobTypeOutgoing || + slf == BaseJobTypeInternal +} + +type ReservationMethod int + +const ( + ReservationMethodAtConfirm ReservationMethod = iota + 1 //鍦ㄧ‘璁ゆ椂 + ReservationMethodManual //鎵嬪姩 + ReservationMethodByDate //鍦ㄩ瀹氭棩鏈熶箣鍓� +) + +func (slf ReservationMethod) IsValid() bool { + return slf == ReservationMethodAtConfirm || + slf == ReservationMethodManual || + slf == ReservationMethodByDate +} + +type WhetherType int + +const ( + WhetherTypeAsk WhetherType = iota + 1 //璇㈤棶 + WhetherTypeAlways //鎬绘槸 + ReservationNever //浠庝笉 +) + +func (slf WhetherType) IsValid() bool { + return slf == WhetherTypeAsk || + slf == WhetherTypeAlways || + slf == ReservationNever +} diff --git a/controllers/company.go b/controllers/company.go new file mode 100644 index 0000000..b00921a --- /dev/null +++ b/controllers/company.go @@ -0,0 +1,153 @@ +package controllers + +import ( + "errors" + "fmt" + "github.com/gin-gonic/gin" + "github.com/spf13/cast" + "gorm.io/gorm" + "wms/extend/code" + "wms/extend/util" + "wms/models" + "wms/pkg/logx" + "wms/pkg/structx" + "wms/request" +) + +type CompanyController struct{} + +// Add +// @Tags 鍏徃 +// @Summary 娣诲姞鍏徃 +// @Produce application/json +// @Param object body request.AddCompany true "鍏徃淇℃伅" +// @Success 200 {object} util.Response "鎴愬姛" +// @Router /api-wms/v1/company/company [post] +func (slf CompanyController) Add(c *gin.Context) { + var reqParams request.AddCompany + var params models.Company + if err := c.BindJSON(&reqParams); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + return + } + if err := structx.AssignTo(reqParams, ¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲閿欒") + return + } + + if err := slf.ParamsCheck(params); err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + if err := models.NewCompanySearch().Create(¶ms); err != nil { + logx.Errorf("Company create err: %v", err) + util.ResponseFormat(c, code.SaveFail, "鎻掑叆澶辫触") + return + } + + util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") +} + +// Update +// @Tags 鍏徃 +// @Summary 缂栬緫鍏徃 +// @Produce application/json +// @Param object body request.UpdateCompany true "鍏徃淇℃伅" +// @Param id path string true "鍏徃id" +// @Success 200 {object} util.Response "鎴愬姛" +// @Router /api-wms/v1/company/company/{id} [put] +func (slf CompanyController) Update(c *gin.Context) { + id := cast.ToUint(c.Param("id")) + if id == 0 { + util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id") + return + } + var ( + reqParams request.UpdateCompany + params models.Company + ) + if err := c.BindJSON(&reqParams); err != nil { + util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("鍙傛暟瑙f瀽澶辫触: %v"+err.Error())) + return + } + if err := structx.AssignTo(reqParams, ¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("鏁版嵁杞崲閿欒: %v", err.Error())) + return + } + params.ID = id + if err := slf.ParamsCheck(params); err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + + err := models.NewCompanySearch().SetID(params.ID).Update(¶ms) + + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "淇敼澶辫触") + return + } + + util.ResponseFormat(c, code.UpdateSuccess, "鏇存柊鎴愬姛") +} + +func (slf CompanyController) ParamsCheck(params models.Company) (err error) { + var oldRecord *models.Company + if params.ID != 0 { + oldRecord, err = models.NewCompanySearch().SetID(params.ID).First() + if err == gorm.ErrRecordNotFound { + return errors.New("璁板綍涓嶅瓨鍦�") + } + } + if oldRecord == nil || params.Name != oldRecord.Name { + _, err = models.NewCompanySearch().SetName(params.Name).First() + if err != gorm.ErrRecordNotFound { + return errors.New("鍏徃鍚嶇О閲嶅") + } + } + + return nil +} + +// List +// @Tags 鍏徃 +// @Summary 鏌ヨ鍏徃鍒楄〃 +// @Produce application/json +// @Param object query request.GetCompanyList true "鏌ヨ鍙傛暟" +// @Success 200 {object} util.ResponseList{data=[]models.Company} "鎴愬姛" +// @Router /api-wms/v1/company/company [get] +func (slf CompanyController) List(c *gin.Context) { + var params request.GetCompanyList + if err := c.ShouldBindQuery(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + list, total, err := models.NewCompanySearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetOrder("id desc").Find() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") + return + } + + util.ResponseFormatList(c, code.Success, list, cast.ToInt(total)) +} + +// Delete +// @Tags 鍏徃 +// @Summary 鍒犻櫎鍏徃 +// @Produce application/json +// @Param id path string true "鍏徃id" +// @Success 200 {object} util.Response "鎴愬姛" +// @Router /api-wms/v1/company/company/{id} [delete] +func (slf CompanyController) Delete(c *gin.Context) { + id := cast.ToUint(c.Param("id")) + if id == 0 { + util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id") + return + } + + err := models.NewCompanySearch().SetID(id).Delete() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎澶辫触") + return + } + util.ResponseFormat(c, code.UpdateSuccess, "鍒犻櫎鎴愬姛") +} diff --git a/controllers/job_type.go b/controllers/job_type.go new file mode 100644 index 0000000..9ad6439 --- /dev/null +++ b/controllers/job_type.go @@ -0,0 +1,146 @@ +package controllers + +import ( + "errors" + "fmt" + "github.com/gin-gonic/gin" + "github.com/spf13/cast" + "gorm.io/gorm" + "wms/extend/code" + "wms/extend/util" + "wms/models" + "wms/pkg/logx" + "wms/pkg/structx" + "wms/request" +) + +type JobTypeController struct{} + +// Add +// @Tags 浣滀笟绫诲瀷 +// @Summary 娣诲姞浣滀笟绫诲瀷 +// @Produce application/json +// @Param object body request.AddJobType 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 + if err := c.BindJSON(&reqParams); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + return + } + if err := structx.AssignTo(reqParams, ¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲閿欒") + return + } + + if err := slf.ParamsCheck(params); err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + if err := models.NewJobTypeSearch().Create(¶ms); err != nil { + logx.Errorf("JobType create err: %v", err) + util.ResponseFormat(c, code.SaveFail, "鎻掑叆澶辫触") + return + } + + util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") +} + +// Update +// @Tags 浣滀笟绫诲瀷 +// @Summary 缂栬緫浣滀笟绫诲瀷 +// @Produce application/json +// @Param object body request.UpdateJobType 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) { + id := cast.ToUint(c.Param("id")) + if id == 0 { + util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id") + return + } + var ( + reqParams request.UpdateJobType + params models.JobType + ) + if err := c.BindJSON(&reqParams); err != nil { + util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("鍙傛暟瑙f瀽澶辫触: %v"+err.Error())) + return + } + if err := structx.AssignTo(reqParams, ¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("鏁版嵁杞崲閿欒: %v", err.Error())) + return + } + params.ID = id + if err := slf.ParamsCheck(params); err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + + err := models.NewJobTypeSearch().SetID(params.ID).Update(¶ms) + + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "淇敼澶辫触") + return + } + + util.ResponseFormat(c, code.UpdateSuccess, "鏇存柊鎴愬姛") +} + +func (slf JobTypeController) ParamsCheck(params models.JobType) (err error) { + if params.ID != 0 { + _, err = models.NewJobTypeSearch().SetID(params.ID).First() + if err == gorm.ErrRecordNotFound { + return errors.New("璁板綍涓嶅瓨鍦�") + } + } + + return nil +} + +// List +// @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 + 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() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") + return + } + + util.ResponseFormatList(c, code.Success, list, cast.ToInt(total)) +} + +// Delete +// @Tags 浣滀笟绫诲瀷 +// @Summary 鍒犻櫎浣滀笟绫诲瀷 +// @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) { + id := cast.ToUint(c.Param("id")) + if id == 0 { + util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id") + return + } + + err := models.NewJobTypeSearch().SetID(id).Delete() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍒犻櫎澶辫触") + return + } + util.ResponseFormat(c, code.UpdateSuccess, "鍒犻櫎鎴愬姛") +} diff --git a/docs/docs.go b/docs/docs.go index 854c05e..5efc844 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -150,6 +150,294 @@ } } }, + "/api-wms/v1/company/company": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "鏌ヨ鍏徃鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Company" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "娣诲姞鍏徃", + "parameters": [ + { + "description": "鍏徃淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddCompany" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/company/company/{id}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "缂栬緫鍏徃", + "parameters": [ + { + "description": "鍏徃淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateCompany" + } + }, + { + "type": "string", + "description": "鍏徃id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "鍒犻櫎鍏徃", + "parameters": [ + { + "type": "string", + "description": "鍏徃id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/warehouse/jobType": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.JobType" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "娣诲姞浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddJobType" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/warehouse/jobType/{id}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "缂栬緫浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateJobType" + } + }, + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鍒犻櫎浣滀笟绫诲瀷", + "parameters": [ + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, "/api-wms/v1/warehouse/warehouse": { "get": { "produces": [ @@ -296,6 +584,78 @@ } }, "definitions": { + "constvar.BaseJobType": { + "type": "integer", + "enum": [ + 1, + 2, + 3 + ], + "x-enum-comments": { + "BaseJobTypeIncoming": "鏀惰揣", + "BaseJobTypeInternal": "鍐呴儴璋冩嫧", + "BaseJobTypeOutgoing": "浜よ揣" + }, + "x-enum-varnames": [ + "BaseJobTypeIncoming", + "BaseJobTypeOutgoing", + "BaseJobTypeInternal" + ] + }, + "constvar.ReservationMethod": { + "type": "integer", + "enum": [ + 1, + 2, + 3 + ], + "x-enum-comments": { + "ReservationMethodAtConfirm": "鍦ㄧ‘璁ゆ椂", + "ReservationMethodByDate": "鍦ㄩ瀹氭棩鏈熶箣鍓�", + "ReservationMethodManual": "鎵嬪姩" + }, + "x-enum-varnames": [ + "ReservationMethodAtConfirm", + "ReservationMethodManual", + "ReservationMethodByDate" + ] + }, + "constvar.WhetherType": { + "type": "integer", + "enum": [ + 1, + 2, + 3 + ], + "x-enum-comments": { + "ReservationNever": "浠庝笉", + "WhetherTypeAlways": "鎬绘槸", + "WhetherTypeAsk": "璇㈤棶" + }, + "x-enum-varnames": [ + "WhetherTypeAsk", + "WhetherTypeAlways", + "ReservationNever" + ] + }, + "models.Company": { + "type": "object", + "properties": { + "createTime": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "鍏徃鍚嶇О", + "type": "string" + }, + "updateTime": { + "type": "string" + } + } + }, "models.Department": { "type": "object", "properties": { @@ -334,6 +694,138 @@ } } }, + "models.JobType": { + "type": "object", + "properties": { + "ReservationDaysBeforePriority": { + "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", + "type": "integer" + }, + "baseJobType": { + "description": "鍩虹浣滀笟绫诲瀷", + "allOf": [ + { + "$ref": "#/definitions/constvar.BaseJobType" + } + ] + }, + "company": { + "description": "鍏徃", + "allOf": [ + { + "$ref": "#/definitions/models.Company" + } + ] + }, + "companyId": { + "description": "鍏徃id", + "type": "integer" + }, + "createBackorder": { + "description": "鍒涘缓娆犲崟", + "allOf": [ + { + "$ref": "#/definitions/constvar.WhetherType" + } + ] + }, + "createTime": { + "type": "string" + }, + "defaultLocationDest": { + "description": "榛樿鐩爣浣嶇疆", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "defaultLocationDestId": { + "description": "榛樿鐩爣浣嶇疆id", + "type": "integer" + }, + "defaultLocationSrc": { + "description": "榛樿婧愪綅缃�", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "defaultLocationSrcId": { + "description": "榛樿婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浠撳簱鍚嶇О", + "type": "string" + }, + "printLabel": { + "description": "鏄惁鎵撳嵃鏍囩", + "type": "boolean" + }, + "reservationDaysBefore": { + "description": "鏀惰揣鍓嶅嚑澶�", + "type": "integer" + }, + "reservationMethod": { + "description": "淇濈暀鏂瑰紡", + "allOf": [ + { + "$ref": "#/definitions/constvar.ReservationMethod" + } + ] + }, + "returnJobType": { + "description": "閫�璐х被鍨嬪悕绉�", + "type": "string" + }, + "returnJobTypeID": { + "description": "閫�璐х被鍨婭D", + "type": "integer" + }, + "showOperations": { + "description": "鏄剧ず浣滀笟璇︽儏", + "type": "boolean" + }, + "updateTime": { + "type": "string" + }, + "warehouse": { + "description": "浠撳簱", + "allOf": [ + { + "$ref": "#/definitions/models.Warehouse" + } + ] + }, + "warehouseId": { + "description": "浠撳簱id", + "type": "integer" + } + } + }, + "models.Location": { + "type": "object", + "properties": { + "createTime": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浣嶇疆鍚嶇О", + "type": "string" + }, + "updateTime": { + "type": "string" + } + } + }, "models.Warehouse": { "type": "object", "required": [ @@ -354,8 +846,17 @@ "maxLength": 5, "minLength": 1 }, + "company": { + "$ref": "#/definitions/models.Company" + }, + "companyId": { + "type": "integer" + }, "createTime": { "type": "string" + }, + "id": { + "type": "integer" }, "name": { "description": "浠撳簱鍚嶇О", @@ -384,6 +885,15 @@ } } }, + "request.AddCompany": { + "type": "object", + "properties": { + "name": { + "description": "鍏徃鍚嶇О", + "type": "string" + } + } + }, "request.AddDepartment": { "type": "object", "properties": { @@ -402,6 +912,78 @@ "remark": { "description": "澶囨敞", "type": "string" + } + } + }, + "request.AddJobType": { + "type": "object", + "properties": { + "ReservationDaysBeforePriority": { + "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", + "type": "integer" + }, + "baseJobType": { + "description": "鍩虹浣滀笟绫诲瀷", + "allOf": [ + { + "$ref": "#/definitions/constvar.BaseJobType" + } + ] + }, + "companyId": { + "description": "鍏徃id", + "type": "integer" + }, + "createBackorder": { + "description": "鍒涘缓娆犲崟", + "allOf": [ + { + "$ref": "#/definitions/constvar.WhetherType" + } + ] + }, + "defaultLocationDestId": { + "description": "榛樿鐩爣浣嶇疆id", + "type": "integer" + }, + "defaultLocationSrcId": { + "description": "榛樿婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浠撳簱鍚嶇О", + "type": "string" + }, + "printLabel": { + "description": "鏄惁鎵撳嵃鏍囩", + "type": "boolean" + }, + "reservationDaysBefore": { + "description": "鏀惰揣鍓嶅嚑澶�", + "type": "integer" + }, + "reservationMethod": { + "description": "淇濈暀鏂瑰紡", + "allOf": [ + { + "$ref": "#/definitions/constvar.ReservationMethod" + } + ] + }, + "returnJobTypeID": { + "description": "閫�璐х被鍨婭D", + "type": "integer" + }, + "showOperations": { + "description": "鏄剧ず浣滀笟璇︽儏", + "type": "boolean" + }, + "warehouseId": { + "description": "浠撳簱id", + "type": "integer" } } }, @@ -442,6 +1024,18 @@ } } }, + "request.UpdateCompany": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "description": "鍏徃鍚嶇О", + "type": "string" + } + } + }, "request.UpdateDepartment": { "type": "object", "properties": { @@ -466,6 +1060,78 @@ } } }, + "request.UpdateJobType": { + "type": "object", + "properties": { + "ReservationDaysBeforePriority": { + "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", + "type": "integer" + }, + "baseJobType": { + "description": "鍩虹浣滀笟绫诲瀷", + "allOf": [ + { + "$ref": "#/definitions/constvar.BaseJobType" + } + ] + }, + "companyId": { + "description": "鍏徃id", + "type": "integer" + }, + "createBackorder": { + "description": "鍒涘缓娆犲崟", + "allOf": [ + { + "$ref": "#/definitions/constvar.WhetherType" + } + ] + }, + "defaultLocationDestId": { + "description": "榛樿鐩爣浣嶇疆id", + "type": "integer" + }, + "defaultLocationSrcId": { + "description": "榛樿婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浠撳簱鍚嶇О", + "type": "string" + }, + "printLabel": { + "description": "鏄惁鎵撳嵃鏍囩", + "type": "boolean" + }, + "reservationDaysBefore": { + "description": "鏀惰揣鍓嶅嚑澶�", + "type": "integer" + }, + "reservationMethod": { + "description": "淇濈暀鏂瑰紡", + "allOf": [ + { + "$ref": "#/definitions/constvar.ReservationMethod" + } + ] + }, + "returnJobTypeID": { + "description": "閫�璐х被鍨婭D", + "type": "integer" + }, + "showOperations": { + "description": "鏄剧ず浣滀笟璇︽儏", + "type": "boolean" + }, + "warehouseId": { + "description": "浠撳簱id", + "type": "integer" + } + } + }, "request.UpdateWarehouse": { "type": "object", "required": [ diff --git a/docs/swagger.json b/docs/swagger.json index 9170dce..ba4c8df 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -138,6 +138,294 @@ } } }, + "/api-wms/v1/company/company": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "鏌ヨ鍏徃鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Company" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "娣诲姞鍏徃", + "parameters": [ + { + "description": "鍏徃淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddCompany" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/company/company/{id}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "缂栬緫鍏徃", + "parameters": [ + { + "description": "鍏徃淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateCompany" + } + }, + { + "type": "string", + "description": "鍏徃id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏徃" + ], + "summary": "鍒犻櫎鍏徃", + "parameters": [ + { + "type": "string", + "description": "鍏徃id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/warehouse/jobType": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "parameters": [ + { + "type": "string", + "name": "keyword", + "in": "query" + }, + { + "type": "integer", + "description": "椤电爜", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "description": "姣忛〉澶у皬", + "name": "pageSize", + "in": "query" + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.JobType" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "娣诲姞浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddJobType" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/warehouse/jobType/{id}": { + "put": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "缂栬緫浣滀笟绫诲瀷", + "parameters": [ + { + "description": "浣滀笟绫诲瀷淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.UpdateJobType" + } + }, + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + }, + "delete": { + "produces": [ + "application/json" + ], + "tags": [ + "浣滀笟绫诲瀷" + ], + "summary": "鍒犻櫎浣滀笟绫诲瀷", + "parameters": [ + { + "type": "string", + "description": "浣滀笟绫诲瀷id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, "/api-wms/v1/warehouse/warehouse": { "get": { "produces": [ @@ -284,6 +572,78 @@ } }, "definitions": { + "constvar.BaseJobType": { + "type": "integer", + "enum": [ + 1, + 2, + 3 + ], + "x-enum-comments": { + "BaseJobTypeIncoming": "鏀惰揣", + "BaseJobTypeInternal": "鍐呴儴璋冩嫧", + "BaseJobTypeOutgoing": "浜よ揣" + }, + "x-enum-varnames": [ + "BaseJobTypeIncoming", + "BaseJobTypeOutgoing", + "BaseJobTypeInternal" + ] + }, + "constvar.ReservationMethod": { + "type": "integer", + "enum": [ + 1, + 2, + 3 + ], + "x-enum-comments": { + "ReservationMethodAtConfirm": "鍦ㄧ‘璁ゆ椂", + "ReservationMethodByDate": "鍦ㄩ瀹氭棩鏈熶箣鍓�", + "ReservationMethodManual": "鎵嬪姩" + }, + "x-enum-varnames": [ + "ReservationMethodAtConfirm", + "ReservationMethodManual", + "ReservationMethodByDate" + ] + }, + "constvar.WhetherType": { + "type": "integer", + "enum": [ + 1, + 2, + 3 + ], + "x-enum-comments": { + "ReservationNever": "浠庝笉", + "WhetherTypeAlways": "鎬绘槸", + "WhetherTypeAsk": "璇㈤棶" + }, + "x-enum-varnames": [ + "WhetherTypeAsk", + "WhetherTypeAlways", + "ReservationNever" + ] + }, + "models.Company": { + "type": "object", + "properties": { + "createTime": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "鍏徃鍚嶇О", + "type": "string" + }, + "updateTime": { + "type": "string" + } + } + }, "models.Department": { "type": "object", "properties": { @@ -322,6 +682,138 @@ } } }, + "models.JobType": { + "type": "object", + "properties": { + "ReservationDaysBeforePriority": { + "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", + "type": "integer" + }, + "baseJobType": { + "description": "鍩虹浣滀笟绫诲瀷", + "allOf": [ + { + "$ref": "#/definitions/constvar.BaseJobType" + } + ] + }, + "company": { + "description": "鍏徃", + "allOf": [ + { + "$ref": "#/definitions/models.Company" + } + ] + }, + "companyId": { + "description": "鍏徃id", + "type": "integer" + }, + "createBackorder": { + "description": "鍒涘缓娆犲崟", + "allOf": [ + { + "$ref": "#/definitions/constvar.WhetherType" + } + ] + }, + "createTime": { + "type": "string" + }, + "defaultLocationDest": { + "description": "榛樿鐩爣浣嶇疆", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "defaultLocationDestId": { + "description": "榛樿鐩爣浣嶇疆id", + "type": "integer" + }, + "defaultLocationSrc": { + "description": "榛樿婧愪綅缃�", + "allOf": [ + { + "$ref": "#/definitions/models.Location" + } + ] + }, + "defaultLocationSrcId": { + "description": "榛樿婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浠撳簱鍚嶇О", + "type": "string" + }, + "printLabel": { + "description": "鏄惁鎵撳嵃鏍囩", + "type": "boolean" + }, + "reservationDaysBefore": { + "description": "鏀惰揣鍓嶅嚑澶�", + "type": "integer" + }, + "reservationMethod": { + "description": "淇濈暀鏂瑰紡", + "allOf": [ + { + "$ref": "#/definitions/constvar.ReservationMethod" + } + ] + }, + "returnJobType": { + "description": "閫�璐х被鍨嬪悕绉�", + "type": "string" + }, + "returnJobTypeID": { + "description": "閫�璐х被鍨婭D", + "type": "integer" + }, + "showOperations": { + "description": "鏄剧ず浣滀笟璇︽儏", + "type": "boolean" + }, + "updateTime": { + "type": "string" + }, + "warehouse": { + "description": "浠撳簱", + "allOf": [ + { + "$ref": "#/definitions/models.Warehouse" + } + ] + }, + "warehouseId": { + "description": "浠撳簱id", + "type": "integer" + } + } + }, + "models.Location": { + "type": "object", + "properties": { + "createTime": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浣嶇疆鍚嶇О", + "type": "string" + }, + "updateTime": { + "type": "string" + } + } + }, "models.Warehouse": { "type": "object", "required": [ @@ -342,8 +834,17 @@ "maxLength": 5, "minLength": 1 }, + "company": { + "$ref": "#/definitions/models.Company" + }, + "companyId": { + "type": "integer" + }, "createTime": { "type": "string" + }, + "id": { + "type": "integer" }, "name": { "description": "浠撳簱鍚嶇О", @@ -372,6 +873,15 @@ } } }, + "request.AddCompany": { + "type": "object", + "properties": { + "name": { + "description": "鍏徃鍚嶇О", + "type": "string" + } + } + }, "request.AddDepartment": { "type": "object", "properties": { @@ -390,6 +900,78 @@ "remark": { "description": "澶囨敞", "type": "string" + } + } + }, + "request.AddJobType": { + "type": "object", + "properties": { + "ReservationDaysBeforePriority": { + "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", + "type": "integer" + }, + "baseJobType": { + "description": "鍩虹浣滀笟绫诲瀷", + "allOf": [ + { + "$ref": "#/definitions/constvar.BaseJobType" + } + ] + }, + "companyId": { + "description": "鍏徃id", + "type": "integer" + }, + "createBackorder": { + "description": "鍒涘缓娆犲崟", + "allOf": [ + { + "$ref": "#/definitions/constvar.WhetherType" + } + ] + }, + "defaultLocationDestId": { + "description": "榛樿鐩爣浣嶇疆id", + "type": "integer" + }, + "defaultLocationSrcId": { + "description": "榛樿婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浠撳簱鍚嶇О", + "type": "string" + }, + "printLabel": { + "description": "鏄惁鎵撳嵃鏍囩", + "type": "boolean" + }, + "reservationDaysBefore": { + "description": "鏀惰揣鍓嶅嚑澶�", + "type": "integer" + }, + "reservationMethod": { + "description": "淇濈暀鏂瑰紡", + "allOf": [ + { + "$ref": "#/definitions/constvar.ReservationMethod" + } + ] + }, + "returnJobTypeID": { + "description": "閫�璐х被鍨婭D", + "type": "integer" + }, + "showOperations": { + "description": "鏄剧ず浣滀笟璇︽儏", + "type": "boolean" + }, + "warehouseId": { + "description": "浠撳簱id", + "type": "integer" } } }, @@ -430,6 +1012,18 @@ } } }, + "request.UpdateCompany": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "description": "鍏徃鍚嶇О", + "type": "string" + } + } + }, "request.UpdateDepartment": { "type": "object", "properties": { @@ -454,6 +1048,78 @@ } } }, + "request.UpdateJobType": { + "type": "object", + "properties": { + "ReservationDaysBeforePriority": { + "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", + "type": "integer" + }, + "baseJobType": { + "description": "鍩虹浣滀笟绫诲瀷", + "allOf": [ + { + "$ref": "#/definitions/constvar.BaseJobType" + } + ] + }, + "companyId": { + "description": "鍏徃id", + "type": "integer" + }, + "createBackorder": { + "description": "鍒涘缓娆犲崟", + "allOf": [ + { + "$ref": "#/definitions/constvar.WhetherType" + } + ] + }, + "defaultLocationDestId": { + "description": "榛樿鐩爣浣嶇疆id", + "type": "integer" + }, + "defaultLocationSrcId": { + "description": "榛樿婧愪綅缃甶d", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "name": { + "description": "浠撳簱鍚嶇О", + "type": "string" + }, + "printLabel": { + "description": "鏄惁鎵撳嵃鏍囩", + "type": "boolean" + }, + "reservationDaysBefore": { + "description": "鏀惰揣鍓嶅嚑澶�", + "type": "integer" + }, + "reservationMethod": { + "description": "淇濈暀鏂瑰紡", + "allOf": [ + { + "$ref": "#/definitions/constvar.ReservationMethod" + } + ] + }, + "returnJobTypeID": { + "description": "閫�璐х被鍨婭D", + "type": "integer" + }, + "showOperations": { + "description": "鏄剧ず浣滀笟璇︽儏", + "type": "boolean" + }, + "warehouseId": { + "description": "浠撳簱id", + "type": "integer" + } + } + }, "request.UpdateWarehouse": { "type": "object", "required": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 034292b..5a1e9a2 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,4 +1,58 @@ definitions: + constvar.BaseJobType: + enum: + - 1 + - 2 + - 3 + type: integer + x-enum-comments: + BaseJobTypeIncoming: 鏀惰揣 + BaseJobTypeInternal: 鍐呴儴璋冩嫧 + BaseJobTypeOutgoing: 浜よ揣 + x-enum-varnames: + - BaseJobTypeIncoming + - BaseJobTypeOutgoing + - BaseJobTypeInternal + constvar.ReservationMethod: + enum: + - 1 + - 2 + - 3 + type: integer + x-enum-comments: + ReservationMethodAtConfirm: 鍦ㄧ‘璁ゆ椂 + ReservationMethodByDate: 鍦ㄩ瀹氭棩鏈熶箣鍓� + ReservationMethodManual: 鎵嬪姩 + x-enum-varnames: + - ReservationMethodAtConfirm + - ReservationMethodManual + - ReservationMethodByDate + constvar.WhetherType: + enum: + - 1 + - 2 + - 3 + type: integer + x-enum-comments: + ReservationNever: 浠庝笉 + WhetherTypeAlways: 鎬绘槸 + WhetherTypeAsk: 璇㈤棶 + x-enum-varnames: + - WhetherTypeAsk + - WhetherTypeAlways + - ReservationNever + models.Company: + properties: + createTime: + type: string + id: + type: integer + name: + description: 鍏徃鍚嶇О + type: string + updateTime: + type: string + type: object models.Department: properties: children: @@ -26,6 +80,88 @@ description: 鎺掑簭 type: integer type: object + models.JobType: + properties: + ReservationDaysBeforePriority: + description: 鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ + type: integer + baseJobType: + allOf: + - $ref: '#/definitions/constvar.BaseJobType' + description: 鍩虹浣滀笟绫诲瀷 + company: + allOf: + - $ref: '#/definitions/models.Company' + description: 鍏徃 + companyId: + description: 鍏徃id + type: integer + createBackorder: + allOf: + - $ref: '#/definitions/constvar.WhetherType' + description: 鍒涘缓娆犲崟 + createTime: + type: string + defaultLocationDest: + allOf: + - $ref: '#/definitions/models.Location' + description: 榛樿鐩爣浣嶇疆 + defaultLocationDestId: + description: 榛樿鐩爣浣嶇疆id + type: integer + defaultLocationSrc: + allOf: + - $ref: '#/definitions/models.Location' + description: 榛樿婧愪綅缃� + defaultLocationSrcId: + description: 榛樿婧愪綅缃甶d + type: integer + id: + type: integer + name: + description: 浠撳簱鍚嶇О + type: string + printLabel: + description: 鏄惁鎵撳嵃鏍囩 + type: boolean + reservationDaysBefore: + description: 鏀惰揣鍓嶅嚑澶� + type: integer + reservationMethod: + allOf: + - $ref: '#/definitions/constvar.ReservationMethod' + description: 淇濈暀鏂瑰紡 + returnJobType: + description: 閫�璐х被鍨嬪悕绉� + type: string + returnJobTypeID: + description: 閫�璐х被鍨婭D + type: integer + showOperations: + description: 鏄剧ず浣滀笟璇︽儏 + type: boolean + updateTime: + type: string + warehouse: + allOf: + - $ref: '#/definitions/models.Warehouse' + description: 浠撳簱 + 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: active: @@ -39,8 +175,14 @@ maxLength: 5 minLength: 1 type: string + company: + $ref: '#/definitions/models.Company' + companyId: + type: integer createTime: type: string + id: + type: integer name: description: 浠撳簱鍚嶇О type: string @@ -62,6 +204,12 @@ required: - code type: object + request.AddCompany: + properties: + name: + description: 鍏徃鍚嶇О + type: string + type: object request.AddDepartment: properties: name: @@ -76,6 +224,53 @@ remark: description: 澶囨敞 type: string + type: object + request.AddJobType: + properties: + ReservationDaysBeforePriority: + description: 鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ + type: integer + baseJobType: + allOf: + - $ref: '#/definitions/constvar.BaseJobType' + description: 鍩虹浣滀笟绫诲瀷 + companyId: + description: 鍏徃id + type: integer + createBackorder: + allOf: + - $ref: '#/definitions/constvar.WhetherType' + description: 鍒涘缓娆犲崟 + defaultLocationDestId: + description: 榛樿鐩爣浣嶇疆id + type: integer + defaultLocationSrcId: + description: 榛樿婧愪綅缃甶d + type: integer + id: + type: integer + name: + description: 浠撳簱鍚嶇О + type: string + printLabel: + description: 鏄惁鎵撳嵃鏍囩 + type: boolean + reservationDaysBefore: + description: 鏀惰揣鍓嶅嚑澶� + type: integer + reservationMethod: + allOf: + - $ref: '#/definitions/constvar.ReservationMethod' + description: 淇濈暀鏂瑰紡 + returnJobTypeID: + description: 閫�璐х被鍨婭D + type: integer + showOperations: + description: 鏄剧ず浣滀笟璇︽儏 + type: boolean + warehouseId: + description: 浠撳簱id + type: integer type: object request.AddWarehouse: properties: @@ -104,6 +299,14 @@ required: - code type: object + request.UpdateCompany: + properties: + id: + type: integer + name: + description: 鍏徃鍚嶇О + type: string + type: object request.UpdateDepartment: properties: id: @@ -120,6 +323,53 @@ remark: description: 澶囨敞 type: string + type: object + request.UpdateJobType: + properties: + ReservationDaysBeforePriority: + description: 鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ + type: integer + baseJobType: + allOf: + - $ref: '#/definitions/constvar.BaseJobType' + description: 鍩虹浣滀笟绫诲瀷 + companyId: + description: 鍏徃id + type: integer + createBackorder: + allOf: + - $ref: '#/definitions/constvar.WhetherType' + description: 鍒涘缓娆犲崟 + defaultLocationDestId: + description: 榛樿鐩爣浣嶇疆id + type: integer + defaultLocationSrcId: + description: 榛樿婧愪綅缃甶d + type: integer + id: + type: integer + name: + description: 浠撳簱鍚嶇О + type: string + printLabel: + description: 鏄惁鎵撳嵃鏍囩 + type: boolean + reservationDaysBefore: + description: 鏀惰揣鍓嶅嚑澶� + type: integer + reservationMethod: + allOf: + - $ref: '#/definitions/constvar.ReservationMethod' + description: 淇濈暀鏂瑰紡 + returnJobTypeID: + description: 閫�璐х被鍨婭D + type: integer + showOperations: + description: 鏄剧ず浣滀笟璇︽儏 + type: boolean + warehouseId: + description: 浠撳簱id + type: integer type: object request.UpdateWarehouse: properties: @@ -258,6 +508,186 @@ summary: 缂栬緫閮ㄩ棬淇℃伅 tags: - 閮ㄩ棬淇℃伅 + /api-wms/v1/company/company: + get: + parameters: + - in: query + name: keyword + type: string + - description: 椤电爜 + in: query + name: page + type: integer + - description: 姣忛〉澶у皬 + in: query + name: pageSize + type: integer + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.Company' + type: array + type: object + summary: 鏌ヨ鍏徃鍒楄〃 + tags: + - 鍏徃 + post: + parameters: + - description: 鍏徃淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.AddCompany' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 娣诲姞鍏徃 + tags: + - 鍏徃 + /api-wms/v1/company/company/{id}: + delete: + parameters: + - description: 鍏徃id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 鍒犻櫎鍏徃 + tags: + - 鍏徃 + put: + parameters: + - description: 鍏徃淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.UpdateCompany' + - description: 鍏徃id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 缂栬緫鍏徃 + tags: + - 鍏徃 + /api-wms/v1/warehouse/jobType: + get: + parameters: + - in: query + name: keyword + type: string + - description: 椤电爜 + in: query + name: page + type: integer + - description: 姣忛〉澶у皬 + in: query + name: pageSize + type: integer + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.JobType' + type: array + type: object + summary: 鏌ヨ浣滀笟绫诲瀷鍒楄〃 + tags: + - 浣滀笟绫诲瀷 + post: + parameters: + - description: 浣滀笟绫诲瀷淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.AddJobType' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 娣诲姞浣滀笟绫诲瀷 + tags: + - 浣滀笟绫诲瀷 + /api-wms/v1/warehouse/jobType/{id}: + delete: + parameters: + - description: 浣滀笟绫诲瀷id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 鍒犻櫎浣滀笟绫诲瀷 + tags: + - 浣滀笟绫诲瀷 + put: + parameters: + - description: 浣滀笟绫诲瀷淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.UpdateJobType' + - description: 浣滀笟绫诲瀷id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 缂栬緫浣滀笟绫诲瀷 + tags: + - 浣滀笟绫诲瀷 /api-wms/v1/warehouse/warehouse: get: parameters: diff --git a/models/company.go b/models/company.go new file mode 100644 index 0000000..d4a3602 --- /dev/null +++ b/models/company.go @@ -0,0 +1,232 @@ +package models + +import ( + "fmt" + "gorm.io/gorm" + "wms/pkg/mysqlx" +) + +type ( + // Company 鍏徃 + Company 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:鍏徃鍚嶇О"` //鍏徃鍚嶇О + } + + CompanySearch struct { + Company + Order string + PageNum int + PageSize int + Keyword string + Orm *gorm.DB + } +) + +func (slf *Company) TableName() string { + return "company" +} + +func NewCompanySearch() *CompanySearch { + return &CompanySearch{Orm: mysqlx.GetDB()} +} + +func (slf *CompanySearch) SetOrm(tx *gorm.DB) *CompanySearch { + slf.Orm = tx + return slf +} + +func (slf *CompanySearch) SetPage(page, size int) *CompanySearch { + slf.PageNum, slf.PageSize = page, size + return slf +} + +func (slf *CompanySearch) SetOrder(order string) *CompanySearch { + slf.Order = order + return slf +} + +func (slf *CompanySearch) SetID(id uint) *CompanySearch { + slf.ID = id + return slf +} + +func (slf *CompanySearch) SetName(name string) *CompanySearch { + slf.Name = name + return slf +} + +func (slf *CompanySearch) SetKeyword(keyword string) *CompanySearch { + slf.Keyword = keyword + return slf +} + +func (slf *CompanySearch) build() *gorm.DB { + var db = slf.Orm.Table(slf.TableName()) + + if slf.ID != 0 { + db = db.Where("id = ?", slf.ID) + } + + if slf.Order != "" { + db = db.Order(slf.Order) + } + + if slf.Keyword != "" { + db = db.Where("name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) + } + if slf.Name != "" { + db = db.Where("name = ?", slf.Name) + } + + return db +} + +// Create 鍗曟潯鎻掑叆 +func (slf *CompanySearch) Create(record *Company) error { + var db = slf.build() + + if err := db.Create(record).Error; err != nil { + return err + } + + return nil +} + +// CreateBatch 鎵归噺鎻掑叆 +func (slf *CompanySearch) CreateBatch(records []*Company) error { + var db = slf.build() + + if err := db.Create(&records).Error; err != nil { + return fmt.Errorf("create batch err: %v, records: %+v", err, records) + } + + return nil +} + +func (slf *CompanySearch) Update(record *Company) error { + var db = slf.build() + + if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { + return fmt.Errorf("save err: %v, record: %+v", err, record) + } + + return nil +} + +func (slf *CompanySearch) UpdateByMap(upMap map[string]interface{}) error { + var ( + db = slf.build() + ) + + if err := db.Updates(upMap).Error; err != nil { + return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) + } + + return nil +} + +func (slf *CompanySearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error { + var ( + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if err := db.Updates(upMap).Error; err != nil { + return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap) + } + + return nil +} + +func (slf *CompanySearch) Delete() error { + var db = slf.build() + return db.Delete(&Company{}).Error +} + +func (slf *CompanySearch) First() (*Company, error) { + var ( + record = new(Company) + db = slf.build() + ) + + if err := db.First(record).Error; err != nil { + return record, err + } + + return record, nil +} + +func (slf *CompanySearch) Find() ([]*Company, int64, error) { + var ( + records = make([]*Company, 0) + total int64 + db = slf.build() + ) + + if err := db.Count(&total).Error; err != nil { + return records, total, fmt.Errorf("find count err: %v", err) + } + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, total, fmt.Errorf("find records err: %v", err) + } + + return records, total, nil +} + +func (slf *CompanySearch) FindNotTotal() ([]*Company, error) { + var ( + records = make([]*Company, 0) + db = slf.build() + ) + + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("find records err: %v", err) + } + + return records, nil +} + +// FindByQuery 鎸囧畾鏉′欢鏌ヨ. +func (slf *CompanySearch) FindByQuery(query string, args []interface{}) ([]*Company, int64, error) { + var ( + records = make([]*Company, 0) + total int64 + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if err := db.Count(&total).Error; err != nil { + return records, total, fmt.Errorf("find by query count err: %v", err) + } + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) + } + + return records, total, nil +} + +// FindByQueryNotTotal 鎸囧畾鏉′欢鏌ヨ&涓嶆煡璇㈡�绘潯鏁�. +func (slf *CompanySearch) FindByQueryNotTotal(query string, args []interface{}) ([]*Company, error) { + var ( + records = make([]*Company, 0) + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) + } + + return records, nil +} diff --git a/models/db.go b/models/db.go index 1892385..230903e 100644 --- a/models/db.go +++ b/models/db.go @@ -73,7 +73,10 @@ func RegisterTables() error { db := mysqlx.GetDB() err := db.AutoMigrate( + Company{}, Warehouse{}, + JobType{}, + Location{}, ) return err } diff --git a/models/job_type.go b/models/job_type.go new file mode 100644 index 0000000..12947cb --- /dev/null +++ b/models/job_type.go @@ -0,0 +1,263 @@ +package models + +import ( + "fmt" + "gorm.io/gorm" + "wms/constvar" + "wms/pkg/mysqlx" +) + +type ( + // JobType 浣滀笟绫诲瀷 + JobType 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"` //浠撳簱 + + DefaultLocationSrcId int `json:"defaultLocationSrcId" gorm:"type:int;not null;comment:榛樿婧愪綅缃甶d"` //榛樿婧愪綅缃甶d + DefaultLocationSrc Location `json:"defaultLocationSrc" gorm:"foreignKey:DefaultLocationSrcId"` //榛樿婧愪綅缃� + DefaultLocationDestId int `json:"defaultLocationDestId" gorm:"type:int;not null;comment:榛樿鐩爣浣嶇疆id"` //榛樿鐩爣浣嶇疆id + DefaultLocationDest Location `json:"defaultLocationDest" gorm:"foreignKey:DefaultLocationDestId"` //榛樿鐩爣浣嶇疆 + + 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"` //鍒涘缓娆犲崟 + ReturnJobTypeID int `json:"returnJobTypeID" gorm:"column:return_job_type_id"` //閫�璐х被鍨婭D + ReturnJobType string `json:"returnJobType" gorm:"-"` //閫�璐х被鍨嬪悕绉� + } + + JobTypeSearch struct { + JobType + Order string + PageNum int + PageSize int + Keyword string + Orm *gorm.DB + Preload bool + } +) + +func (slf *JobType) TableName() string { + return "job_type" +} + +func NewJobTypeSearch() *JobTypeSearch { + return &JobTypeSearch{Orm: mysqlx.GetDB()} +} + +func (slf *JobTypeSearch) SetOrm(tx *gorm.DB) *JobTypeSearch { + slf.Orm = tx + return slf +} + +func (slf *JobTypeSearch) SetPage(page, size int) *JobTypeSearch { + slf.PageNum, slf.PageSize = page, size + return slf +} + +func (slf *JobTypeSearch) SetOrder(order string) *JobTypeSearch { + slf.Order = order + return slf +} + +func (slf *JobTypeSearch) SetID(id uint) *JobTypeSearch { + slf.ID = id + return slf +} + +func (slf *JobTypeSearch) SetName(name string) *JobTypeSearch { + slf.Name = name + return slf +} + +func (slf *JobTypeSearch) SetKeyword(keyword string) *JobTypeSearch { + slf.Keyword = keyword + return slf +} + +func (slf *JobTypeSearch) SetPreload(preload bool) *JobTypeSearch { + slf.Preload = preload + return slf +} + +func (slf *JobTypeSearch) build() *gorm.DB { + var db = slf.Orm.Model(&JobType{}) + + if slf.ID != 0 { + db = db.Where("id = ?", slf.ID) + } + + if slf.Order != "" { + db = db.Order(slf.Order) + } + + if slf.Keyword != "" { + db = db.Where("name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) + } + + if slf.Name != "" { + db = db.Where("name = ?", slf.Name) + } + + if slf.Preload { + db = db.Preload("Company").Preload("Warehouse").Preload("DefaultLocationSrc").Preload("DefaultLocationDest") + } + + return db +} + +// Create 鍗曟潯鎻掑叆 +func (slf *JobTypeSearch) Create(record *JobType) error { + var db = slf.build() + + if err := db.Create(record).Error; err != nil { + return err + } + + return nil +} + +// CreateBatch 鎵归噺鎻掑叆 +func (slf *JobTypeSearch) CreateBatch(records []*JobType) error { + var db = slf.build() + + if err := db.Create(&records).Error; err != nil { + return fmt.Errorf("create batch err: %v, records: %+v", err, records) + } + + return nil +} + +func (slf *JobTypeSearch) Update(record *JobType) error { + var db = slf.build() + + if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { + return fmt.Errorf("save err: %v, record: %+v", err, record) + } + + return nil +} + +func (slf *JobTypeSearch) UpdateByMap(upMap map[string]interface{}) error { + var ( + db = slf.build() + ) + + if err := db.Updates(upMap).Error; err != nil { + return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) + } + + return nil +} + +func (slf *JobTypeSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error { + var ( + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if err := db.Updates(upMap).Error; err != nil { + return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap) + } + + return nil +} + +func (slf *JobTypeSearch) Delete() error { + var db = slf.build() + return db.Delete(&JobType{}).Error +} + +func (slf *JobTypeSearch) First() (*JobType, error) { + var ( + record = new(JobType) + db = slf.build() + ) + + if err := db.First(record).Error; err != nil { + return record, err + } + + return record, nil +} + +func (slf *JobTypeSearch) Find() ([]*JobType, int64, error) { + var ( + records = make([]*JobType, 0) + total int64 + db = slf.build() + ) + + if err := db.Count(&total).Error; err != nil { + return records, total, fmt.Errorf("find count err: %v", err) + } + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, total, fmt.Errorf("find records err: %v", err) + } + + return records, total, nil +} + +func (slf *JobTypeSearch) FindNotTotal() ([]*JobType, error) { + var ( + records = make([]*JobType, 0) + db = slf.build() + ) + + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("find records err: %v", err) + } + + return records, nil +} + +// FindByQuery 鎸囧畾鏉′欢鏌ヨ. +func (slf *JobTypeSearch) FindByQuery(query string, args []interface{}) ([]*JobType, int64, error) { + var ( + records = make([]*JobType, 0) + total int64 + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if err := db.Count(&total).Error; err != nil { + return records, total, fmt.Errorf("find by query count err: %v", err) + } + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) + } + + return records, total, nil +} + +// FindByQueryNotTotal 鎸囧畾鏉′欢鏌ヨ&涓嶆煡璇㈡�绘潯鏁�. +func (slf *JobTypeSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*JobType, error) { + var ( + records = make([]*JobType, 0) + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) + } + + return records, nil +} diff --git a/models/location.go b/models/location.go new file mode 100644 index 0000000..54ec4af --- /dev/null +++ b/models/location.go @@ -0,0 +1,239 @@ +package models + +import ( + "fmt" + "gorm.io/gorm" + "wms/pkg/mysqlx" +) + +type ( + // Location 浣嶇疆 + Location 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:浣嶇疆鍚嶇О"` //浣嶇疆鍚嶇О + } + + LocationSearch struct { + Location + Order string + PageNum int + PageSize int + Keyword string + Orm *gorm.DB + Preload bool + } +) + +func (slf *Location) TableName() string { + return "location" +} + +func NewLocationSearch() *LocationSearch { + return &LocationSearch{Orm: mysqlx.GetDB()} +} + +func (slf *LocationSearch) SetOrm(tx *gorm.DB) *LocationSearch { + slf.Orm = tx + return slf +} + +func (slf *LocationSearch) SetPage(page, size int) *LocationSearch { + slf.PageNum, slf.PageSize = page, size + return slf +} + +func (slf *LocationSearch) SetOrder(order string) *LocationSearch { + slf.Order = order + return slf +} + +func (slf *LocationSearch) SetID(id uint) *LocationSearch { + slf.ID = id + return slf +} + +func (slf *LocationSearch) SetName(name string) *LocationSearch { + slf.Name = name + return slf +} + +func (slf *LocationSearch) SetKeyword(keyword string) *LocationSearch { + slf.Keyword = keyword + return slf +} + +func (slf *LocationSearch) SetPreload(preload bool) *LocationSearch { + slf.Preload = preload + return slf +} + +func (slf *LocationSearch) build() *gorm.DB { + var db = slf.Orm.Model(&Location{}) + + if slf.ID != 0 { + db = db.Where("id = ?", slf.ID) + } + + if slf.Order != "" { + db = db.Order(slf.Order) + } + + if slf.Keyword != "" { + db = db.Where("name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) + } + + if slf.Name != "" { + db = db.Where("name = ?", slf.Name) + } + + return db +} + +// Create 鍗曟潯鎻掑叆 +func (slf *LocationSearch) Create(record *Location) error { + var db = slf.build() + + if err := db.Create(record).Error; err != nil { + return err + } + + return nil +} + +// CreateBatch 鎵归噺鎻掑叆 +func (slf *LocationSearch) CreateBatch(records []*Location) error { + var db = slf.build() + + if err := db.Create(&records).Error; err != nil { + return fmt.Errorf("create batch err: %v, records: %+v", err, records) + } + + return nil +} + +func (slf *LocationSearch) Update(record *Location) error { + var db = slf.build() + + if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { + return fmt.Errorf("save err: %v, record: %+v", err, record) + } + + return nil +} + +func (slf *LocationSearch) UpdateByMap(upMap map[string]interface{}) error { + var ( + db = slf.build() + ) + + if err := db.Updates(upMap).Error; err != nil { + return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) + } + + return nil +} + +func (slf *LocationSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error { + var ( + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if err := db.Updates(upMap).Error; err != nil { + return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap) + } + + return nil +} + +func (slf *LocationSearch) Delete() error { + var db = slf.build() + return db.Delete(&Location{}).Error +} + +func (slf *LocationSearch) First() (*Location, error) { + var ( + record = new(Location) + db = slf.build() + ) + + if err := db.First(record).Error; err != nil { + return record, err + } + + return record, nil +} + +func (slf *LocationSearch) Find() ([]*Location, int64, error) { + var ( + records = make([]*Location, 0) + total int64 + db = slf.build() + ) + + if err := db.Count(&total).Error; err != nil { + return records, total, fmt.Errorf("find count err: %v", err) + } + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, total, fmt.Errorf("find records err: %v", err) + } + + return records, total, nil +} + +func (slf *LocationSearch) FindNotTotal() ([]*Location, error) { + var ( + records = make([]*Location, 0) + db = slf.build() + ) + + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("find records err: %v", err) + } + + return records, nil +} + +// FindByQuery 鎸囧畾鏉′欢鏌ヨ. +func (slf *LocationSearch) FindByQuery(query string, args []interface{}) ([]*Location, int64, error) { + var ( + records = make([]*Location, 0) + total int64 + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if err := db.Count(&total).Error; err != nil { + return records, total, fmt.Errorf("find by query count err: %v", err) + } + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) + } + + return records, total, nil +} + +// FindByQueryNotTotal 鎸囧畾鏉′欢鏌ヨ&涓嶆煡璇㈡�绘潯鏁�. +func (slf *LocationSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*Location, error) { + var ( + records = make([]*Location, 0) + db = slf.Orm.Table(slf.TableName()).Where(query, args...) + ) + + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) + } + + return records, nil +} diff --git a/models/warehouse.go b/models/warehouse.go index 42f6408..49a4e9b 100644 --- a/models/warehouse.go +++ b/models/warehouse.go @@ -8,9 +8,10 @@ ) type ( - // Warehouse 閮ㄩ棬淇℃伅 + // Warehouse 浠撳簱 Warehouse 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:浠撳簱鍚嶇О"` //浠撳簱鍚嶇О Active bool `json:"active" gorm:"type:tinyint(1);not null;comment:鏄惁婵�娲�"` //鏄惁鍚敤锛屼紶true灏辫 Code string `json:"code" binding:"required,min=1,max=5" gorm:"index;type:varchar(255);not null;comment:浠撳簱缂栫爜"` //浠撳簱缂栫爜 @@ -19,6 +20,8 @@ ResupplyWhIdsStr string `json:"-" gorm:"column:resupply_wh_ids;type:varchar(255);not null;comment:琛ョ粰鏉ユ簮浠撳簱ID"` //琛ョ粰鏉ユ簮浠撳簱ID ResupplyWhIds []string `json:"resupplyWhIds" gorm:"-"` //琛ョ粰鏉ユ簮浠撳簱ID ResupplyWh []*Warehouse `json:"resupplyWh" gorm:"-"` //琛ョ粰鏉ユ簮浠撳簱 + CompanyId int `json:"companyId" gorm:"type:int;not null;comment:鍏徃id"` + Company Company `json:"company" gorm:"foreignKey:CompanyId"` } WarehouseSearch struct { @@ -28,6 +31,7 @@ PageSize int Keyword string Orm *gorm.DB + Preload bool } ) @@ -79,8 +83,13 @@ return slf } +func (slf *WarehouseSearch) SetPreload(preload bool) *WarehouseSearch { + slf.Preload = preload + return slf +} + func (slf *WarehouseSearch) build() *gorm.DB { - var db = slf.Orm.Table(slf.TableName()) + var db = slf.Orm.Model(&Warehouse{}) if slf.ID != 0 { db = db.Where("id = ?", slf.ID) @@ -93,10 +102,15 @@ if slf.Keyword != "" { db = db.Where("name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) } + if slf.Name != "" { db = db.Where("name = ?", slf.Name) } + if slf.Preload { + db = db.Preload("Company") + } + return db } diff --git a/request/company.go b/request/company.go new file mode 100644 index 0000000..15f87f5 --- /dev/null +++ b/request/company.go @@ -0,0 +1,15 @@ +package request + +type GetCompanyList struct { + PageInfo + Keyword string `json:"keyword"` +} + +type AddCompany struct { + Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:鍏徃鍚嶇О"` //鍏徃鍚嶇О +} + +type UpdateCompany struct { + ID uint `gorm:"comment:涓婚敭ID;primaryKey;" json:"id"` + AddCompany +} diff --git a/request/job_type.go b/request/job_type.go new file mode 100644 index 0000000..2ec6ecb --- /dev/null +++ b/request/job_type.go @@ -0,0 +1,32 @@ +package request + +import "wms/constvar" + +type GetJobTypeList struct { + PageInfo + Keyword string `json:"keyword"` +} + +type AddJobType struct { + 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 + WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:浠撳簱id"` //浠撳簱id + + DefaultLocationSrcId int `json:"defaultLocationSrcId" gorm:"type:int;not null;comment:榛樿婧愪綅缃甶d"` //榛樿婧愪綅缃甶d + 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"` //鍒涘缓娆犲崟 + ReturnJobTypeID int `json:"returnJobTypeID" gorm:"column:return_job_type_id"` //閫�璐х被鍨婭D +} + +type UpdateJobType struct { + ID uint `gorm:"comment:涓婚敭ID;primaryKey;" json:"id"` + AddJobType +} diff --git a/router/router.go b/router/router.go index 8637e3f..cfec672 100644 --- a/router/router.go +++ b/router/router.go @@ -31,6 +31,16 @@ organizeAPI.DELETE("department/:id", departmentController.Delete) // 鍒犻櫎閮ㄩ棬 } + // 鍏徃绠$悊 + companyController := new(controllers.CompanyController) + companyAPI := r.Group(urlPrefix + "/company") + { + companyAPI.GET("company", companyController.List) // 鑾峰彇鍏徃鍒楄〃 + companyAPI.POST("company", companyController.Add) // 鏂板鍏徃 + companyAPI.PUT("company/:id", companyController.Update) // 淇敼鍏徃 + companyAPI.DELETE("company/:id", companyController.Delete) // 鍒犻櫎鍏徃 + } + // 浠撳簱绠$悊 warehouseController := new(controllers.WarehouseController) warehouseAPI := r.Group(urlPrefix + "/warehouse") @@ -41,5 +51,15 @@ warehouseAPI.DELETE("warehouse/:id", warehouseController.Delete) // 鍒犻櫎浠撳簱 } + // 浣滀笟绫诲瀷 + jobTypeController := new(controllers.JobTypeController) + jobTypeAPI := 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) // 鍒犻櫎浣滀笟绫诲瀷 + } + return r } -- Gitblit v1.8.0