package com.hc.gpweb.controller.api;

import com.hc.gpbusiness.model.WebBanner;
import com.hc.gpbusiness.service.WebBannerService;
import com.hc.gpcore.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 广告表
 * (WebBanner)表控制层
 *
 * @author java
 * @since 2020-07-29 16:23:04
 */

@RestController
@RequestMapping("/api/banner")
public class BannerController {

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

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

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


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


}