lishihai
2024-06-14 86530fe51ee65aea39e07e8fa131bf6e3310c4b0
controllers/attribute_value.go
@@ -95,7 +95,6 @@
// DeleteAttributeValue
// @Tags      属性值和对象
// @Summary   删除属性值和对象
// @Produce   application/json
// @Param      id   path      unit         true   "id"
// @Success   200 {object} util.Response "成功"
// @Router    /api-wms/v1/attributeValue/delete/{id} [delete]
@@ -113,3 +112,55 @@
   }
   util.ResponseFormat(c, code.Success, "删除成功")
}
// ListAttributeValue
// @Tags      属性值和对象
// @Summary   查询属性值和对象 分页条件筛选Value 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, "参数解析失败,数据类型错误")
      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)
}