Commit fc2e9128 authored by Bess严根旺's avatar Bess严根旺

修改

parent 84d48121
...@@ -4,7 +4,7 @@ import ( ...@@ -4,7 +4,7 @@ import (
"bufio" "bufio"
"context" "context"
"doc-service/domain/entity/serversitemicros/docserverproject" "doc-service/domain/entity/serversitemicros/docserverproject"
"doc-service/domain/service" service2 "doc-service/domain/repository"
"doc-service/infra/db" "doc-service/infra/db"
"fmt" "fmt"
"gitlab.galaxy-immi.com/Backend-group/go-com/third/log" "gitlab.galaxy-immi.com/Backend-group/go-com/third/log"
...@@ -15,7 +15,6 @@ import ( ...@@ -15,7 +15,6 @@ import (
func DoAliData() { func DoAliData() {
fmt.Println("开始刷新请求...") fmt.Println("开始刷新请求...")
ctx := context.Background() ctx := context.Background()
// 启动一个协程来执行定时任务 20秒一次 // 启动一个协程来执行定时任务 20秒一次
ticker := time.NewTicker(5 * time.Second) ticker := time.NewTicker(5 * time.Second)
...@@ -62,8 +61,7 @@ func toDoData(c context.Context) int8 { ...@@ -62,8 +61,7 @@ func toDoData(c context.Context) int8 {
} }
for _, item := range projectData { for _, item := range projectData {
docService := &service.DocServiceService{} ali := DoConversionToAli(c, item.ID)
ali := docService.DoConversionToAli(c, item.ID)
if ali { if ali {
_, errUpdate := db.GetServerSiteMicrosDB().DocServerProject.UpdateOneID(item.ID).SetStatus(1).Save(c) _, errUpdate := db.GetServerSiteMicrosDB().DocServerProject.UpdateOneID(item.ID).SetStatus(1).Save(c)
if errUpdate != nil { if errUpdate != nil {
...@@ -76,3 +74,46 @@ func toDoData(c context.Context) int8 { ...@@ -76,3 +74,46 @@ func toDoData(c context.Context) int8 {
} }
return 1 return 1
} }
// 执行文件转换(脚本使用)
func DoConversionToAli(c context.Context, projectId int32) bool {
ConversionInfo, infoErr := db.GetServerSiteMicrosDB().DocServerProject.Get(c, projectId)
if infoErr != nil {
return false
}
IsPrivate := true
if ConversionInfo.IsPrivate == 0 {
IsPrivate = false
}
request := &service2.DoConversionRequest{
ProjectName: ConversionInfo.ProjectName,
SourceType: ConversionInfo.SourceType,
TargetType: ConversionInfo.TargetType,
SourceURI: *ConversionInfo.SourceURL,
TargetURI: *ConversionInfo.TargetURL,
IsPrivate: IsPrivate,
}
//创建项目
createErr := service2.NewConversion().CreateProject()
if createErr != nil {
log.Info("创建项目出错" + createErr.Error())
return false
}
//执行转换
result, errs := service2.NewConversion().Conversion(request)
if errs != nil {
log.Info("转换出错" + errs.Error())
return false
}
taskId := result["body"].(map[string]interface{})["TaskId"].(string)
//修改taskId
_, errsInfo := db.GetServerSiteMicrosDB().DocServerProject.UpdateOneID(projectId).SetTaskID(taskId).Save(c)
if errsInfo != nil {
log.Info("入库出错" + errsInfo.Error())
return false
}
return true
}
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
service "doc-service/domain/repository" service "doc-service/domain/repository"
"doc-service/infra/db" "doc-service/infra/db"
"github.com/nacos-group/nacos-sdk-go/v2/common/logger" "github.com/nacos-group/nacos-sdk-go/v2/common/logger"
"gitlab.galaxy-immi.com/Backend-group/go-com/third/log"
pb "gitlab.galaxy-immi.com/Backend-group/proto/pb/docservice" pb "gitlab.galaxy-immi.com/Backend-group/proto/pb/docservice"
"time" "time"
) )
...@@ -88,49 +87,6 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi ...@@ -88,49 +87,6 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi
return resp, nil return resp, nil
} }
// 执行文件转换(脚本使用)
func (doc *DocServiceService) DoConversionToAli(c context.Context, projectId int32) bool {
ConversionInfo, infoErr := db.GetServerSiteMicrosDB().DocServerProject.Get(c, projectId)
if infoErr != nil {
return false
}
IsPrivate := true
if ConversionInfo.IsPrivate == 0 {
IsPrivate = false
}
request := &service.DoConversionRequest{
ProjectName: ConversionInfo.ProjectName,
SourceType: ConversionInfo.SourceType,
TargetType: ConversionInfo.TargetType,
SourceURI: *ConversionInfo.SourceURL,
TargetURI: *ConversionInfo.TargetURL,
IsPrivate: IsPrivate,
}
//创建项目
createErr := service.NewConversion().CreateProject()
if createErr != nil {
log.Info("创建项目出错" + createErr.Error())
return false
}
//执行转换
result, errs := service.NewConversion().Conversion(request)
if errs != nil {
log.Info("转换出错" + errs.Error())
return false
}
taskId := result["body"].(map[string]interface{})["TaskId"].(string)
//入库
_, errsInfo := db.GetServerSiteMicrosDB().DocServerProject.UpdateOneID(projectId).SetTaskID(taskId).Save(c)
if errsInfo != nil {
log.Info("入库出错" + errsInfo.Error())
return false
}
return true
}
// 获取转换结果 // 获取转换结果
func (doc *DocServiceService) GetProjectInfo(c context.Context, req *pb.GetProjectRequest) (resp *pb.GetProjectResponse, err error) { func (doc *DocServiceService) GetProjectInfo(c context.Context, req *pb.GetProjectRequest) (resp *pb.GetProjectResponse, err error) {
resp = &pb.GetProjectResponse{} resp = &pb.GetProjectResponse{}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment