package com.yuchen.saas.park.service.controller.property;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.property.PropertyAdsPositionLeaseDto;
import com.yuchen.saas.park.api.dto.property.PropertyAdsPositionLeaseQueryDto;
import com.yuchen.saas.park.api.vo.property.PropertyAdsPositionLeaseListVo;
import com.yuchen.saas.park.service.service.property.IPropertyAdsPositionLeaseService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author 蔡文强
 * @Date 2024/1/2 10:56
 * @Description 广告位租赁表 前端控制器
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/propertyAdsPositionLease")
public class PropertyAdsPositionLeaseController {

    @Resource
    private IPropertyAdsPositionLeaseService baseService;

    /**
     * 添加广告位租赁
     * @param leaseDto 广告位租赁Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/saveLease")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "添加广告位租赁", notes = "添加广告位租赁")
    public R<Boolean> saveLease(@RequestBody @Validated PropertyAdsPositionLeaseDto leaseDto) {
        return R.data(baseService.saveorUpdateLease(leaseDto));
    }

    /**
     * 编辑广告位租赁
     * @param leaseDto 广告位租赁Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/updateLease")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "编辑广告位租赁", notes = "编辑广告位租赁")
    public R<Boolean> updateLease(@RequestBody @Validated PropertyAdsPositionLeaseDto leaseDto) {
        return R.data(baseService.saveorUpdateLease(leaseDto));
    }

    /**
     * 删除广告位租赁
     * @param id 入驻企业ID
     * @return TRUE/FALSE
     */
    @DeleteMapping("/deleteLease/{id}")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "删除广告位租赁", notes = "删除广告位租赁")
    public R<Boolean> deleteLease(@ApiParam(name = "id", value = "主键ID", required = true) @PathVariable("id") Long id) {
        return R.data(baseService.deleteLease(id));
    }


    /**
     * 广告位租赁列表(分页)
     * @param queryDto 广告位租赁列表查询参数
     * @return 广告位租赁列表Vo
     */
    @PostMapping("/getLeasePageList")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "广告位租赁列表(分页)", notes = "广告位租赁列表(分页)")
    public R<NestPage<PropertyAdsPositionLeaseListVo>> getLeasePageList(@RequestBody @Validated PropertyAdsPositionLeaseQueryDto queryDto) {
        return R.data(baseService.getLeasePageList(queryDto));
    }

}
