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 lombok.extern.slf4j.Slf4j;
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")
@Slf4j
public class KylinBannersController {

    @Autowired
    private BannersServiceImpl bannersServiceImpl;

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

}
