package com.ruoyi.web.controller.projectV2;

import java.util.List;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.projectV2.XmConstructionRate;
import com.ruoyi.system.service.projectV2.IXmConstructionRateService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目施工进度照片
 * 
 * @author boman
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/projectV2/rate")
public class XmConstructionRateController extends BaseController
{
    @Autowired
    private IXmConstructionRateService xmConstructionRateService;

    /**
     * 查询项目施工进度列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:list')")
    @GetMapping("/list")
    public TableDataInfo list(XmConstructionRate xmConstructionRate)
    {
        startPage();
        List<XmConstructionRate> list = xmConstructionRateService.selectXmConstructionRateList(xmConstructionRate);
        return getDataTable(list);
    }

    /**
     * 查询项目施工进度列表_引资单位
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:listYj')")
    @GetMapping("/listYj")
    public TableDataInfo listYj(XmConstructionRate xmConstructionRate)
    {
        startPage();
        List<XmConstructionRate> list = xmConstructionRateService.selectXmConstructionRateList(xmConstructionRate);
        return getDataTable(list);
    }

    /**
     * 导出项目施工进度列表
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:export')")
    @Log(title = "项目施工进度", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(XmConstructionRate xmConstructionRate)
    {
        List<XmConstructionRate> list = xmConstructionRateService.selectXmConstructionRateList(xmConstructionRate);
        ExcelUtil<XmConstructionRate> util = new ExcelUtil<XmConstructionRate>(XmConstructionRate.class);
        return util.exportExcel(list, "rate");
    }

    /**
     * 获取项目施工进度详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(xmConstructionRateService.selectXmConstructionRateById(id));
    }

    /**
     * 新增项目施工进度
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:add')")
    @Log(title = "项目施工进度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XmConstructionRate xmConstructionRate)
    {
        return toAjax(xmConstructionRateService.insertXmConstructionRate(xmConstructionRate));
    }

    /**
     * 新增项目施工进度_引荐单位
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:addYj')")
    @Log(title = "项目施工进度", businessType = BusinessType.INSERT)
    @PostMapping("/addYj")
    public AjaxResult addYj(@RequestBody XmConstructionRate xmConstructionRate)
    {
        return toAjax(xmConstructionRateService.insertXmConstructionRate(xmConstructionRate));
    }

    /**
     * 修改项目施工进度
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:edit')")
    @Log(title = "项目施工进度", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody XmConstructionRate xmConstructionRate)
    {
        return toAjax(xmConstructionRateService.updateXmConstructionRate(xmConstructionRate));
    }

    /**
     * 修改项目施工进度_引荐单位
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:editYj')")
    @Log(title = "项目施工进度", businessType = BusinessType.UPDATE)
    @PostMapping("/editYj")
    public AjaxResult editYj(@RequestBody XmConstructionRate xmConstructionRate)
    {
        return toAjax(xmConstructionRateService.updateXmConstructionRate(xmConstructionRate));
    }

    /**
     * 删除项目施工进度
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:remove')")
    @Log(title = "项目施工进度", businessType = BusinessType.DELETE)
	@GetMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xmConstructionRateService.deleteXmConstructionRateByIds(ids));
    }

    /**
     * 删除项目施工进度_引荐单位
     */
    @PreAuthorize("@ss.hasPermi('projectV2:rate:removeYj')")
    @Log(title = "项目施工进度", businessType = BusinessType.DELETE)
    @GetMapping("/deleteYj/{ids}")
    public AjaxResult removeYj(@PathVariable Long[] ids)
    {
        return toAjax(xmConstructionRateService.deleteXmConstructionRateByIds(ids));
    }
}
