package com.djhk.uav.tfly.controller;

import com.djhk.common.annotation.Log;
import com.djhk.common.api.domain.SysPoliceFly;
import com.djhk.common.core.controller.BaseController;
import com.djhk.common.core.domain.AjaxResult;
import com.djhk.common.core.domain.entity.SysUser;
import com.djhk.common.core.domain.model.LoginUser;
import com.djhk.common.core.page.TableDataInfo;
import com.djhk.common.enums.BusinessType;
import com.djhk.common.exception.ServiceException;
import com.djhk.common.utils.SecurityUtils;
import com.djhk.common.core.domain.R;

import com.djhk.common.utils.poi.ExcelUtil;
import com.djhk.uav.tfly.model.TFly;
import com.djhk.uav.tfly.model.TFlyData;
import com.djhk.uav.tfly.service.ITFlyDataService;
import com.djhk.uav.tfly.service.ITFlyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * 飞行架次Controller
 *
 * @author ruoyi
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/fly")
public class TFlyController extends BaseController
{
    @Autowired
    private ITFlyService tFlyService;

    @Autowired
    private ITFlyDataService tFlyDataService;


    /**
     * 查询飞行架次列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TFly tFly)
    {
        startPage();
        tFly.setDeptId(SecurityUtils.getDeptId());
        List<TFly> list = tFlyService.selectTFlyList(tFly);
        return getDataTable(list);
    }

    /**
     * 导出飞行架次列表
     */
    @Log(title = "飞行架次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TFly tFly)
    {
        List<TFly> list = tFlyService.selectTFlyList(tFly);
        ExcelUtil<TFly> util = new ExcelUtil<TFly>(TFly.class);
        util.exportExcel(response, list, "飞行架次数据");
    }

    /**
     * 获取飞行架次详细信息
     */
    @GetMapping(value = "/{flySeq}")
    public R<TFly> getInfo(@PathVariable("flySeq") String flySeq)
    {
        return R.ok(tFlyService.selectTFlyByFlySeq(flySeq));
    }

    /**
     * 获取飞行架次详细信息
     */
//    @RequiresPermissions("system:fly:query")
    @GetMapping(value = "/tflyData/{orderid}")
    public R getTflyDataByOrderId(@PathVariable("orderid") String orderid)
    {
        List<TFlyData> list = tFlyDataService.getTflyDataByOrderId(orderid);
        return R.ok(list);
    }

}

