package com.zfire.mall.manager.controller.k3;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zfire.mall.manager.bean.k3.KingDeeMaterialBean;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.k3.K3CategoryLogic;
import com.zfire.mall.manager.plus.entity.KingDeeCategory;
import com.zfire.mall.manager.plus.entity.KingDeeMaterial;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Api(value = "存货类别API", tags ={"存货类别API"} )
@RequestMapping(value = "/k3/category", produces = "application/json; charset=utf-8")
public class K3CategoryController {

    @Autowired
    K3CategoryLogic k3CategoryLogic;

    @ApiOperation(value = "存货类别列表")
    @GetMapping("/list")
    public ResponseHelper<IPage<KingDeeCategory>> list(
            @ApiParam(required = false, value = "搜索内容") @RequestParam(required = false) String keyword,
            @ApiParam(value = "页号",required = true)@RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true)@RequestParam Integer pageSize
    ) throws Exception {
        IPage<KingDeeCategory> list = k3CategoryLogic.list(keyword, pageNum, pageSize);
        return ResponseHelper.success(list);
    }


    @ApiOperation(value = "编辑存货类别")
    @PostMapping("/edit")
    public ResponseHelper edit(
            @ApiParam(required = true, value = "存货类别") @RequestBody KingDeeCategory kingDeeCategory
    ) throws Exception {
        k3CategoryLogic.edit(kingDeeCategory);
        return ResponseHelper.success();
    }



    @ApiOperation(value = "新增存货类别")
    @PostMapping("/add")
    public ResponseHelper add(
            @RequestBody KingDeeCategory kingDeeCategory
    ) throws Exception {
        k3CategoryLogic.add(kingDeeCategory);
        return ResponseHelper.success();
    }


    @ApiOperation(value = "删除存货类别")
    @PostMapping("/del")
    public ResponseHelper del(
            @ApiParam(value = "品类id",required = true)@RequestParam String id
    ) throws Exception {
        k3CategoryLogic.del(id);
        return ResponseHelper.success();
    }


    @ApiOperation(value = "存货类别详情")
    @PostMapping("/detail")
    public ResponseHelper<KingDeeCategory> detail(
            @ApiParam(value = "品类id",required = true)@RequestParam String id
    ) throws Exception {
        KingDeeCategory kingDeeCategory = k3CategoryLogic.detail(id);
        return ResponseHelper.success(kingDeeCategory);
    }

}
