package com.hzs.system.config.controller.api;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.utils.StringUtils;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.system.config.BdAdvertBanner;
import com.hzs.common.domain.system.config.ext.BdAdvertBannerExt;
import com.hzs.system.config.service.IBdAdvertBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 广告banner 前端控制器
 * </p>
 *
 * @author hzs
 * @since 2022-12-08
 */
@RestController
@RequestMapping("/api/bd-advert-banner")
public class ApiBdAdvertBannerController extends BaseController {

    @Autowired
    private IBdAdvertBannerService advertBannerService;

    /**
     * @description: 查询广告banner
     * @author: zhang jing
     * @date: 2022/8/30 10:20
     * @param: [advertBanner]
     * @return: com.hzs.common.core.web.page.TableDataInfo
     **/
    @GetMapping("/list")
    public TableDataInfo list(BdAdvertBannerExt advertBannerExt) {
        QueryWrapper<BdAdvertBanner> queryWrapper = new QueryWrapper();
        if(StringUtils.isNotNull(advertBannerExt.getPosition())){
            queryWrapper.eq("POSITION",advertBannerExt.getPosition());
        }
        queryWrapper.lt("EFFECTIVE_DATE",new Date());
        queryWrapper.orderByAsc("SORT");
        List<BdAdvertBanner> list = advertBannerService.list(queryWrapper);
        return getDataTable(list);
    }


}
