mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-26 06:52:43 +08:00
优化系统配置返回
This commit is contained in:
parent
8dbe266132
commit
7251c68e83
@ -10,6 +10,7 @@ import org.springframework.boot.ApplicationRunner;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import xyz.playedu.api.constant.BackendConstant;
|
import xyz.playedu.api.constant.BackendConstant;
|
||||||
|
import xyz.playedu.api.constant.CConfig;
|
||||||
import xyz.playedu.api.domain.AppConfig;
|
import xyz.playedu.api.domain.AppConfig;
|
||||||
import xyz.playedu.api.service.AppConfigService;
|
import xyz.playedu.api.service.AppConfigService;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ public class AppConfigCheck implements ApplicationRunner {
|
|||||||
setName("网站名");
|
setName("网站名");
|
||||||
setSort(10);
|
setSort(10);
|
||||||
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
||||||
setKeyName("system.name");
|
setKeyName(CConfig.SYSTEM_NAME);
|
||||||
setKeyValue("");
|
setKeyValue("");
|
||||||
setHelp("请输入网站名");
|
setHelp("请输入网站名");
|
||||||
}
|
}
|
||||||
@ -45,7 +46,7 @@ public class AppConfigCheck implements ApplicationRunner {
|
|||||||
setName("Logo");
|
setName("Logo");
|
||||||
setSort(20);
|
setSort(20);
|
||||||
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_IMAGE);
|
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_IMAGE);
|
||||||
setKeyName("system.logo");
|
setKeyName(CConfig.SYSTEM_LOGO);
|
||||||
setKeyValue("");
|
setKeyValue("");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -54,7 +55,7 @@ public class AppConfigCheck implements ApplicationRunner {
|
|||||||
setName("API访问地址");
|
setName("API访问地址");
|
||||||
setSort(30);
|
setSort(30);
|
||||||
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
||||||
setKeyName("system.api_url");
|
setKeyName(CConfig.SYSTEM_API_URL);
|
||||||
setKeyValue("");
|
setKeyValue("");
|
||||||
setHelp("请输入API访问地址");
|
setHelp("请输入API访问地址");
|
||||||
}
|
}
|
||||||
@ -64,7 +65,7 @@ public class AppConfigCheck implements ApplicationRunner {
|
|||||||
setName("PC端口访问地址");
|
setName("PC端口访问地址");
|
||||||
setSort(40);
|
setSort(40);
|
||||||
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
||||||
setKeyName("system.pc_url");
|
setKeyName(CConfig.SYSTEM_PC_URL);
|
||||||
setKeyValue("");
|
setKeyValue("");
|
||||||
setHelp("请输入PC端访问地址");
|
setHelp("请输入PC端访问地址");
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ public class AppConfigCheck implements ApplicationRunner {
|
|||||||
setName("H5端口访问地址");
|
setName("H5端口访问地址");
|
||||||
setSort(50);
|
setSort(50);
|
||||||
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_INPUT);
|
||||||
setKeyName("system.h5_url");
|
setKeyName(CConfig.SYSTEM_H5_URL);
|
||||||
setKeyValue("");
|
setKeyValue("");
|
||||||
setHelp("请输入H5端访问地址");
|
setHelp("请输入H5端访问地址");
|
||||||
}
|
}
|
||||||
@ -143,6 +144,19 @@ public class AppConfigCheck implements ApplicationRunner {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
put(
|
||||||
|
"学员配置",
|
||||||
|
new AppConfig[] {
|
||||||
|
new AppConfig() {
|
||||||
|
{
|
||||||
|
setName("默认头像");
|
||||||
|
setSort(10);
|
||||||
|
setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_IMAGE);
|
||||||
|
setKeyName(CConfig.MEMBER_DEFAULT_AVATAR);
|
||||||
|
setKeyValue("");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
21
src/main/java/xyz/playedu/api/constant/CConfig.java
Normal file
21
src/main/java/xyz/playedu/api/constant/CConfig.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* This file is part of the PlayEdu.
|
||||||
|
* (c) 杭州白书科技有限公司
|
||||||
|
*/
|
||||||
|
package xyz.playedu.api.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author 杭州白书科技有限公司
|
||||||
|
*
|
||||||
|
* @create 2023/4/11 10:12
|
||||||
|
*/
|
||||||
|
public class CConfig {
|
||||||
|
|
||||||
|
public static final String SYSTEM_NAME = "system.name";
|
||||||
|
public static final String SYSTEM_LOGO = "system.logo";
|
||||||
|
public static final String SYSTEM_API_URL = "system.api_url";
|
||||||
|
public static final String SYSTEM_PC_URL = "system.pc_url";
|
||||||
|
public static final String SYSTEM_H5_URL = "system.h5_url";
|
||||||
|
|
||||||
|
public static final String MEMBER_DEFAULT_AVATAR = "member.default_avatar";
|
||||||
|
}
|
@ -4,22 +4,29 @@
|
|||||||
*/
|
*/
|
||||||
package xyz.playedu.api.controller.backend;
|
package xyz.playedu.api.controller.backend;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import xyz.playedu.api.BCtx;
|
import xyz.playedu.api.BCtx;
|
||||||
|
import xyz.playedu.api.constant.CConfig;
|
||||||
import xyz.playedu.api.service.ImageCaptchaService;
|
import xyz.playedu.api.service.ImageCaptchaService;
|
||||||
import xyz.playedu.api.types.ImageCaptchaResult;
|
import xyz.playedu.api.types.ImageCaptchaResult;
|
||||||
import xyz.playedu.api.types.JsonResponse;
|
import xyz.playedu.api.types.JsonResponse;
|
||||||
|
import xyz.playedu.api.util.RequestUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/backend/v1/system")
|
@RequestMapping("/backend/v1/system")
|
||||||
|
@Slf4j
|
||||||
public class SystemController {
|
public class SystemController {
|
||||||
|
|
||||||
@Autowired private ImageCaptchaService imageCaptchaService;
|
@Autowired private ImageCaptchaService imageCaptchaService;
|
||||||
@ -37,7 +44,34 @@ public class SystemController {
|
|||||||
|
|
||||||
@GetMapping("/config")
|
@GetMapping("/config")
|
||||||
public JsonResponse config() {
|
public JsonResponse config() {
|
||||||
Map<String, String> data = BCtx.getConfig();
|
Map<String, String> configData = BCtx.getConfig();
|
||||||
|
|
||||||
|
String apiUrl = configData.get(CConfig.SYSTEM_API_URL);
|
||||||
|
if (apiUrl == null || apiUrl.trim().length() == 0) {
|
||||||
|
apiUrl = RequestUtil.uriWithProtocol();
|
||||||
|
}
|
||||||
|
|
||||||
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
|
|
||||||
|
data.put(CConfig.SYSTEM_NAME, configData.get(CConfig.SYSTEM_NAME));
|
||||||
|
data.put(CConfig.SYSTEM_LOGO, configData.get(CConfig.SYSTEM_LOGO));
|
||||||
|
data.put(CConfig.SYSTEM_API_URL, apiUrl);
|
||||||
|
data.put(CConfig.SYSTEM_PC_URL, configData.get(CConfig.SYSTEM_PC_URL));
|
||||||
|
data.put(CConfig.SYSTEM_H5_URL, configData.get(CConfig.SYSTEM_H5_URL));
|
||||||
|
|
||||||
|
// 学员的默认头像
|
||||||
|
String memberDefaultAvatar = configData.get(CConfig.MEMBER_DEFAULT_AVATAR);
|
||||||
|
if (memberDefaultAvatar == null || memberDefaultAvatar.trim().length() == 0) {
|
||||||
|
data.put(CConfig.MEMBER_DEFAULT_AVATAR, apiUrl + "/images/default_avatar.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内置的三个线上课封面
|
||||||
|
List<String> defaultCourseThumbs = new ArrayList<>();
|
||||||
|
defaultCourseThumbs.add(apiUrl + "/images/courses/thumb1.png");
|
||||||
|
defaultCourseThumbs.add(apiUrl + "/images/courses/thumb2.png");
|
||||||
|
defaultCourseThumbs.add(apiUrl + "/images/courses/thumb3.png");
|
||||||
|
data.put("default_course_thumbs", defaultCourseThumbs);
|
||||||
|
|
||||||
return JsonResponse.data(data);
|
return JsonResponse.data(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import xyz.playedu.api.constant.CConfig;
|
||||||
import xyz.playedu.api.service.AppConfigService;
|
import xyz.playedu.api.service.AppConfigService;
|
||||||
import xyz.playedu.api.service.ImageCaptchaService;
|
import xyz.playedu.api.service.ImageCaptchaService;
|
||||||
import xyz.playedu.api.types.ImageCaptchaResult;
|
import xyz.playedu.api.types.ImageCaptchaResult;
|
||||||
@ -37,11 +38,11 @@ public class SystemController {
|
|||||||
|
|
||||||
HashMap<String, String> data = new HashMap<>();
|
HashMap<String, String> data = new HashMap<>();
|
||||||
|
|
||||||
data.put("system-name", configs.get("system.name"));
|
data.put("system-name", configs.get(CConfig.SYSTEM_NAME));
|
||||||
data.put("system-logo", configs.get("system.logo"));
|
data.put("system-logo", configs.get(CConfig.SYSTEM_LOGO));
|
||||||
data.put("system-api-url", configs.get("system.api_url"));
|
data.put("system-api-url", configs.get(CConfig.SYSTEM_API_URL));
|
||||||
data.put("system-pc-url", configs.get("system.pc_url"));
|
data.put("system-pc-url", configs.get(CConfig.SYSTEM_PC_URL));
|
||||||
data.put("system-h5-url", configs.get("system.h5_url"));
|
data.put("system-h5-url", configs.get(CConfig.SYSTEM_H5_URL));
|
||||||
data.put("system-pc-index-footer-msg", configs.get("system.pc_index_footer_msg"));
|
data.put("system-pc-index-footer-msg", configs.get("system.pc_index_footer_msg"));
|
||||||
|
|
||||||
data.put("player-poster", configs.get("player.poster"));
|
data.put("player-poster", configs.get("player.poster"));
|
||||||
|
@ -54,6 +54,13 @@ public class RequestUtil {
|
|||||||
+ (Arrays.asList(443, 80, 0).contains(portNumber) ? "" : ":" + portNumber);
|
+ (Arrays.asList(443, 80, 0).contains(portNumber) ? "" : ":" + portNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String uriWithProtocol() {
|
||||||
|
Integer portNumber = port();
|
||||||
|
return RequestUtil.protocol()
|
||||||
|
+ RequestUtil.domain()
|
||||||
|
+ (Arrays.asList(443, 80, 0).contains(portNumber) ? "" : ":" + portNumber);
|
||||||
|
}
|
||||||
|
|
||||||
public static String pathname() {
|
public static String pathname() {
|
||||||
HttpServletRequest request = RequestUtil.handler();
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
return request == null ? "" : request.getRequestURI();
|
return request == null ? "" : request.getRequestURI();
|
||||||
@ -74,4 +81,15 @@ public class RequestUtil {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String protocol() {
|
||||||
|
HttpServletRequest request = RequestUtil.handler();
|
||||||
|
if (request != null) {
|
||||||
|
String requestUrl = request.getRequestURL().toString();
|
||||||
|
List<String> urls = Arrays.asList(requestUrl.split("//"));
|
||||||
|
|
||||||
|
return urls.get(0) + "//";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/main/resources/static/images/courses/thumb1.png
Normal file
BIN
src/main/resources/static/images/courses/thumb1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
src/main/resources/static/images/courses/thumb2.png
Normal file
BIN
src/main/resources/static/images/courses/thumb2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
src/main/resources/static/images/courses/thumb3.png
Normal file
BIN
src/main/resources/static/images/courses/thumb3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
src/main/resources/static/images/default_avatar.png
Normal file
BIN
src/main/resources/static/images/default_avatar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Loading…
x
Reference in New Issue
Block a user