package com.bonus.zlpt.home.controller;

import com.bonus.zlpt.common.core.web.controller.BaseController;
import com.bonus.zlpt.common.core.web.domain.AjaxResult;
import com.bonus.zlpt.common.core.web.page.TableDataInfo;
import com.bonus.zlpt.common.security.utils.SecurityUtils;
import com.bonus.zlpt.file.service.FileUploadTencentService;
import com.bonus.zlpt.home.pojo.BmCarouselSet;
import com.bonus.zlpt.home.service.BmCarouselSetService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 轮播图配置(BmCarouselSet)表控制层
 *
 * @author makejava
 * @since 2023-12-03 15:24:10
 */
@RestController
@RequestMapping("bmCarouselSet")
public class BmCarouselSetController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private BmCarouselSetService bmCarouselSetService;

    @Resource
    private FileUploadTencentService fileUploadTencentService;

    /**
     * 获取轮播图列表
     * @param
     * @return
     */
    @GetMapping("/list/{carName}/{beginTime}/{endTime}")
    public TableDataInfo getCarouselChartList(@PathVariable("carName") String carName, @PathVariable("beginTime") String beginTime, @PathVariable("endTime") String endTime)
    {
        startPage();
        List<BmCarouselSet> list = bmCarouselSetService.selectBmCarouseList(carName, beginTime, endTime);
        return getDataTable(list);
    }

    /**
     * 新增轮播图信息
     * @param bmCarouselSet
     * @return
     */
    @PostMapping
    public AjaxResult addCarouselChartInfo(@RequestBody BmCarouselSet bmCarouselSet)
    {
        return toAjax(bmCarouselSetService.insertConfig(bmCarouselSet));
    }

    /**
     * 根据id查询轮播图信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public AjaxResult getCarouselChartInfo(@PathVariable("id") String id)
    {
        return toAjax(bmCarouselSetService.selectListById(id));
    }

    /**
     * 编辑轮播图信息
     * @param bmCarouselSet
     * @return
     */
    @PutMapping
    public AjaxResult updateCarouselChartInfo(@RequestBody BmCarouselSet bmCarouselSet)
    {
        return toAjax(bmCarouselSetService.update(bmCarouselSet));
    }

    /**
     * 删除轮播图信息
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public AjaxResult delCarouselChartInfo(@PathVariable("id") String id)
    {
        return toAjax(bmCarouselSetService.deleteById(id));
    }
}

