package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.GoodsCategory;
import com.ym.mec.biz.dal.page.GoodsCategoryQueryInfo;
import com.ym.mec.biz.service.GoodsCategoryService;
import com.ym.mec.common.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("category")
@Api(tags = "商品分类服务")
@RestController
public class GoodsCategoryController extends BaseController {

    @Autowired
    private GoodsCategoryService goodsCategoryService;

    @ApiOperation(value = "删除商品分类")
    @PostMapping("/del")
    public Object del(Integer id) {
        return succeed(goodsCategoryService.delete(id));
    }

    @ApiOperation(value = "新增、修改商品类型")
    @PostMapping("/upset")
    public Object upset(@RequestBody GoodsCategory goodsCategory){
        goodsCategoryService.upsetGoodsCategory(goodsCategory);
        return succeed();
    }

    @ApiOperation(value = "分页查询商品分类列表")
    @GetMapping("/queryPage")
    public Object queryPage(GoodsCategoryQueryInfo queryInfo) {
        return succeed(goodsCategoryService.queryPage(queryInfo));
    }
}
