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.PropertyPeopleInfoPageVO;
import com.yuchen.saas.park.api.vo.people.PropertyPeopleInfoVO;
import com.yuchen.saas.park.api.vo.people.SpecialPeopleInfoVO;
import com.yuchen.saas.park.api.vo.people.SpecialPeoplePageVO;
import com.yuchen.saas.park.service.service.people.ISaasParkSpecialPeopleInfoService;
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-02
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/saasParkSpecialPeopleInfo")
public class SaasParkSpecialPeopleInfoController {

    private final ISaasParkSpecialPeopleInfoService baseService;



    /**
     * 特殊人员分页
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "特殊人员分页")
    @GetMapping("/page")
    public R<NestPage<SpecialPeoplePageVO>> getPage(SpecialPeopleInfoPageDTO dto) {
        return R.data(baseService.getPage(dto));
    }

    /**
     * 特殊人员详情
     * @param id
     * @return
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "特殊人员详情")
    @GetMapping("/info/{id}")
    public R<SpecialPeopleInfoVO> 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 PropertySpecialPeopleInfoSaveDTO dto) {
        return R.status(baseService.save(dto));
    }

    /**
     * 特殊人员修改
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "特殊人员修改")
    @PostMapping("/update")
    public R<Boolean> update(@RequestBody @Validated PropertySpecialPeopleInfoUpdateDTO 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)));
    }

}
