mirror of
https://github.com/ctwj/urldb.git
synced 2025-11-25 03:15:04 +08:00
update: 添加logo的配置
This commit is contained in:
@@ -18,6 +18,7 @@ func FileToResponse(file *entity.File) dto.FileResponse {
|
||||
FileSize: file.FileSize,
|
||||
FileType: file.FileType,
|
||||
MimeType: file.MimeType,
|
||||
FileHash: file.FileHash,
|
||||
AccessURL: file.AccessURL,
|
||||
UserID: file.UserID,
|
||||
Status: file.Status,
|
||||
|
||||
@@ -30,6 +30,8 @@ func SystemConfigToResponse(configs []entity.SystemConfig) *dto.SystemConfigResp
|
||||
response.Author = config.Value
|
||||
case entity.ConfigKeyCopyright:
|
||||
response.Copyright = config.Value
|
||||
case entity.ConfigKeySiteLogo:
|
||||
response.SiteLogo = config.Value
|
||||
case entity.ConfigKeyAutoProcessReadyResources:
|
||||
if val, err := strconv.ParseBool(config.Value); err == nil {
|
||||
response.AutoProcessReadyResources = val
|
||||
@@ -103,6 +105,7 @@ func RequestToSystemConfig(req *dto.SystemConfigRequest) []entity.SystemConfig {
|
||||
configs = append(configs, entity.SystemConfig{Key: entity.ConfigKeyKeywords, Value: req.Keywords, Type: entity.ConfigTypeString})
|
||||
configs = append(configs, entity.SystemConfig{Key: entity.ConfigKeyAuthor, Value: req.Author, Type: entity.ConfigTypeString})
|
||||
configs = append(configs, entity.SystemConfig{Key: entity.ConfigKeyCopyright, Value: req.Copyright, Type: entity.ConfigTypeString})
|
||||
configs = append(configs, entity.SystemConfig{Key: entity.ConfigKeySiteLogo, Value: req.SiteLogo, Type: entity.ConfigTypeString})
|
||||
configs = append(configs, entity.SystemConfig{Key: entity.ConfigKeyApiToken, Value: req.ApiToken, Type: entity.ConfigTypeString})
|
||||
configs = append(configs, entity.SystemConfig{Key: entity.ConfigKeyForbiddenWords, Value: req.ForbiddenWords, Type: entity.ConfigTypeString})
|
||||
configs = append(configs, entity.SystemConfig{Key: entity.ConfigKeyAdKeywords, Value: req.AdKeywords, Type: entity.ConfigTypeString})
|
||||
@@ -140,6 +143,7 @@ func SystemConfigToPublicResponse(configs []entity.SystemConfig) map[string]inte
|
||||
entity.ConfigResponseFieldKeywords: entity.ConfigDefaultKeywords,
|
||||
entity.ConfigResponseFieldAuthor: entity.ConfigDefaultAuthor,
|
||||
entity.ConfigResponseFieldCopyright: entity.ConfigDefaultCopyright,
|
||||
"site_logo": "",
|
||||
entity.ConfigResponseFieldAutoProcessReadyResources: false,
|
||||
entity.ConfigResponseFieldAutoProcessInterval: 30,
|
||||
entity.ConfigResponseFieldAutoTransferEnabled: false,
|
||||
@@ -167,6 +171,8 @@ func SystemConfigToPublicResponse(configs []entity.SystemConfig) map[string]inte
|
||||
response[entity.ConfigResponseFieldAuthor] = config.Value
|
||||
case entity.ConfigKeyCopyright:
|
||||
response[entity.ConfigResponseFieldCopyright] = config.Value
|
||||
case entity.ConfigKeySiteLogo:
|
||||
response["site_logo"] = config.Value
|
||||
case entity.ConfigKeyAutoProcessReadyResources:
|
||||
if val, err := strconv.ParseBool(config.Value); err == nil {
|
||||
response[entity.ConfigResponseFieldAutoProcessReadyResources] = val
|
||||
@@ -231,6 +237,7 @@ func getDefaultConfigResponse() *dto.SystemConfigResponse {
|
||||
Keywords: entity.ConfigDefaultKeywords,
|
||||
Author: entity.ConfigDefaultAuthor,
|
||||
Copyright: entity.ConfigDefaultCopyright,
|
||||
SiteLogo: "",
|
||||
AutoProcessReadyResources: false,
|
||||
AutoProcessInterval: 30,
|
||||
AutoTransferEnabled: false,
|
||||
|
||||
@@ -2,7 +2,8 @@ package dto
|
||||
|
||||
// FileUploadRequest 文件上传请求
|
||||
type FileUploadRequest struct {
|
||||
IsPublic bool `json:"is_public" form:"is_public"` // 是否公开
|
||||
IsPublic bool `json:"is_public" form:"is_public"` // 是否公开
|
||||
FileHash string `json:"file_hash" form:"file_hash"` // 文件哈希值
|
||||
}
|
||||
|
||||
// FileResponse 文件响应
|
||||
@@ -18,6 +19,7 @@ type FileResponse struct {
|
||||
FileSize int64 `json:"file_size"`
|
||||
FileType string `json:"file_type"`
|
||||
MimeType string `json:"mime_type"`
|
||||
FileHash string `json:"file_hash"`
|
||||
|
||||
// 访问信息
|
||||
AccessURL string `json:"access_url"`
|
||||
@@ -52,9 +54,10 @@ type FileListResponse struct {
|
||||
|
||||
// FileUploadResponse 文件上传响应
|
||||
type FileUploadResponse struct {
|
||||
File FileResponse `json:"file"`
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
File FileResponse `json:"file"`
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
IsDuplicate bool `json:"is_duplicate"` // 是否为重复文件
|
||||
}
|
||||
|
||||
// FileDeleteRequest 文件删除请求
|
||||
|
||||
@@ -8,6 +8,7 @@ type SystemConfigRequest struct {
|
||||
Keywords string `json:"keywords"`
|
||||
Author string `json:"author"`
|
||||
Copyright string `json:"copyright"`
|
||||
SiteLogo string `json:"site_logo"`
|
||||
|
||||
// 自动处理配置组
|
||||
AutoProcessReadyResources bool `json:"auto_process_ready_resources"` // 自动处理待处理资源
|
||||
@@ -48,6 +49,7 @@ type SystemConfigResponse struct {
|
||||
Keywords string `json:"keywords"`
|
||||
Author string `json:"author"`
|
||||
Copyright string `json:"copyright"`
|
||||
SiteLogo string `json:"site_logo"`
|
||||
|
||||
// 自动处理配置组
|
||||
AutoProcessReadyResources bool `json:"auto_process_ready_resources"` // 自动处理待处理资源
|
||||
|
||||
@@ -17,6 +17,7 @@ type File struct {
|
||||
FileSize int64 `json:"file_size" gorm:"not null;comment:文件大小(字节)"`
|
||||
FileType string `json:"file_type" gorm:"size:100;not null;comment:文件类型"`
|
||||
MimeType string `json:"mime_type" gorm:"size:100;comment:MIME类型"`
|
||||
FileHash string `json:"file_hash" gorm:"size:64;uniqueIndex;comment:文件哈希值"`
|
||||
|
||||
// 访问信息
|
||||
AccessURL string `json:"access_url" gorm:"size:500;comment:访问URL"`
|
||||
|
||||
@@ -8,6 +8,7 @@ const (
|
||||
ConfigKeyKeywords = "keywords"
|
||||
ConfigKeyAuthor = "author"
|
||||
ConfigKeyCopyright = "copyright"
|
||||
ConfigKeySiteLogo = "site_logo"
|
||||
|
||||
// 自动处理配置组
|
||||
ConfigKeyAutoProcessReadyResources = "auto_process_ready_resources"
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
type FileRepository interface {
|
||||
BaseRepository[entity.File]
|
||||
FindByFileName(fileName string) (*entity.File, error)
|
||||
FindByHash(fileHash string) (*entity.File, error)
|
||||
FindByUserID(userID uint, page, pageSize int) ([]entity.File, int64, error)
|
||||
FindPublicFiles(page, pageSize int) ([]entity.File, int64, error)
|
||||
SearchFiles(search string, fileType, status string, userID uint, page, pageSize int) ([]entity.File, int64, error)
|
||||
@@ -142,3 +143,13 @@ func (r *FileRepositoryImpl) UpdateFileStatus(id uint, status string) error {
|
||||
func (r *FileRepositoryImpl) UpdateFilePublic(id uint, isPublic bool) error {
|
||||
return r.db.Model(&entity.File{}).Where("id = ?", id).Update("is_public", isPublic).Error
|
||||
}
|
||||
|
||||
// FindByHash 根据文件哈希查找文件
|
||||
func (r *FileRepositoryImpl) FindByHash(fileHash string) (*entity.File, error) {
|
||||
var file entity.File
|
||||
err := r.db.Where("file_hash = ? AND is_deleted = ?", fileHash, false).First(&file).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &file, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user