package com.muyu.car.controller;

import com.muyu.car.domain.CarMessage;
import com.muyu.car.domain.CarTemplate;
import com.muyu.car.service.SysCarMessageService;
import com.muyu.car.service.SysCarTemplateService;
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("/template") // 报文
@Tag(name = "模版模块",description = "报文模版模块")
public class SysCarTemplateController extends BaseController {
    @Autowired
    private SysCarTemplateService sysCarTemplateService;

    /**
     * 查询所有模版信息
     * @return
     */
    @PostMapping("selectTemplateShow")
    public List<CarTemplate> selectTemplateShow(){
        return sysCarTemplateService.selectTemplateShow();
    }
    /**
     * 通过id查询模版信息
     * @return
     */
    @PostMapping("selectTemplateByTemplateId")
    public CarTemplate selectTemplateByTemplateId(@RequestParam("templateId") Long templateId){
        return sysCarTemplateService.selectTemplateByTemplateId(templateId);
    }

   /**
     * 添加模版信息
     * @return carMessage
     */
    @PostMapping("insertTemplate")
    public Result insertTemplate(@RequestBody CarTemplate carTemplate){
        sysCarTemplateService.save(carTemplate);
        return Result.success("添加成功");
    }
    /**
     * 修改模版信息
     * @return carMessage
     */
    @PostMapping("updataTemplate")
    public Result updataTemplate(@RequestBody CarTemplate carTemplate){
        sysCarTemplateService.updateById(carTemplate);
        return Result.success("修改成功");
    }
    /**
     * 删除模版信息
     * @return carMessage
     */
    @PostMapping("deleteTemplate")
    public Result deleteTemplate(@RequestParam("ids") List<Long> ids){
        sysCarTemplateService.removeBatchByIds(ids);
        return Result.success("删除成功");
    }


}
