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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.approve.PeopleApproveHandleDto;
import com.yuchen.saas.park.api.dto.approve.PeopleApproveQueryDto;
import com.yuchen.saas.park.api.entity.approve.PeopleApprove;
import com.yuchen.saas.park.service.service.approve.PeopleApproveService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/peopleApprove")
public class PeopleApproveController {
    @Resource
    private final PeopleApproveService baseService;

    @PostMapping("/add")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增人员审批", notes = "新增人员审批")
    public R<Boolean> savePeopleApprove(@RequestBody @Validated PeopleApprove peopleApprove) {
        return R.data(baseService.savePeopleApprove(peopleApprove));
    }

    @PostMapping("/accept")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "通过", notes = "通过")
    public R<Boolean> accept(@RequestBody @Validated PeopleApproveHandleDto handleDto) {
        return R.data(baseService.accept(handleDto));
    }



    @PostMapping("/list")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "人员审批列表(分页)", notes = "人员审批列表(分页)")
    public R<Page<PeopleApprove>> getPeopleApproveList(@RequestBody PeopleApproveQueryDto queryDto) {
        return R.data(baseService.getPeopleApproveList(queryDto));
    }

    @PostMapping("/listTenants")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "住户审批列表", notes = "住户审批列表")
    public R<Page<PeopleApprove>> getTenantApproveList(@RequestBody PeopleApproveQueryDto queryDto) {
        return R.data(baseService.getTenantApproveList(queryDto));
    }

    @GetMapping("/detail")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "人员审批详情", notes = "人员审批详情")
    public R<PeopleApprove> getPeopleApproveDetail(@RequestParam("id") Long id) {
        return R.data(baseService.getPeopleApproveDetail(id));
    }



}
