package com.zzsmart.qomo.kn.cost.manage.controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailSearch;
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * <p>
 * 标准成本明细表 前端控制器
 * </p>
 *
 * @author app_scene_cost_purchase_price
 * @since 2024-06-19
 */
@Api(tags = "cost-标准成本单行查询")
@RestController
@RequestMapping("//costStandardDetail")
@Slf4j
public class CostStandardDetailController extends JeecgController<CostStandardDetail, CostStandardDetailService> {
    @Autowired
    private CostStandardDetailService costStandardDetailService;

    /**
     * 分页列表查询
     *
     * @param costStandard
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    //@AutoLog(value = "标准成本单行列表查询")
    @ApiOperation(value = "标准成本单行列表查询", notes = "标准成本单行列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<CostStandardDetailVO>> queryPageList(CostStandardDetailVO costStandard, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {

        Page<CostStandardDetailVO> page = new Page<CostStandardDetailVO>(pageNo, pageSize);
        IPage<CostStandardDetailVO> pageList = costStandardDetailService.pageList(page, costStandard);
        return Result.OK(pageList);
    }

    /**
     * 导出excel
     *
     * @param request
     * @param costStandardDetailSearch
     */
    @RequestMapping(value = "/exportXls", method = RequestMethod.GET)
    @ApiOperation(value = "单行查询导出", notes = "单行查询导出")
    public Result exportXls(HttpServletRequest request, HttpServletResponse response, CostStandardDetailSearch costStandardDetailSearch) throws IOException {
        JSONObject result = costStandardDetailService.exportExcel(request, response, costStandardDetailSearch);
        return Result.OK(result);
    }
}
