🎨 增加 Go 后端

This commit is contained in:
江西小徐
2024-04-07 11:08:05 +08:00
parent 04c82ab25d
commit 61275be2bf
165 changed files with 7043 additions and 3599 deletions
+25
View File
@@ -0,0 +1,25 @@
package v1
// WhoisApiInterface is the interface for WhoisApi
type WhoisApiInterface struct {
Label string `json:"label"`
Name string `json:"name"`
Order int `json:"order"`
Show bool `json:"show"`
Disabled bool `json:"disabled"`
}
// DNSApiInterface is the interface for DNSApi
type DNSApiInterface struct {
Label string `json:"label"`
Name string `json:"name"`
Order int `json:"order"`
Show bool `json:"show"`
Disabled bool `json:"disabled"`
IName string `json:"iName"`
Flag string `json:"flag"`
}
type FileConfig struct {
Config string `json:"config" binding:"required"`
}
+62
View File
@@ -0,0 +1,62 @@
package v1
import (
"github.com/gin-gonic/gin"
"net/http"
)
type Response struct {
Code int `json:"code"`
Data interface{} `json:"data"`
Msg string `json:"msg"`
}
const (
ERROR = 500
SUCCESS = 200
)
func Result(code int, data interface{}, msg string, c *gin.Context) {
// 开始时间
c.JSON(http.StatusOK, Response{
code,
data,
msg,
})
}
func Ok(c *gin.Context) {
Result(SUCCESS, map[string]interface{}{}, "操作成功", c)
}
func OkWithMessage(message string, c *gin.Context) {
Result(SUCCESS, map[string]interface{}{}, message, c)
}
func OkWithData(data interface{}, c *gin.Context) {
Result(SUCCESS, data, "查询成功", c)
}
func OkWithDetailed(data interface{}, message string, c *gin.Context) {
Result(SUCCESS, data, message, c)
}
func Fail(c *gin.Context) {
Result(ERROR, map[string]interface{}{}, "操作失败", c)
}
func FailWithMessage(message string, c *gin.Context) {
Result(ERROR, map[string]interface{}{}, message, c)
}
func NoAuth(message string, c *gin.Context) {
c.JSON(http.StatusUnauthorized, Response{
7,
nil,
message,
})
}
func FailWithDetailed(data interface{}, message string, c *gin.Context) {
Result(ERROR, data, message, c)
}
+82
View File
@@ -0,0 +1,82 @@
package v1
import "time"
// TianHuWhoisResponse represents the top-level structure of the WHOIS response.
type TianHuWhoisResponse struct {
Code string `json:"code"`
Message string `json:"message"`
Data TianHuWhoisData `json:"data"`
}
// TianHuWhoisData represents the detailed data part of the WHOIS response.
type TianHuWhoisData struct {
URL string `json:"url"`
Result string `json:"result"`
Status int `json:"status"`
Formatted TianHuFormattedWhois `json:"formatted"`
TLD string `json:"tld"`
Timezone TianHuWhoisTimezone `json:"timezone"`
}
// TianHuFormattedWhois represents the formatted WHOIS data.
type TianHuFormattedWhois struct {
Key string `json:"key"`
Domain TianHuDomainInfo `json:"domain"`
Registrar TianHuRegistrarInfo `json:"registrar"`
Registrant TianHuRegistrantInfo `json:"registrant"`
Administrative TianHuAdministrativeInfo `json:"administrative"`
Technical TianHuTechnicalInfo `json:"technical"`
Billing TianHuBillingInfo `json:"billing"`
}
// TianHuDomainInfo contains information about the domain.
type TianHuDomainInfo struct {
NameServers []string `json:"name_servers"`
Status []string `json:"status"`
Domain string `json:"domain"`
ID string `json:"id"`
WhoisServer string `json:"whois_server"`
UpdatedDate time.Time `json:"updated_date"`
CreatedDate time.Time `json:"created_date"`
ExpiredDate time.Time `json:"expired_date"`
DNSSEC bool `json:"dnssec"`
}
// TianHuRegistrarInfo contains information about the registrar.
type TianHuRegistrarInfo struct {
Key string `json:"key"`
ReferralURL string `json:"referral_url"`
RegistrarName string `json:"registrar_name"`
RegistrarIANAID string `json:"registrar_ianaid"`
RegistrarEmail string `json:"registrar_email"`
RegistrarPhone string `json:"registrar_phone"`
}
// TianHuRegistrantInfo, TianHuAdministrativeInfo, TianHuTechnicalInfo, and TianHuBillingInfo
// can be defined similarly, depending on the details you wish to include.
type TianHuRegistrantInfo struct {
Key string `json:"key"`
// Additional fields can be added here.
}
type TianHuAdministrativeInfo struct {
Key string `json:"key"`
// Additional fields can be added here.
}
type TianHuTechnicalInfo struct {
Key string `json:"key"`
// Additional fields can be added here.
}
type TianHuBillingInfo struct {
Key string `json:"key"`
// Additional fields can be added here.
}
// TianHuWhoisTimezone represents the timezone information of the WHOIS data.
type TianHuWhoisTimezone struct {
UTCOffset int `json:"utcoffset"`
Demo time.Time `json:"demo"`
}
+14
View File
@@ -0,0 +1,14 @@
package v1
type WhoisServer struct {
Name string `json:"name" binding:"required"`
Domain string `json:"domain" binding:"required"`
}
// WhocxRequestParams 请求参数结构体
type WhocxRequestParams struct {
Domain string `json:"domain"` // 域名 (必选)
Whois string `json:"whois"` // 域名的whois原始信息 (必选)
Lang string `json:"lang,omitempty"` // 语言代码 (可选)
TimeZone string `json:"time_zone,omitempty"` // 时区 (可选)
}