yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
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
35
36
37
38
39
package com.qianwen.smartman.modules.system.service.impl;
 
import org.springframework.stereotype.Service;
 
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.mp.base.BaseServiceImpl;
import com.qianwen.smartman.common.utils.MessageUtils;
import com.qianwen.smartman.modules.system.entity.Param;
import com.qianwen.smartman.modules.system.entity.Theme;
import com.qianwen.smartman.modules.system.mapper.ThemeMapper;
import com.qianwen.smartman.modules.system.service.IParamService;
import com.qianwen.smartman.modules.system.service.IThemeService;
 
@Service
public class ThemeServiceImpl extends BaseServiceImpl<ThemeMapper, Theme> implements IThemeService {
    private final IParamService paramService;
    private final String PARAM_KEY = "system.theme";
 
 
    public ThemeServiceImpl(final IParamService paramService) {
        this.paramService = paramService;
    }
 
    @Override // org.springblade.modules.system.service.IThemeService
    public Param changeTheme(String theme) {
        Param param = this.paramService.getOne(Wrappers.<Param>query().lambda().eq(Param::getParamKey, "system.theme"));
        /*
        Param param = (Param) this.paramService.getOne((Wrapper) Wrappers.query().lambda().eq((v0) -> {
            return v0.getParamKey();
        }, "system.theme"));*/
        param.setParamValue(theme);
        boolean update = this.paramService.updateById(param);
        if (!update) {
            throw new ServiceException(MessageUtils.message("system.theme.change.is.wrong", new Object[0]));
        }
        return param;
    }
}