mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 09:13:49 +08:00
feat: 同步前端修改
This commit is contained in:
@@ -445,7 +445,7 @@ func (r *CertController) CertList(ctx http.Context) http.Response {
|
||||
|
||||
var certs []models.Cert
|
||||
var total int64
|
||||
err := facades.Orm().Query().Paginate(paginateRequest.Page, paginateRequest.Limit, &certs, &total)
|
||||
err := facades.Orm().Query().With("Website").With("User").With("DNS").Paginate(paginateRequest.Page, paginateRequest.Limit, &certs, &total)
|
||||
if err != nil {
|
||||
facades.Log().Request(ctx.Request()).Tags("面板", "证书管理").With(map[string]any{
|
||||
"error": err.Error(),
|
||||
@@ -619,7 +619,7 @@ func (r *CertController) Obtain(ctx http.Context) http.Response {
|
||||
facades.Log().Request(ctx.Request()).Tags("面板", "证书管理").With(map[string]any{
|
||||
"error": err.Error(),
|
||||
}).Error("签发证书失败")
|
||||
return ErrorSystem(ctx)
|
||||
return Error(ctx, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return Success(ctx, nil)
|
||||
@@ -649,7 +649,7 @@ func (r *CertController) Renew(ctx http.Context) http.Response {
|
||||
facades.Log().Request(ctx.Request()).Tags("面板", "证书管理").With(map[string]any{
|
||||
"error": err.Error(),
|
||||
}).Error("续签证书失败")
|
||||
return ErrorSystem(ctx)
|
||||
return Error(ctx, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return Success(ctx, nil)
|
||||
@@ -679,7 +679,7 @@ func (r *CertController) ManualDNS(ctx http.Context) http.Response {
|
||||
facades.Log().Request(ctx.Request()).Tags("面板", "证书管理").With(map[string]any{
|
||||
"error": err.Error(),
|
||||
}).Error("获取手动DNS记录失败")
|
||||
return ErrorSystem(ctx)
|
||||
return Error(ctx, http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return Success(ctx, resolves)
|
||||
|
||||
@@ -3,13 +3,14 @@ package requests
|
||||
import (
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/goravel/framework/contracts/validation"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type CertStore struct {
|
||||
Type string `form:"type" json:"type"`
|
||||
Domains []string `form:"domains" json:"domains"`
|
||||
AutoRenew bool `form:"auto_renew" json:"auto_renew"`
|
||||
UserID uint `form:"user_id" json:"user_id"`
|
||||
UserID uint `form:"user_id" json:"user_id" filter:"uint"`
|
||||
DNSID *uint `form:"dns_id" json:"dns_id"`
|
||||
WebsiteID *uint `form:"website_id" json:"website_id"`
|
||||
}
|
||||
@@ -23,7 +24,9 @@ func (r *CertStore) Rules(ctx http.Context) map[string]string {
|
||||
"type": "required|in:P256,P384,2048,4096",
|
||||
"domains": "required|array",
|
||||
"auto_renew": "required|bool",
|
||||
"user_id": "required|exists:cert_users,id",
|
||||
"user_id": "required|uint|exists:cert_users,id",
|
||||
"dns_id": "uint",
|
||||
"website_id": "uint",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,5 +39,22 @@ func (r *CertStore) Attributes(ctx http.Context) map[string]string {
|
||||
}
|
||||
|
||||
func (r *CertStore) PrepareForValidation(ctx http.Context, data validation.Data) error {
|
||||
// TODO 由于验证器 filter 标签的问题,暂时这里这样处理
|
||||
dnsID, exist := data.Get("dns_id")
|
||||
if exist {
|
||||
err := data.Set("dns_id", cast.ToUint(dnsID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
websiteID, exist := data.Get("website_id")
|
||||
if exist {
|
||||
err := data.Set("website_id", cast.ToUint(websiteID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package requests
|
||||
import (
|
||||
"github.com/goravel/framework/contracts/http"
|
||||
"github.com/goravel/framework/contracts/validation"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type CertUpdate struct {
|
||||
@@ -10,7 +11,7 @@ type CertUpdate struct {
|
||||
Type string `form:"type" json:"type"`
|
||||
Domains []string `form:"domains" json:"domains"`
|
||||
AutoRenew bool `form:"auto_renew" json:"auto_renew"`
|
||||
UserID uint `form:"user_id" json:"user_id"`
|
||||
UserID uint `form:"user_id" json:"user_id" filter:"uint"`
|
||||
DNSID *uint `form:"dns_id" json:"dns_id"`
|
||||
WebsiteID *uint `form:"website_id" json:"website_id"`
|
||||
}
|
||||
@@ -25,7 +26,9 @@ func (r *CertUpdate) Rules(ctx http.Context) map[string]string {
|
||||
"type": "required|in:P256,P384,2048,4096",
|
||||
"domains": "required|array",
|
||||
"auto_renew": "required|bool",
|
||||
"user_id": "required|exists:cert_users,id",
|
||||
"user_id": "required|uint|exists:cert_users,id",
|
||||
"dns_id": "uint",
|
||||
"website_id": "uint",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,5 +41,22 @@ func (r *CertUpdate) Attributes(ctx http.Context) map[string]string {
|
||||
}
|
||||
|
||||
func (r *CertUpdate) PrepareForValidation(ctx http.Context, data validation.Data) error {
|
||||
// TODO 由于验证器 filter 标签的问题,暂时这里这样处理
|
||||
dnsID, exist := data.Get("dns_id")
|
||||
if exist {
|
||||
err := data.Set("dns_id", cast.ToUint(dnsID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
websiteID, exist := data.Get("website_id")
|
||||
if exist {
|
||||
err := data.Set("website_id", cast.ToUint(websiteID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
type Update struct {
|
||||
Name string `form:"name" json:"name"`
|
||||
Port uint `form:"port" json:"port" filter:"int"`
|
||||
Port uint `form:"port" json:"port" filter:"uint"`
|
||||
BackupPath string `form:"backup_path" json:"backup_path"`
|
||||
WebsitePath string `form:"website_path" json:"website_path"`
|
||||
Entrance string `form:"entrance" json:"entrance"`
|
||||
|
||||
@@ -18,7 +18,7 @@ type Cert struct {
|
||||
CreatedAt carbon.DateTime `gorm:"autoCreateTime;column:created_at" json:"created_at"`
|
||||
UpdatedAt carbon.DateTime `gorm:"autoUpdateTime;column:updated_at" json:"updated_at"`
|
||||
|
||||
Website *Website `gorm:"foreignKey:WebsiteID" json:"-"`
|
||||
User *CertUser `gorm:"foreignKey:UserID" json:"-"`
|
||||
DNS *CertDNS `gorm:"foreignKey:DNSID" json:"-"`
|
||||
Website *Website `gorm:"foreignKey:WebsiteID" json:"website"`
|
||||
User *CertUser `gorm:"foreignKey:UserID" json:"user"`
|
||||
DNS *CertDNS `gorm:"foreignKey:DNSID" json:"dns"`
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ func (s *CertImpl) ManualDNS(ID uint) (map[string]acme.Resolve, error) {
|
||||
// Renew 续签证书
|
||||
func (s *CertImpl) Renew(ID uint) (certificate.Resource, error) {
|
||||
var cert models.Cert
|
||||
err := facades.Orm().Query().With("User").With("DNS").Where("id = ?", ID).First(&cert)
|
||||
err := facades.Orm().Query().With("Website").With("User").With("DNS").Where("id = ?", ID).First(&cert)
|
||||
if err != nil {
|
||||
return certificate.Resource{}, err
|
||||
}
|
||||
|
||||
44
docs/docs.go
44
docs/docs.go
@@ -1348,6 +1348,9 @@ const docTemplate = `{
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"dns": {
|
||||
"$ref": "#/definitions/models.CertDNS"
|
||||
},
|
||||
"dns_id": {
|
||||
"description": "关联的 DNS ID",
|
||||
"type": "integer"
|
||||
@@ -1372,10 +1375,16 @@ const docTemplate = `{
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"user": {
|
||||
"$ref": "#/definitions/models.CertUser"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "关联的 ACME 用户 ID",
|
||||
"type": "integer"
|
||||
},
|
||||
"website": {
|
||||
"$ref": "#/definitions/models.Website"
|
||||
},
|
||||
"website_id": {
|
||||
"description": "关联的网站 ID",
|
||||
"type": "integer"
|
||||
@@ -1440,6 +1449,41 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.Website": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cert": {
|
||||
"$ref": "#/definitions/models.Cert"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"php": {
|
||||
"type": "integer"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"ssl": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"status": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requests.CertStore": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1341,6 +1341,9 @@
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"dns": {
|
||||
"$ref": "#/definitions/models.CertDNS"
|
||||
},
|
||||
"dns_id": {
|
||||
"description": "关联的 DNS ID",
|
||||
"type": "integer"
|
||||
@@ -1365,10 +1368,16 @@
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"user": {
|
||||
"$ref": "#/definitions/models.CertUser"
|
||||
},
|
||||
"user_id": {
|
||||
"description": "关联的 ACME 用户 ID",
|
||||
"type": "integer"
|
||||
},
|
||||
"website": {
|
||||
"$ref": "#/definitions/models.Website"
|
||||
},
|
||||
"website_id": {
|
||||
"description": "关联的网站 ID",
|
||||
"type": "integer"
|
||||
@@ -1433,6 +1442,41 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.Website": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cert": {
|
||||
"$ref": "#/definitions/models.Cert"
|
||||
},
|
||||
"created_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"php": {
|
||||
"type": "integer"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"ssl": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"status": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"updated_at": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requests.CertStore": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -52,6 +52,8 @@ definitions:
|
||||
type: string
|
||||
created_at:
|
||||
type: string
|
||||
dns:
|
||||
$ref: '#/definitions/models.CertDNS'
|
||||
dns_id:
|
||||
description: 关联的 DNS ID
|
||||
type: integer
|
||||
@@ -69,9 +71,13 @@ definitions:
|
||||
type: string
|
||||
updated_at:
|
||||
type: string
|
||||
user:
|
||||
$ref: '#/definitions/models.CertUser'
|
||||
user_id:
|
||||
description: 关联的 ACME 用户 ID
|
||||
type: integer
|
||||
website:
|
||||
$ref: '#/definitions/models.Website'
|
||||
website_id:
|
||||
description: 关联的网站 ID
|
||||
type: integer
|
||||
@@ -115,6 +121,29 @@ definitions:
|
||||
updated_at:
|
||||
type: string
|
||||
type: object
|
||||
models.Website:
|
||||
properties:
|
||||
cert:
|
||||
$ref: '#/definitions/models.Cert'
|
||||
created_at:
|
||||
type: string
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
path:
|
||||
type: string
|
||||
php:
|
||||
type: integer
|
||||
remark:
|
||||
type: string
|
||||
ssl:
|
||||
type: boolean
|
||||
status:
|
||||
type: boolean
|
||||
updated_at:
|
||||
type: string
|
||||
type: object
|
||||
requests.CertStore:
|
||||
properties:
|
||||
auto_renew:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package acme
|
||||
|
||||
type Resolve struct {
|
||||
Key string
|
||||
Value string
|
||||
Err string
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
Err string `json:"err"`
|
||||
}
|
||||
|
||||
type manualDnsProvider struct {
|
||||
|
||||
Reference in New Issue
Block a user