yupeng
2025-04-09 db7e077ea8f2d995e922bc11b77dc149592a7455
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.ruoyi.web.controller.api;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginUserApplet;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.model.TContract;
import com.ruoyi.system.model.TRentalReturnRecord;
import com.ruoyi.system.service.ITRentalReturnRecordService;
import com.ruoyi.system.service.TContractService;
import com.ruoyi.system.vo.RentalRetureApplyVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
 
import java.time.LocalDateTime;
 
@RestController
@RequestMapping("/rentalReturnRecord")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
@Api(tags = {"房屋管理-退租申请"})
public class TRentalReturnRecordController extends BaseController {
    private final ITRentalReturnRecordService rentalReturnRecordService;
    private final TokenService tokenService;
 
    /**
     * 申请退租
     */
    @ApiOperation(value = "申请退租")
    @PostMapping("/apply")
    public R<?> apply(@RequestBody RentalRetureApplyVO rentalReture) {
        rentalReturnRecordService.apply(rentalReture, tokenService.getLoginUserApplet().getUserId());
        return R.ok();
    }
 
    /**
     * 申请详情
     */
    @ApiOperation(value = "申请详情")
    @GetMapping("/detail")
    public R<TRentalReturnRecord> detail(@ApiParam (value = "合同id") @RequestParam String contractId) {
        TRentalReturnRecord rentalReturnRecord = rentalReturnRecordService.getOne(new LambdaQueryWrapper<TRentalReturnRecord>()
                .eq(TRentalReturnRecord::getContractId, contractId)
                .last("limit 1")
                .orderByDesc(TRentalReturnRecord::getCreateTime));
        if (rentalReturnRecord == null){
            return R.fail("暂无申请记录");
        }
        TRentalReturnRecord detail = rentalReturnRecordService.getOne(new LambdaQueryWrapper<TRentalReturnRecord>()
                .eq(TRentalReturnRecord::getId, rentalReturnRecord.getId()));
        return R.ok(detail);
    }
}