package com.zksy.controller.property;

import com.zksy.property.domain.AHouseInfoDetail;
import com.zksy.property.service.AHouseInfoDetailService;
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 java.time.LocalDateTime;
import java.util.Arrays;

/**
 * @author Administrator
 * @version 1.0
 * @project enterprise-assets-service
 * @description 房屋详细信息控制层
 * @date 2025/6/24 14:33:13
 */

@RestController
@RequestMapping("/ahouseInfoDetail")
@Api(tags = "房屋详细信息",description = "房屋详细信息desc")
public class AHouseInfoDetailController {
    @Autowired
    private AHouseInfoDetailService service;
    @GetMapping("/findByPage")
    @ApiOperation(value = "房屋详细信息查询分页")
    public AjaxResult findByPage(long pageNum, long pageSize, String area,String introduce,String houseType){
        return AjaxResult.success(service.findByPage(pageNum, pageSize, area,introduce,houseType));
    }
    @GetMapping("/getAHouseInfoDetailList")
    @ApiOperation(value = "房屋详细信息查询")
    public AjaxResult getAHouseInfoDetailList(String area,String introduce,String houseType){
        return AjaxResult.success(service.getAHouseInfoDetailList(area,introduce,houseType));
    }
    @GetMapping("/getById/{id}")
    @ApiOperation(value = "根据Id查询房屋详细信息")
    public AjaxResult getById(@PathVariable String id){
        return AjaxResult.success(service.getById(id));
    }
    @PostMapping("/save")
    @ApiOperation(value = "房屋详细信息保存")
    public AjaxResult save(@RequestBody AHouseInfoDetail entity) {
        return service.save(entity) ? AjaxResult.success(entity) : AjaxResult.error("保存失败");
    }
    @PostMapping("/update")
    @ApiOperation(value = "房屋详细信息修改")
    public AjaxResult update(@RequestBody AHouseInfoDetail entity) {
        entity.setUpdateTime(LocalDateTime.now());
        return service.updateById(entity) ? AjaxResult.success(entity) : AjaxResult.error("修改失败");
    }
    @PostMapping("/deleteBatch")
    @ApiOperation(value = "房屋详细信息删除")
    public AjaxResult delete(@RequestBody String[] ids) {
        return service.removeBatchByIds(Arrays.asList(ids)) ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
    }

    @GetMapping("/getBySimplifiedHouseId")
    @ApiOperation(value = "根据房屋id查询房屋详细信息")
    public AjaxResult getBySimplifiedHouseId(String simplifiedHouseId){
        return AjaxResult.success(service.getBySimplifiedHouseId(simplifiedHouseId));
    }

}
