package com.ruoyi.invest.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
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.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.invest.domain.HeartJourney;
import com.ruoyi.invest.domain.vo.HeartJourneyVo;
import com.ruoyi.invest.domain.dto.HeartJourneyDto;
import com.ruoyi.invest.service.IHeartJourneyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 心路历程Controller
 *
 * @author tianyongbao
 * @date 2024-04-09
 */
@Api(tags=" 心路历程")
@RestController
@RequestMapping("/heartJourney")
public class HeartJourneyController extends BaseController
{
    @Resource
    private IHeartJourneyService heartJourneyService;

    /**
     * 查询心路历程列表
     */
    @ApiOperation(value="查询心路历程列表",response = HeartJourneyVo.class)
    @RequiresPermissions("invest:heartJourney:list")
    @GetMapping("/list")
    public TableDataInfo list(HeartJourneyDto heartJourneyDto)
    {
        startPage();
        List<HeartJourneyVo> list = heartJourneyService.selectHeartJourneyList(heartJourneyDto);
        return getDataTable(list);
    }

    /**
     * 导出心路历程列表
     */
    @ApiOperation(value="导出心路历程列表")
    @RequiresPermissions("invest:heartJourney:export")
    @Log(title = "心路历程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HeartJourneyDto heartJourneyDto)
    {
        List<HeartJourneyVo> list = heartJourneyService.selectHeartJourneyList(heartJourneyDto);
        ExcelUtil<HeartJourneyVo> util = new ExcelUtil<HeartJourneyVo>(HeartJourneyVo.class);
        util.exportExcel(response, list, "心路历程数据");
    }

    /**
     * 获取心路历程详细信息
     */
    @ApiOperation(value="获取心路历程详细信息")
    @RequiresPermissions("invest:heartJourney:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(heartJourneyService.selectHeartJourneyById(id));
    }

    /**
     * 新增心路历程
     */
    @ApiOperation(value="新增心路历程")
    @RequiresPermissions("invest:heartJourney:add")
    @Log(title = "心路历程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HeartJourney heartJourney)
    {
        return toAjax(heartJourneyService.insertHeartJourney(heartJourney));
    }

    /**
     * 修改心路历程
     */
    @ApiOperation(value="修改心路历程")
    @RequiresPermissions("invest:heartJourney:edit")
    @Log(title = "心路历程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HeartJourney heartJourney)
    {
        return toAjax(heartJourneyService.updateHeartJourney(heartJourney));
    }

    /**
     * 删除心路历程
     */
    @ApiOperation(value="删除心路历程")
    @RequiresPermissions("invest:heartJourney:remove")
    @Log(title = "心路历程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(heartJourneyService.deleteHeartJourneyByIds(ids));
    }
}
