package com.zksy.controller.property;

import com.zksy.property.domain.ASimplifiedHouseInfo;
import com.zksy.property.domain.dto.ASimplifiedHouseInfoDto;
import com.zksy.property.service.ASimplifiedHouseInfoService;
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;

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

@RestController
@RequestMapping("/asimplifiedHouseInfo")
@Api(tags = "房屋信息",description = "房屋信息desc")
public class ASimplifiedHouseInfoController {
    @Autowired
    private ASimplifiedHouseInfoService service;
    @GetMapping("/findByPage")
    @ApiOperation(value = "房屋信息查询分页")
    public AjaxResult findByPage(long pageNum, long pageSize, String assetType,String building,String houseName,String status){
        return AjaxResult.success(service.findByPage(pageNum, pageSize, assetType,building,houseName, status));
    }
    @GetMapping("/getASimplifiedHouseInfoList")
    @ApiOperation(value = "房屋信息查询")
    public AjaxResult getASimplifiedHouseInfoList(String assetType,String building,String houseName,String status){
        return AjaxResult.success(service.getASimplifiedHouseInfoList(assetType,building,houseName, status));
    }
    @GetMapping("/getList")
    @ApiOperation(value = "房屋查询")
    public AjaxResult getList(@ModelAttribute ASimplifiedHouseInfoDto entity){
        return AjaxResult.success(service.getListPage( entity));
    }
    @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 ASimplifiedHouseInfo entity) {
        return service.save(entity) ? AjaxResult.success(entity) : AjaxResult.error("保存失败");
    }
    @PostMapping("/update")
    @ApiOperation(value = "房屋信息修改")
    public AjaxResult update(@RequestBody ASimplifiedHouseInfo 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.removeBatchId(ids) ? AjaxResult.success("删除成功") : AjaxResult.error("删除失败");
    }

    @GetMapping("/getHouseDetailInfo")
    @ApiOperation(value = "房屋信息详情")
    public AjaxResult getHouseDetailInfo(String houseId){
        return AjaxResult.success(service.getHouseDetailInfo(houseId));
    }

    @GetMapping("/getArrears")
    @ApiOperation(value = "欠费信息")
    public AjaxResult getArrears(){
        return AjaxResult.success(service.getArrears());
    }
}
