package com.ruoyi.web.controller.invest;

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

import com.ruoyi.invest.domain.TProjectCirculation;
import com.ruoyi.invest.service.ITProjectCirculationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目流转记录Controller
 * 
 * @author ruoyi
 * @date 2024-03-04
 */
@Api(tags = "项目流转记录")
@RestController
@RequestMapping("/system/circulation")
public class TProjectCirculationController extends BaseController
{
    @Autowired
    private ITProjectCirculationService tProjectCirculationService;

    /**
     * 查询项目流转记录列表
     */
    @ApiOperation("查询项目流转记录列表")
    @PreAuthorize("@ss.hasPermi('system:circulation:list')")
    @GetMapping("/list")
    public TableDataInfo list(TProjectCirculation tProjectCirculation)
    {
        startPage();
        List<TProjectCirculation> list = tProjectCirculationService.selectTProjectCirculationList(tProjectCirculation);
        return getDataTable(list);
    }

    /**
     * 导出项目流转记录列表
     */
    @ApiOperation("导出项目流转记录列表")
    @PreAuthorize("@ss.hasPermi('system:circulation:export')")
    @Log(title = "项目流转记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TProjectCirculation tProjectCirculation)
    {
        List<TProjectCirculation> list = tProjectCirculationService.selectTProjectCirculationList(tProjectCirculation);
        ExcelUtil<TProjectCirculation> util = new ExcelUtil<TProjectCirculation>(TProjectCirculation.class);
        util.exportExcel(response, list, "项目流转记录数据");
    }

    /**
     * 获取项目流转记录详细信息
     */
    @ApiOperation("获取项目流转记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:circulation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tProjectCirculationService.selectTProjectCirculationById(id));
    }

    /**
     * 新增项目流转记录
     */
    @ApiOperation("新增项目流转记录")
    @PreAuthorize("@ss.hasPermi('system:circulation:add')")
    @Log(title = "项目流转记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TProjectCirculation tProjectCirculation)
    {

        return toAjax(tProjectCirculationService.insertTProjectCirculation(tProjectCirculation));
    }

    /**
     * 修改项目流转记录
     */
    @ApiOperation("修改项目流转记录")
    @PreAuthorize("@ss.hasPermi('system:circulation:edit')")
    @Log(title = "项目流转记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TProjectCirculation tProjectCirculation)
    {
        return toAjax(tProjectCirculationService.updateTProjectCirculation(tProjectCirculation));
    }

    /**
     * 删除项目流转记录
     */
    @ApiOperation("删除项目流转记录")
    @PreAuthorize("@ss.hasPermi('system:circulation:remove')")
    @Log(title = "项目流转记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tProjectCirculationService.deleteTProjectCirculationByIds(ids));
    }

    /**
     * 根据项目ID获取项目流转记录
     */
    @ApiOperation("根据项目ID获取项目流转记录")
    @GetMapping(value = "/listProjectPoolId")
    public AjaxResult listProjectPoolId(String projectPoolId)
    {
        return success(tProjectCirculationService.listProjectPoolId(projectPoolId));
    }

}
