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


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.manage.system.api.param.CommonIdParam;
import com.yuchen.saas.park.api.dto.property.PropertyMoveInBatchDto;
import com.yuchen.saas.park.api.dto.property.PropertyMoveInRegisterQryDto;
import com.yuchen.saas.park.api.entity.property.PropertyMoveInRegister;
import com.yuchen.saas.park.service.service.property.IPropertyMoveInRegisterService;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 入住登记表 前端控制器
 * </p>
 *
 * @author 洪铭铭
 * @since 2024-11-29
 */
@RestController
@RequestMapping("/property/property-move-in-register")
public class PropertyMoveInRegisterController {


    @Autowired
    private IPropertyMoveInRegisterService propertyMoveInRegisterService;

    @PostMapping("/save")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增", notes = "入住登记新增")
    public R save(@Valid @RequestBody PropertyMoveInRegister propertyMoveInRegister) {
        return R.status(propertyMoveInRegisterService.save(propertyMoveInRegister));
    }

    @PostMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "返回所有", notes = "所有入住登记列表")
    public R<List<PropertyMoveInRegister>> getAll() {
        return R.data(propertyMoveInRegisterService.list(new LambdaQueryWrapper<>()));
    }

    @PostMapping("/update")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "修改", notes = "入住登记修改")
    public R update(@Valid @RequestBody PropertyMoveInRegister propertyMoveInRegister) {
        return R.status(propertyMoveInRegisterService.saveOrUpdate(propertyMoveInRegister));
    }

    @PostMapping("/delete")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "删除", notes = "入住登记删除")
    public R delete(@Valid @RequestBody CommonIdParam param) {
        return R.data(propertyMoveInRegisterService.removeById(param.getId()));
    }

    @GetMapping("/detail")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "详情", notes = "入住登记详情")
    public R<PropertyMoveInRegister> detail(@RequestParam("id") Long id) {
        return R.data(propertyMoveInRegisterService.getById(id));
    }

    @PostMapping("/page")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "分页列表", notes = "入住登记分页列表")
    public R<Page<PropertyMoveInRegister>> selectPage(@RequestBody PropertyMoveInRegisterQryDto propertyMoveInRegisterQryDto) {
        return R.data(propertyMoveInRegisterService.selectPage(propertyMoveInRegisterQryDto));
    }

    @PostMapping("/addBatch")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "批量添加", notes = "批量添加入住登记")
    public R addBatch(@RequestBody PropertyMoveInBatchDto propertyMoveInBatchDto) {
        //return R.data(propertyMoveInRegisterService.selectPage(saasParkSecurityDeviceQryDto));
        return null;
    }


}
