package com.dk.mdm.controller.mst;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.mst.GoodsCategory;
import com.dk.common.controller.BaseController;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.mst.GoodsCategoryQuery;
import com.dk.mdm.model.query.mst.GoodsSeriesQuery;
import com.dk.mdm.model.response.mst.GoodsBrandResponse;
import com.dk.mdm.model.response.mst.GoodsCategoryResponse;
import com.dk.mdm.model.vo.mst.GoodsBrandVO;
import com.dk.mdm.model.vo.mst.GoodsCategoryVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.mst.GoodsCategoryService;

@Api(tags = "商品种类API接口")
@RestController
@RequestMapping("/mst/goodsCategory")
public class GoodsCategoryController{

    public BaseService<GoodsCategory> getService() {
        return goodsCategoryService;
    }

    @Autowired
    private GoodsCategoryService goodsCategoryService;


    /**
     * @desc : 条件查询
     * @author : 于继渤
     * @date : 2024/2/26 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<GoodsCategoryResponse>> selectByCond(@RequestBody GoodsCategoryQuery goodsCategoryQuery) {
        return goodsCategoryService.selectByCond(goodsCategoryQuery);
    }


    /**
     * @desc : 新建
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation(value = "新建", notes = "新建")
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody GoodsCategoryVO goodsCategoryVO) {
        return goodsCategoryService.insert(goodsCategoryVO);
    }




    /**
     * @desc : 编辑
     * @author : 于继渤
     * @date : 2023/1/5 9:39
     */
    @ApiOperation( value = "编辑", notes = "编辑" )
    @PostMapping({"update"})
    public ResponseResultVO<?> update(@RequestBody GoodsCategoryVO goodsCategoryVO) {
        return goodsCategoryService.update(goodsCategoryVO);
    }


    /**
     * @desc : 停用
     * @author : 于继渤
     * @date :  2023/1/4 9:39
     */
    @PostMapping("disable/{id}")
    public ResponseResultVO<Boolean> disable(@PathVariable String id) {
        //批量停用
        goodsCategoryService.disableBachByParentId(id);
        return this.getService().disable(id);
    }

    /**
     * @desc : 启用
     * @author : 于继渤
     * @date :  2023/1/4 9:39
     */
    @PostMapping("enable/{id}")
    public ResponseResultVO<Boolean> enable(@PathVariable String id) {
        //批量启用
        goodsCategoryService.enableBachByParentId(id);
        return this.getService().enable(id);
    }

}
