Skip to content

Commit

Permalink
Merge pull request #109 from jamebal/develop
Browse files Browse the repository at this point in the history
feat: 添加预览配置
  • Loading branch information
jamebal authored Jun 22, 2024
2 parents 78a5a21 + a492ac5 commit bccb920
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/jmal/clouddisk/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AsyncTaskExecutor taskExecutor() {
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("GET", "OPTIONS")
.allowedMethods("*")
.allowedHeaders("*");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.jmal.clouddisk.lucene.TaskProgressService;
import com.jmal.clouddisk.model.LdapConfigDTO;
import com.jmal.clouddisk.model.LogOperation;
import com.jmal.clouddisk.model.WebsiteSettingDTO;
import com.jmal.clouddisk.service.IAuthService;
import com.jmal.clouddisk.service.IUserService;
import com.jmal.clouddisk.service.impl.SettingService;
Expand Down Expand Up @@ -120,27 +121,42 @@ public ResponseResult<Object> disabledWebp(@RequestParam String userId, @Request
}

@Operation(summary = "加载ldap配置")
@LogOperatingFun(logType = LogOperation.Type.LOGIN)
@GetMapping("/ldap/config")
public ResponseResult<Object> loadLdapConfig() {
return ResultUtil.success(authService.loadLdapConfig());
}

@Operation(summary = "ldap配置")
@LogOperatingFun(logType = LogOperation.Type.LOGIN)
@LogOperatingFun(logType = LogOperation.Type.OPERATION)
@PutMapping("/ldap/config")
@Permission(value = "cloud:set:sync")
public ResponseResult<Object> updateLdapConfig(@RequestBody LdapConfigDTO ldapConfigDTO) {
return authService.updateLdapConfig(ldapConfigDTO);
}

@Operation(summary = "测试ldap配置")
@LogOperatingFun(logType = LogOperation.Type.BROWSE)
@PutMapping("/ldap/test-config")
@Permission(value = "cloud:set:sync")
public ResponseResult<Object> testLdapConfig(@RequestBody LdapConfigDTO ldapConfigDTO) {
authService.testLdapConfig(ldapConfigDTO);
return ResultUtil.success();
}

@Operation(summary = "获取预览配置")
@GetMapping("/cloud/setting/preview/config")
public ResponseResult<Object> getPreviewConfig() {
return ResultUtil.success(settingService.getPreviewConfig());
}

@Operation(summary = "更新预览配置")
@LogOperatingFun(logType = LogOperation.Type.OPERATION)
@PutMapping("/cloud/setting/preview/config")
@Permission(value = "cloud:set:sync")
public ResponseResult<Object> updatePreviewConfig(@RequestBody WebsiteSettingDTO websiteSettingDTO) {
settingService.updatePreviewConfig(websiteSettingDTO);
return ResultUtil.success();
}

@Operation(summary = "加载任务进度")
@GetMapping("/cloud/task/progress")
@Permission(value = "cloud:file:upload")
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/jmal/clouddisk/model/WebsiteSettingDO.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ public class WebsiteSettingDO {
* 公网备案号 展示文本
*/
String networkRecordNumberStr;
/**
* iframe预览配置
*/
String iframe;
}
5 changes: 5 additions & 0 deletions src/main/java/com/jmal/clouddisk/model/WebsiteSettingDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ public class WebsiteSettingDTO {
*/
String networkRecordNumberStr;

/**
* iframe预览配置
*/
String iframe;

@Data
public static class OperatingButton {
/***
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/jmal/clouddisk/model/rbac/ConsumerDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@ public class ConsumerDTO extends ConsumerBase {
@Schema(name = "newVersion", title = "新版本", hidden = true)
String newVersion;

String iframe;

}
15 changes: 15 additions & 0 deletions src/main/java/com/jmal/clouddisk/service/impl/SettingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,19 @@ public void resetMenuAndRole() {
roleService.initRoles();
}

public WebsiteSettingDTO getPreviewConfig() {
Query query = new Query();
query.fields().include("iframe");
WebsiteSettingDTO websiteSettingDTO = mongoTemplate.findOne(new Query(), WebsiteSettingDTO.class, COLLECTION_NAME_WEBSITE_SETTING);
if (websiteSettingDTO == null) {
return new WebsiteSettingDTO();
}
return websiteSettingDTO;
}

public synchronized void updatePreviewConfig(WebsiteSettingDTO websiteSettingDTO) {
Update update = new Update();
update.set("iframe", websiteSettingDTO.getIframe());
mongoTemplate.upsert(new Query(), update, COLLECTION_NAME_WEBSITE_SETTING);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public ResponseResult<ConsumerDTO> userInfo(String id) {
if (websiteSettingDO != null) {
consumerDTO.setNetdiskName(websiteSettingDO.getNetdiskName());
consumerDTO.setNetdiskLogo(websiteSettingDO.getNetdiskLogo());
consumerDTO.setIframe(websiteSettingDO.getIframe());
}
String newVersion = fileMonitor.hasNewVersion();
if (!StrUtil.isBlank(newVersion)) {
Expand Down

0 comments on commit bccb920

Please sign in to comment.