|
|
|
|
@ -2,10 +2,9 @@ package cn.iocoder.yudao.module.infra.service.branding;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.infra.controller.admin.branding.vo.BrandingLogoRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.infra.controller.admin.branding.vo.BrandingLogoSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigSaveReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
|
|
|
|
|
import cn.iocoder.yudao.module.infra.service.config.ConfigService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper;
|
|
|
|
|
import cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
@ -21,7 +20,7 @@ public class BrandingServiceImpl implements BrandingService {
|
|
|
|
|
private static final String APP_LOGIN_LOGO_KEY = "ui.logo.app.login";
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private ConfigService configService;
|
|
|
|
|
private ConfigMapper configMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BrandingLogoRespVO getLogo() {
|
|
|
|
|
@ -34,35 +33,36 @@ public class BrandingServiceImpl implements BrandingService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void saveLogo(BrandingLogoSaveReqVO saveReqVO) {
|
|
|
|
|
saveConfigIfPresent(WEB_LOGIN_LOGO_KEY, "Web 登录页 Logo", saveReqVO.getWebLoginLogo());
|
|
|
|
|
saveConfigIfPresent(WEB_HEADER_LOGO_KEY, "Web 顶部 Logo", saveReqVO.getWebHeaderLogo());
|
|
|
|
|
saveConfigIfPresent(APP_LOGIN_LOGO_KEY, "App 登录页 Logo", saveReqVO.getAppLoginLogo());
|
|
|
|
|
saveConfigIfNotNull(WEB_LOGIN_LOGO_KEY, "Web 登录页 Logo", saveReqVO.getWebLoginLogo());
|
|
|
|
|
saveConfigIfNotNull(WEB_HEADER_LOGO_KEY, "Web 顶部 Logo", saveReqVO.getWebHeaderLogo());
|
|
|
|
|
saveConfigIfNotNull(APP_LOGIN_LOGO_KEY, "App 登录页 Logo", saveReqVO.getAppLoginLogo());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getConfigValue(String key) {
|
|
|
|
|
ConfigDO config = configService.getConfigByKey(key);
|
|
|
|
|
ConfigDO config = configMapper.selectByKey(key);
|
|
|
|
|
return config == null || !Boolean.TRUE.equals(config.getVisible()) ? null : config.getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveConfigIfPresent(String key, String name, String value) {
|
|
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
|
|
private void saveConfigIfNotNull(String key, String name, String value) {
|
|
|
|
|
if (value == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ConfigDO config = configService.getConfigByKey(key);
|
|
|
|
|
ConfigSaveReqVO saveReqVO = new ConfigSaveReqVO();
|
|
|
|
|
ConfigDO config = configMapper.selectByKey(key);
|
|
|
|
|
ConfigDO saveObj = new ConfigDO();
|
|
|
|
|
if (config != null) {
|
|
|
|
|
saveReqVO.setId(config.getId());
|
|
|
|
|
saveObj.setId(config.getId());
|
|
|
|
|
}
|
|
|
|
|
saveReqVO.setCategory(CATEGORY);
|
|
|
|
|
saveReqVO.setName(name);
|
|
|
|
|
saveReqVO.setKey(key);
|
|
|
|
|
saveReqVO.setValue(value);
|
|
|
|
|
saveReqVO.setVisible(true);
|
|
|
|
|
saveReqVO.setRemark("品牌 Logo 配置");
|
|
|
|
|
saveObj.setCategory(CATEGORY);
|
|
|
|
|
saveObj.setName(name);
|
|
|
|
|
saveObj.setConfigKey(key);
|
|
|
|
|
saveObj.setValue(value);
|
|
|
|
|
saveObj.setType(ConfigTypeEnum.CUSTOM.getType());
|
|
|
|
|
saveObj.setVisible(true);
|
|
|
|
|
saveObj.setRemark("品牌 Logo 配置");
|
|
|
|
|
if (config == null) {
|
|
|
|
|
configService.createConfig(saveReqVO);
|
|
|
|
|
configMapper.insert(saveObj);
|
|
|
|
|
} else {
|
|
|
|
|
configService.updateConfig(saveReqVO);
|
|
|
|
|
configMapper.updateById(saveObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|