package com.zksy.controller.property;

import cn.hutool.core.date.DateTime;
import com.zksy.property.domain.ARoom;
import com.zksy.property.service.ARoomService;
import com.zksy.utils.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author Administrator
 * @version 1.0
 * @project enterprise-assets-service
 * @description 房间控制层
 * @date 2025/6/24 14:33:13
 */
@RestController
@RequestMapping("/aroom")
@Api(tags = "房间控制层",description = "房间控制层desc")
public class ARoomController {
    @Autowired
    private ARoomService service;
    @GetMapping("/getById/{houseTypeId}")
    @ApiOperation(value = "根据户型id查询房间")
    public AjaxResult getList(@PathVariable String houseTypeId) {
        return AjaxResult.success(service.getByHouseTypeId(houseTypeId));
    }
    @PostMapping("/save")
    @ApiOperation(value = "房间保存")
    public AjaxResult save(ARoom houseType, MultipartFile multipartFile) {
        return service.saveARoom(houseType,multipartFile)? AjaxResult.success(houseType): AjaxResult.error("保存失败");
    }
    @PostMapping("/update")
    @ApiOperation(value = "房间修改")
    public AjaxResult update(ARoom aRoom, MultipartFile multipartFile) {
        aRoom.setUpdateTime(LocalDateTime.now());
        return service.updateARoom(aRoom,multipartFile)? AjaxResult.success(aRoom): AjaxResult.error("修改失败");
    }
    @PostMapping("/updateBatch")
    @ApiOperation(value = "房间批量修改按钮属性")
    public AjaxResult updateBatch(@RequestBody List<ARoom> aRoomList) {
        return service.updateBatchById(aRoomList)? AjaxResult.success(aRoomList): AjaxResult.error("修改失败");
    }
    @PostMapping("/deleteBatch")
    @ApiOperation(value = "房间删除")
    public AjaxResult delete(@RequestBody String[] ids) {
        return service.removeBatchARoom(ids)? AjaxResult.success(): AjaxResult.error("删除失败");
    }
}
