package com.gree.mall.manager.controller.goods;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gree.mall.manager.helper.ResponseHelper;
import com.gree.mall.manager.logic.goods.GoodsTagLogic;
import com.gree.mall.manager.plus.entity.GoodsTag;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@Api(value = "商品标签", tags = {"商品标签"})
@RequestMapping(value = "/goods/tag/", produces = "application/json; charset=utf-8")
public class GoodsTagController {

    @Autowired
    GoodsTagLogic goodsTagLogic;




    @ApiOperation(value = "分页查询商品标签")
    @GetMapping("/page")
    public ResponseHelper<IPage<GoodsTag>> pageGoodsTag(
            HttpServletRequest request,
            @ApiParam(value="1 属性标签  2标签",required = true) @RequestParam(required = true) Integer type,
            @ApiParam(required = true, value = "页号") @RequestParam("pageNum") Integer pageNum,
            @ApiParam(required = true, value = "页大小(-1即为不分页)") @RequestParam("pageSize") Integer pageSize
    ) {
        return ResponseHelper.success(goodsTagLogic.pageGoodsTag(request, pageNum, pageSize,type));
    }


    @ApiOperation(value = "批量编辑标签")
    @PostMapping("/add")
    public ResponseHelper updateGoodsTag(
            HttpServletRequest request,
            @ApiParam(value="标签(格式: 标签1,标签2 )",required = true) @RequestParam(required = true) String tags,
            @ApiParam(value="1 属性标签  2标签",required = true) @RequestParam(required = true) Integer type
    ) {
        goodsTagLogic.updateGoodsTag(request, tags,type);
        return ResponseHelper.success();
    }


}
