fix
This commit is contained in:
@@ -41,9 +41,6 @@ func (uc *SettingsUsecase) PrepareAPIToken(ctx context.Context, userID, authorit
|
||||
if days == -1 {
|
||||
duration = 100 * 365 * 24 * time.Hour
|
||||
}
|
||||
if duration <= 0 {
|
||||
return nil, 0, errors.New("有效天数必须大于0或为-1")
|
||||
}
|
||||
return user, duration, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,15 @@ import "context"
|
||||
|
||||
type DataScope struct {
|
||||
All bool
|
||||
Scope int
|
||||
UserID uint
|
||||
AuthorityID uint
|
||||
PrimaryDeptID uint
|
||||
OwnerUserID uint
|
||||
DepartmentIDs []uint
|
||||
RequestID string
|
||||
Method string
|
||||
Path string
|
||||
}
|
||||
|
||||
type dataScopeKey struct{}
|
||||
|
||||
+1
-16
@@ -16,23 +16,8 @@ type EmailUsecase struct{ repo EmailRepo }
|
||||
|
||||
func NewEmailUsecase(repo EmailRepo) *EmailUsecase { return &EmailUsecase{repo: repo} }
|
||||
|
||||
func splitRecipients(value string) []string {
|
||||
parts := strings.Split(value, ",")
|
||||
result := make([]string, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
if recipient := strings.TrimSpace(part); recipient != "" {
|
||||
result = append(result, recipient)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (uc *EmailUsecase) Send(ctx context.Context, to, subject, body string) error {
|
||||
recipients := splitRecipients(to)
|
||||
if len(recipients) == 0 || subject == "" {
|
||||
return errors.New("收件人和邮件标题不能为空")
|
||||
}
|
||||
return uc.repo.Send(ctx, recipients, subject, body)
|
||||
return uc.repo.Send(ctx, strings.Split(to, ","), subject, body)
|
||||
}
|
||||
|
||||
func (uc *EmailUsecase) Test(ctx context.Context) error {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -50,9 +52,13 @@ func (uc *MediaUsecase) Upload(ctx context.Context, userID uint, name, mime stri
|
||||
return nil, err
|
||||
}
|
||||
ext := strings.ToLower(filepath.Ext(name))
|
||||
buffered := bufio.NewReader(reader)
|
||||
if header, _ := buffered.Peek(512); len(header) > 0 {
|
||||
mime = http.DetectContentType(header)
|
||||
}
|
||||
key := time.Now().Format("20060102") + "/" + uuid.NewString() + ext
|
||||
hash := md5.New()
|
||||
stored, err := uc.files.Put(ctx, key, io.TeeReader(reader, hash))
|
||||
stored, err := uc.files.Put(ctx, key, io.TeeReader(buffered, hash))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -34,9 +34,6 @@ type SecurityRepo interface {
|
||||
}
|
||||
|
||||
func (uc *SettingsUsecase) UpdateSecurity(ctx context.Context, value *SecurityConfig) error {
|
||||
if value.KeyLong < 1 || value.ImgWidth < 1 || value.ImgHeight < 1 || value.PwdMinLength < 1 || value.LimitWindow < 1 || value.LimitCount < 1 || value.LockThreshold < 1 || value.LockDuration < 1 || value.PwdExpireDays < 1 {
|
||||
return errors.New("安全配置数值必须大于0")
|
||||
}
|
||||
return uc.SaveSecurityConfig(ctx, value)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user