package com.ruoyi.web.controller.system;

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

import com.ruoyi.ss.intention.service.IIntentionService;
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.ss.intention.domain.Intention;
import com.ruoyi.ss.intention.domain.IntentionVO;
import com.ruoyi.ss.intention.domain.IntentionQuery;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合作意向Controller
 *
 * @author qzz
 * @date 2024-11-21
 */
@RestController
@RequestMapping("/system/intention")
public class IntentionController extends BaseController
{
    @Autowired
    private IIntentionService eIntentionService;

    /**
     * 查询合作意向列表
     */
    @PreAuthorize("@ss.hasPermi('system:intention:list')")
    @GetMapping("/list")
    public TableDataInfo list(IntentionQuery query)
    {
        startPage();
        startOrderBy();
        List<IntentionVO> list = eIntentionService.selectEIntentionList(query);
        return getDataTable(list);
    }

    /**
     * 导出合作意向列表
     */
    @PreAuthorize("@ss.hasPermi('system:intention:export')")
    @Log(title = "合作意向", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IntentionQuery query)
    {
        List<IntentionVO> list = eIntentionService.selectEIntentionList(query);
        ExcelUtil<IntentionVO> util = new ExcelUtil<IntentionVO>(IntentionVO.class);
        util.exportExcel(response, list, "合作意向数据");
    }

    /**
     * 获取合作意向详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:intention:query')")
    @GetMapping(value = "/{intentionId}")
    public AjaxResult getInfo(@PathVariable("intentionId") Long intentionId)
    {
        return success(eIntentionService.selectEIntentionByIntentionId(intentionId));
    }

    /**
     * 新增合作意向
     */
    @PreAuthorize("@ss.hasPermi('system:intention:add')")
    @Log(title = "合作意向", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Intention eIntention)
    {
        return toAjax(eIntentionService.insertEIntention(eIntention));
    }

    /**
     * 修改合作意向
     */
    @PreAuthorize("@ss.hasPermi('system:intention:edit')")
    @Log(title = "合作意向", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Intention eIntention)
    {
        return toAjax(eIntentionService.updateEIntention(eIntention));
    }

    /**
     * 删除合作意向
     */
    @PreAuthorize("@ss.hasPermi('system:intention:remove')")
    @Log(title = "合作意向", businessType = BusinessType.DELETE)
	@DeleteMapping("/{intentionIds}")
    public AjaxResult remove(@PathVariable Long[] intentionIds)
    {
        return toAjax(eIntentionService.deleteEIntentionByIntentionIds(intentionIds));
    }
}
