package com.yanzhu.project.controller;

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

import com.yanzhu.common.core.domain.entity.SysUser;
import com.yanzhu.common.core.text.Convert;
import com.yanzhu.project.domain.ProProjectInfo;
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.yanzhu.common.annotation.Log;
import com.yanzhu.common.core.controller.BaseController;
import com.yanzhu.common.core.domain.AjaxResult;
import com.yanzhu.common.enums.BusinessType;
import com.yanzhu.project.domain.ProProjectApply;
import com.yanzhu.project.service.IProProjectApplyService;
import com.yanzhu.common.utils.poi.ExcelUtil;
import com.yanzhu.common.core.page.TableDataInfo;

/**
 * 项目申请Controller
 * 
 * @author yanZhu
 * @date 2024-02-23
 */
@RestController
@RequestMapping("/project/projectApply")
public class ProProjectApplyController extends BaseController
{
    @Autowired
    private IProProjectApplyService proProjectApplyService;

    /**
     * 查询项目申请列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProProjectApply proProjectApply)
    {
        startPage();
        List<ProProjectApply> list = proProjectApplyService.selectProProjectApplyList(proProjectApply);
        return getDataTable(list);
    }

    /**
     * 导出项目申请列表
     */
    @PreAuthorize("@ss.hasPermi('project:projectApply:export')")
    @Log(title = "项目申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProProjectApply proProjectApply)
    {
        List<ProProjectApply> list = proProjectApplyService.selectProProjectApplyList(proProjectApply);
        ExcelUtil<ProProjectApply> util = new ExcelUtil<ProProjectApply>(ProProjectApply.class);
        util.exportExcel(response, list, "项目申请数据");
    }

    /**
     * 获取项目申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:projectApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proProjectApplyService.selectProProjectApplyById(id));
    }

    /**
     * 新增项目申请
     */
    @PreAuthorize("@ss.hasPermi('project:projectApply:add')")
    @Log(title = "项目申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProProjectApply proProjectApply)
    {
        return toAjax(proProjectApplyService.insertProProjectApply(proProjectApply));
    }

    /**
     * 修改项目申请
     */
    @PreAuthorize("@ss.hasPermi('project:projectApply:edit')")
    @Log(title = "项目申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProProjectApply proProjectApply)
    {
        return toAjax(proProjectApplyService.updateProProjectApply(proProjectApply));
    }

    /**
     * 删除项目申请
     */
    @PreAuthorize("@ss.hasPermi('project:projectApply:remove')")
    @Log(title = "项目申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proProjectApplyService.deleteProProjectApplyByIds(ids));
    }

}
