package com.yanzhu.jh.work.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.yanzhu.jh.work.domain.WorkJournalism;
import com.yanzhu.jh.work.service.IWorkJournalismService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 集团新闻Controller
 * 
 * @author JiangYuQi
 * @date 2023-08-18
 */
@RestController
@RequestMapping("/work/workJournalism")
public class WorkJournalismController extends BaseController
{
    @Autowired
    private IWorkJournalismService workJournalismService;

    /**
     * 查询集团新闻列表
     */
    @PreAuthorize("@ss.hasPermi('work:workJournalism:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkJournalism workJournalism)
    {
        startPage();
        List<WorkJournalism> list = workJournalismService.selectWorkJournalismList(workJournalism);
        return getDataTable(list);
    }

    /**
     * 查询集团新闻列表
     */
    @PreAuthorize("@ss.hasPermi('work:workJournalism:list')")
    @GetMapping("/findWorkJournalismGroupStatus")
    public AjaxResult findWorkJournalismGroupStatus(WorkJournalism workJournalism)
    {
        return success(workJournalismService.findWorkJournalismGroupStatus(workJournalism));
    }

    /**
     * 导出集团新闻列表
     */
    @PreAuthorize("@ss.hasPermi('work:workJournalism:export')")
    @Log(title = "集团新闻", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkJournalism workJournalism)
    {
        List<WorkJournalism> list = workJournalismService.selectWorkJournalismList(workJournalism);
        ExcelUtil<WorkJournalism> util = new ExcelUtil<WorkJournalism>(WorkJournalism.class);
        util.exportExcel(response, list, "集团新闻数据");
    }

    /**
     * 获取集团新闻详细信息
     */
    @PreAuthorize("@ss.hasPermi('work:workJournalism:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(workJournalismService.selectWorkJournalismById(id));
    }

    /**
     * 新增集团新闻
     */
    @PreAuthorize("@ss.hasPermi('work:workJournalism:add')")
    @Log(title = "集团新闻", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkJournalism workJournalism)
    {
        return toAjax(workJournalismService.insertWorkJournalism(workJournalism));
    }

    /**
     * 修改集团新闻
     */
    @PreAuthorize("@ss.hasPermi('work:workJournalism:edit')")
    @Log(title = "集团新闻", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkJournalism workJournalism)
    {
        return toAjax(workJournalismService.updateWorkJournalism(workJournalism));
    }

    /**
     * 删除集团新闻
     */
    @PreAuthorize("@ss.hasPermi('work:workJournalism:remove')")
    @Log(title = "集团新闻", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(workJournalismService.deleteWorkJournalismByIds(ids));
    }
}
