package com.xiaoniu.system.insurancerescue.controller;

import com.xiaoniu.common.core.resdata.Result;
import com.xiaoniu.common.core.resdata.RowsData;
import com.xiaoniu.system.insurancerescue.dto.EditInsuranceRescueDTO;
import com.xiaoniu.system.insurancerescue.dto.InsuranceRescueQueryDTO;
import com.xiaoniu.system.insurancerescue.service.ITbInsuranceRescueService;
import com.xiaoniu.system.insurancerescue.vo.InsuranceRescueDetailsVO;
import com.xiaoniu.system.insurancerescue.vo.InsuranceRescueListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 保险救援信息表 前端控制器
 * </p>
 *
 * @author haoxuyang
 * @since 2024-10-18 05:03:00
 */
@Tag(name = "保险救援管理")
@RestController
@RequestMapping("/insuranceRescue")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class TbInsuranceRescueController {

    private final ITbInsuranceRescueService tbInsuranceRescueService;

    @Operation(summary = "保险救援列表")
    @PostMapping("/list")
    public Result<RowsData<InsuranceRescueListVO>> list(@RequestBody InsuranceRescueQueryDTO dto) {
        return Result.success("查询成功", tbInsuranceRescueService.insuranceRescueList(dto));
    }

    @Operation(summary = "修改保险救援")
    @PostMapping("/edit")
    public Result<String> edit(@RequestBody @Validated EditInsuranceRescueDTO dto) {
        tbInsuranceRescueService.editInsuranceRescue(dto);
        return Result.success("操作成功");
    }

    @Operation(summary = "保险救援详情")
    @GetMapping("/details")
    public Result<InsuranceRescueDetailsVO> details(@RequestParam Long id) {
        return Result.success("查询成功", tbInsuranceRescueService.details(id));
    }

}
