From 2baa7bad0482613829e217997c44a51d8ec0ec66 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期三, 20 九月 2023 09:51:58 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS

---
 models/location.go |   39 ++++++++++++++++++++++++++++++++++++++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/models/location.go b/models/location.go
index 41e6992..5bcffe7 100644
--- a/models/location.go
+++ b/models/location.go
@@ -16,7 +16,7 @@
 		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:tinyint;not null;comment:浣嶇疆绫诲瀷"`                //浣嶇疆绫诲瀷
+		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:鏄惁閫�璐т綅缃�"`  //鏄惁閫�璐т綅缃�
@@ -77,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{})
 
@@ -94,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
@@ -246,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