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.Supplier;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.mst.SupplierQuery;
import com.dk.mdm.model.vo.mst.SupplierVo;
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.SupplierService;

import java.util.List;

@Api(tags = "供应商API接口")
@RestController
@RequestMapping("/mst/supplier")
public class SupplierController{

    public BaseService<Supplier> getService() {
        return supplierService;
    }

    @Autowired
    private SupplierService supplierService;
    /**
     * @desc   : 条件查询
     * @author : 王英杰
     * @date   : 2024/2/26 14:02
     */
    @ApiOperation( value = "分页、关联、条件查询", notes = "分页、关联、条件查询" )
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<Supplier>> selectByCond(@RequestBody SupplierQuery supplierQuery) {
        return supplierService.selectByCond(supplierQuery);
    }

    /**
     * @desc : 新建供应商
     * @author : 王英杰
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "新建供应商", notes = "新建供应商")
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody SupplierVo supplierVo) {
        return supplierService.insert(supplierVo);
    }

    /**
     * @desc : 编辑供应商
     * @author : 王英杰
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "编辑员工", notes = "编辑员工")
    @PostMapping({"update"})
    public ResponseResultVO<?> update(@RequestBody SupplierVo supplierVo) {
        return supplierService.update(supplierVo);
    }


    /**
     * @desc : 停用供应商
     * @author : 王英杰
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "停用供应商", notes = "停用供应商")
    @PostMapping({"deactivate_data"})
    public ResponseResultVO<?> deactivateData(@RequestBody SupplierVo supplierVo) {
        return supplierService.deactivateData(supplierVo);
    }

    /**
     * @desc : 停用批量
     * @author : songy
     * @date : 2023/2/29 10:34
     */
    @ApiOperation(value = "批量停用", notes = "批量停用")
    @PostMapping("disable_batch")
    public ResponseResultVO<Boolean> disableBatch(@RequestBody List<String> ids) {
        return this.getService().disableBatch(ids);
    }

    /**
     * @desc : 启用批量
     * @author : songy
     * @date : 2023/2/29 10:34
     */
    @ApiOperation(value = "批量启用", notes = "批量启用")
    @PostMapping("enable_batch")
    public ResponseResultVO<Boolean> enableBatch(@RequestBody List<String> ids) {
        return this.getService().enableBatch(ids);
    }

    /**
     * @desc : 通过ID查询
     * @author : 王英杰
     * @date : 2023/1/9 10:41
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return supplierService.selectById(id);
    }

}
