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(net): evento api #26

Merged
merged 15 commits into from
Aug 17, 2024
Merged

feat(net): evento api #26

merged 15 commits into from
Aug 17, 2024

Conversation

schoolbag123
Copy link
Collaborator

@schoolbag123 schoolbag123 commented Aug 15, 2024

  • SAST Link 登录
  • 刷新 access token
  • 获取用户信息
  • 查询活动(新增)
  • 获取正在进行的活动
  • 获取最新的活动
  • 获取历史活动(分页)
  • 获取已参加的活动
  • 获取已订阅的活动
  • 获取指定部门的活动(分页)(新增)
  • 获取用户反馈
  • 添加反馈
  • 签到
  • 订阅活动
  • 订阅部门
  • 获取主页幻灯片
  • 获取活动幻灯片
  • 获取部门列表(新增)

网络层 Evento 相关 API 更新日志和注意事项

版本:8.17

注意: 本文档仅对部分难以理解的参数进行解释,其余参数可以语义化理解。如有其他事项或疑问,请在开发者群中询问或直接私聊。

非兼容性改动

Task<Result<bool>> checkInEvent(int eventId, std::string const& code);

Task<Result<bool>> subscribeEvent(int eventId, bool subscribe);

Task<Result<bool>> subscribeDepartment(std::string const& larkDepartment, bool subscribe);
  • 以上三个函数的返回值最底层类型从 void 改为 bool
  • 请注意,成功返回 bool 值仅代表服务器成功收到请求并处理,bool 值表示服务器处理后的最终结果,需要根据结果判断整个操作是否成功。
Task<Result<EventQueryRes>> getActiveEventList();

Task<Result<EventQueryRes>> getLatestEventList();

Task<Result<EventQueryRes>> getHistoryEventList(int page, int size = 10);
  • 以上三个函数的返回值类型从 EventEntityList 改为 EventQueryRes,类型描述见下方或相关文件。
Task<Result<std::optional<FeedbackEntity>>> getUserFeedback(int eventId);
  • 函数返回值最底层类型从 FeedbackEntity 改为 std::optional<FeedbackEntity>
  • 在用户对该活动没有反馈(即 data 字段为空)时,std::optional<FeedbackEntity> 值为 std::nullopt,请注意相关判别和逻辑处理。

新增接口

Task<Result<DepartmentInfoEntityList>> getDepartmentInfo();
  • 用途: 获取部门列表。
  • 参数: 空。
  • 返回值类型: 详见下方或相关文件。
Task<Result<EventQueryRes>> getDepartmentEventList(std::string const& larkDepartment, int page, int size = 10);
  • 用途: 通过 Department 获取指定部门的相关活动。
  • 参数: std::string const& larkDepartment, int page, int size
  • 注意: 部门名称字段的值应采用 getDepartmentInfo 函数中返回的对应值。
Task<Result<EventQueryRes>> getEventList(std::initializer_list<urls::param> params);
  • 用途: 向 Evento 后端根据 params 请求事件列表。
  • 参数: std::initializer_list<urls::param> params
  • 可选参数和相关约束: 请参考 API 文档
  • 注意事项: 请严格按照接口要求的键值对构造 params,具体详见示例。

使用示例:

// 构造一个请求 SAST 部门当前正在进行的活动的参数
// 第一个参数例如 "active" 内容必须和接口规范中的描述严格一致
std::initializer_list<urls::param> params = {{"active", "true"}, {"larkDepartmentName", "SAST"}};

新增类型

EventQueryRes 类型定义:

struct EventQueryRes {
    std::vector<EventEntity> elements;
    int current;
    int total;
};
  • elements 字段代表事件列表。
  • currenttotal 字段代表服务器返回的相应值。

DepartmentInfoEntityList 类型定义:

using DepartmentEntityList = std::vector<DepartmentEntity>;

struct DepartmentEntity {
    std::string id;
    std::string name;
};
  • 各字段含义同变量名,请注意所有字段类型均为 std::string

类型变更

struct EventEntity {
    int id;
    std::string summary;
    std::string description;
    std::string start;
    std::string end;
    std::string location;
    std::string tag;
    std::string larkMeetingRoomName;
    std::string larkDepartmentName;
    State state;
    bool isSubscribed; // 已订阅
    bool isCheckedIn;  // 已签到
};
  • 返回类型 EventEntityisChecked 变更为 isCheckedIn 以满足后端接口规范。

