feat: release v1.0.0
This commit is contained in:
@@ -5,7 +5,8 @@ import (
|
||||
"mime/multipart"
|
||||
"os"
|
||||
"path/filepath"
|
||||
db "server/internal/db/sqlc"
|
||||
"server/internal/db"
|
||||
"server/internal/db/sqlc"
|
||||
"server/internal/model/common"
|
||||
"server/internal/model/response"
|
||||
"server/internal/pkg/httputil"
|
||||
@@ -14,12 +15,12 @@ import (
|
||||
)
|
||||
|
||||
type SysFileService struct {
|
||||
queries *db.Queries
|
||||
store *db.Store
|
||||
}
|
||||
|
||||
func NewSysFileService(queries *db.Queries) *SysFileService {
|
||||
func NewSysFileService(store *db.Store) *SysFileService {
|
||||
return &SysFileService{
|
||||
queries: queries,
|
||||
store: store,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,19 +41,19 @@ func MakeSavedDir(folder string) (string, error) {
|
||||
return uploadDir, nil
|
||||
}
|
||||
|
||||
func (s *SysFileService) ListPage(ctx context.Context, p *common.Pagination) ([]db.File, int64, error) {
|
||||
params := db.GetFilesParams{
|
||||
func (s *SysFileService) ListPage(ctx context.Context, p *common.Pagination) ([]sqlc.File, int64, error) {
|
||||
params := sqlc.GetFilesParams{
|
||||
Limit: p.PageSize,
|
||||
Offset: (p.Page - 1) * p.PageSize,
|
||||
}
|
||||
|
||||
total, err := s.queries.CountFiles(ctx)
|
||||
total, err := s.store.CountFiles(ctx)
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
list, err := s.queries.GetFiles(ctx, params)
|
||||
list, err := s.store.GetFiles(ctx, params)
|
||||
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -61,7 +62,7 @@ func (s *SysFileService) ListPage(ctx context.Context, p *common.Pagination) ([]
|
||||
return response.ToFiles(list), total, nil
|
||||
}
|
||||
|
||||
func (s *SysFileService) Upload(ctx context.Context, folder string, file *multipart.FileHeader) (*db.CreateFileRow, error) {
|
||||
func (s *SysFileService) Upload(ctx context.Context, folder string, file *multipart.FileHeader) (*sqlc.CreateFileRow, error) {
|
||||
// 生成文件名
|
||||
fileID, err := gonanoid.New()
|
||||
if err != nil {
|
||||
@@ -98,7 +99,7 @@ func (s *SysFileService) Upload(ctx context.Context, folder string, file *multip
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params := db.CreateFileParams{
|
||||
params := sqlc.CreateFileParams{
|
||||
FileName: filename,
|
||||
FilePath: filePath,
|
||||
OriginalName: file.Filename,
|
||||
@@ -107,7 +108,7 @@ func (s *SysFileService) Upload(ctx context.Context, folder string, file *multip
|
||||
FileSize: file.Size,
|
||||
}
|
||||
|
||||
result, err := s.queries.CreateFile(ctx, params)
|
||||
result, err := s.store.CreateFile(ctx, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user