package com.zhongzheng.controller.base;

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

import com.zhongzheng.modules.base.bo.ActivityAdvertisingLocationAddBo;
import com.zhongzheng.modules.base.bo.ActivityAdvertisingLocationEditBo;
import com.zhongzheng.modules.base.bo.ActivityAdvertisingLocationQueryBo;
import com.zhongzheng.modules.base.service.IActivityAdvertisingLocationService;
import com.zhongzheng.modules.base.vo.ActivityAdvertisingLocationVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 广告位Controller
 *
 * @author hjl
 * @date 2022-01-13
 */
@Api(value = "广告位控制器", tags = {"广告位管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/base/adv/location")
public class ActivityAdvertisingLocationController extends BaseController {

    private final IActivityAdvertisingLocationService iActivityAdvertisingLocationService;

    /**
     * 查询广告位列表
     */
    @ApiOperation("查询广告位列表")
    @PreAuthorize("@ss.hasPermi('system:location:list')")
    @GetMapping("/list")
    public TableDataInfo<ActivityAdvertisingLocationVo> list(ActivityAdvertisingLocationQueryBo bo) {
        startPage();
        List<ActivityAdvertisingLocationVo> list = iActivityAdvertisingLocationService.queryList(bo);
        return getDataTable(list);
    }

    /**
     * 导出广告位列表
     */
    /*@ApiOperation("导出广告位列表")
    @PreAuthorize("@ss.hasPermi('system:location:export')")
    @Log(title = "广告位", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ActivityAdvertisingLocationVo> export(ActivityAdvertisingLocationQueryBo bo) {
        List<ActivityAdvertisingLocationVo> list = iActivityAdvertisingLocationService.queryList(bo);
        ExcelUtil<ActivityAdvertisingLocationVo> util = new ExcelUtil<ActivityAdvertisingLocationVo>(ActivityAdvertisingLocationVo.class);
        return util.exportExcel(list, "广告位");
    }*/

    /**
     * 获取广告位详细信息
     */
    @ApiOperation("获取广告位详细信息")
    @PreAuthorize("@ss.hasPermi('system:location:query')")
    @GetMapping("/{locationId}")
    public AjaxResult<ActivityAdvertisingLocationVo> getInfo(@PathVariable("locationId" ) Long locationId) {
        return AjaxResult.success(iActivityAdvertisingLocationService.queryById(locationId));
    }

    /**
     * 新增广告位
     */
    @ApiOperation("新增广告位")
    @PreAuthorize("@ss.hasPermi('system:location:add')")
    @Log(title = "广告位", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody ActivityAdvertisingLocationAddBo bo) {
        return toAjax(iActivityAdvertisingLocationService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改广告位
     */
    @ApiOperation("修改广告位")
    @PreAuthorize("@ss.hasPermi('system:location:edit')")
    @Log(title = "广告位", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody ActivityAdvertisingLocationEditBo bo) {
        return toAjax(iActivityAdvertisingLocationService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除广告位
     */
   /* @ApiOperation("删除广告位")
    @PreAuthorize("@ss.hasPermi('system:location:remove')")
    @Log(title = "广告位" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{locationIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] locationIds) {
        return toAjax(iActivityAdvertisingLocationService.deleteWithValidByIds(Arrays.asList(locationIds), true) ? 1 : 0);
    }*/
}
