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


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.people.PropertyPeopleRegisterApproveDTO;
import com.yuchen.saas.park.api.dto.people.PropertyPeopleRegisterDTO;
import com.yuchen.saas.park.api.dto.people.PropertyPeopleRegisterPageDTO;
import com.yuchen.saas.park.api.vo.people.PropertyPeopleRegisterPageVO;
import com.yuchen.saas.park.service.service.people.ISaasParkPropertyPeopleRegisterService;
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.nest.springwrap.core.tool.utils.Func;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 物业人员登记
 * <p>
 * 物业人员登记信息表 前端控制器
 * </p>
 *
 * @author linyb
 * @since 2024-11-30
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/saasParkPropertyPeopleRegister")
public class SaasParkPropertyPeopleRegisterController {

    private final ISaasParkPropertyPeopleRegisterService baseService;


    /**
     * 分页
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "分页")
    @GetMapping("/page")
    public R<NestPage<PropertyPeopleRegisterPageVO>> getPage(PropertyPeopleRegisterPageDTO dto) {
        return R.data(baseService.getPage(dto));
    }

    /**
     * 详情
     * @param id
     * @return
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "详情")
    @GetMapping("/info/{id}")
    public R<PropertyPeopleRegisterPageVO> info(@PathVariable Long id) {
        return R.data(baseService.info(id));
    }

    /**
     * 小程序登记保存
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "小程序登记保存")
    @PostMapping("/save")
    public R<Boolean> save(@RequestBody @Validated PropertyPeopleRegisterDTO dto) {
        return R.status(baseService.save(dto));
    }



    /**
     * 删除
     * @param id
     * @return
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "删除")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> update(@PathVariable String id) {
        return R.data(baseService.deleteLogic(Func.toLongList(id)));
    }


    /**
     * 审核
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "后台审核")
    @PostMapping("/approve")
    public R<Boolean> approve(@RequestBody @Validated PropertyPeopleRegisterApproveDTO dto) {
        return R.data(baseService.approve(dto));
    }
    /**
     * 用户取消
     * @param id
     * @return
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "用户取消")
    @PostMapping("/cancel/{id}")
    public R<Boolean> cancel(@PathVariable String id) {
        return R.data(baseService.cancel(id));
    }
}
