数据集上传代码增加,未调通
Former-commit-id: 8935c877b5ffc7bcd726b59926aa91b7ae3bdc57
This commit is contained in:
parent
028a21c16f
commit
d7cf48e3bb
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
//}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue