#ifndef SOUND_COLUMN_H
#define SOUND_COLUMN_H
#include <string>

#include "common/json_util.h"
#include "nlohmann/json.hpp"

namespace zsy
{
    struct PlayVoiceReq
    {
        std::string uuid;
        std::string text; //播放的文本内容
        std::string deviceNo; //设备编号
        std::string carNo;
    };

    inline void from_json(const nlohmann::json &j, PlayVoiceReq &o)
    {
        PARSE_JSON(uuid, o.uuid);
        PARSE_JSON(text, o.text);
        PARSE_JSON(deviceNo, o.deviceNo);
        PARSE_JSON(carNo, o.carNo);
    }

    class SoundColumn
    {
    public:
        virtual ~SoundColumn() = default;

        virtual void play(const std::string &content) = 0;

        virtual std::string getSn() = 0;

        static std::string convert(const std::string &numberStr)
        {
            static const std::unordered_map<char, std::string> digitMap = {
                {'0', "零"}, {'1', "一"}, {'2', "二"}, {'3', "三"}, {'4', "四"},
                {'5', "五"}, {'6', "六"}, {'7', "七"}, {'8', "八"}, {'9', "九"},
                {'.', "点"}
            };

            std::string result;
            for (char c : numberStr) {
                if (digitMap.contains(c)) {
                    result += digitMap.at(c);
                } else {
                    result += c;
                }
            }
            return result;
        }
    };
} // zsy

#endif //SOUND_COLUMN_H
