From 028a21c16f060b05aa07e95c1e8043f61a029705 Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Mon, 12 Jun 2023 21:14:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AE=97=E7=BD=91=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E7=B1=BB=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 6249ae97f9c48e57e56163c2a9e5b4f51f9b3bd1 --- common/enum/partnerEnum.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/enum/partnerEnum.go b/common/enum/partnerEnum.go index 8936d176..db5560da 100644 --- a/common/enum/partnerEnum.go +++ b/common/enum/partnerEnum.go @@ -4,6 +4,7 @@ type Partner string const ( AC Partner = "ac" + TH Partner = "th" KubeNative Partner = "kubeNative" ModelArts Partner = "modelArts" ) @@ -16,6 +17,8 @@ func (p Partner) String() string { return "长沙云算" case ModelArts: return "南京智算" + case TH: + return "天河超算" default: return "" } From d7cf48e3bb32fbf24e938fb6a32014ed823b8930 Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Mon, 12 Jun 2023 21:20:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E4=BB=A3=E7=A0=81=E5=A2=9E=E5=8A=A0=EF=BC=8C=E6=9C=AA?= =?UTF-8?q?=E8=B0=83=E9=80=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 8935c877b5ffc7bcd726b59926aa91b7ae3bdc57 --- .../handler/image/datasetcheckhandler.go | 25 ++++++++ .../handler/image/uploaddatasethandler.go | 58 +++++++++++++++++++ .../internal/logic/image/datasetchecklogic.go | 37 ++++++++++++ .../logic/image/uploaddatasetlogic.go | 28 +++++++++ 4 files changed, 148 insertions(+) create mode 100644 adaptor/PCM-CORE/api/internal/handler/image/datasetcheckhandler.go create mode 100644 adaptor/PCM-CORE/api/internal/handler/image/uploaddatasethandler.go create mode 100644 adaptor/PCM-CORE/api/internal/logic/image/datasetchecklogic.go create mode 100644 adaptor/PCM-CORE/api/internal/logic/image/uploaddatasetlogic.go diff --git a/adaptor/PCM-CORE/api/internal/handler/image/datasetcheckhandler.go b/adaptor/PCM-CORE/api/internal/handler/image/datasetcheckhandler.go new file mode 100644 index 00000000..4e2514bc --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/handler/image/datasetcheckhandler.go @@ -0,0 +1,25 @@ +package image + +import ( + result2 "PCM/common/result" + "net/http" + + "PCM/adaptor/PCM-CORE/api/internal/logic/image" + "PCM/adaptor/PCM-CORE/api/internal/svc" + "PCM/adaptor/PCM-CORE/api/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func DataSetCheckHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.CheckReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := image.NewDataSetCheckLogic(r.Context(), svcCtx) + resp, err := l.DataSetCheck(&req) + result2.HttpResult(r, w, resp, err) + } +} diff --git a/adaptor/PCM-CORE/api/internal/handler/image/uploaddatasethandler.go b/adaptor/PCM-CORE/api/internal/handler/image/uploaddatasethandler.go new file mode 100644 index 00000000..c8dc3a4a --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/handler/image/uploaddatasethandler.go @@ -0,0 +1,58 @@ +package image + +import ( + "PCM/adaptor/PCM-CORE/api/internal/svc" + "net/http" +) + +func UploadDataSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ////file, fileHeader, err := r.FormFile("file") + ////if err != nil { + //// return + ////} + //AK := "your_access_key" + //SK := "your_secret_key" + //cred := aws.Credentials{AccessKeyID: AK, SecretAccessKey: SK} + // + //uploader := manager.NewUploader(client) + //endpointURL := "http://10.105.24.4:7480" + // + //customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { + // return aws.Endpoint{ + // URL: endpointURL, + // }, nil + //}) + // + //client := s3.NewFromConfig(aws.Config{Credentials: credentials.NewAccessKeyCredential()}) + //cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithEndpointResolverWithOptions(customResolver)) + //if err != nil { + // panic(err) + //} + // + //s3Client := s3.NewFromConfig(cfg, func(options *s3.Options) { + // options.UsePathStyle = true + //}) + // 上传文件 + //uploader := manager.NewUploader(s3Client) + //bucket := "pcm" + //key := fileHeader.Filename + //result, err := uploader.Upload(context.TODO(), &s3.PutObjectInput{ + // Bucket: &bucket, + // Key: &key, + // Body: file, + //}) + //println(result) + //output, err := s3Client.ListObjectsV2(context.TODO(), &s3.ListObjectsV2Input{ + // Bucket: aws.String("my-bucket"), + //}) + //if err != nil { + // log.Fatal(err) + //} + // + //log.Println("first page results:") + //for _, object := range output.Contents { + // log.Printf("key=%s size=%d", aws.ToString(object.Key), object.Size) + //} + } +} diff --git a/adaptor/PCM-CORE/api/internal/logic/image/datasetchecklogic.go b/adaptor/PCM-CORE/api/internal/logic/image/datasetchecklogic.go new file mode 100644 index 00000000..1f7370cd --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/logic/image/datasetchecklogic.go @@ -0,0 +1,37 @@ +package image + +import ( + "PCM/adaptor/PCM-CORE/model" + "context" + + "PCM/adaptor/PCM-CORE/api/internal/svc" + "PCM/adaptor/PCM-CORE/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type DataSetCheckLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewDataSetCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DataSetCheckLogic { + return &DataSetCheckLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *DataSetCheckLogic) DataSetCheck(req *types.CheckReq) (resp *types.CheckResp, err error) { + resp = &types.CheckResp{} + var dataSets []model.DataSet + l.svcCtx.DbEngin.Find(&dataSets).Where("md5", req.FileMd5) + if len(dataSets) != 0 { + resp.Exist = true + } else { + resp.Exist = false + } + return resp, nil +} diff --git a/adaptor/PCM-CORE/api/internal/logic/image/uploaddatasetlogic.go b/adaptor/PCM-CORE/api/internal/logic/image/uploaddatasetlogic.go new file mode 100644 index 00000000..346c8cd8 --- /dev/null +++ b/adaptor/PCM-CORE/api/internal/logic/image/uploaddatasetlogic.go @@ -0,0 +1,28 @@ +package image + +import ( + "context" + + "PCM/adaptor/PCM-CORE/api/internal/svc" + "github.com/zeromicro/go-zero/core/logx" +) + +type UploadDataSetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUploadDataSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadDataSetLogic { + return &UploadDataSetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *UploadDataSetLogic) UploadDataSet() error { + // todo: add your logic here and delete this line + + return nil +}