package com.kym.admin.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.kym.common.R;
import com.kym.common.annotation.SysLog;
import com.kym.entity.Banner;
import com.kym.entity.queryParams.BannerQueryParam;
import com.kym.service.BannerService;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * banner配置表 前端控制器
 * </p>
 *
 * @author skyline
 * @since 2023-10-18
 */
@RestController
@RequestMapping("/banner")
public class BannerController {

    private final BannerService bannerService;

    public BannerController(BannerService bannerService) {
        this.bannerService = bannerService;
    }

    @SysLog("新增Banner")
    @PostMapping("add")
    R<?> createBanner(@RequestBody Banner banner) {
        return R.success(bannerService.createBanner(banner));
    }

    @SysLog("修改Banner")
    @PostMapping("modify")
    R<?> updateBanner(@RequestBody Banner banner) {
        return R.success(bannerService.updateBanner(banner));
    }

    @SysLog("Banner列表")
    @SaIgnore
    @PostMapping("list")
    R<?> listBanner(@RequestBody BannerQueryParam params) {
        return R.success(bannerService.listBanner(params));
    }

    @SysLog("查询单个Banner")
    @GetMapping("/{bannerId}")
    R<?> getBannerById(@PathVariable("bannerId") String bannerId) {
        return R.success(bannerService.getById(bannerId));
    }


}
