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

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.property.PropertyEnterpriseRegisterAuditDto;
import com.yuchen.saas.park.api.dto.property.PropertyEnterpriseRegisterDto;
import com.yuchen.saas.park.api.dto.property.PropertyEnterpriseRegisterQueryDto;
import com.yuchen.saas.park.api.dto.property.PropertyEnterpriseRegisterUpdateDto;
import com.yuchen.saas.park.api.vo.property.PropertyEnterpriseRegisterListVo;
import com.yuchen.saas.park.api.vo.property.PropertyEnterpriseRegisterResultVo;
import com.yuchen.saas.park.service.service.property.IPropertyEnterpriseRegisterService;
import io.swagger.annotations.ApiOperation;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author 蔡文强
 * @Date 2023/11/28 10:56
 * @Description 企业入驻登记表 前端控制器
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/propertyEnterpriseRegister")
public class PropertyEnterpriseRegisterController {

    @Resource
    private IPropertyEnterpriseRegisterService baseService;

    /**
     * 小程序企业端->企业入驻登记
     * @param enterpriseRegisterDto 企业入驻登记Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/register")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "小程序企业端->企业入驻登记", notes = "小程序企业端->企业入驻登记")
    public R<PropertyEnterpriseRegisterResultVo> register(@RequestBody @Validated PropertyEnterpriseRegisterDto enterpriseRegisterDto) {
        return R.data(baseService.register(enterpriseRegisterDto));
    }

    /**
     * 审核企业入驻登记
     * @param auditDto 审核企业入驻登记Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/audit")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "审核企业入驻登记", notes = "审核企业入驻登记")
    public R<Boolean> audit(@RequestBody @Validated PropertyEnterpriseRegisterAuditDto auditDto) {
        return R.data(baseService.audit(auditDto));
    }

    /**
     * 更新已读状态
     * @param updateDto 更新已读状态Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/updateStatus")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "更新已读状态", notes = "更新已读状态")
    public R<Boolean> updateStatus(@RequestBody @Validated PropertyEnterpriseRegisterUpdateDto updateDto) {
        return R.data(baseService.updateStatus(updateDto));
    }

    /**
     * 企业入驻登记列表(分页)
     * @param queryDto 企业入驻登记列表查询参数
     * @return 企业入驻登记列表Vo
     */
    @PostMapping("/getEnterpriseRegisterList")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "企业入驻登记列表(分页)", notes = "企业入驻登记列表(分页)")
    public R<NestPage<PropertyEnterpriseRegisterListVo>> getEnterpriseRegisterList(@RequestBody PropertyEnterpriseRegisterQueryDto queryDto) {
        return R.data(baseService.getEnterpriseRegisterList(queryDto));
    }

    /**
     * 导出企业入驻登记列表
     * @return page 分页数据
     */
    @PostMapping("/exportEnterpriseRegister")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "导出企业入驻登记列表", notes = "导出企业入驻登记列表")
    public void exportEnterpriseRegister(@RequestBody PropertyEnterpriseRegisterQueryDto queryDto, HttpServletResponse response) {
        baseService.exportEnterpriseRegister(queryDto, response);
    }

}
