package com.hc.web.controller.browser.front;

import com.hc.business.service.BannerService;
import com.hc.core.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;


/**
 * 广告表
 * (Banner)表控制层
 *
 * @author java
 * @since 2020-11-26 09:29:54
 */

@RestController
@RequestMapping("/new/api/front/banner")
public class FrontBannerController {

    /**
     * 服务对象
     */
    private final BannerService bannerService;

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

    @GetMapping("/{id}")
    @ApiOperation(value = "依据主键获取 Banner", response = Result.class)
    public Result selectFrontDetail(@PathVariable("id") Integer id) {
        return Result.success(this.bannerService.queryById(id));
    }

    @GetMapping("/list")
    @ApiOperation(value = "获取 Banner列表(分页)", response = Result.class)
    public Result listFrontBanner(@RequestParam(defaultValue = "0") Integer page,
                                  @RequestParam(defaultValue = "0") Integer size) {
        return Result.success(bannerService.queryAllByLimit(page, size));
    }


}