@schoolbag123 schoolbag123 added the feature New feature or request label Aug 15, 2024
Copy link

clang-tidy review says "All clean, LGTM! 👍"

@schoolbag123 schoolbag123 linked an issue Aug 15, 2024 that may be closed by this pull request
…interface requirements of the URL library to resolve the compilation error.
Copy link

clang-tidy review says "All clean, LGTM! 👍"

@Serein207 Serein207 changed the title feat(net):evento api feat(net): evento api Aug 15, 2024
@Serein207
Copy link
Member

Serein207 commented Aug 16, 2024

NOTE: 后端接口更改

网络层已有接口保持不变,根据后端接口更改以下接口实现方式:

  • 获取正在进行的活动
  • 获取最新的活动
  • 获取历史活动
  • 获取指定部门的活动(新增)
  • 获取部门列表(新增)

可以新增一个和后端接口完全对应的接口,参数就是 std::initializer_list<std::param>,提供最高的可拓展性

… the return type from void to bool for some function
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Member

@Serein207 Serein207 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

查询活动接口的返回数据类型有变动,注意同步变更

src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
Copy link

clang-tidy review says "All clean, LGTM! 👍"

src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
… passing arguments by reference.

Additionally, renamed some incorrectly named variables in EventEntity to conform to backend interface specifications.
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

clang-tidy review says "All clean, LGTM! 👍"

src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/Response/DepartmentInfoEntity.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/ResponseStruct.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/Response/EventEntity.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
Copy link

clang-tidy review says "All clean, LGTM! 👍"

src/Infrastructure/Network/Response/EventEntity.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.cc Outdated Show resolved Hide resolved
src/Infrastructure/Network/NetworkClient.h Outdated Show resolved Hide resolved
@Serein207
Copy link
Member

改完之后就可以把 PR 打开,准备合入 dev

Additionally changed the definition locations of some variables and optimized the parameter names of some functions.
@schoolbag123 schoolbag123 marked this pull request as ready for review August 17, 2024 13:23
Copy link

clang-tidy review says "All clean, LGTM! 👍"

Copy link

clang-tidy review says "All clean, LGTM! 👍"

@Serein207 Serein207 merged commit 1c89d8a into dev Aug 17, 2024
5 checks passed
@Serein207 Serein207 deleted the feat/net/evento branch August 17, 2024 13:54
aurora0x27 pushed a commit that referenced this pull request Aug 18, 2024
* feat:Preliminarily completed the implementation of the evento api interface

* fix(net): Use `std::string` for all non-string arguments to meet the interface requirements of the URL library to resolve the compilation error.

* fix(net)!: fix the false return type of refreshAccessToken and change the return type from void to bool for some function

* fix(net): Fixed incorrect behavior in refreshAccessToken function.

* refactor(net): Modified the return value settings of some functions to make the overall behavior more in line with server interface expectations

* feat(net)!: Modified some function interfaces and implementations to align with the new backend interface specifications

* feat(net): Implemented department-related functions.

* fix(net): fix JSON parsing problem

* feat(net)!: Changed the return value types of some functions to avoid passing arguments by reference.

Additionally, renamed some incorrectly named variables in EventEntity to conform to backend interface specifications.

* style(net): Modified code style to meet requirements.

* feat(net): Add getEventList function

* feat(net)!: Deprecated some functions and change the name of some variables and functions.

* feat(net)!: Primarily enhanced the security of certain functions.

Additionally changed the definition locations of some variables and optimized the parameter names of some functions.

* feat(net): Initialize `std::optional<FeedbackEntity>` as `std::nullopt` in getUserFeedback
zwow-cj pushed a commit that referenced this pull request Aug 19, 2024
* feat:Preliminarily completed the implementation of the evento api interface

* fix(net): Use `std::string` for all non-string arguments to meet the interface requirements of the URL library to resolve the compilation error.

* fix(net)!: fix the false return type of refreshAccessToken and change the return type from void to bool for some function

* fix(net): Fixed incorrect behavior in refreshAccessToken function.

* refactor(net): Modified the return value settings of some functions to make the overall behavior more in line with server interface expectations

