Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: keep the json struct of getFestivalMonth #168

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions calendar-client/src/dbus/dbushuanglirequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(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<char>(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<int>(year);
}
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion calendar-common/src/huangliData/lunardatastruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<HolidayInfo> listHoliday {};
} FestivalInfo;

Expand Down
18 changes: 14 additions & 4 deletions calendar-service/src/dbusservice/dhuangliservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// 获取指定公历日的黄历信息
Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> Fri, 12 Jan 2024 17:47:37 +0800

dde-calendar (5.12.0) unstable; urgency=medium

* feat: add deepin-log config
Expand Down
1 change: 1 addition & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading