管理端按用户查询开启通讯录/相册/媒体拉取;服务端写入路径自动压图;新增 /v1/sign 与 /v1/energy。 Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
538 B
Go
25 lines
538 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"spark-server/internal/pkg/errs"
|
|
)
|
|
|
|
// BalanceView is the energy query payload.
|
|
type BalanceView struct {
|
|
Energy int64 `json:"energy"`
|
|
}
|
|
|
|
// Balance returns the user's energy wallet (creating an empty one if needed).
|
|
func (s *Service) Balance(ctx context.Context, userID int64) (*BalanceView, error) {
|
|
if !s.ready() || userID <= 0 {
|
|
return nil, errs.ErrUnauthorized
|
|
}
|
|
w, err := s.repo.EnsureWallet(ctx, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &BalanceView{Energy: w.Energy}, nil
|
|
}
|