package com.unis.crk.cplbusiness.controller;

import com.unis.crk.cplbusiness.entity.DataKcglCplxckcDefault;
import com.unis.crk.cplbusiness.service.IDataKcglCplxckcDefaultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.unis.crk.utils.ResultUtil;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.unis.crk.cplbusiness.entity.vo.DataKcglCplxckcDefaultVo;
import com.unis.crk.cplbusiness.entity.vo.DataKcglCplxckcDefaultVo;import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import cn.hutool.json.JSONObject;


/**
 * <p>
 * 成品粮形成库存 前端控制器
 * </p>
 *
 * @author TangSong
 * @since 2022-03-21
 */
@CrossOrigin
@Api(value = "成品粮形成库存",tags = {"成品粮形成库存"})
@RestController
@RequestMapping("dataKcglCplxckcDefault")
public class DataKcglCplxckcDefaultController {

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


    @Autowired
    private IDataKcglCplxckcDefaultService dataKcglCplxckcDefaultService;


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

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

    /**
     * 查询保管台账
     * @return
     */
    @ApiOperation(value="查询保管台账", notes="查询保管台账")
    @PostMapping(value="/findPageBgtz")
    public ResultUtil findPageBgtz(@RequestBody DataKcglCplxckcDefaultVo pageQuery) {
        ResultUtil<IPage<Map<String,Object>>> data = new ResultUtil<>();
        if(StringUtils.isEmpty(pageQuery.getUnitId())){
            data.failed("传入的单位ID为空");
            return data;
        }
        data.success(this.dataKcglCplxckcDefaultService.findPageVoBgtz(pageQuery));
        return data;
    }

}

