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.ISaasParkPropertyPeopleInfoService;
import com.yuchen.saas.park.service.service.people.ISaasParkPropertyPeopleRegisterService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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("/saasParkPropertyPeopleInfo")
public class SaasParkPropertyPeopleInfoController {

    private final ISaasParkPropertyPeopleInfoService baseService;




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

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

    /**
     * 工作人员修改
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "工作人员修改")
    @PostMapping("/update")
    public R<Boolean> update(@RequestBody @Validated PropertyPeopleInfoUpdateDTO 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 = 1)
    @ApiOperation(value = "楼栋管家/楼栋工程师分页")
    @GetMapping("/buildingManager/page")
    public R<NestPage<PropertyPeopleBuildingManagerPageVO>> getPage(PropertyPeopleBuildManagerPageDTO dto) {
        return R.data(baseService.getPage(dto));
    }

    /**
     * 楼栋管家/楼栋工程师新增
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "楼栋管家/楼栋工程师新增")
    @PostMapping("/buildingManager/add")
    public R<Boolean> buildingManagerAdd(@RequestBody @Validated PropertyPeopleBuildManagerAddDTO dto) {
        return R.data(baseService.buildingManagerAdd(dto));
    }

    /**
     * 楼栋管家/楼栋工程师移除
     * @param dto
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "楼栋管家/楼栋工程师移除")
    @PostMapping("/buildingManager/delete")
    public R<Boolean> buildingManagerDelete(@RequestBody @Validated PropertyPeopleBuildManagerDeleteDTO dto) {
        return R.status(baseService.buildingManagerDelete(dto));
    }

    /**
     * 获取楼栋管家微信二维码
     * @param buildingId
     * @return
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "获取楼栋管家微信二维码")
    @GetMapping("/buildingManager/infoByBuildingId")
    public R<PropertyPeopleBuildingManagerWechatVO> infoByBuildingId(@RequestParam @ApiParam(value = "楼栋id") Long buildingId) {
        PropertyPeopleBuildingManagerWechatVO propertyPeopleBuildingManagerWechatVO = baseService.infoByBuildingId(buildingId);
        return R.data(propertyPeopleBuildingManagerWechatVO);
    }
}
