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

希望在Content API中提供通过themeId查询主题信息及配置的接口 #1659

Closed
fuzui opened this issue Feb 17, 2022 · 3 comments · Fixed by #1660
Closed

希望在Content API中提供通过themeId查询主题信息及配置的接口 #1659

fuzui opened this issue Feb 17, 2022 · 3 comments · Fixed by #1660
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. pr welcome
Milestone

Comments

@fuzui
Copy link
Contributor

fuzui commented Feb 17, 2022

Your current Halo version

1.4.17

Describe this feature

目前Content API中仅能够查询当前使用的主题的信息及配置。
因如果我想在其他端(例如APP、小程序)中能够通过后台灵活配置一些参数,但我仍不想放弃我当前在web端正在使用的主题。
目前能想到的便是通过拉取一个特有主题来获取其配置,但在后台仅仅只是配置它,并不启用它。

Additional information

No response

@JohnNiang
Copy link
Member

@fuzui Thanks for reaching out here. We will consider your request in Halo 1.5.x.

/kind feature

@JohnNiang JohnNiang added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 18, 2022
@JohnNiang JohnNiang added this to the 1.5.x milestone Feb 18, 2022
@JohnNiang
Copy link
Member

这里我提供一下实现思路,希望有兴趣的朋友能够根据该思路达成参与 Halo 的成就。

思路

实现“根据 themeId 获取主题信息及配置信息”接口

@RequestMapping("/api/content/themes")
public class ThemeController {
private final ThemeService themeService;
private final ThemeSettingService themeSettingService;
public ThemeController(ThemeService themeService, ThemeSettingService themeSettingService) {
this.themeService = themeService;
this.themeSettingService = themeSettingService;
}
@GetMapping("activation")
@ApiOperation("Gets activated theme property")
public ThemeProperty getBy() {
return themeService.getThemeOfNonNullBy(themeService.getActivatedThemeId());
}
@GetMapping("activation/settings")
@ApiOperation("Lists activated theme settings")
public Map<String, Object> listSettingsBy() {
return themeSettingService.listAsMapBy(themeService.getActivatedThemeId());
}
}

实现过程中,可能需要通过以下服务来获取主题详情:

ThemeProperty getThemeOfNonNullBy(@NonNull String themeId);

@ruibaby
Copy link
Member

ruibaby commented Feb 18, 2022

/assign @guqing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants