package com.ruoyi.app.user;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.SysAds;
import com.ruoyi.system.service.ISysAdsService;
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.List;

/**
 * 首页广告Controller
 * @author hupeng
 * @date 2020-02-02
 */
@RestController
@RequestMapping("/app/ads")
public class AdsController {
    @Autowired
    private ISysAdsService sysAdsService;

    /**
     * 查询首页广告列表
     */
    @Anonymous
    @GetMapping("/getAds")
    public R<List<SysAds>> getAds(){
        LambdaQueryWrapper<SysAds> query=new LambdaQueryWrapper<>();
        query.eq(SysAds::getStatus,"0");
        query.eq(SysAds::getDeleted,"0");
        query.orderByAsc(SysAds::getSort);
        List<SysAds> sysAds = sysAdsService.list();
        return R.ok(sysAds);
    }

}
