package com.xiaoniu.system.platformsettings.advertis.controller;

import com.xiaoniu.common.core.resdata.Result;
import com.xiaoniu.common.core.resdata.RowsData;
import com.xiaoniu.system.platformsettings.advertis.dto.AddAdvertisDTO;
import com.xiaoniu.system.platformsettings.advertis.dto.AdvertisListQueryDTO;
import com.xiaoniu.system.platformsettings.advertis.dto.EditAdvertisDTO;
import com.xiaoniu.system.platformsettings.advertis.service.ITbAdvertisInfoService;
import com.xiaoniu.system.platformsettings.advertis.vo.AdvertisDetailsVO;
import com.xiaoniu.system.platformsettings.advertis.vo.AdvertisListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 广告信息表 前端控制器
 * </p>
 *
 * @author haoxuyang
 * @since 2024-10-10 01:59:09
 */
@Tag(name = "广告位管理")
@RestController
@RequestMapping("/advertis")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TbAdvertisInfoController {

    private final ITbAdvertisInfoService tbAdvertisInfoService;

    @Operation(summary = "广告位列表")
    @PostMapping("/list")
    public Result<RowsData<AdvertisListVO>> list(@RequestBody AdvertisListQueryDTO dto) {
        return Result.success("查询成功", tbAdvertisInfoService.advertisList(dto));
    }

    @Operation(summary = "新增广告位")
    @PostMapping("/add")
    public Result<String> add(@RequestBody @Validated AddAdvertisDTO dto) {
        tbAdvertisInfoService.addAdvertis(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "修改广告位")
    @PostMapping("/edit")
    public Result<String> edit(@RequestBody @Validated EditAdvertisDTO dto) {
        tbAdvertisInfoService.editAdvertis(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "广告位详情")
    @GetMapping("/details")
    public Result<AdvertisDetailsVO> details(@RequestParam Long id) {
        return Result.success("查询成功", tbAdvertisInfoService.details(id));
    }

    @Operation(summary = "删除广告位")
    @GetMapping("/del")
    public Result<String> delAdvertis(@RequestParam Long id) {
        tbAdvertisInfoService.delAdvertis(id);
        return Result.success("操作成功");
    }

}
