mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-10-16 13:00:52 +08:00
optimal storge choice
This commit is contained in:
42
internal/app/search/sqlite/sqlite.go
Normal file
42
internal/app/search/sqlite/sqlite.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package sqlite
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/lzh-1625/go_process_manager/internal/app/model"
|
||||
"github.com/lzh-1625/go_process_manager/internal/app/repository"
|
||||
"github.com/lzh-1625/go_process_manager/internal/app/search"
|
||||
)
|
||||
|
||||
func init() {
|
||||
search.Register("sqlite", new(sqliteSearch))
|
||||
}
|
||||
|
||||
type sqliteSearch struct{}
|
||||
|
||||
func (l *sqliteSearch) Search(req model.GetLogReq, filterProcessName ...string) model.LogResp {
|
||||
req.FilterName = filterProcessName
|
||||
data, total := repository.LogRepository.SearchLog(req)
|
||||
if req.Match.Log != "" {
|
||||
for i := range data {
|
||||
data[i].Log = strings.ReplaceAll(data[i].Log, req.Match.Log, "\033[43m"+req.Match.Log+"\033[0m")
|
||||
}
|
||||
}
|
||||
return model.LogResp{
|
||||
Data: data,
|
||||
Total: total,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *sqliteSearch) Insert(log string, processName string, using string, ts int64) {
|
||||
repository.LogRepository.InsertLog(model.ProcessLog{
|
||||
Log: log,
|
||||
Name: processName,
|
||||
Using: using,
|
||||
Time: ts,
|
||||
})
|
||||
}
|
||||
|
||||
func (l *sqliteSearch) Init() error {
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user