From 726662cd89d0fe6b24461c850495db8c37a3e8f1 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期三, 20 九月 2023 14:16:04 +0800
Subject: [PATCH] 作业类型路径修改

---
 models/location.go |   52 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/models/location.go b/models/location.go
index 54ec4af..5bcffe7 100644
--- a/models/location.go
+++ b/models/location.go
@@ -3,6 +3,7 @@
 import (
 	"fmt"
 	"gorm.io/gorm"
+	"wms/constvar"
 	"wms/pkg/mysqlx"
 )
 
@@ -10,8 +11,16 @@
 	// 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:浣嶇疆鍚嶇О"` //浣嶇疆鍚嶇О
+		Id                int                   `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+		Name              string                `json:"name" gorm:"index;type:varchar(255);not null;comment:浣嶇疆鍚嶇О"`     //浣嶇疆鍚嶇О
+		ParentId          int                   `json:"parentId" gorm:"type:int;not null"`                             //涓婄骇id
+		CompanyId         int                   `json:"companyId" gorm:"type:int;not null"`                            //鍏徃id
+		Company           Company               `json:"company" gorm:"foreignKey:CompanyId"`                           //鍏徃
+		Type              constvar.LocationType `json:"type" gorm:"type:int(11);not null;comment:浣嶇疆绫诲瀷"`                //浣嶇疆绫诲瀷
+		CountFrequency    int                   `json:"countFrequency" gorm:"type:tinyint;not null;comment:鐩樼偣棰戠巼锛堝ぉ锛�"`   //鐩樼偣棰戠巼锛堝ぉ锛�
+		IsScrapLocation   bool                  `json:"isScrapLocation" gorm:"type:tinyint;not null;comment:鏄惁鎶ュ簾浣嶇疆"`   //鏄惁鎶ュ簾浣嶇疆
+		IsReturnLocation  bool                  `json:"isReturnLocation" gorm:"type:tinyint;not null;comment:鏄惁閫�璐т綅缃�"`  //鏄惁閫�璐т綅缃�
+		ReplenishLocation bool                  `json:"replenishLocation" gorm:"type:tinyint;not null;comment:鏄惁琛ュ厖浣嶇疆"` //鏄惁琛ュ厖浣嶇疆
 	}
 
 	LocationSearch struct {
@@ -26,7 +35,7 @@
 )
 
 func (slf *Location) TableName() string {
-	return "location"
+	return "wms_location"
 }
 
 func NewLocationSearch() *LocationSearch {
@@ -68,6 +77,21 @@
 	return slf
 }
 
+func (slf *LocationSearch) SetType(_type int) *LocationSearch {
+	slf.Type = constvar.LocationType(_type)
+	return slf
+}
+
+func (slf *LocationSearch) SetParentId(parentId int) *LocationSearch {
+	slf.ParentId = parentId
+	return slf
+}
+
+func (slf *LocationSearch) SetCompanyId(companyId int) *LocationSearch {
+	slf.CompanyId = companyId
+	return slf
+}
+
 func (slf *LocationSearch) build() *gorm.DB {
 	var db = slf.Orm.Model(&Location{})
 
@@ -85,6 +109,17 @@
 
 	if slf.Name != "" {
 		db = db.Where("name = ?", slf.Name)
+	}
+
+	if slf.Type != 0 {
+		db = db.Where("type=?", slf.Type)
+	}
+
+	if slf.ParentId != 0 {
+		db = db.Where("parent_id=?", slf.ParentId)
+	}
+	if slf.CompanyId != 0 {
+		db = db.Where("company_id=?", slf.CompanyId)
 	}
 
 	return db
@@ -237,3 +272,14 @@
 
 	return records, nil
 }
+
+func (slf *LocationSearch) FindAll() ([]*Location, error) {
+	var (
+		records = make([]*Location, 0)
+		db      = slf.build()
+	)
+	if err := db.Find(&records); err != nil {
+		return records, fmt.Errorf("func FindAll err: %v", err)
+	}
+	return records, nil
+}

--
Gitblit v1.8.0