package com.ruoyi.project.business.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.business.domain.TjCivilEngineering;
import com.ruoyi.project.business.domain.bo.civil.EngineeringAddBO;
import com.ruoyi.project.business.domain.vo.Civil.CivilParam;
import com.ruoyi.project.business.domain.vo.Civil.TjCivilEngineeringVo;
import com.ruoyi.project.business.domain.vo.selectParam.CivilEngineeringParam;
import com.ruoyi.project.business.service.ITjCivilEngineeringService;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 【土建出图】Controller
 *
 * @author ruoyi
 * @date 2024-05-20
 */
@RestController
@RequestMapping("/business/engineering")
public class TjCivilEngineeringController extends BaseController {

    @Autowired
    private ITjCivilEngineeringService tjCivilEngineeringService;

    /**
     * 查询【土建出图】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CivilEngineeringParam tjCivilEngineering) {
        startPage();
        PageInfo<TjCivilEngineering> list = tjCivilEngineeringService.selectTjCivilEngineeringList(tjCivilEngineering);
        return getDataTable(list);
    }

    /**
     * 导出【土建出图】列表
     */
    @Log(title = "【土建出图】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CivilEngineeringParam tjCivilEngineering) {
        PageInfo<TjCivilEngineering> list = tjCivilEngineeringService.selectTjCivilEngineeringList(tjCivilEngineering);
        ExcelUtil<TjCivilEngineering> util = new ExcelUtil<TjCivilEngineering>(TjCivilEngineering.class);
        util.exportExcel(response, list.getList(), "【土建出图】数据");
    }

    /**
     * 获取【土建出图】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tjCivilEngineeringService.selectTjCivilEngineeringById(id));
    }

    /**
     * 新增【土建出图】
     */
    @Log(title = "【土建出图】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EngineeringAddBO tjCivilEngineering) {
        return toAjax(tjCivilEngineeringService.insertTjCivilEngineering(tjCivilEngineering));
    }

    /**
     * 修改【土建出图】
     */
    @Log(title = "【土建出图】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TjCivilEngineering tjCivilEngineering) {
        return toAjax(tjCivilEngineeringService.updateTjCivilEngineering(tjCivilEngineering));
    }

    /**
     * 删除【土建出图】
     */
    @Log(title = "【土建出图】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tjCivilEngineeringService.deleteTjCivilEngineeringByIds(ids));
    }

    @GetMapping("/unFinish")
    public TableDataInfo getOutList() {
        List<TjCivilEngineeringVo> list = tjCivilEngineeringService.getOutList();
        return getDataTable(list);
    }

    @PostMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody CivilParam civilParam) {
        return toAjax(tjCivilEngineeringService.changeStatus(civilParam));
    }
}
