package com.unis.crk.business.kcgl.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.unis.crk.business.kcgl.entity.DataKcglKcswDefault;
import com.unis.crk.business.kcgl.entity.vo.DataKcglKcswDefaultVo;
import com.unis.crk.business.kcgl.service.IDataKcglKcswDefaultService;
import com.unis.crk.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * <p>
 * 库存管理-库存实物表 前端控制器
 * </p>
 *
 * @author TangSong
 * @since 2021-10-11
 */
@Api(value = "库存管理-库存实物表",tags = {"库存管理-库存实物表"})
@RestController
@RequestMapping("dataKcglKcswDefault")
public class DataKcglKcswDefaultController {

    private final static Logger LOGGER = LoggerFactory.getLogger(DataKcglKcswDefaultController.class);


    @Autowired
    private IDataKcglKcswDefaultService dataKcglKcswDefaultService;


    /**
     * 根据ID查询数据
     * @param id
     * @return
     */
    @ApiOperation(value="查询", notes="根据ID查询数据")
    @PostMapping("getOne")
    public ResultUtil getOne(@RequestBody String id){
        LOGGER.info("入参为:{}",id);
        ResultUtil<DataKcglKcswDefault> data = new ResultUtil<>();
        if (StringUtils.isEmpty(id)){
            data.failed("传入的主键为空");
            return data;
        }
        data.success(this.dataKcglKcswDefaultService.getById(id));
        return data;
    }

    /**
         * 分页高级查询
         * @return
         */
    @ApiOperation(value="查询", notes="分页高级查询")
    @PostMapping(value="/findPage")
    public ResultUtil findPage(@RequestBody DataKcglKcswDefaultVo pageQuery) {
        ResultUtil<IPage<Map<String,Object>>> data = new ResultUtil<>();
        data.success(this.dataKcglKcswDefaultService.findPageVo(pageQuery));
        return data;
    }


}

