package com.muyu.car.controller;

import com.muyu.car.domain.CarMessage;
import com.muyu.car.service.SysCarMessageService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
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;

@RestController
@RequestMapping("/message") // 报文
@Tag(name = "报文",description = "报文模块")
public class SysCarMessageController extends BaseController {
    @Autowired
    private SysCarMessageService sysCarMessageService;

    /**
     * 查询所有报文信息
     * @return
     */
    @PostMapping("selectMessageShow")
    public List<CarMessage> selectMessageShow(@RequestParam("templateId") Long templateId){
        return sysCarMessageService.selectMessageShow(templateId);
    }
    /**
     * 通过id查询报文信息
     * @return
     */
    @PostMapping("selectMessageByMessageId")
    public CarMessage selectMessageByMessageId(@RequestParam("messageId") Long messageId){
        return sysCarMessageService.selectMessageByMessageId(messageId);
    }

   /**
     * 添加报文信息
     * @return carMessage
     */
    @PostMapping("insertMessage")
    public Result insertMessage(@RequestBody CarMessage carMessage){
        sysCarMessageService.save(carMessage);
        return Result.success("添加成功");
    }
    /**
     * 修改报文信息
     * @return carMessage
     */
    @PostMapping("updataMessage")
    public Result updataMessage(@RequestBody CarMessage carMessage){
        sysCarMessageService.updateById(carMessage);
        return Result.success("修改成功");
    }
    /**
     * 删除报文信息
     * @return carMessage
     */
    @PostMapping("deleteMessage")
    public Result deleteMessage(@RequestParam("ids") List<Long> ids){
        sysCarMessageService.removeBatchByIds(ids);
        return Result.success("删除成功");
    }


}
