package com.zhongzheng.controller.cmmon;

import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.core.page.TableDataInfo;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.base.bo.ActivityAdvertisingAddBo;
import com.zhongzheng.modules.base.bo.ActivityAdvertisingEditBo;
import com.zhongzheng.modules.base.bo.ActivityAdvertisingQueryBo;
import com.zhongzheng.modules.base.service.IActivityAdvertisingLocationService;
import com.zhongzheng.modules.base.service.IActivityAdvertisingService;
import com.zhongzheng.modules.base.vo.ActivityAdvertisingLocationVo;
import com.zhongzheng.modules.base.vo.ActivityAdvertisingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 广告发布储存Controller
 *
 * @author hjl
 * @date 2022-01-13
 */
@Api(value = "广告发布储存控制器", tags = {"广告发布储存管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/common/base/advertising")
public class ActivityAdvertisingController extends BaseController {

    private final IActivityAdvertisingService iActivityAdvertisingService;

    private final IActivityAdvertisingLocationService iActivityAdvertisingLocationService;

    /**
     * 查询广告发布储存列表
     */
    @ApiOperation("查询广告发布储存列表")
    @PreAuthorize("@ss.hasPermi('system:advertising:list')")
    @GetMapping("/list")
    public TableDataInfo<ActivityAdvertisingVo> list(ActivityAdvertisingQueryBo bo) {
        bo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
        startPage();
        List<ActivityAdvertisingVo> list = iActivityAdvertisingService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 获取广告位详细信息
     */
    @ApiOperation("获取首页广告位详细信息")
    @PreAuthorize("@ss.hasPermi('system:location:query')")
    @GetMapping("/homeLocation")
    public AjaxResult<ActivityAdvertisingLocationVo> homeLocation() {
        return AjaxResult.success(iActivityAdvertisingLocationService.queryByKey("home-banner"));
    }


}
