package io.renren.modules.app.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.admin.entity.AdvertiseEntity;
import io.renren.modules.admin.service.AdvertiseService;
import io.renren.common.utils.R;

/**
 * 广告接口
 */
@RestController
@RequestMapping("/app/advertise")
public class AppAdvertiseController {
    @Autowired
    private AdvertiseService advertiseService;
    @Value("${fyhs-meeting.url.domainName}")
    private String domainName;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(){
        List<AdvertiseEntity> list = advertiseService.queryList();
        
        return R.ok().put("list", list);
    }

    /**
     * 列表
     */
    @RequestMapping("/listwithhost")
    public R listOnline(){
        List<AdvertiseEntity> list = advertiseService.queryList();
        for (AdvertiseEntity advertiseEntity : list) {
            advertiseEntity.setPicture(domainName + advertiseEntity.getPicture());
        }

        return R.ok().put("list", list);
    }
}