package com.yuchen.saas.park.service.controller.repair;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.dto.repair.PmgBatRepairRecordDTO;
import com.yuchen.saas.park.api.dto.repair.PmgBatRepairRecordProcessDTO;
import com.yuchen.saas.park.api.dto.repair.PmgBatRepairRecordQueryDTO;
import com.yuchen.saas.park.api.vo.repair.PmgBatRepairRecordAppVO;
import com.yuchen.saas.park.api.vo.repair.PmgBatRepairRecordVO;
import com.yuchen.saas.park.service.service.PmgBatRepairRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
 * @Author 蔡文强
 * @Date 2023/4/13 15:56
 * @Description 报修记录表 前端控制器
 */

@RestController
@RequestMapping("/repair/record")
@Api(value = "报修记录数据相关接口", tags = "报修记录数据相关接口")
public class PmgBatRepairRecordController {

    @Resource
    private PmgBatRepairRecordService repairRecordService;


    /**
     * 小程序->提交报修
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "小程序->提交报修", notes = "传入报修相关信息")
    public R<Boolean> saveRepairRecord(@RequestBody @Validated PmgBatRepairRecordDTO repairRecordDTO) {
        return R.data(repairRecordService.saveRepairRecord(repairRecordDTO));
    }


    /**
     * 报修记录标记已处理
     */
    @PostMapping("update")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "报修记录标记已处理", notes = "传入处理说明相关信息")
    public R<Boolean> updateRepairRecord(@RequestBody @Validated PmgBatRepairRecordProcessDTO processDTO) {
        return R.data(repairRecordService.updateRepairRecord(processDTO));
    }


    /**
     * 报修记录详情
     * @param id 报修记录ID
     * @return
     */
    @GetMapping("/detail/{id}")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "报修记录详情", notes = "传报修记录ID")
    public R<PmgBatRepairRecordVO> getRepairRecordDetailById(@PathVariable("id") Long id) {
        return R.data(repairRecordService.getRepairRecordDetailById(id));
    }


    /**
     * 小程序->我提交的报修记录
     */
    @GetMapping("/mylist")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "小程序->我提交的报修记录", notes = "小程序->我提交的报修记录")
    public R<List<PmgBatRepairRecordAppVO>> getMyRepairRecordList() {
        return R.data(repairRecordService.getMyRepairRecordList());
    }


    /**
     * 查询报修记录列表(分页)
     */
    @PostMapping("/list")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "查询报修记录列表(分页)", notes = "查询报修记录列表(分页)")
    public R<NestPage<PmgBatRepairRecordVO>> getRepairRecordPageList(@RequestBody PmgBatRepairRecordQueryDTO queryDTO) {
        return R.data(repairRecordService.getRepairRecordPageList(queryDTO));
    }

}
