package com.ruoyi.web.controller.post;

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.ruoyi.post.domain.PostSeries;
import com.ruoyi.post.service.IPostSeriesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 邮贝套系信息; 
 * 
 * @author huianan
 * @date 2023-02-11
 */
@RestController
@RequestMapping("/post/series")
public class PostSeriesController extends BaseController
{
    @Autowired
    private IPostSeriesService postSeriesService;

    /**
     * 查询邮贝套系信息; 
     */
    @PreAuthorize("@ss.hasPermi('system:series:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostSeries postSeries)
    {
        startPage();
        List<PostSeries> list = postSeriesService.selectPostSeriesList(postSeries);
        return getDataTable(list);
    }

    /**
     * 导出邮贝套系信息; 
     */
    @PreAuthorize("@ss.hasPermi('system:series:export')")
    @Log(title = "邮贝套系信息; ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PostSeries postSeries)
    {
        List<PostSeries> list = postSeriesService.selectPostSeriesList(postSeries);
        ExcelUtil<PostSeries> util = new ExcelUtil<PostSeries>(PostSeries.class);
        util.exportExcel(response, list, "邮贝套系信息; ");
    }

    /**
     * 获取邮贝套系信息; 详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:series:query')")
    @GetMapping(value = "/{seriesId}")
    public AjaxResult getInfo(@PathVariable("seriesId") Long seriesId)
    {
        return success(postSeriesService.selectPostSeriesBySeriesId(seriesId));
    }

    /**
     * 新增邮贝套系信息; 
     */
    @PreAuthorize("@ss.hasPermi('system:series:add')")
    @Log(title = "邮贝套系信息; ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostSeries postSeries)
    {
        return toAjax(postSeriesService.insertPostSeries(postSeries));
    }

    /**
     * 修改邮贝套系信息; 
     */
    @PreAuthorize("@ss.hasPermi('system:series:edit')")
    @Log(title = "邮贝套系信息; ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostSeries postSeries)
    {
        return toAjax(postSeriesService.updatePostSeries(postSeries));
    }

    /**
     * 删除邮贝套系信息; 
     */
    @PreAuthorize("@ss.hasPermi('system:series:remove')")
    @Log(title = "邮贝套系信息; ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{seriesIds}")
    public AjaxResult remove(@PathVariable Long[] seriesIds)
    {
        return toAjax(postSeriesService.deletePostSeriesBySeriesIds(seriesIds));
    }
}
