This commit is contained in:
Daniel Goc
2026-04-01 13:30:54 +02:00
parent 684f910090
commit b2acb8c922
14 changed files with 326 additions and 15 deletions

View File

@@ -32,12 +32,12 @@ func New() UISearchRepo {
}
func (r *SearchRepo) Search(index string, body []byte) (*SearchProxyResponse, error) {
url := fmt.Sprintf("%s/indexes/%s/search", r.cfg.MailiSearch.ServerURL, index)
url := fmt.Sprintf("%s/indexes/%s/search", r.cfg.MeiliSearch.ServerURL, index)
return r.doRequest(http.MethodPost, url, body)
}
func (r *SearchRepo) GetIndexSettings(index string) (*SearchProxyResponse, error) {
url := fmt.Sprintf("%s/indexes/%s/settings", r.cfg.MailiSearch.ServerURL, index)
url := fmt.Sprintf("%s/indexes/%s/settings", r.cfg.MeiliSearch.ServerURL, index)
return r.doRequest(http.MethodGet, url, nil)
}
@@ -55,8 +55,8 @@ func (r *SearchRepo) doRequest(method, url string, body []byte) (*SearchProxyRes
}
req.Header.Set("Content-Type", "application/json")
if r.cfg.MailiSearch.ApiKey != "" {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", r.cfg.MailiSearch.ApiKey))
if r.cfg.MeiliSearch.ApiKey != "" {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", r.cfg.MeiliSearch.ApiKey))
}
client := &http.Client{}

View File

@@ -0,0 +1,51 @@
package storageRepo
import (
"os"
"git.ma-al.com/goc_daniel/b2b/app/model"
)
type UIStorageRepo interface {
EntryInfo(absPath string) (os.FileInfo, error)
ListContent(absPath string) (*[]model.EntryInList, error)
OpenFile(absPath string) (*os.File, error)
CreateFolder(absPath string, name string) error
}
type StorageRepo struct{}
func New() UIStorageRepo {
return &StorageRepo{}
}
func (r *StorageRepo) EntryInfo(absPath string) (os.FileInfo, error) {
return os.Stat(absPath)
}
func (r *StorageRepo) ListContent(absPath string) (*[]model.EntryInList, error) {
entries, err := os.ReadDir(absPath)
if err != nil {
return nil, err
}
var entries_in_list []model.EntryInList
for _, entry := range entries {
var next_entry_in_list model.EntryInList
next_entry_in_list.Name = entry.Name()
next_entry_in_list.IsFolder = entry.IsDir()
entries_in_list = append(entries_in_list, next_entry_in_list)
}
return &entries_in_list, nil
}
func (r *StorageRepo) OpenFile(absPath string) (*os.File, error) {
return os.Open(absPath)
}
func (r *StorageRepo) CreateFolder(absPath string, name string) error {
os.(absPath)
}