* feat(net)!: Modified some function interfaces and implementations to align with the new backend interface specifications

* feat(net): Implemented department-related functions.

* fix(net): fix JSON parsing problem

* feat(net)!: Changed the return value types of some functions to avoid passing arguments by reference.

Additionally, renamed some incorrectly named variables in EventEntity to conform to backend interface specifications.

* style(net): Modified code style to meet requirements.

* feat(net): Add getEventList function

* feat(net)!: Deprecated some functions and change the name of some variables and functions.

* feat(net)!: Primarily enhanced the security of certain functions.

Additionally changed the definition locations of some variables and optimized the parameter names of some functions.

* feat(net): Initialize `std::optional<FeedbackEntity>` as `std::nullopt` in getUserFeedback
Serein207 added a commit that referenced this pull request Sep 19, 2024
* feat(ui): complete main layout, add carousel.

* feat(ui): add layout to "current activity"

* feat(executor): different modes of `asyncExecute` using a timer

One more parameter of `asyncExecute` when using a timer: TimerFlag flag
TimerFlag::Once: perform the operation only once
TimerFlag::Periodic: perform the operation periodically
Implementation of `asyncExecuteByTimer` optimized
`io_context` exposed for more flexibility

* feat(executor): add execution strategy

* feat: add view data to `ViewManager` (#17)

* fix: added assert to `UiBridge::call`

* refactor: added included header in `BasicView` for convenience

* feat: added view data to `ViewManager`

* feat(net): github api  (#28)

* feat:completed github api  interface

* style:Change code style to match clang-format

---------

Co-authored-by: Serein <[email protected]>

* docs(executor): optimize flag description

* feat(net): evento api (#26)

* feat:Preliminarily completed the implementation of the evento api interface

* fix(net): Use `std::string` for all non-string arguments to meet the interface requirements of the URL library to resolve the compilation error.

* fix(net)!: fix the false return type of refreshAccessToken and change the return type from void to bool for some function

* fix(net): Fixed incorrect behavior in refreshAccessToken function.

* refactor(net): Modified the return value settings of some functions to make the overall behavior more in line with server interface expectations

* feat(net)!: Modified some function interfaces and implementations to align with the new backend interface specifications

* feat(net): Implemented department-related functions.

* fix(net): fix JSON parsing problem

* feat(net)!: Changed the return value types of some functions to avoid passing arguments by reference.

Additionally, renamed some incorrectly named variables in EventEntity to conform to backend interface specifications.

* style(net): Modified code style to meet requirements.

* feat(net): Add getEventList function

* feat(net)!: Deprecated some functions and change the name of some variables and functions.

* feat(net)!: Primarily enhanced the security of certain functions.

Additionally changed the definition locations of some variables and optimized the parameter names of some functions.

* feat(net): Initialize `std::optional<FeedbackEntity>` as `std::nullopt` in getUserFeedback

* feat(ui): add scrollview to layout

* feat/ui/discovery-page: add scarousel to scroollview

* feat/ui/DiscoveryPage: accomplish dynamic grid
using double for loop in VerticalLayout, but font not set yet

* feat(ui): ui core multiple update (#31)

* feat(ui): added state layer
* feat(ui): modify overlay, improve menu and login
* feat(ui): improve `MessageManager`
* feat(ui): added developer shortcut to skip `LoginOverlay`

Press Ctrl + Shift + Right click on shadow of `LoginOverlay` to skip login

* feat: set default slint style to material

* fix(ui): fix toast and login shadow (#33)

* fix(ui): make login shadow opaque
* fix(ui): make toast higher than overlay

* feat: slint experimental feature

* feat(ui): initialize sur-ui default theme

* fix: crash showing message when another message on screen

* feat(ui): optimize menu overlay

* fix: open url failed on macos

* build(deps): bump 3rdpart/sast-link-cxx-sdk from `9e2e743` to `2f62634` (#34)

Bumps [3rdpart/sast-link-cxx-sdk](https://github.com/Serein207/sast-link-cxx-sdk) from `9e2e743` to `2f62634`.
- [Release notes](https://github.com/Serein207/sast-link-cxx-sdk/releases)
- [Commits](Serein207/sast-link-cxx-sdk@9e2e743...2f62634)

---
updated-dependencies:
- dependency-name: 3rdpart/sast-link-cxx-sdk
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: make `openBrowser` inline, added dev shortcut

Ctrl+Shift+Left click for skip login
Ctrl+Shift+Right click for fake login (not trigger onLogin)

* fix: menu expand animation lost

* chore(cmake): remove useless variable

* build(deps): bump 3rdpart/sast-link-cxx-sdk from `9e2e743` to `2f62634` (#35)

Bumps [3rdpart/sast-link-cxx-sdk](https://github.com/Serein207/sast-link-cxx-sdk) from `9e2e743` to `2f62634`.
- [Release notes](https://github.com/Serein207/sast-link-cxx-sdk/releases)
- [Commits](Serein207/sast-link-cxx-sdk@9e2e743...2f62634)

---
updated-dependencies:
- dependency-name: 3rdpart/sast-link-cxx-sdk
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Serein <[email protected]>

* feat(ui): finish setting page (#21)

* feat:some basic laying

* feat(ui): basic laying on the page

* ui laying primary draft

* feat(ui): callbacks and root

* attempt to fill in .cc and .slint

* callbacks fiied

* feat: setting page

* feat: change theme when app start

* chore: clean up code

* feat(ui): add scroll view in setting page

---------

Co-authored-by: Serein <[email protected]>

* feat(ui): `LoadingButton` component (#37)

* feat: basic `LoadingButton`
* feat: add custom animate
* feat: export component in index, clean up code

* refactor!: drop icon color auto switch function (#42)

* refactor!: drop icon color auto switch
* fix: correct existing `Image`

reasons:
- reduce resource file number and executable size when embed resource
- color not exactly match environment (not the same color of text)
- auto switch require duplicate files with little difference, and not fit into some special requirements perfectly
- colorize support animation

How to migrate:

```
Image {
    source: Token.image.icon.me;
    colorize: Token.color.on-surface; // should be added to all Image with source Token.image.icon.*
}
```

Following icon keep previous behavior.

- evento (bad support for `colorize`)

BREAKING CHANGE: remove support for icon color auto-switch, please use `colorize` property of `Image` instead.

* feat(ui): event card (#38)

feat(ui): `Card`, `EventCard` , `EventCardGroup` and coversion function in `Convert.hh`

* feat(ui): improve view data logic

use std::array instead for convenience

* feat(assets): remove useless images

* feat(card): optimize animation

* feat(card): optimize event card

* feat(font): increase font size

* feat(ui)!: add md3 button (#46)

* feat(ui): added scrim, shadow color and elevation
* feat(ui): improve menu shadow
* feat(ui): improve state layer
* feat(ui): improve `LoadingAnimation`
* feat(ui): added md3 button

BREAKING CHANGE: 目前 LoadingButton 已被删除,请使用 LoadingAnimation 和 Button 的组合

* feat(ui): complete main layout, add carousel.

* feat(ui): add scrollview to layout

* feat/ui/DiscoveryPage: accomplish dynamic grid
using double for loop in VerticalLayout, but font not set yet

* feat/ui/discovery-page: use component eventcardgroup

* feat/ui/discovery-page: pull before push to remote

* feat(ui): fix compile error and conflicts

* feat/ui/discovery-page: modify component height

* feat/ui/discovery-page: finish page display

* feat/ui/discovery-page: seperate current and newest event

* feat/ui/discovery-page: delete dead code

* fix: correct about page link color

* refactor: new login overlay

* docs(readme): change to english

* feat(cache): clear disk cache

* fix(net)!: potential lifetime problem & modify api

* perf(net): change buffer to local variable

* fix(ui): load image logic

* feat(ui): clean up code

* fix

* ci: limit thread number of build

* build: replace platform macro

* fix: remove redundant code due to merge

* feat: controller logic

* fix: miss header

* perf: condition render info text

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Mairon <[email protected]>
Co-authored-by: Serein <[email protected]>
Co-authored-by: cEvolve05 <[email protected]>
Co-authored-by: shuzhuxvchuang <[email protected]>
Co-authored-by: Serein <[email protected]>
Co-authored-by: ZhiweiCOfficial <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: DTPA101 <[email protected]>
Co-authored-by: Mairon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(network): implement evento api
2 participants