package com.ruoyi.web.controller.system;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.system.domain.PostCollectionsSystem;
import com.ruoyi.system.service.IPostCollectionsSystemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 藏品套系Controller
 *
 * @author ruoyi
 * @date 2023-02-15
 */
@Api(tags = "PostCollectionsSystemController",description = "藏品套系")
@RestController
@RequestMapping("/system/system")
public class PostCollectionsSystemController extends BaseController
{
    @Autowired
    private IPostCollectionsSystemService postCollectionsSystemService;

    /**
     * 查询藏品套系列表
     */
    @ApiOperation("查询藏品套系列表")
    @PreAuthorize("@ss.hasPermi('system:system:list')")
    @GetMapping("/list")
    public TableDataInfo list(PostCollectionsSystem postCollectionsSystem)
    {
        startPage();
        List<PostCollectionsSystem> list = postCollectionsSystemService.selectPostCollectionsSystemList(postCollectionsSystem);
        return getDataTable(list);
    }

    /**
     * 导出藏品套系列表
     */
    @ApiOperation("导入藏品套系列表")
    @PreAuthorize("@ss.hasPermi('system:system:export')")
    @Log(title = "藏品套系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PostCollectionsSystem postCollectionsSystem)
    {
        List<PostCollectionsSystem> list = postCollectionsSystemService.selectPostCollectionsSystemList(postCollectionsSystem);
        ExcelUtil<PostCollectionsSystem> util = new ExcelUtil<PostCollectionsSystem>(PostCollectionsSystem.class);
        util.exportExcel(response, list, "藏品套系数据");
    }

    /**
     * 获取藏品套系详细信息
     */
    @ApiOperation("获取藏品套系详细信息")
    @PreAuthorize("@ss.hasPermi('system:system:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(postCollectionsSystemService.selectPostCollectionsSystemById(id));
    }

    /**
     * 新增藏品套系
     */
    @ApiOperation("新增藏品套系")
    @PreAuthorize("@ss.hasPermi('system:system:add')")
    @Log(title = "藏品套系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostCollectionsSystem postCollectionsSystem)
    {
        return toAjax(postCollectionsSystemService.insertPostCollectionsSystem(postCollectionsSystem));
    }

    /**
     * 修改藏品套系
     */
    @ApiOperation("修改藏品套系")
    @PreAuthorize("@ss.hasPermi('system:system:edit')")
    @Log(title = "藏品套系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostCollectionsSystem postCollectionsSystem)
    {
        return toAjax(postCollectionsSystemService.updatePostCollectionsSystem(postCollectionsSystem));
    }

    /**
     * 删除藏品套系
     */
    @ApiOperation("删除藏品套系")
    @PreAuthorize("@ss.hasPermi('system:system:remove')")
    @Log(title = "藏品套系", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(postCollectionsSystemService.deletePostCollectionsSystemByIds(ids));
    }

    /**
     * 根据套系名称进行查询
     * @param title
     * @param TimeLeft
     * @param TimeRight
     * @return
     */
    @ApiOperation("根据套系名称进行查询")
    @PreAuthorize("@ss.hasPermi('system:collections:queryCollections')")
    @GetMapping("/queryCollections")
    public TableDataInfo list(@RequestParam(value="title",required = false)String title,
                              @RequestParam(value="TimeLeft",required = false) Date TimeLeft,
                              @RequestParam(value="TimeRight",required = false) Date TimeRight)
    {
        startPage();
        List<PostCollectionsSystem> list= postCollectionsSystemService.selectByTitleAndTime(title,TimeLeft,TimeRight);
        return getDataTable(list);
    }
}
