Skip to content

Commit

Permalink
feat: 重构目录结构与添加证书管理
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Nov 1, 2023
1 parent 47a9e67 commit c46656e
Show file tree
Hide file tree
Showing 53 changed files with 5,297 additions and 1,301 deletions.
488 changes: 488 additions & 0 deletions app/http/controllers/cert_controller.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,57 @@ import (
"panel/app/services"
)

func Success(ctx http.Context, data ...any) http.Response {
var d any
if len(data) > 0 {
d = data[0]
}
// SuccessResponse 通用成功响应
type SuccessResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data"`
}

// ErrorResponse 通用错误响应
type ErrorResponse struct {
Code int `json:"code"`
Message string `json:"message"`
}

return ctx.Response().Success().Json(http.Json{
"code": 0,
"message": "success",
"data": d,
// Success 响应成功
func Success(ctx http.Context, data any) http.Response {
return ctx.Response().Success().Json(&SuccessResponse{
Code: 0,
Message: "success",
Data: data,
})
}

func Error(ctx http.Context, code int, message any) http.Response {
return ctx.Response().Json(http.StatusOK, http.Json{
"code": code,
"message": message,
// Error 响应错误
func Error(ctx http.Context, code int, message string) http.Response {
return ctx.Response().Json(http.StatusOK, &ErrorResponse{
Code: code,
Message: message,
})
}

func SystemError(ctx http.Context) http.Response {
return ctx.Response().Json(http.StatusOK, http.Json{
"code": http.StatusInternalServerError,
"message": "系统内部错误",
// ErrorSystem 响应系统错误
func ErrorSystem(ctx http.Context) http.Response {
return ctx.Response().Json(http.StatusOK, &ErrorResponse{
Code: http.StatusInternalServerError,
Message: "系统内部错误",
})
}

// Sanitize 消毒请求参数
func Sanitize(ctx http.Context, request http.FormRequest) http.Response {
errors, err := ctx.Request().ValidateRequest(request)
if err != nil {
return Error(ctx, http.StatusUnprocessableEntity, err.Error())
}
if errors != nil {
return Error(ctx, http.StatusUnprocessableEntity, errors.One())
}

return nil
}

// Check 检查插件是否可用
func Check(ctx http.Context, slug string) http.Response {
plugin := services.NewPluginImpl().GetBySlug(slug)
Expand Down
274 changes: 0 additions & 274 deletions app/http/controllers/plugins/certbot/certbot_controller.go

This file was deleted.

29 changes: 29 additions & 0 deletions app/http/controllers/plugins/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package plugins

type PHPExtension struct {
Name string `json:"name"`
Slug string `json:"slug"`
Description string `json:"description"`
Installed bool `json:"installed"`
}

type LoadInfo struct {
Name string `json:"name"`
Value string `json:"value"`
}

type Fail2banJail struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
LogPath string `json:"log_path"`
MaxRetry int `json:"max_retry"`
FindTime int `json:"find_time"`
BanTime int `json:"ban_time"`
}

type S3fsMount struct {
ID int64 `json:"id"`
Path string `json:"path"`
Bucket string `json:"bucket"`
Url string `json:"url"`
}
Loading

0 comments on commit c46656e

Please sign in to comment.