package com.bonus.material.lease.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.lease.domain.LeasePriceRecord;
import com.bonus.material.lease.domain.LeaseRecordDto;
import com.bonus.material.lease.domain.LeaseRepair;
import com.bonus.material.lease.domain.LeaseRepairRecord;
import com.bonus.material.lease.service.LeaseRepairRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author ma_sh
 * @create 2024/12/2 15:33
 */
@Api(value = "退租检修及费用结算控制层")
@RestController
@RequestMapping("/lease-repair")
public class LeaseRepairRecordController extends BaseController {

    @Resource
    private LeaseRepairRecordService recordService;

    /**
     * 查询退租检修列表
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询退租检修列表")
    @GetMapping("/list")
    public AjaxResult list(LeaseRepair dto) {
        startPage();
        List<LeaseRepair> list = recordService.list(dto);
        return AjaxResult.success(getDataTable(list));
    }

    /**
     * 查询退租检修单个详情
     * @param dto
     * @return
     */
    @ApiOperation(value = "查询退租检修单个详情")
    @GetMapping("/getById")
    public AjaxResult getById(LeaseRepair dto) {
        LeaseRecordDto leaseRecordDto =  recordService.getById(dto);
        return AjaxResult.success(leaseRecordDto);
    }

    /**
     * 新增退租检修
     * @param leaseRecordDto
     * @return
     */
    @ApiOperation(value = "发起退租检修")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LeaseRecordDto leaseRecordDto) {
        return recordService.add(leaseRecordDto);
    }

    /**
     * 装备费用改价
     * @param leasePriceRecord
     * @return
     */
    @ApiOperation(value = "装备费用改价")
    @PostMapping("/changePrice")
    public AjaxResult changePrice(@RequestBody LeasePriceRecord leasePriceRecord) {
        return recordService.changePrice(leasePriceRecord);
    }

    /**
     * 承租方费用确定
     * @param leaseRepairRecord
     * @return
     */
    @ApiOperation(value = "承租方确认价格")
    @PostMapping("/confirmPrice")
    public AjaxResult confirmPrice(@RequestBody LeaseRepairRecord leaseRepairRecord) {
        return recordService.confirmPrice(leaseRepairRecord);
    }


}
