Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth
This commit is contained in:
@@ -12,4 +12,13 @@ type Config struct {
|
||||
Auth types.Auth
|
||||
ReplicaId uint64
|
||||
SourceRabbitMq string
|
||||
AWS struct {
|
||||
S3 struct {
|
||||
Credentials struct {
|
||||
AccessKeyID string
|
||||
Secret string
|
||||
Token string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"fusenapi/constants"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/file"
|
||||
"fusenapi/utils/websocket_data"
|
||||
|
||||
"fusenapi/server/render/internal/svc"
|
||||
@@ -62,15 +63,31 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
||||
if req.Sign != sign {
|
||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid sign")
|
||||
}*/
|
||||
//创建/更新资源
|
||||
|
||||
// 上传文件
|
||||
var upload = file.Upload{
|
||||
Ctx: l.ctx,
|
||||
MysqlConn: l.svcCtx.MysqlConn,
|
||||
AwsSession: l.svcCtx.AwsSession,
|
||||
}
|
||||
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
||||
FileHash: req.Info.TaskId,
|
||||
FileData: req.Info.Image,
|
||||
UploadBucket: 1,
|
||||
ApiType: 2,
|
||||
UserId: req.Info.UserId,
|
||||
GuestId: req.Info.GuestId,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image")
|
||||
}
|
||||
//发送消息到对应的rabbitmq
|
||||
data := websocket_data.RenderImageNotify{
|
||||
TaskId: req.Info.TaskId,
|
||||
Image: req.Info.Image,
|
||||
Image: uploadRes.ResourceUrl,
|
||||
}
|
||||
d, _ := json.Marshal(data)
|
||||
if err := l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil {
|
||||
if err = l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatus(basic.CodeServiceErr, "failed to send data")
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ import (
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/model/gmodel"
|
||||
|
||||
@@ -19,21 +23,25 @@ type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
RabbitMq *initalize.RabbitMqHandle
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
RabbitMq *initalize.RabbitMqHandle
|
||||
AwsSession *session.Session
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
config := aws.Config{
|
||||
Credentials: credentials.NewStaticCredentials(c.AWS.S3.Credentials.AccessKeyID, c.AWS.S3.Credentials.Secret, c.AWS.S3.Credentials.Token),
|
||||
}
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
MysqlConn: conn,
|
||||
SharedState: StateServer,
|
||||
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
|
||||
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
|
||||
AwsSession: session.Must(session.NewSession(&config)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user