package com.zksy.controller.property;

import com.zksy.property.domain.AHouseType;
import com.zksy.property.service.AHouseTypeService;
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.LocalDateTime;

/**
 * @author Administrator
 * @version 1.0
 * @project enterprise-assets-service
 * @description 户型控制层
 * @date 2025/6/24 14:33:13
 */
@RestController
@RequestMapping("/houseType")
@Api(tags = "户型控制层",description = "户型控制层desc")
public class AHouseTypeController {
    @Autowired
    private AHouseTypeService service;
    @GetMapping("/getById/{id}")
    @ApiOperation(value = "户型查询")
    public AjaxResult getById(@PathVariable String id) {
        return AjaxResult.success(service.getById(id));
    }
    @GetMapping("/getList")
    @ApiOperation(value = "户型查询所有")
    public AjaxResult getList(String accountNumber) {
        return AjaxResult.success(service.getHouseTypeList(accountNumber));
    }
    @GetMapping("/findByPage")
    @ApiOperation(value = "户型查询分页")
    public AjaxResult findByPage(long pageNum, long pageSize, String accountNumber){
        return AjaxResult.success(service.findByPage(pageNum, pageSize, accountNumber));
    }
    @PostMapping("/save")
    @ApiOperation(value = "户型保存")
    public AjaxResult save(AHouseType houseType, MultipartFile multipartFile) {
        return service.saveHouseType(houseType, multipartFile)? AjaxResult.success(houseType): AjaxResult.error("保存失败");
    }
    @PostMapping("/update")
    @ApiOperation(value = "户型修改")
    public AjaxResult update(AHouseType houseType, MultipartFile multipartFile) {
        houseType.setUpdateTime(LocalDateTime.now());
        return service.updateHouseType(houseType, multipartFile)? AjaxResult.success(houseType): AjaxResult.error("修改失败");
    }
    @PostMapping("/deleteBatch")
    @ApiOperation(value = "户型删除")
    public AjaxResult delete(@RequestBody String[] ids) {
        return service.removeBatchHouseType(ids)? AjaxResult.success(): AjaxResult.error("删除失败");
    }

    @GetMapping("/getByRoomType")
    @ApiOperation(value = "AR户型查询")
    public AjaxResult getByRoomType(Integer roomType) {
        return AjaxResult.success(service.getByRoomType(roomType));
    }
}
