feat:新增图标logo接口
parent
497dabf8f8
commit
67f714f080
@ -0,0 +1,47 @@
|
|||||||
|
package cn.iocoder.yudao.module.infra.controller.admin.branding;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
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.service.branding.BrandingService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.annotation.security.PermitAll;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 品牌 Logo")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/infra/branding")
|
||||||
|
@Validated
|
||||||
|
public class BrandingController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BrandingService brandingService;
|
||||||
|
|
||||||
|
@GetMapping("/logo")
|
||||||
|
@PermitAll
|
||||||
|
@Operation(summary = "获得品牌 Logo 配置")
|
||||||
|
public CommonResult<BrandingLogoRespVO> getLogo() {
|
||||||
|
return success(brandingService.getLogo());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/logo")
|
||||||
|
@Operation(summary = "保存品牌 Logo 配置")
|
||||||
|
@PreAuthorize("@ss.hasPermission('infra:config:update')")
|
||||||
|
public CommonResult<Boolean> saveLogo(@Valid @RequestBody BrandingLogoSaveReqVO saveReqVO) {
|
||||||
|
brandingService.saveLogo(saveReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package cn.iocoder.yudao.module.infra.controller.admin.branding.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 品牌 Logo Response VO")
|
||||||
|
@Data
|
||||||
|
public class BrandingLogoRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "Web 登录页 Logo")
|
||||||
|
private String webLoginLogo;
|
||||||
|
|
||||||
|
@Schema(description = "Web 系统内顶部 Logo")
|
||||||
|
private String webHeaderLogo;
|
||||||
|
|
||||||
|
@Schema(description = "App 登录页 Logo")
|
||||||
|
private String appLoginLogo;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package cn.iocoder.yudao.module.infra.controller.admin.branding.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 品牌 Logo 保存 Request VO")
|
||||||
|
@Data
|
||||||
|
public class BrandingLogoSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "Web 登录页 Logo")
|
||||||
|
private String webLoginLogo;
|
||||||
|
|
||||||
|
@Schema(description = "Web 系统内顶部 Logo")
|
||||||
|
private String webHeaderLogo;
|
||||||
|
|
||||||
|
@Schema(description = "App 登录页 Logo")
|
||||||
|
private String appLoginLogo;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
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 javax.validation.Valid;
|
||||||
|
|
||||||
|
public interface BrandingService {
|
||||||
|
|
||||||
|
BrandingLogoRespVO getLogo();
|
||||||
|
|
||||||
|
void saveLogo(@Valid BrandingLogoSaveReqVO saveReqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
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 org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class BrandingServiceImpl implements BrandingService {
|
||||||
|
|
||||||
|
private static final String CATEGORY = "ui_branding";
|
||||||
|
private static final String WEB_LOGIN_LOGO_KEY = "ui.logo.web.login";
|
||||||
|
private static final String WEB_HEADER_LOGO_KEY = "ui.logo.web.header";
|
||||||
|
private static final String APP_LOGIN_LOGO_KEY = "ui.logo.app.login";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ConfigService configService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BrandingLogoRespVO getLogo() {
|
||||||
|
BrandingLogoRespVO respVO = new BrandingLogoRespVO();
|
||||||
|
respVO.setWebLoginLogo(getConfigValue(WEB_LOGIN_LOGO_KEY));
|
||||||
|
respVO.setWebHeaderLogo(getConfigValue(WEB_HEADER_LOGO_KEY));
|
||||||
|
respVO.setAppLoginLogo(getConfigValue(APP_LOGIN_LOGO_KEY));
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getConfigValue(String key) {
|
||||||
|
ConfigDO config = configService.getConfigByKey(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)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ConfigDO config = configService.getConfigByKey(key);
|
||||||
|
ConfigSaveReqVO saveReqVO = new ConfigSaveReqVO();
|
||||||
|
if (config != null) {
|
||||||
|
saveReqVO.setId(config.getId());
|
||||||
|
}
|
||||||
|
saveReqVO.setCategory(CATEGORY);
|
||||||
|
saveReqVO.setName(name);
|
||||||
|
saveReqVO.setKey(key);
|
||||||
|
saveReqVO.setValue(value);
|
||||||
|
saveReqVO.setVisible(true);
|
||||||
|
saveReqVO.setRemark("品牌 Logo 配置");
|
||||||
|
if (config == null) {
|
||||||
|
configService.createConfig(saveReqVO);
|
||||||
|
} else {
|
||||||
|
configService.updateConfig(saveReqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue