From 924d4245c26934dfcb069a25a4911a6289389097 Mon Sep 17 00:00:00 2001
From: lishihai <dslsh@dscom>
Date: 星期四, 20 六月 2024 17:03:07 +0800
Subject: [PATCH] 查询属性值和对象 通过主键ID查询
---
controllers/attribute.go | 21 +++++++++++++++++++++
models/attribute.go | 4 ++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/controllers/attribute.go b/controllers/attribute.go
index 5f94874..926a09f 100644
--- a/controllers/attribute.go
+++ b/controllers/attribute.go
@@ -6,6 +6,7 @@
"github.com/gin-gonic/gin"
"github.com/spf13/cast"
"gorm.io/gorm"
+ "strconv"
"wms/extend/code"
"wms/extend/util"
"wms/models"
@@ -184,3 +185,23 @@
//
// util.ResponseFormat(c, code.UpdateSuccess, first)
//}
+
+// PrimaryAttribute
+// @Tags 灞炴�у�煎拰瀵硅薄
+// @Summary 鏌ヨ灞炴�у�煎拰瀵硅薄 閫氳繃涓婚敭ID鏌ヨ
+// object body request.OperationList true "鏌ヨ鍙傛暟"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/attribute/primary/{id} [get]
+func (slf *AttributeValueController) PrimaryAttribute(c *gin.Context) {
+ id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
+ if id == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "鏃犳晥id")
+ return
+ }
+ attribute, err := models.NewAttributeSearch().SetID(uint(id)).First()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏌ヨ澶辫触")
+ return
+ }
+ util.ResponseFormat(c, code.Success, attribute)
+}
diff --git a/models/attribute.go b/models/attribute.go
index 31e6d90..496178e 100644
--- a/models/attribute.go
+++ b/models/attribute.go
@@ -25,6 +25,7 @@
PageNum int
PageSize int
Orm *gorm.DB
+ Keyword string
}
)
@@ -130,6 +131,9 @@
if slf.Name != "" {
db = db.Where("name = ?", slf.Name)
}
+ if slf.Keyword != "" {
+ db = db.Where("id like ? or data_type like ? or entity_type like ?", fmt.Sprintf("%%%v%%", slf.Keyword), fmt.Sprintf("%%%v%%", slf.Keyword), fmt.Sprintf("%%%v%%", slf.Keyword))
+ }
return db
}
--
Gitblit v1.8.0