无关风月
2025-01-22 ca38f03d6799bd31d8ad26156f160009fe3fb6e0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
@@ -21,11 +21,14 @@
import com.ruoyi.system.vo.TContractVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
/**
 * <p>
@@ -43,6 +46,8 @@
    private TContractService contractService;
    @Autowired
    private TContractRentTypeService contractRentTypeService;
    @Autowired
    private THouseService houseService;
    @Log(title = "合同管理-新增合同", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增合同")
    @PostMapping(value = "/addContract")
@@ -91,7 +96,24 @@
    @ApiOperation(value = "查询合同信息信息")
    @GetMapping(value = "/getContractById")
    public AjaxResult<TContractVO> getContractById(@RequestParam Long id) {
        return AjaxResult.success(contractService.getById(id));
        TContractVO res = new TContractVO();
        TContract contract = contractService.getById(id);
        BeanUtils.copyProperties(contract,res);
        TContractRentType contractRentType = contractRentTypeService.lambdaQuery().eq(TContractRentType::getContractId, id).one();
        if (contractRentType!=null){
            BeanUtils.copyProperties(contractRentType,res);
        }
        TContract oldContract = contractService.getOne(new LambdaQueryWrapper<TContract>()
                        .eq(TContract::getHouseId,contract.getHouseId())
                .eq(TContract::getStatus, 4)
                .le(TContract::getStartTime, LocalDateTime.now())
                .ge(TContract::getEndTime, LocalDateTime.now()));
        THouse house = houseService.getById(contract.getHouseId());
        if (oldContract!=null){
            house.setTenantType(oldContract.getPayType());
        }
        res.setHouse(house);
        return AjaxResult.success();
    }
}