package com.xinquan.system.service;
|
|
import com.xinquan.common.core.utils.page.BeanUtils;
|
import com.xinquan.system.domain.ContentSetting;
|
import com.xinquan.system.domain.vo.ContentSettingVO;
|
import java.util.Optional;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* @author mitao
|
* @date 2024/8/23
|
*/
|
@Slf4j
|
@Service
|
@RequiredArgsConstructor
|
public class PublicService {
|
|
private final ContentSettingService contentSettingService;
|
|
/**
|
* 根据key获取内容
|
*
|
* @param key
|
* @return
|
*/
|
public ContentSettingVO getContent(Integer key) {
|
Optional<ContentSetting> contentSetting = contentSettingService.lambdaQuery()
|
.eq(ContentSetting::getContentType, key).oneOpt();
|
return contentSetting.map(setting -> BeanUtils.copyBean(setting, ContentSettingVO.class))
|
.orElse(null);
|
}
|
}
|