进一步补充后端API
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"xboard-go/internal/database"
|
||||
@@ -198,11 +197,101 @@ func PluginUserAddIPv6SyncPassword(c *gin.Context) {
|
||||
|
||||
func AdminConfigFetch(c *gin.Context) {
|
||||
Success(c, gin.H{
|
||||
"app_name": service.MustGetString("app_name", "XBoard"),
|
||||
"app_url": service.GetAppURL(),
|
||||
"secure_path": service.GetAdminSecurePath(),
|
||||
"server_pull_interval": service.MustGetInt("server_pull_interval", 60),
|
||||
"server_push_interval": service.MustGetInt("server_push_interval", 60),
|
||||
"invite": gin.H{
|
||||
"invite_force": service.MustGetBool("invite_force", false),
|
||||
"invite_commission": service.MustGetInt("invite_commission", 10),
|
||||
"invite_gen_limit": service.MustGetInt("invite_gen_limit", 5),
|
||||
"invite_never_expire": service.MustGetBool("invite_never_expire", false),
|
||||
"commission_first_time_enable": service.MustGetBool("commission_first_time_enable", true),
|
||||
"commission_auto_check_enable": service.MustGetBool("commission_auto_check_enable", true),
|
||||
"commission_withdraw_limit": service.MustGetInt("commission_withdraw_limit", 100),
|
||||
"withdraw_close_enable": service.MustGetBool("withdraw_close_enable", false),
|
||||
"commission_distribution_enable": service.MustGetBool("commission_distribution_enable", false),
|
||||
"commission_distribution_l1": service.MustGetInt("commission_distribution_l1", 0),
|
||||
"commission_distribution_l2": service.MustGetInt("commission_distribution_l2", 0),
|
||||
"commission_distribution_l3": service.MustGetInt("commission_distribution_l3", 0),
|
||||
},
|
||||
"site": gin.H{
|
||||
"logo": service.MustGetString("logo", ""),
|
||||
"force_https": service.MustGetBool("force_https", false),
|
||||
"stop_register": service.MustGetBool("stop_register", false),
|
||||
"app_name": service.MustGetString("app_name", "XBoard"),
|
||||
"app_description": service.MustGetString("app_description", "XBoard is best!"),
|
||||
"app_url": service.GetAppURL(),
|
||||
"subscribe_url": service.MustGetString("subscribe_url", ""),
|
||||
"try_out_enable": service.MustGetBool("try_out_enable", false),
|
||||
"try_out_plan_id": service.MustGetInt("try_out_plan_id", 0),
|
||||
"try_out_hour": service.MustGetInt("try_out_hour", 1),
|
||||
"tos_url": service.MustGetString("tos_url", ""),
|
||||
"currency": service.MustGetString("currency", "CNY"),
|
||||
"currency_symbol": service.MustGetString("currency_symbol", "¥"),
|
||||
"ticket_must_wait_reply": service.MustGetBool("ticket_must_wait_reply", false),
|
||||
},
|
||||
"subscribe": gin.H{
|
||||
"plan_change_enable": service.MustGetBool("plan_change_enable", true),
|
||||
"reset_traffic_method": service.MustGetInt("reset_traffic_method", 0),
|
||||
"surplus_enable": service.MustGetBool("surplus_enable", true),
|
||||
"new_order_event_id": service.MustGetInt("new_order_event_id", 0),
|
||||
"renew_order_event_id": service.MustGetInt("renew_order_event_id", 0),
|
||||
"change_order_event_id": service.MustGetInt("change_order_event_id", 0),
|
||||
"show_info_to_server_enable": service.MustGetBool("show_info_to_server_enable", false),
|
||||
"show_protocol_to_server_enable": service.MustGetBool("show_protocol_to_server_enable", false),
|
||||
"subscribe_path": service.MustGetString("subscribe_path", "s"),
|
||||
},
|
||||
"frontend": gin.H{
|
||||
"frontend_theme": service.MustGetString("frontend_theme", "Xboard"),
|
||||
"frontend_theme_sidebar": service.MustGetString("frontend_theme_sidebar", "light"),
|
||||
"frontend_theme_header": service.MustGetString("frontend_theme_header", "dark"),
|
||||
"frontend_theme_color": service.MustGetString("frontend_theme_color", "default"),
|
||||
"frontend_background_url": service.MustGetString("frontend_background_url", ""),
|
||||
},
|
||||
"server": gin.H{
|
||||
"server_token": service.MustGetString("server_token", ""),
|
||||
"server_pull_interval": service.MustGetInt("server_pull_interval", 60),
|
||||
"server_push_interval": service.MustGetInt("server_push_interval", 60),
|
||||
"device_limit_mode": service.MustGetInt("device_limit_mode", 0),
|
||||
"server_ws_enable": service.MustGetBool("server_ws_enable", true),
|
||||
"server_ws_url": service.MustGetString("server_ws_url", ""),
|
||||
},
|
||||
"email": gin.H{
|
||||
"email_template": service.MustGetString("email_template", "default"),
|
||||
"email_host": service.MustGetString("email_host", ""),
|
||||
"email_port": service.MustGetString("email_port", ""),
|
||||
"email_username": service.MustGetString("email_username", ""),
|
||||
"email_password": service.MustGetString("email_password", ""),
|
||||
"email_encryption": service.MustGetString("email_encryption", ""),
|
||||
"email_from_address": service.MustGetString("email_from_address", ""),
|
||||
"remind_mail_enable": service.MustGetBool("remind_mail_enable", false),
|
||||
},
|
||||
"telegram": gin.H{
|
||||
"telegram_bot_enable": service.MustGetBool("telegram_bot_enable", false),
|
||||
"telegram_bot_token": service.MustGetString("telegram_bot_token", ""),
|
||||
"telegram_webhook_url": service.MustGetString("telegram_webhook_url", ""),
|
||||
"telegram_discuss_link": service.MustGetString("telegram_discuss_link", ""),
|
||||
},
|
||||
"app": gin.H{
|
||||
"windows_version": service.MustGetString("windows_version", ""),
|
||||
"windows_download_url": service.MustGetString("windows_download_url", ""),
|
||||
"macos_version": service.MustGetString("macos_version", ""),
|
||||
"macos_download_url": service.MustGetString("macos_download_url", ""),
|
||||
"android_version": service.MustGetString("android_version", ""),
|
||||
"android_download_url": service.MustGetString("android_download_url", ""),
|
||||
},
|
||||
"safe": gin.H{
|
||||
"email_verify": service.MustGetBool("email_verify", false),
|
||||
"safe_mode_enable": service.MustGetBool("safe_mode_enable", false),
|
||||
"secure_path": service.GetAdminSecurePath(),
|
||||
"email_whitelist_enable": service.MustGetBool("email_whitelist_enable", false),
|
||||
"email_whitelist_suffix": service.MustGetString("email_whitelist_suffix", ""),
|
||||
"email_gmail_limit_enable": service.MustGetBool("email_gmail_limit_enable", false),
|
||||
"captcha_enable": service.MustGetBool("captcha_enable", false),
|
||||
"register_limit_by_ip_enable": service.MustGetBool("register_limit_by_ip_enable", false),
|
||||
"register_limit_count": service.MustGetInt("register_limit_count", 3),
|
||||
"register_limit_expire": service.MustGetInt("register_limit_expire", 60),
|
||||
"password_limit_enable": service.MustGetBool("password_limit_enable", true),
|
||||
"password_limit_count": service.MustGetInt("password_limit_count", 5),
|
||||
"password_limit_expire": service.MustGetInt("password_limit_expire", 60),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -211,39 +300,11 @@ func AdminSystemStatus(c *gin.Context) {
|
||||
"server_time": time.Now().Unix(),
|
||||
"app_name": service.MustGetString("app_name", "XBoard"),
|
||||
"app_url": service.GetAppURL(),
|
||||
"version": "1.0.0",
|
||||
"go_version": "1.21+",
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
func parsePositiveInt(raw string, defaultValue int) int {
|
||||
value, err := strconv.Atoi(strings.TrimSpace(raw))
|
||||
if err != nil || value <= 0 {
|
||||
return defaultValue
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func calculateLastPage(total int64, perPage int) int {
|
||||
if perPage <= 0 {
|
||||
return 1
|
||||
}
|
||||
last := int((total + int64(perPage) - 1) / int64(perPage))
|
||||
if last == 0 {
|
||||
return 1
|
||||
}
|
||||
return last
|
||||
}
|
||||
|
||||
func formatUnixValue(value int64) string {
|
||||
if value <= 0 {
|
||||
return "-"
|
||||
}
|
||||
return time.Unix(value, 0).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func formatTimeValue(value *time.Time) string {
|
||||
if value == nil {
|
||||
return "-"
|
||||
}
|
||||
return value.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user