feat: CR login, register, subscribe

This commit is contained in:
ericprd
2025-02-24 16:48:20 +08:00
parent ae5b2cb975
commit cb3d06fa02
48 changed files with 1027 additions and 59 deletions
+20
View File
@@ -0,0 +1,20 @@
package cachingsvc
import (
"context"
cachingdomain "github.com/ardeman/project-legalgo-go/internal/domain/caching"
"github.com/redis/go-redis/v9"
)
type impl struct {
redisClient *redis.Client
}
type implIntf interface {
Set(context.Context, cachingdomain.CacheSpec) error
}
func New() implIntf {
return &impl{}
}
+31
View File
@@ -0,0 +1,31 @@
package cachingsvc
import (
"context"
"encoding/json"
cachingdomain "github.com/ardeman/project-legalgo-go/internal/domain/caching"
"github.com/ardeman/project-legalgo-go/internal/utilities/response"
"github.com/sirupsen/logrus"
)
func (i *impl) Set(ctx context.Context, spec cachingdomain.CacheSpec) error {
redisClient := i.redisClient
if redisClient == nil {
logrus.WithContext(ctx).Errorf("redis not found")
return response.ErrRedisConnNotFound
}
dataBytes, err := json.Marshal(spec.Data)
if err != nil {
return response.ErrMarshal
}
if err := redisClient.Set(ctx, spec.Key, string(dataBytes), spec.TTL); err != nil {
return response.ErrRedisSet
}
return nil
}