mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-08 16:00:25 +08:00
37 lines
798 B
Go
37 lines
798 B
Go
|
|
package dao
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||
|
|
)
|
||
|
|
|
||
|
|
var SharedLogDAO = NewLogDAO()
|
||
|
|
|
||
|
|
type LogDAO struct {
|
||
|
|
BaseDAO
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewLogDAO() *LogDAO {
|
||
|
|
return &LogDAO{}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *LogDAO) CreateUserLog(ctx context.Context, level string, action string, description string, ip string) error {
|
||
|
|
_, err := this.RPC().LogRPC().CreateLog(ctx, &pb.CreateLogRequest{
|
||
|
|
Level: level,
|
||
|
|
Description: description,
|
||
|
|
Action: action,
|
||
|
|
Ip: ip,
|
||
|
|
})
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
func (this *LogDAO) CreateAdminLog(ctx context.Context, level string, action string, description string, ip string) error {
|
||
|
|
_, err := this.RPC().LogRPC().CreateLog(ctx, &pb.CreateLogRequest{
|
||
|
|
Level: level,
|
||
|
|
Description: description,
|
||
|
|
Action: action,
|
||
|
|
Ip: ip,
|
||
|
|
})
|
||
|
|
return err
|
||
|
|
}
|