package com.zehong.web.controller.project;

import java.util.List;

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.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.project.TProductProject;
import com.zehong.system.service.project.ITProductProjectService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;

/**
 * 项目资料Controller
 * 
 * @author zehong
 * @date 2024-08-19
 */
@RestController
@RequestMapping("/project/info")
public class TProductProjectController extends BaseController
{
    @Autowired
    private ITProductProjectService tProductProjectService;

    /**
     * 查询项目资料列表
     */
    //@PreAuthorize("@ss.hasPermi('system:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProductProject tProductProject)
    {
        startPage();
        List<TProductProject> list = tProductProjectService.selectTProductProjectList(tProductProject);
        return getDataTable(list);
    }

    /**
     * 导出项目资料列表
     */
    //@PreAuthorize("@ss.hasPermi('system:project:export')")
    @Log(title = "项目资料", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TProductProject tProductProject)
    {
        List<TProductProject> list = tProductProjectService.selectTProductProjectList(tProductProject);
        ExcelUtil<TProductProject> util = new ExcelUtil<TProductProject>(TProductProject.class);
        return util.exportExcel(list, "项目资料数据");
    }

    /**
     * 获取项目资料详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:project:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tProductProjectService.selectTProductProjectById(id));
    }

    /**
     * 新增项目资料
     */
    //@PreAuthorize("@ss.hasPermi('system:project:add')")
    @Log(title = "项目资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProductProject tProductProject)
    {
        return toAjax(tProductProjectService.insertTProductProject(tProductProject));
    }

    /**
     * 修改项目资料
     */
    //@PreAuthorize("@ss.hasPermi('system:project:edit')")
    @Log(title = "项目资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProductProject tProductProject)
    {
        return toAjax(tProductProjectService.updateTProductProject(tProductProject));
    }

    /**
     * 删除项目资料
     */
    //@PreAuthorize("@ss.hasPermi('system:project:remove')")
    @Log(title = "项目资料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tProductProjectService.deleteTProductProjectByIds(ids));
    }
}
