package com.muyu.enterprise.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.FaultType;
import com.muyu.enterprise.service.FaultTypeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 故障类型控制层
 * @author chenruijia
 * @Date 2024/9/28 11:58
 * @Description FaultTypeController:故障类型控制层
 */
@RestController
@RequestMapping("/type")
@Tag(name = "故障类型",description = "对故障类型的定义")
public class FaultTypeController {
    @Autowired
    private FaultTypeService faultTypeService;

    /**
     * 故障类型表
     * @return
     */
    @RequestMapping(value = "faultTypeList",method = RequestMethod.GET)
    public Result<List<FaultType>> faultTypeList(FaultType faultType){
        return Result.success(faultTypeService.faultTypeList(faultType));
    }


    /**
     * 添加故障类型
     * @param faultType
     * @return
     */
    @RequestMapping(value = "insertType",method = RequestMethod.POST)
    public Result insertType(@RequestBody FaultType faultType){
        return Result.success(faultTypeService.save(faultType));
    }


    /**
     * 修改故障类型
     * @param faultType
     * @return
     */
    @RequestMapping(value = "updateType",method = RequestMethod.POST)
    public Result updateype(@RequestBody FaultType faultType){
        return Result.success(faultTypeService.updateById(faultType));
    }


    /**
     * 删除故障类型
     * @param faultTypeId
     * @return
     */
    @RequestMapping(value = "deleteType/{faultTypeId}",method = RequestMethod.DELETE)
    public Result deleteType(@PathVariable(name = "faultTypeId") Long faultTypeId){
        return Result.success(faultTypeService.removeById(faultTypeId));
    }


    /**
     * 查询类型详细信息
     * @param faultTypeId
     * @return
     */
    @RequestMapping(value = "/typeDetailOne/{faultTypeId}",method = RequestMethod.POST)
    public Result<List<FaultType>> typeDetailOne(@PathVariable Long faultTypeId){
        return Result.success(faultTypeService.typeDatailOne(faultTypeId));
    }

}
