mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
[SSL证书]ACME任务中列出最后执行结果
This commit is contained in:
@@ -196,7 +196,7 @@ func (this *ACMETaskDAO) RunTask(taskId int64) (isOk bool, errMsg string, result
|
||||
isOk, errMsg, resultCertId = this.runTaskWithoutLog(taskId)
|
||||
|
||||
// 记录日志
|
||||
err := SharedACMETaskLogDAO.CreateACMELog(taskId, isOk, errMsg)
|
||||
err := SharedACMETaskLogDAO.CreateACMETaskLog(taskId, isOk, errMsg)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func init() {
|
||||
}
|
||||
|
||||
// 生成日志
|
||||
func (this *ACMETaskLogDAO) CreateACMELog(taskId int64, isOk bool, errMsg string) error {
|
||||
func (this *ACMETaskLogDAO) CreateACMETaskLog(taskId int64, isOk bool, errMsg string) error {
|
||||
op := NewACMETaskLogOperator()
|
||||
op.TaskId = taskId
|
||||
op.Error = errMsg
|
||||
@@ -36,3 +36,15 @@ func (this *ACMETaskLogDAO) CreateACMELog(taskId int64, isOk bool, errMsg string
|
||||
_, err := this.Save(op)
|
||||
return err
|
||||
}
|
||||
|
||||
// 取得任务的最后一条执行日志
|
||||
func (this *ACMETaskLogDAO) FindLatestACMETasKLog(taskId int64) (*ACMETaskLog, error) {
|
||||
one, err := this.Query().
|
||||
Attr("taskId", taskId).
|
||||
DescPk().
|
||||
Find()
|
||||
if err != nil || one == nil {
|
||||
return nil, err
|
||||
}
|
||||
return one.(*ACMETaskLog), nil
|
||||
}
|
||||
|
||||
@@ -121,16 +121,32 @@ func (this *ACMETaskService) ListEnabledACMETasks(ctx context.Context, req *pb.L
|
||||
}
|
||||
}
|
||||
|
||||
// 最近一条日志
|
||||
var pbTaskLog *pb.ACMETaskLog = nil
|
||||
taskLog, err := models.SharedACMETaskLogDAO.FindLatestACMETasKLog(int64(task.Id))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if taskLog != nil {
|
||||
pbTaskLog = &pb.ACMETaskLog{
|
||||
Id: int64(taskLog.Id),
|
||||
IsOk: taskLog.IsOk == 1,
|
||||
Error: taskLog.Error,
|
||||
CreatedAt: int64(taskLog.CreatedAt),
|
||||
}
|
||||
}
|
||||
|
||||
result = append(result, &pb.ACMETask{
|
||||
Id: int64(task.Id),
|
||||
IsOn: task.IsOn == 1,
|
||||
DnsDomain: task.DnsDomain,
|
||||
Domains: task.DecodeDomains(),
|
||||
CreatedAt: int64(task.CreatedAt),
|
||||
AutoRenew: task.AutoRenew == 1,
|
||||
AcmeUser: pbACMEUser,
|
||||
DnsProvider: pbProvider,
|
||||
SslCert: pbCert,
|
||||
Id: int64(task.Id),
|
||||
IsOn: task.IsOn == 1,
|
||||
DnsDomain: task.DnsDomain,
|
||||
Domains: task.DecodeDomains(),
|
||||
CreatedAt: int64(task.CreatedAt),
|
||||
AutoRenew: task.AutoRenew == 1,
|
||||
AcmeUser: pbACMEUser,
|
||||
DnsProvider: pbProvider,
|
||||
SslCert: pbCert,
|
||||
LatestACMETaskLog: pbTaskLog,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user