mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 18:10:25 +08:00
实现统计设置
This commit is contained in:
@@ -146,6 +146,16 @@ func (this *HTTPWebDAO) ComposeWebConfig(webId int64) (*serverconfigs.HTTPWebCon
|
|||||||
config.AccessLog = accessLogConfig
|
config.AccessLog = accessLogConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统计配置
|
||||||
|
if IsNotNull(web.Stat) {
|
||||||
|
statConfig := &serverconfigs.HTTPStatConfig{}
|
||||||
|
err = json.Unmarshal([]byte(web.Stat), statConfig)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
config.Stat = statConfig
|
||||||
|
}
|
||||||
|
|
||||||
// TODO 更多配置
|
// TODO 更多配置
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
@@ -291,6 +301,22 @@ func (this *HTTPWebDAO) UpdateWebAccessLogConfig(webId int64, accessLogJSON []by
|
|||||||
return this.NotifyUpdating(webId)
|
return this.NotifyUpdating(webId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更改统计配置
|
||||||
|
func (this *HTTPWebDAO) UpdateWebStat(webId int64, statJSON []byte) error {
|
||||||
|
if webId <= 0 {
|
||||||
|
return errors.New("invalid webId")
|
||||||
|
}
|
||||||
|
op := NewHTTPWebOperator()
|
||||||
|
op.Id = webId
|
||||||
|
op.Stat = JSONBytes(statJSON)
|
||||||
|
_, err := this.Save(op)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.NotifyUpdating(webId)
|
||||||
|
}
|
||||||
|
|
||||||
// 通知更新
|
// 通知更新
|
||||||
func (this *HTTPWebDAO) NotifyUpdating(webId int64) error {
|
func (this *HTTPWebDAO) NotifyUpdating(webId int64) error {
|
||||||
err := SharedServerDAO.UpdateServerIsUpdatingWithWebId(webId)
|
err := SharedServerDAO.UpdateServerIsUpdatingWithWebId(webId)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ type HTTPWeb struct {
|
|||||||
RequestHeaderPolicyId uint32 `field:"requestHeaderPolicyId"` // Request Header策略ID
|
RequestHeaderPolicyId uint32 `field:"requestHeaderPolicyId"` // Request Header策略ID
|
||||||
ResponseHeaderPolicyId uint32 `field:"responseHeaderPolicyId"` // Response Header策略
|
ResponseHeaderPolicyId uint32 `field:"responseHeaderPolicyId"` // Response Header策略
|
||||||
AccessLog string `field:"accessLog"` // 访问日志配置
|
AccessLog string `field:"accessLog"` // 访问日志配置
|
||||||
|
Stat string `field:"stat"` // 统计配置
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPWebOperator struct {
|
type HTTPWebOperator struct {
|
||||||
@@ -47,6 +48,7 @@ type HTTPWebOperator struct {
|
|||||||
RequestHeaderPolicyId interface{} // Request Header策略ID
|
RequestHeaderPolicyId interface{} // Request Header策略ID
|
||||||
ResponseHeaderPolicyId interface{} // Response Header策略
|
ResponseHeaderPolicyId interface{} // Response Header策略
|
||||||
AccessLog interface{} // 访问日志配置
|
AccessLog interface{} // 访问日志配置
|
||||||
|
Stat interface{} // 统计配置
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHTTPWebOperator() *HTTPWebOperator {
|
func NewHTTPWebOperator() *HTTPWebOperator {
|
||||||
|
|||||||
@@ -177,3 +177,18 @@ func (this *HTTPWebService) UpdateHTTPAccessLog(ctx context.Context, req *pb.Upd
|
|||||||
}
|
}
|
||||||
return rpcutils.RPCUpdateSuccess()
|
return rpcutils.RPCUpdateSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更改统计配置
|
||||||
|
func (this *HTTPWebService) UpdateHTTPStat(ctx context.Context, req *pb.UpdateHTTPStatRequest) (*pb.RPCUpdateSuccess, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = models.SharedHTTPWebDAO.UpdateWebStat(req.WebId, req.StatJSON)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return rpcutils.RPCUpdateSuccess()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user