diff --git a/calendar-client/src/dbus/dbushuanglirequest.cpp b/calendar-client/src/dbus/dbushuanglirequest.cpp index 9a4b56704..0a6d28df1 100644 --- a/calendar-client/src/dbus/dbushuanglirequest.cpp +++ b/calendar-client/src/dbus/dbushuanglirequest.cpp @@ -41,15 +41,38 @@ bool DbusHuangLiRequest::getFestivalMonth(quint32 year, quint32 month, FestivalI // 解析数据 QJsonArray rootarry = jsonDoc.array(); for (int i = 0; i < rootarry.size(); i++) { - QJsonObject hsubObj = rootarry.at(i).toObject(); - HolidayInfo dayinfo; - if (hsubObj.contains("status")) { - dayinfo.status = static_cast(hsubObj.value("status").toInt()); + QJsonObject subObj = rootarry.at(i).toObject(); + // 因为是预先定义好的JSON数据格式,所以这里可以这样读取 + if (subObj.contains("id")) { + festivalInfo.ID = subObj.value("id").toString(); } - if (hsubObj.contains("date")) { - dayinfo.date = QDate::fromString(hsubObj.value("date").toString(), "yyyy-MM-dd"); + if (subObj.contains("name")) { + festivalInfo.FestivalName = subObj.value("name").toString(); } - festivalInfo.listHoliday.append(dayinfo); + if (subObj.contains("description")) { + festivalInfo.description = subObj.value("description").toString(); + } + if (subObj.contains("rest")) { + festivalInfo.Rest = subObj.value("rest").toString(); + } + if (subObj.contains("month")) { + festivalInfo.month = subObj.value("month").toInt(); + } + if (subObj.contains("list")) { + QJsonArray sublistArray = subObj.value("list").toArray(); + for (int j = 0; j < sublistArray.size(); j++) { + QJsonObject hsubObj = sublistArray.at(j).toObject(); + HolidayInfo dayinfo; + if (hsubObj.contains("status")) { + dayinfo.status = static_cast(hsubObj.value("status").toInt()); + } + if (hsubObj.contains("date")) { + dayinfo.date = QDate::fromString(hsubObj.value("date").toString(), "yyyy-M-d"); + } + festivalInfo.listHoliday.append(dayinfo); + } + } + festivalInfo.year = static_cast(year); } return true; } diff --git a/calendar-common/src/huangliData/lunardatastruct.h b/calendar-common/src/huangliData/lunardatastruct.h index adf9e038c..53b40a191 100644 --- a/calendar-common/src/huangliData/lunardatastruct.h +++ b/calendar-common/src/huangliData/lunardatastruct.h @@ -16,10 +16,16 @@ typedef struct HuangLi { typedef struct _tagHolidayInfo { QDate date; - uint status; // 1: 休 2: 补班 + char status {}; } HolidayInfo; typedef struct _tagFestivalInfo { + QString ID {}; + QString FestivalName {}; + QString description {}; + QString Rest {}; + int month = 0; + int year = 0; QVector listHoliday {}; } FestivalInfo; diff --git a/calendar-service/src/dbusservice/dhuangliservice.cpp b/calendar-service/src/dbusservice/dhuangliservice.cpp index c32354496..3e2224475 100644 --- a/calendar-service/src/dbusservice/dhuangliservice.cpp +++ b/calendar-service/src/dbusservice/dhuangliservice.cpp @@ -18,13 +18,23 @@ DHuangliService::DHuangliService(QObject *parent) } // 获取指定公历月的假日信息 +// !这个接口 dde-daemon 在使用,不能变动! QString DHuangliService::getFestivalMonth(quint32 year, quint32 month) { DServiceExitControl exitControl; - auto arr = m_huangli->getFestivalMonth(year, month); - QJsonDocument result; - result.setArray(arr); - return result.toJson(QJsonDocument::Compact); + auto list = m_huangli->getFestivalMonth(year, month); + // 保持接口返回值兼容 + QJsonArray result; + if (!list.empty()) { + QJsonObject obj; + obj.insert("id", list.at(0)["date"]); + obj.insert("description", ""); + obj.insert("list", list); + result.push_back(obj); + } + QJsonDocument doc; + doc.setArray(result); + return doc.toJson(QJsonDocument::Compact); } // 获取指定公历日的黄历信息 diff --git a/debian/changelog b/debian/changelog index fc0086cea..8ab19f87b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +dde-calendar (5.12.1) unstable; urgency=medium + + * fix: Unable sync schedule based on cloud sync + * feat: keep the json struct of getFestivalMonth + + -- myml Fri, 12 Jan 2024 17:47:37 +0800 + dde-calendar (5.12.0) unstable; urgency=medium * feat: add deepin-log config diff --git a/debian/rules b/debian/rules index cccd2fc47..df287368a 100755 --- a/debian/rules +++ b/debian/rules @@ -13,5 +13,6 @@ export QT_SELECT := 5 override_dh_auto_configure: dh_auto_configure -- \ -DCMAKE_BUILD_TYPE=Release \ + -DSERVICE_INSTALL_DIR="/usr/lib/deepin-daemon" -DCMAKE_SAFETYTEST_ARG="CMAKE_SAFETYTEST_ARG_OFF" \ -DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)