package com.muyu.server.controller;

import com.muyu.common.core.domain.Result;
import com.muyu.common.domain.MessageTemplateType;
import com.muyu.server.service.MessageTemplateTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 报文模版管理
 * @author liuxinyue
 * @Package：com.sheep.message.controller
 * @Project：cloud-server-c
 * @name：MessageTemplateTypeController
 * @Date：2024/9/19 14:33
 */
@RestController
@RequestMapping("/messageTemplateType")
@AllArgsConstructor
@Tag(name = "报文模版管理",description = "报文模版管理")
@Log4j2
public class MessageTemplateTypeController {

    @Autowired
    private MessageTemplateTypeService messageTemplateTypeService;


    /**
     * 列表
     * @return
     */
    @PostMapping("/messageTemplateTypeList")
    @Operation(summary = "报文模版类型列表",description = "报文模版类型列表")
    public Result<List<MessageTemplateType>> messageTemplateTypeList() {
        List<MessageTemplateType> list = messageTemplateTypeService.list();
        return Result.success(list,"查询成功");
    }

    /**
     * 添加
     * @param messageTemplateType
     * @return
     */
    @PostMapping("/addMessageType")
    @Operation(summary = "报文模版类型添加",description = "报文模版类型添加")
    public Result<Integer> addMessageType(@RequestBody MessageTemplateType messageTemplateType) {
        return Result.success(messageTemplateTypeService.addMessageType(messageTemplateType));
    }

    /**
     * 基础类型
     * @param templatedId
     * @param code
     * @return
     */
    @PostMapping("/findvehicleFoundationData")
    @Operation(summary = "基础类型",description = "基础类型")
    public Result<List<MessageTemplateType>> findvehicleFoundationData(@RequestParam("templatedId") Integer templatedId, @RequestParam("code") String code) {
        return Result.success(messageTemplateTypeService.findvehicleFoundationData(templatedId,code));
    }


    /**
     * 数据类型
     * @param templatedId
     * @param code
     * @return
     */
    @PostMapping("/findvehicleData")
    @Operation(summary = "数据类型",description = "数据类型")
    public Result<List<MessageTemplateType>> findvehicleData(@RequestParam("templatedId") Integer templatedId,@RequestParam("code") String code) {
        return Result.success(messageTemplateTypeService.findvehicleData(templatedId,code));
    }

    /**
     * 设备状态
     * @param templatedId
     * @param code
     * @return
     */
    @PostMapping("/finddeviceStatusData")
    @Operation(summary = "设备状态",description = "设备状态")
    public Result<List<MessageTemplateType>> finddeviceStatusData(@RequestParam("templatedId") Integer templatedId,@RequestParam("code") String code) {
        return Result.success(messageTemplateTypeService.finddeviceStatusData(templatedId,code));
    }

    /**
     * 根据车辆类型查出所对应的模版
     * @param templatedId
     * @return
     */
    @PostMapping("/findMessageByTemplateName")
    @Operation(summary = "根据车辆类型查出所对应的模版",description = "根据车辆类型查出所对应的模版")
    public Result<List<MessageTemplateType>> findMessageByTemplateName(@RequestParam("templatedId") Integer templatedId) {
        return Result.success(messageTemplateTypeService.findMessageByTemplateName(templatedId));
    }
}
