| | |
| | | // @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) { |
| | |
| | | // @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) { |
| | |
| | | // 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) { |
| | |
| | | } |
| | | 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(¶ms); 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) |
| | | } |