#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::vector<std::string> digits = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
            std::string chineseStr;
            for (char c: numberStr)
            {
                if ('0' <= c && c <= '9')
                {
                    chineseStr += digits[c - '0'];
                } else if (c == '.')
                {
                    chineseStr += '点';
                } else
                {
                    chineseStr += c;
                }
            }
            return chineseStr;
        }
    };
} // zsy

#endif //SOUND_COLUMN_H
