package com.zhongzheng.controller.base;

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

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.IActivityAdvertisingService;
import com.zhongzheng.modules.base.vo.ActivityAdvertisingVo;
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/advertising")
public class ActivityAdvertisingController extends BaseController {

    private final IActivityAdvertisingService iActivityAdvertisingService;

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

    /**
     * 导出广告发布储存列表
     */
   /* @ApiOperation("导出广告发布储存列表")
    @PreAuthorize("@ss.hasPermi('system:advertising:export')")
    @Log(title = "广告发布储存", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ActivityAdvertisingVo> export(ActivityAdvertisingQueryBo bo) {
        List<ActivityAdvertisingVo> list = iActivityAdvertisingService.queryList(bo);
        ExcelUtil<ActivityAdvertisingVo> util = new ExcelUtil<ActivityAdvertisingVo>(ActivityAdvertisingVo.class);
        return util.exportExcel(list, "广告发布储存");
    }*/

    /**
     * 获取广告发布储存详细信息
     */
    @ApiOperation("获取广告发布储存详细信息")
    @PreAuthorize("@ss.hasPermi('system:advertising:query')")
    @GetMapping("/{id}")
    public AjaxResult<ActivityAdvertisingVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iActivityAdvertisingService.queryById(id));
    }

    /**
     * 新增广告发布储存
     */
    @ApiOperation("新增广告发布储存")
    @PreAuthorize("@ss.hasPermi('system:advertising:add')")
    @Log(title = "广告发布储存", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody ActivityAdvertisingAddBo bo) {
        return toAjax(iActivityAdvertisingService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改广告发布储存
     */
    @ApiOperation("修改广告发布储存")
    @PreAuthorize("@ss.hasPermi('system:advertising:edit')")
    @Log(title = "广告发布储存", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody ActivityAdvertisingEditBo bo) {
        return toAjax(iActivityAdvertisingService.updateByEditBo(bo) ? 1 : 0);
    }

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