package com.liquidnet.service.kylin.controller;


import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.entity.KylinBanners;
import com.liquidnet.service.kylin.service.impl.BannersServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 轮播图 前端接口控制器
 * </p>
 *
 * @author jiangxiulong
 * @since 2021-05-10
 */

@Api(tags = "前端-banner")
@RestController
@RequestMapping("banners")
public class KylinBannersController {

    @Autowired
    private BannersServiceImpl bannersServiceImpl;

    @GetMapping("")
    @ApiOperation("banner列表")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "query", dataType = "String", name = "position", value = "展示位置 1首页 3周边 5积分商城 6YB 8视频", required = true),
            @ApiImplicitParam(type = "query", dataType = "String", name = "provinceName", value = "城市名称"),
    })
    public ResponseDto<List<KylinBanners>> blist(
            @RequestParam() String position,
            @RequestParam(defaultValue = "") String provinceName
    ) {
        try {
            List<KylinBanners> result = bannersServiceImpl.blist(position, provinceName);
            return ResponseDto.success(result);
        } catch (Exception e) {
            return ResponseDto.success(new ArrayList<>());
        }
    }

}
