package com.hzs.system.home.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.ext.HoAdvertBannerExt;
import com.hzs.common.domain.system.home.HoAdvertBanner;
import com.hzs.system.home.service.IHoAdvertBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

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

    @Autowired
    private IHoAdvertBannerService 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(HoAdvertBannerExt advertBannerExt) {
        QueryWrapper<HoAdvertBanner> queryWrapper = new QueryWrapper();
        if(StringUtils.isNotNull(advertBannerExt.getPosition())){
            queryWrapper.eq("POSITION",advertBannerExt.getPosition());
        }
        queryWrapper.lt("EFFECTIVE_DATE",new Date());
        queryWrapper.orderByAsc("SORT");
        List<HoAdvertBanner> list = advertBannerService.list(queryWrapper);
        return getDataTable(list);
    }


}
