From 91d7ca06128f996844aa7d2d691d083c944bdf1d Mon Sep 17 00:00:00 2001
From: lishihai <dslsh@dscom>
Date: 星期三, 03 七月 2024 17:22:16 +0800
Subject: [PATCH] 导入物料/产品->新模版BUG修复

---
 controllers/attribute_value.go |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/controllers/attribute_value.go b/controllers/attribute_value.go
index a641d34..736b1d5 100644
--- a/controllers/attribute_value.go
+++ b/controllers/attribute_value.go
@@ -18,7 +18,7 @@
 // @Tags      灞炴�у�煎拰瀵硅薄
 // @Summary   娣诲姞灞炴�у�煎拰瀵硅薄
 // @Produce   application/json
-// @Param     object  body  request.AttributeValue true  "灞炴�у�煎拰瀵硅薄淇℃伅"
+// @Param     object  body  request.AddAttributeValue true  "灞炴�у�煎拰瀵硅薄淇℃伅"
 // @Success   200 {object} util.Response "鎴愬姛"
 // @Router    /api-wms/v1/attributeValue/add [post]
 func (slf *AttributeValueController) AddAttributeValue(c *gin.Context) {
@@ -55,7 +55,7 @@
 // @Tags      灞炴�у�煎拰瀵硅薄
 // @Summary   鏇存柊灞炴�у�煎拰瀵硅薄
 // @Produce   application/json
-// @Param     object  body  request.AttributeValue true  "灞炴�у�煎拰瀵硅薄淇℃伅"
+// @Param     object  body  request.UpdateAttributeValue true  "灞炴�у�煎拰瀵硅薄淇℃伅"
 // @Success   200 {object} util.Response "鎴愬姛"
 // @Router    /api-wms/v1/attributeValue/update [post]
 func (slf *AttributeValueController) UpdateAttributeValue(c *gin.Context) {
@@ -95,8 +95,7 @@
 // DeleteAttributeValue
 // @Tags      灞炴�у�煎拰瀵硅薄
 // @Summary   鍒犻櫎灞炴�у�煎拰瀵硅薄
-// @Produce   application/json
-// @Param		id	path		unit			true	"id"
+// @Param		id	path		string			true	"id"
 // @Success   200 {object} util.Response "鎴愬姛"
 // @Router    /api-wms/v1/attributeValue/delete/{id} [delete]
 func (slf *AttributeValueController) DeleteAttributeValue(c *gin.Context) {
@@ -113,3 +112,55 @@
 	}
 	util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛")
 }
+
+// ListAttributeValue
+// @Tags      灞炴�у�煎拰瀵硅薄
+// @Summary   鏌ヨ灞炴�у�煎拰瀵硅薄 鍒嗛〉鏉′欢绛涢�塚alue like '%v%' 妯$硦鏌ヨ
+// @Produce   application/json
+// object  body  request.OperationList true  "鏌ヨ鍙傛暟"
+// @Success   200 {object} util.Response "鎴愬姛"
+// @Router    /api-wms/v1/attributeValue/list [post]
+func (slf *AttributeValueController) ListAttributeValue(c *gin.Context) {
+	var params request.AttributeValueList
+	if err := c.BindJSON(&params); err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
+		return
+	}
+	search := models.NewAttributeValueSearch()
+	search.SetPage(params.Page, params.PageSize)
+	if params.EntityID != "" {
+		search.SetEntityID(params.EntityID)
+	}
+	if params.AttributeID != 0 {
+		search.SetAttributeID(params.AttributeID)
+	}
+	if params.Value != "" {
+		search.SetValue(params.Value)
+	}
+	list, total, err := search.Find()
+	if err != nil {
+		util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
+		return
+	}
+	util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
+}
+
+// PrimaryAttributeValue
+// @Tags      灞炴�у�煎拰瀵硅薄
+// @Summary   鏌ヨ灞炴�у�煎拰瀵硅薄 閫氳繃涓婚敭ID鏌ヨ
+// object  body  request.OperationList true  "鏌ヨ鍙傛暟"
+// @Success   200 {object} util.Response "鎴愬姛"
+// @Router    /api-wms/v1/attributeValue/primary/{id}  [get]
+func (slf *AttributeValueController) PrimaryAttributeValue(c *gin.Context) {
+	id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
+	if id == 0 {
+		util.ResponseFormat(c, code.RequestParamError, "鏃犳晥id")
+		return
+	}
+	attributeValue, err := models.NewAttributeValueSearch().SetID(uint(id)).First()
+	if err != nil {
+		util.ResponseFormat(c, code.RequestParamError, "鏌ヨ澶辫触")
+		return
+	}
+	util.ResponseFormat(c, code.Success, attributeValue)
+}

--
Gitblit v1.8.0