mitao
2024-08-24 403fbe8fa8d3df96d692ad41ffa1c300b0db5493
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
    }
}