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


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.people.*;
import com.yuchen.saas.park.api.vo.people.*;
import com.yuchen.saas.park.service.service.people.ISaasParkExternalPeopleInfoService;
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-12-01
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/saasParkExternalPeopleInfo")
public class SaasParkExternalPeopleInfoController {

    private final ISaasParkExternalPeopleInfoService baseService;

    /**
     * 家政/装修人员分页
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "家政/装修人员分页")
    @GetMapping("/page")
    public R<NestPage<ExternalPeopleInfoPageVO>> getPage(ExternalPeopleInfoPageDTO dto) {
        return R.data(baseService.getPage(dto));
    }

    /**
     * 家政/装修人员详情
     * @param id
     * @return
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "家政/装修人员详情")
    @GetMapping("/info/{id}")
    public R<ExternalPeopleInfoVO> 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 ExternalPeopleInfoSaveDTO dto) {
        return R.status(baseService.save(dto));
    }

    /**
     * 外部人员修改
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "家政/装修人员修改")
    @PostMapping("/update")
    public R<Boolean> update(@RequestBody @Validated ExternalPeopleInfoUpdateDTO dto) {
        return R.status(baseService.update(dto));
    }

    /**
     * 外部人员删除
     * @param id
     * @return
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "外部人员删除")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> delete(@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 PropertyPeopleExternalApproveDTO dto) {
        return R.data(baseService.approve(dto));
    }


    /**
     * 审核
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "批量审核")
    @PostMapping("/approveBatch")
    public R<Boolean> approveBatch(@RequestBody @Validated PropertyPeopleExternalApproveBatchDTO dto) {
        return R.data(baseService.approveBatch(dto));
    }


    /**
     * 快递/外卖人员分页
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "快递/外卖人员分页")
    @GetMapping("/express/page")
    public R<NestPage<ExternalExpressPeopleInfoPageVO>> getPage(ExternalExpressPeopleInfoPageDTO dto) {
        return R.data(baseService.getPage(dto));
    }

    /**
     * 快递/外卖人员分页
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "快递/外卖人员登记保存")
    @PostMapping("/express/save")
    public R<Boolean> expressSave(@RequestBody @Validated ExternalExpressPeopleInfoSaveDTO dto) {
        return R.status(baseService.expressSave(dto));
    }

    /**
     * 快递/外卖人员详情
     * @param id
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "快递/外卖人员详情")
    @GetMapping("/express/info/{id}")
    public R<ExternalExpressPeopleInfoVO> expressInfo(@PathVariable Long id) {
        return R.data(baseService.expressInfo(id));
    }
}
