-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from actiontech/issue-256-1
记录下发sql的审计日志
- Loading branch information
Showing
15 changed files
with
495 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package biz | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/actiontech/dms/internal/dms/pkg/constant" | ||
utilLog "github.com/actiontech/dms/pkg/dms-common/pkg/log" | ||
) | ||
|
||
type CbOperationLogType string | ||
|
||
const ( | ||
CbOperationLogTypeSql CbOperationLogType = "SQL" | ||
) | ||
|
||
// CbOperationLogRepo 定义操作日志的存储接口 | ||
type CbOperationLogRepo interface { | ||
GetCbOperationLogByID(ctx context.Context, uid string) (*CbOperationLog, error) | ||
SaveCbOperationLog(ctx context.Context, log *CbOperationLog) error | ||
UpdateCbOperationLog(ctx context.Context, log *CbOperationLog) error | ||
ListCbOperationLogs(ctx context.Context, opt *ListCbOperationLogOption) ([]*CbOperationLog, int64, error) | ||
} | ||
|
||
// CbOperationLog 代表操作日志记录 | ||
type CbOperationLog struct { | ||
UID string | ||
OpPersonUID string | ||
OpTime *time.Time | ||
DBServiceUID string | ||
OpType CbOperationLogType | ||
OpDetail string | ||
OpSessionID *string | ||
OpHost string | ||
ProjectID string | ||
AuditResults []*AuditResult | ||
IsAuditPass *bool | ||
ExecResult string | ||
ExecTotalSec int64 | ||
ResultSetRowCount int64 | ||
|
||
User *User | ||
DbService *DBService | ||
} | ||
|
||
func (c CbOperationLog) GetOpTime() time.Time { | ||
if c.OpTime != nil { | ||
return *c.OpTime | ||
} | ||
return time.Time{} | ||
} | ||
|
||
func (c CbOperationLog) GetSessionID() string { | ||
if c.OpSessionID != nil { | ||
return *c.OpSessionID | ||
} | ||
return "" | ||
} | ||
|
||
// ListCbOperationLogOption 用于查询操作日志的选项 | ||
type ListCbOperationLogOption struct { | ||
PageNumber uint32 | ||
LimitPerPage uint32 | ||
OrderBy string | ||
FilterBy []constant.FilterCondition | ||
} | ||
|
||
// CbOperationLogUsecase 定义操作日志的业务逻辑 | ||
type CbOperationLogUsecase struct { | ||
opPermissionVerifyUsecase *OpPermissionVerifyUsecase | ||
repo CbOperationLogRepo | ||
log *utilLog.Helper | ||
} | ||
|
||
// NewCbOperationLogUsecase 创建一个新的操作日志业务逻辑实例 | ||
func NewCbOperationLogUsecase(logger utilLog.Logger, repo CbOperationLogRepo, opPermissionVerifyUsecase *OpPermissionVerifyUsecase) *CbOperationLogUsecase { | ||
return &CbOperationLogUsecase{ | ||
repo: repo, | ||
log: utilLog.NewHelper(logger, utilLog.WithMessageKey("biz.cbOperationLog")), | ||
opPermissionVerifyUsecase: opPermissionVerifyUsecase, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//go:build !enterprise | ||
|
||
package biz | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
) | ||
|
||
var errNotSupportCbOperationLog = errors.New("cb operation log related functions are enterprise version functions") | ||
|
||
func (cu *CbOperationLogUsecase) GetCbOperationLogByID(ctx context.Context, uid string) (*CbOperationLog, error) { | ||
return nil, errNotSupportCbOperationLog | ||
} | ||
|
||
func (u *CbOperationLogUsecase) SaveCbOperationLog(ctx context.Context, log *CbOperationLog) error { | ||
return errNotSupportCbOperationLog | ||
} | ||
|
||
func (u *CbOperationLogUsecase) UpdateCbOperationLog(ctx context.Context, log *CbOperationLog) error { | ||
return errNotSupportCbOperationLog | ||
} | ||
|
||
func (u *CbOperationLogUsecase) ListCbOperationLog(ctx context.Context, option *ListCbOperationLogOption, currentUid string, filterPersonID string, projectUid string) ([]*CbOperationLog, int64, error) { | ||
return nil, 0, errNotSupportCbOperationLog | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.