package com.muyu.enterpise.controller;



import com.muyu.common.core.domain.Result;
import com.muyu.domain.req.FaultCodeAddReq;
import com.muyu.domain.req.FaultCodeListReq;
import com.muyu.domain.req.FaultCodeUpdReq;
import com.muyu.domain.resp.FaultCodeTotalListResp;
import com.muyu.enterpise.service.FaultCodeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 车辆故障码
 *  * @className: FaultCodeController  ️✈️
 *  * @author: Yang 鹏  🦅
 *  * @date: 2024/9/23 22:06 ⏰
 *  * @Version: 1.0
 *  * @description: 车辆故障码
 */
@RestController
@RequestMapping("/faultcode")
@Tag(name = "故障模块" ,description = "故障模块")
public class FaultCodeController {

    @Autowired
    private FaultCodeService faultCodeService;

    /**
     * 故障码展示(仅故障码单表)
     * @param faultCodeListReq
     * @return
     */
    @PostMapping(path = "/list")
    @Operation(summary = "故障码列表(单)",description = "展示故障码信息")
    public Result<FaultCodeTotalListResp> selectlist(@Validated @RequestBody FaultCodeListReq faultCodeListReq){
        return Result.success(faultCodeService.selectlist(faultCodeListReq));
    }


    /**
     * 故障码展示(故障码联查)
     * @param faultCodeListReq
     * @return
     */
    @PostMapping("/faultcodelist")
    @Operation(summary = "故障码列表(多)",description = "展示故障码信息")
    public Result<FaultCodeTotalListResp> selectfaultcodelist(@Validated @RequestBody FaultCodeListReq faultCodeListReq){
        return Result.success(faultCodeService.selectfaultcodelist(faultCodeListReq));
    }


    /**
     * 新增故障码
     * @param faultCodeAddReq
     * @return
     */
    @PostMapping("/faultcodeadd")
    @Operation(summary = "新增故障码",description = "新增故障码信息")
    public Result insertfaultcode(@Validated @RequestBody FaultCodeAddReq faultCodeAddReq){
        faultCodeService.insert(faultCodeAddReq);
        return Result.success(null,"新增成功");
    }

    /**
     * 修改故障码
     * @param faultCodeUpdReq
     * @return
     */
    @PostMapping("/faultcodeupd")
    @Operation(summary = "修改故障码",description = "修改故障码信息")
    public Result updfaultcode(@Validated @RequestBody FaultCodeUpdReq faultCodeUpdReq){
        faultCodeService.upd(faultCodeUpdReq);
        return Result.success(null,"修改成功");
    }

    /**
     * 删除故障码
     * @param messageTypeId
     * @return
     */
    @PostMapping("/faultcodedel/{messageTypeId}")
    @Operation(summary = "删除故障码",description = "删除故障码信息")
    public Result delfaultcode(@PathVariable("messageTypeId") Integer messageTypeId){
        faultCodeService.del(messageTypeId);
        return Result.success(null,"删除成功");
    }

}
