字体查询接口实现

This commit is contained in:
lizhengwei 2025-11-26 15:27:23 +08:00
parent ce8cc9b621
commit 04302b065b
3 changed files with 7 additions and 17 deletions

View File

@ -39,12 +39,8 @@ public class FontController {
@Operation(summary = "根据字体族名称列表查询字体")
@PostMapping("list")
public List<String> list(@RequestBody List<String> names) {
List<String> fontContents = fontService.listFontsByNames(names);
if (fontContents == null) {
return new ArrayList<>();
}
return fontContents;
public List<Font> list(@RequestBody List<String> names) {
return fontService.listFontsByNames(names);
}
@Operation(summary = "根据ID获取字体详情")

View File

@ -42,7 +42,7 @@ public interface FontService extends IService<Font> {
* @param fontNameList 字体族名称列表
* @return 字体列表
*/
List<String> listFontsByNames(List<String> fontNameList);
List<Font> listFontsByNames(List<String> fontNameList);
/**
* 根据ID获取字体详情

View File

@ -71,24 +71,18 @@ public class FontServiceImpl extends ServiceImpl<FontDao, Font> implements FontS
}
@Override
public List<String> listFontsByNames(List<String> fontNameList) {
public List<Font> listFontsByNames(List<String> fontNameList) {
if (CollectionUtils.isEmpty(fontNameList)) {
return null;
}
// 从MySQL查询字体内容
List<Font> fonts = this.list(new LambdaQueryWrapper<Font>()
.in(Font::getName, fontNameList)
.isNotNull(Font::getContent));
.in(Font::getName, fontNameList)
.isNotNull(Font::getContent));
if (CollectionUtils.isEmpty(fonts)) {
return null;
}
// 提取JSON内容
return fonts.stream()
.map(Font::getContent)
.collect(Collectors.toList());
return fonts;
}
@Override