package com.ruoyi.web.modules.innovation.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
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.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.modules.innovation.domain.BizTechProjectGuide;
import com.ruoyi.web.modules.innovation.service.IBizTechProjectGuideService;

/**
 * 科技项目与活动（科技项目指南）管理
 */
@RestController
@RequestMapping("/innovationPlatform/techProjectGuide")
public class BizTechProjectGuideController extends BaseController
{
    @Autowired
    private IBizTechProjectGuideService bizTechProjectGuideService;

    @PreAuthorize("@ss.hasPermi('innovationPlatform:techProjectGuide:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizTechProjectGuide query)
    {
        startPage();
        List<BizTechProjectGuide> list = bizTechProjectGuideService.selectBizTechProjectGuideList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('innovationPlatform:techProjectGuide:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizTechProjectGuideService.selectBizTechProjectGuideById(id));
    }

    @PreAuthorize("@ss.hasPermi('innovationPlatform:techProjectGuide:add')")
    @Log(title = "科技项目指南", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody BizTechProjectGuide row)
    {
        row.setCreateBy(getUsername());
        return toAjax(bizTechProjectGuideService.insertBizTechProjectGuide(row));
    }

    @PreAuthorize("@ss.hasPermi('innovationPlatform:techProjectGuide:edit')")
    @Log(title = "科技项目指南", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody BizTechProjectGuide row)
    {
        row.setUpdateBy(getUsername());
        return toAjax(bizTechProjectGuideService.updateBizTechProjectGuide(row));
    }

    @PreAuthorize("@ss.hasPermi('innovationPlatform:techProjectGuide:remove')")
    @Log(title = "科技项目指南", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizTechProjectGuideService.deleteBizTechProjectGuideByIds(ids));
    }

    @PreAuthorize("@ss.hasPermi('innovationPlatform:techProjectGuide:publish')")
    @Log(title = "科技项目指南发布", businessType = BusinessType.UPDATE)
    @PostMapping("/publish/{id}")
    public AjaxResult publish(@PathVariable Long id)
    {
        return toAjax(bizTechProjectGuideService.publish(id));
    }

    @PreAuthorize("@ss.hasPermi('innovationPlatform:techProjectGuide:offline')")
    @Log(title = "科技项目指南下架", businessType = BusinessType.UPDATE)
    @PostMapping("/offline/{id}")
    public AjaxResult offline(@PathVariable Long id)
    {
        return toAjax(bizTechProjectGuideService.offline(id));
    }
}
