修改
This commit is contained in:
parent
6f76dd871e
commit
fda56a4690
35
cmd/app.go
35
cmd/app.go
@ -4,8 +4,12 @@ import (
|
||||
dciConfig "chain-dci/config"
|
||||
"chain-dci/internal/controller"
|
||||
_ "chain-dci/internal/handler"
|
||||
"chain-dci/pb/dci"
|
||||
"chain-dci/pkg/app"
|
||||
common "chain-dci/pkg/init"
|
||||
"fmt"
|
||||
"google.golang.org/grpc"
|
||||
"gorm.io/gorm"
|
||||
"net"
|
||||
|
||||
//common "chain-dci/pkg/init"
|
||||
"chain-dci/pkg/tracing"
|
||||
@ -17,12 +21,13 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func NewApp(Lg *zap.Logger, JaegerTracer *tracing.JaegerProvider, BccrClient *bccrClient.Client, SfNode *snowflake.Node) *app.App {
|
||||
func NewApp(Lg *zap.Logger, JaegerTracer *tracing.JaegerProvider, BccrClient *bccrClient.Client, SfNode *snowflake.Node, DciDB *gorm.DB) *app.App {
|
||||
return &app.App{
|
||||
Lg: Lg,
|
||||
JaegerTracer: JaegerTracer,
|
||||
BccrClient: BccrClient,
|
||||
SfNode: SfNode,
|
||||
//DciDB: DciDB,
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,19 +39,19 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//l, err := net.Listen("tcp", ":8883")
|
||||
//if err != nil {
|
||||
// fmt.Printf("failed to listen: %v", err)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//s := grpc.NewServer() // 创建gRPC服务器
|
||||
//dci.RegisterDciServer(s, &controller.DciProvider{}) // 在gRPC服务端注册服务
|
||||
//// 启动服务
|
||||
//err = s.Serve(l)
|
||||
////注册服务
|
||||
config.SetProviderService(&controller.DciProvider{})
|
||||
common.Init()
|
||||
l, err := net.Listen("tcp", ":8883")
|
||||
if err != nil {
|
||||
fmt.Printf("failed to listen: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
s := grpc.NewServer() // 创建gRPC服务器
|
||||
dci.RegisterDciServer(s, &controller.DciProvider{}) // 在gRPC服务端注册服务
|
||||
// 启动服务
|
||||
err = s.Serve(l)
|
||||
//注册服务
|
||||
//config.SetProviderService(&controller.DciProvider{})
|
||||
//common.Init()
|
||||
if err = config.Load(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package main
|
||||
import (
|
||||
"chain-dci/pkg/app"
|
||||
"chain-dci/pkg/bccr"
|
||||
"chain-dci/pkg/db"
|
||||
"chain-dci/pkg/logger"
|
||||
"chain-dci/pkg/snowf"
|
||||
"chain-dci/pkg/tracing"
|
||||
@ -14,6 +15,6 @@ import (
|
||||
)
|
||||
|
||||
func InitApp() (*app.App, error) {
|
||||
wire.Build(logger.Provider, tracing.Provider, bccr.Provider, snowf.Provider, NewApp)
|
||||
wire.Build(logger.Provider, tracing.Provider, bccr.Provider, snowf.Provider, db.DciProvider, NewApp)
|
||||
return &app.App{}, nil
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ package main
|
||||
import (
|
||||
"chain-dci/pkg/app"
|
||||
"chain-dci/pkg/bccr"
|
||||
"chain-dci/pkg/db"
|
||||
"chain-dci/pkg/logger"
|
||||
"chain-dci/pkg/snowf"
|
||||
"chain-dci/pkg/tracing"
|
||||
@ -27,6 +28,7 @@ func InitApp() (*app.App, error) {
|
||||
jaegerProvider := tracing.NewTracing()
|
||||
client := bccr.NewBccrClient()
|
||||
node := snowf.NewSf()
|
||||
appApp := NewApp(zapLogger, jaegerProvider, client, node)
|
||||
gormDB := db.NewDci()
|
||||
appApp := NewApp(zapLogger, jaegerProvider, client, node, gormDB)
|
||||
return appApp, nil
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
system:
|
||||
mode: dev #正式 prod #测试 test #开发 dev
|
||||
config_source: config
|
||||
#oaMeeting:
|
||||
# host: 127.0.0.1
|
||||
# port: 3306
|
||||
# user: dyb
|
||||
# password: rootdyb
|
||||
# db_name: "oa-meeting"
|
||||
chainDci:
|
||||
host: 172.16.100.99
|
||||
port: 9007
|
||||
user: artuser
|
||||
password: C250PflXIWv2SQm8
|
||||
db_name: "chain_dci"
|
||||
antCloud:
|
||||
access_key: "ACsK4CQqzj5rGSKf"
|
||||
access_key_secret: "SJmH5eATWY26tJrVg8QyHaBGbLNCbj7y"
|
||||
|
@ -1,12 +1,12 @@
|
||||
system:
|
||||
mode: dev #正式 prod #测试 test #开发 dev
|
||||
# config_source: configmap
|
||||
#oaMeeting:
|
||||
# host: ${mysql.host|localhost}
|
||||
# port: ${mysql.port|3306}
|
||||
# user: ${mysql.user}
|
||||
# password: ${mysql.password}
|
||||
# db_name: ${oa-meeting.mysql.db_name}
|
||||
chainDci:
|
||||
host: 172.16.100.99
|
||||
port: 9007
|
||||
user: artuser
|
||||
password: C250PflXIWv2SQm8
|
||||
db_name: "chain_dci"
|
||||
Bccr:
|
||||
access_key_id: "ACsK4CQqzj5rGSKf"
|
||||
access_key_secret: "SJmH5eATWY26tJrVg8QyHaBGbLNCbj7y"
|
||||
|
@ -1,12 +1,12 @@
|
||||
system:
|
||||
mode: prod #正式 prod #测试 test #开发 dev
|
||||
# config_source: configmap
|
||||
#oaMeeting:
|
||||
# host: ${mysql.host|localhost}
|
||||
# port: ${mysql.port|3306}
|
||||
# user: ${mysql.user}
|
||||
# password: ${mysql.password}
|
||||
# db_name: ${oa-meeting.mysql.db_name}
|
||||
chainDci:
|
||||
host: ${mysql.host|localhost}
|
||||
port: ${mysql.port|3306}
|
||||
user: ${mysql.user}
|
||||
password: ${mysql.password}
|
||||
db_name: ${chain-dci.mysql.db_name}
|
||||
Bccr:
|
||||
access_key_id: "ACsK4CQqzj5rGSKf"
|
||||
access_key_secret: "SJmH5eATWY26tJrVg8QyHaBGbLNCbj7y"
|
||||
|
23
internal/dao/file.go
Normal file
23
internal/dao/file.go
Normal file
@ -0,0 +1,23 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"chain-dci/internal/model"
|
||||
"chain-dci/pkg/app"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func CreateFileInfo(tx *gorm.DB, info *model.FileInfo) error {
|
||||
if tx == nil {
|
||||
tx = app.ModuleClients.DciDB
|
||||
}
|
||||
err := tx.Model(&model.FileInfo{}).Create(&info).Error
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateFileInfo(tx *gorm.DB, info *model.FileInfo) error {
|
||||
if tx == nil {
|
||||
tx = app.ModuleClients.DciDB
|
||||
}
|
||||
err := tx.Model(&model.FileInfo{}).Where("id =?", info.Model.ID).Updates(&info).Error
|
||||
return err
|
||||
}
|
@ -26,10 +26,12 @@ type DciRegistration struct {
|
||||
|
||||
// CreateDciRegistration 发起数登申请
|
||||
func (r *DciRegistration) CreateDciRegistration(req *dci.CreateDciRegistrationRequest) (res *dci.CreateDciRegistrationResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "发起数登申请 参数信息: ")
|
||||
|
||||
res = new(dci.CreateDciRegistrationResponse)
|
||||
|
||||
createDciRegistrationRequest := new(bccrClient.CreateDciRegistrationRequest)
|
||||
_ = copier.CopyWithOption(&createDciRegistrationRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&createDciRegistrationRequest, req, copier.Option{DeepCopy: false})
|
||||
fmt.Printf("req : %+v\n", req)
|
||||
fmt.Println("======================================================= ============== ===========00")
|
||||
fmt.Printf("createDciRegistrationRequest : %+v\n", createDciRegistrationRequest)
|
||||
@ -42,37 +44,45 @@ func (r *DciRegistration) CreateDciRegistration(req *dci.CreateDciRegistrationRe
|
||||
|
||||
createDciPreregistrationResponse, err := app.ModuleClients.BccrClient.CreateDciRegistration(createDciRegistrationRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrCreateDciRegistration, "发起数登申请 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, createDciPreregistrationResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(createDciPreregistrationResponse, "发起数登申请 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, createDciPreregistrationResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// QueryDciRegistration 查询数登申请
|
||||
func (r *DciRegistration) QueryDciRegistration(req *dci.QueryDciRegistrationRequest) (res *dci.QueryDciRegistrationResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "查询数登申请 参数信息: ")
|
||||
|
||||
res = new(dci.QueryDciRegistrationResponse)
|
||||
|
||||
queryDciRegistrationRequest := new(bccrClient.QueryDciRegistrationRequest)
|
||||
_ = copier.CopyWithOption(&queryDciRegistrationRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&queryDciRegistrationRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
queryDciRegistrationResponse, err := app.ModuleClients.BccrClient.QueryDciRegistration(queryDciRegistrationRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrQueryDciRegistration, "查询数登申请 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciRegistrationResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(queryDciRegistrationResponse, "查询数登申请 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciRegistrationResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetDciPayUrl 数登支付链接获取
|
||||
func (r *DciRegistration) GetDciPayUrl(req *dci.GetDciPayUrlRequest) (res *dci.GetDciPayUrlResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "数登支付链接获取 参数信息: ")
|
||||
|
||||
res = new(dci.GetDciPayUrlResponse)
|
||||
|
||||
getDciPayUrlRequest := new(bccrClient.GetDciPayurlRequest)
|
||||
_ = copier.CopyWithOption(&getDciPayUrlRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&getDciPayUrlRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
clientToken, err := createToken(time.Now().UnixMilli(), req.DigitalRegisterId, app.ModuleClients.SfNode.Generate().Base64())
|
||||
if err != nil {
|
||||
@ -82,37 +92,45 @@ func (r *DciRegistration) GetDciPayUrl(req *dci.GetDciPayUrlRequest) (res *dci.G
|
||||
|
||||
getDciPayUrlResponse, err := app.ModuleClients.BccrClient.GetDciPayurl(getDciPayUrlRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrGetDciPayurl, "数登支付链接获取 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, getDciPayUrlResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(getDciPayUrlResponse, "数登支付链接获取 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, getDciPayUrlResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// QueryDciPay 数登支付查询
|
||||
func (r *DciRegistration) QueryDciPay(req *dci.QueryDciPayRequest) (res *dci.QueryDciPayResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "数登支付查询 参数信息: ")
|
||||
|
||||
res = new(dci.QueryDciPayResponse)
|
||||
|
||||
queryDciPayRequest := new(bccrClient.QueryDciPayRequest)
|
||||
_ = copier.CopyWithOption(&queryDciPayRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&queryDciPayRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
queryDciPayResponse, err := app.ModuleClients.BccrClient.QueryDciPay(queryDciPayRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrQueryDciPay, "数登支付查询 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciPayResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(queryDciPayResponse, "数登支付查询 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciPayResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetDciRegistrationcert 获取数登证书下载
|
||||
func (r *DciRegistration) GetDciRegistrationcert(req *dci.GetDciRegistrationcertRequest) (res *dci.GetDciRegistrationcertResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "获取数登证书下载 参数信息: ")
|
||||
|
||||
res = new(dci.GetDciRegistrationcertResponse)
|
||||
|
||||
getDciRegistrationcertRequest := new(bccrClient.GetDciRegistrationcertRequest)
|
||||
_ = copier.CopyWithOption(&getDciRegistrationcertRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&getDciRegistrationcertRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
clientToken, err := createToken(time.Now().UnixMilli(), req.DigitalRegisterId, app.ModuleClients.SfNode.Generate().Base64())
|
||||
if err != nil {
|
||||
@ -122,20 +140,24 @@ func (r *DciRegistration) GetDciRegistrationcert(req *dci.GetDciRegistrationcert
|
||||
|
||||
getDciRegistrationcertResponse, err := app.ModuleClients.BccrClient.GetDciRegistrationcert(getDciRegistrationcertRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrGetDciRegistrationcert, "获取数登证书下载 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, getDciRegistrationcertResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(getDciRegistrationcertResponse, "获取数登证书下载 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, getDciRegistrationcertResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// RetryDciRegistration 补正申请
|
||||
func (r *DciRegistration) RetryDciRegistration(req *dci.RetryDciRegistrationRequest) (res *dci.RetryDciRegistrationResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "补正申请 参数信息: ")
|
||||
|
||||
res = new(dci.RetryDciRegistrationResponse)
|
||||
|
||||
retryDciRegistrationRequest := new(bccrClient.RetryDciRegistrationRequest)
|
||||
_ = copier.CopyWithOption(&retryDciRegistrationRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&retryDciRegistrationRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
clientToken, err := createToken(time.Now().UnixMilli(), req.DigitalRegisterId, req.DciContentId, app.ModuleClients.SfNode.Generate().Base64())
|
||||
if err != nil {
|
||||
@ -145,20 +167,24 @@ func (r *DciRegistration) RetryDciRegistration(req *dci.RetryDciRegistrationRequ
|
||||
|
||||
retryDciRegistrationResponse, err := app.ModuleClients.BccrClient.RetryDciRegistration(retryDciRegistrationRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrRetryDciRegistration, "补正申请 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, retryDciRegistrationResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(retryDciRegistrationResponse, "补正申请 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, retryDciRegistrationResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CloseDciRegistration 数登停止申请
|
||||
func (r *DciRegistration) CloseDciRegistration(req *dci.CloseDciRegistrationRequest) (res *dci.CloseDciRegistrationResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "数登停止申请 参数信息: ")
|
||||
|
||||
res = new(dci.CloseDciRegistrationResponse)
|
||||
|
||||
closeDciRegistrationRequest := new(bccrClient.CloseDciRegistrationRequest)
|
||||
_ = copier.CopyWithOption(&closeDciRegistrationRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&closeDciRegistrationRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
clientToken, err := createToken(time.Now().UnixMilli(), req.DigitalRegisterId, req.Name, req.MobileNo, app.ModuleClients.SfNode.Generate().Base64())
|
||||
if err != nil {
|
||||
@ -168,10 +194,12 @@ func (r *DciRegistration) CloseDciRegistration(req *dci.CloseDciRegistrationRequ
|
||||
|
||||
closeDciRegistrationResponse, err := app.ModuleClients.BccrClient.CloseDciRegistration(closeDciRegistrationRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrCloseDciRegistration, "数登停止申请 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, closeDciRegistrationResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(closeDciRegistrationResponse, "数登停止申请 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, closeDciRegistrationResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -21,10 +21,12 @@ type DciUser struct {
|
||||
|
||||
// AddDciUser 著作权人 申领 DCI信息
|
||||
func (u *DciUser) AddDciUser(req *dci.AddDciUserRequest) (res *dci.AddDciUserResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "著作权人 申领 DCI信息 参数信息: ")
|
||||
|
||||
res = new(dci.AddDciUserResponse)
|
||||
|
||||
addDciUserRequest := new(bccrClient.AddDciUserRequest)
|
||||
_ = copier.CopyWithOption(&addDciUserRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&addDciUserRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
clientToken, err := createToken(time.Now().UnixMilli(), req.CertName, req.CertificateNumber, req.Phone, app.ModuleClients.SfNode.Generate().Base64())
|
||||
if err != nil {
|
||||
@ -34,20 +36,24 @@ func (u *DciUser) AddDciUser(req *dci.AddDciUserRequest) (res *dci.AddDciUserRes
|
||||
|
||||
addDciUserResponse, err := app.ModuleClients.BccrClient.AddDciUser(addDciUserRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrAddDciUser, "著作权人 申领 DCI信息 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, addDciUserResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(addDciUserResponse, "著作权人 申领 DCI信息 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, addDciUserResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateDciUser 著作权人 更新 DCI信息
|
||||
func (u *DciUser) UpdateDciUser(req *dci.UpdateDciUserRequest) (res *dci.UpdateDciUserResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "著作权人 更新 DCI信息 参数信息: ")
|
||||
|
||||
res = new(dci.UpdateDciUserResponse)
|
||||
|
||||
updateDciUserRequest := new(bccrClient.UpdateDciUserRequest)
|
||||
_ = copier.CopyWithOption(&updateDciUserRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&updateDciUserRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
clientToken, err := createToken(time.Now().UnixMilli(), req.DciUserId, req.CertFrontFileId, req.CertBackFileId, req.Phone, app.ModuleClients.SfNode.Generate().Base64())
|
||||
if err != nil {
|
||||
@ -57,27 +63,33 @@ func (u *DciUser) UpdateDciUser(req *dci.UpdateDciUserRequest) (res *dci.UpdateD
|
||||
|
||||
updateDciUserResponse, err := app.ModuleClients.BccrClient.UpdateDciUser(updateDciUserRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrUpdateDciUser, "著作权人 更新 DCI信息 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, updateDciUserResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(updateDciUserResponse, "著作权人 更新 DCI信息 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, updateDciUserResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// QueryDciUser 著作权人 查询 DCI信息
|
||||
func (u *DciUser) QueryDciUser(req *dci.QueryDciUserRequest) (res *dci.QueryDciUserResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "著作权人 查询 DCI信息 参数信息: ")
|
||||
|
||||
res = new(dci.QueryDciUserResponse)
|
||||
|
||||
queryDciUserRequest := new(bccrClient.QueryDciUserRequest)
|
||||
_ = copier.CopyWithOption(&queryDciUserRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&queryDciUserRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
queryDciUserResponse, err := app.ModuleClients.BccrClient.QueryDciUser(queryDciUserRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrQueryDciUser, "著作权人 查询 DCI信息 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciUserResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(queryDciUserResponse, "著作权人 查询 DCI信息 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciUserResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -20,10 +20,12 @@ type DciWork struct {
|
||||
|
||||
// CreateDciPreregistration 作品 申领 DCI
|
||||
func (w *DciWork) CreateDciPreregistration(req *dci.CreateDciPreregistrationRequest) (res *dci.CreateDciPreregistrationResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "作品 申领 DCI 参数信息: ")
|
||||
|
||||
res = new(dci.CreateDciPreregistrationResponse)
|
||||
|
||||
createDciPreregistrationRequest := new(bccrClient.CreateDciPreregistrationRequest)
|
||||
_ = copier.CopyWithOption(&createDciPreregistrationRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&createDciPreregistrationRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
clientToken, err := createToken(time.Now().UnixMilli(), req.DciUserId, req.WorkName, req.AuthorName, req.WorkFileId, app.ModuleClients.SfNode.Generate().Base64())
|
||||
if err != nil {
|
||||
@ -33,27 +35,33 @@ func (w *DciWork) CreateDciPreregistration(req *dci.CreateDciPreregistrationRequ
|
||||
|
||||
createDciPreregistrationResponse, err := app.ModuleClients.BccrClient.CreateDciPreregistration(createDciPreregistrationRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrCreateDciPreregistration, "作品 申领 DCI 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, createDciPreregistrationResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(createDciPreregistrationResponse, "作品 申领 DCI 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, createDciPreregistrationResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// QueryDciPreregistration 作品 查询 DCI
|
||||
func (w *DciWork) QueryDciPreregistration(req *dci.QueryDciPreregistrationRequest) (res *dci.QueryDciPreregistrationResponse, err error) {
|
||||
errCommon.NoReturnInfo(req, "作品 查询 DCI 参数信息: ")
|
||||
|
||||
res = new(dci.QueryDciPreregistrationResponse)
|
||||
|
||||
queryDciPreregistrationRequest := new(bccrClient.QueryDciPreregistrationRequest)
|
||||
_ = copier.CopyWithOption(&queryDciPreregistrationRequest, req, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&queryDciPreregistrationRequest, req, copier.Option{DeepCopy: false})
|
||||
|
||||
queryDciPreregistrationResponse, err := app.ModuleClients.BccrClient.QueryDciPreregistration(queryDciPreregistrationRequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errCommon.ReturnError(err, msg.ErrQueryDciPreregistration, "作品 查询 DCI 失败: ")
|
||||
}
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciPreregistrationResponse, copier.Option{DeepCopy: true})
|
||||
errCommon.NoReturnInfo(queryDciPreregistrationResponse, "作品 查询 DCI 成功: ")
|
||||
|
||||
_ = copier.CopyWithOption(&res, queryDciPreregistrationResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ func GetUploadUrl(req *bccrClient.GetUploadurlRequest) (result *bccrClient.GetUp
|
||||
errCommon.NoReturnError(err, "调用 蚂蚁链获取 oss url 错误:")
|
||||
return
|
||||
}
|
||||
errCommon.NoReturnInfo(req, "获取 DCI GetUploadurl 返回结果:")
|
||||
return
|
||||
}
|
||||
|
||||
@ -49,6 +50,14 @@ func (f *File) Upload(req *dci.GetUploadUrlRequest) (res *dci.GetUploadUrlRespon
|
||||
fmt.Printf("GetUploadUrlRequest is : %+v\n", req)
|
||||
fmt.Println("+++++++++++++++ GetUploadUrlRequest =================")
|
||||
|
||||
errCommon.NoReturnInfo(req, "上传文件 参数记录:")
|
||||
|
||||
/*// 记录 上传的文件
|
||||
//nil := app.ModuleClients.DciDB.Begin()
|
||||
fileInfo := new(model.FileInfo)
|
||||
fileInfo.FileUrl = req.FileName
|
||||
_ = dao.CreateFileInfo(nil, fileInfo)*/
|
||||
|
||||
isChinese := false
|
||||
|
||||
getUploadUrlRequest := new(bccrClient.GetUploadurlRequest)
|
||||
@ -84,7 +93,7 @@ func (f *File) Upload(req *dci.GetUploadUrlRequest) (res *dci.GetUploadUrlRespon
|
||||
|
||||
getUploadUrlResponse := GetUploadUrl(getUploadUrlRequest)
|
||||
res = new(dci.GetUploadUrlResponse)
|
||||
_ = copier.CopyWithOption(&res, getUploadUrlResponse, copier.Option{DeepCopy: true})
|
||||
_ = copier.CopyWithOption(&res, getUploadUrlResponse, copier.Option{DeepCopy: false})
|
||||
|
||||
fmt.Println("+++++++++++++++ GetUploadUrl =================")
|
||||
fmt.Printf("GetUploadUrl is : %+v\n", res)
|
||||
@ -92,12 +101,24 @@ func (f *File) Upload(req *dci.GetUploadUrlRequest) (res *dci.GetUploadUrlRespon
|
||||
|
||||
fmt.Println("====== =========== =================== 1 ===============")
|
||||
if res.ResultCode != "OK" {
|
||||
/* fileInfo.ReqMsgId = res.ReqMsgId
|
||||
fileInfo.ResultCode = res.ResultCode
|
||||
fileInfo.ResultMsg = res.ResultMsg
|
||||
fileInfo.Url = res.Url
|
||||
fileInfo.FileId = res.FileId
|
||||
err = dao.UpdateFileInfo(nil, fileInfo)*/
|
||||
errCommon.NoReturnError(errors.New(res.ResultMsg), "获取授权访问OSS链接 错误:")
|
||||
return res, nil
|
||||
}
|
||||
|
||||
fmt.Println("====== =========== =================== 2 ===============")
|
||||
if res.Url == "" || res.FileId == "" {
|
||||
/*fileInfo.ReqMsgId = res.ReqMsgId
|
||||
fileInfo.ResultCode = res.ResultCode
|
||||
fileInfo.ResultMsg = res.ResultMsg
|
||||
fileInfo.Url = res.Url
|
||||
fileInfo.FileId = res.FileId
|
||||
_ = dao.UpdateFileInfo(nil, fileInfo)*/
|
||||
errCommon.NoReturnError(errors.New(res.ResultMsg), "获取授权访问OSS链接 错误:")
|
||||
return res, nil
|
||||
}
|
||||
@ -105,7 +126,18 @@ func (f *File) Upload(req *dci.GetUploadUrlRequest) (res *dci.GetUploadUrlRespon
|
||||
fmt.Println("====== =========== =================== 3 ===============")
|
||||
code, result := utils.PutFromFileUrlWithStream(res.Url, fileName, req.FileName)
|
||||
if code != 200 {
|
||||
return res, errCommon.ReturnError(errors.New(result), result, "上传文件 错误:")
|
||||
err = errCommon.ReturnError(errors.New(result), result, "上传文件 错误:")
|
||||
//fileInfo.IsUpload = 3 // 上传失败
|
||||
} else {
|
||||
errCommon.NoReturnInfo(result, "上传文件 最终结果:")
|
||||
//fileInfo.IsUpload = 2 // 上传成功
|
||||
}
|
||||
return
|
||||
/*fileInfo.ReqMsgId = res.ReqMsgId
|
||||
fileInfo.ResultCode = res.ResultCode
|
||||
fileInfo.ResultMsg = res.ResultMsg
|
||||
fileInfo.Url = res.Url
|
||||
fileInfo.FileId = res.FileId
|
||||
_ = dao.UpdateFileInfo(nil, fileInfo)*/
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
25
internal/model/file.go
Normal file
25
internal/model/file.go
Normal file
@ -0,0 +1,25 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type FileInfo struct {
|
||||
gorm.Model
|
||||
// 请求唯一ID,用于链路跟踪和问题排查
|
||||
ReqMsgId string `json:"req_msg_id,omitempty" gorm:"req_msg_id"`
|
||||
// 结果码,一般OK表示调用成功
|
||||
ResultCode string `json:"result_code,omitempty" gorm:"result_code"`
|
||||
// 异常信息的文本描述
|
||||
ResultMsg string `json:"result_msg,omitempty" gorm:"result_msg"`
|
||||
// 授权访问oss链接
|
||||
Url string `json:"url,omitempty" gorm:"column:url;type:varchar(4096)"`
|
||||
// OSS 文件id
|
||||
FileId string `json:"file_id,omitempty" gorm:"file_id"`
|
||||
// 文件链接
|
||||
FileUrl string `json:"file_url,omitempty" gorm:"column:file_url;type:varchar(4096)"`
|
||||
// 真实文件是否上传
|
||||
IsUpload int `json:"is_upload" gorm:"column:is_upload;type:int;default:1"`
|
||||
}
|
||||
|
||||
func (f *FileInfo) GetTableName() string {
|
||||
return "file_info"
|
||||
}
|
@ -1 +0,0 @@
|
||||
package model
|
@ -1 +0,0 @@
|
||||
package serializer
|
@ -1,17 +0,0 @@
|
||||
package serializer
|
||||
|
||||
import (
|
||||
"chain-dci/pb/dci"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
bccrClient "github.com/antchain-openapi-sdk-go/bccr/client"
|
||||
)
|
||||
|
||||
func UploadUrlResponseToRpc(in *bccrClient.GetUploadurlResponse) (out *dci.GetUploadUrlResponse) {
|
||||
out = new(dci.GetUploadUrlResponse)
|
||||
out.ReqMsgId = tea.ToString(in.ReqMsgId)
|
||||
out.ResultMsg = tea.ToString(in.ResultMsg)
|
||||
out.ResultCode = tea.ToString(in.ResultCode)
|
||||
out.Url = tea.ToString(in.Url)
|
||||
out.FileId = tea.ToString(in.FileId)
|
||||
return
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
// - protoc v3.21.4
|
||||
// source: pb/dci.proto
|
||||
|
||||
package grpc
|
||||
package dci
|
||||
|
||||
import (
|
||||
context "context"
|
@ -4,7 +4,7 @@
|
||||
// - protoc v3.21.4
|
||||
// source: pb/dci.proto
|
||||
|
||||
package dci
|
||||
package grpc
|
||||
|
||||
import (
|
||||
context "context"
|
@ -13,7 +13,7 @@ type App struct {
|
||||
Lg *zap.Logger
|
||||
//RedisClient *redis.Client
|
||||
JaegerTracer *tracing.JaegerProvider
|
||||
//DbMeeting *gorm.DB
|
||||
//DciDB *gorm.DB
|
||||
SfNode *snowflake.Node
|
||||
BccrClient *bccrClient.Client
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
dciConfig "chain-dci/config"
|
||||
"github.com/google/wire"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var DciProvider = wire.NewSet(NewDci)
|
||||
|
||||
func NewDci() *gorm.DB {
|
||||
//connOaMeeting := strings.Join([]string{dciConfig.Data.ChainDci.User, ":", dciConfig.Data.ChainDci.Password,
|
||||
// "@tcp(", dciConfig.Data.ChainDci.Host, ":", dciConfig.Data.ChainDci.Port, ")/",
|
||||
// dciConfig.Data.ChainDci.DbName, "?charset=utf8mb4&parseTime=true"}, "")
|
||||
//DbOaMeeting := loadMysqlConn(connOaMeeting)
|
||||
return nil
|
||||
connDci := strings.Join([]string{dciConfig.Data.ChainDci.User, ":", dciConfig.Data.ChainDci.Password,
|
||||
"@tcp(", dciConfig.Data.ChainDci.Host, ":", dciConfig.Data.ChainDci.Port, ")/",
|
||||
dciConfig.Data.ChainDci.DbName, "?charset=utf8mb4&parseTime=true"}, "")
|
||||
DciDB := loadMysqlConn(connDci)
|
||||
return DciDB
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"chain-dci/internal/model"
|
||||
"chain-dci/pkg/app"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
@ -37,12 +39,15 @@ func loadMysqlConn(conn string) *gorm.DB {
|
||||
sqlDB.SetMaxIdleConns(20) //设置连接池,空闲
|
||||
sqlDB.SetMaxOpenConns(100) //打开
|
||||
sqlDB.SetConnMaxLifetime(time.Second * 30)
|
||||
err = db.AutoMigrate(&model.FileInfo{})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func DBMigration() {
|
||||
//addColumn(&model_account.Users{}, "action_code")
|
||||
|
||||
_ = app.ModuleClients.DciDB.AutoMigrate(&model.FileInfo{})
|
||||
}
|
||||
|
||||
func addColumn(dst interface{}, column string) {
|
||||
|
@ -26,3 +26,9 @@ func NoReturnError(err error, print string) {
|
||||
fmt.Printf(print+"%+v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func NoReturnInfo(info interface{}, print string) {
|
||||
field := zap.Field{}
|
||||
field.String = fmt.Sprintf("%+v", info)
|
||||
app.ModuleClients.Lg.Info(print, field)
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package err
|
||||
|
||||
var FileType = map[string]string{
|
||||
"TEXT": "文本(限制pdf类型)(限制文件大小10M)",
|
||||
"IMAGE": "图片(限制jpg、jpeg、png类型)(限制文件大小5M)",
|
||||
"IMAGE": "图片(限制jpg、jpeg、png类型)(限制文件大小5M)(图片像素不低于400x400,不高于5000x5000)",
|
||||
"AUDIO": "音频(限制mp3、wav类型)(限制文件大小50M)",
|
||||
"VIDEO": "视频(限制mp4、avi、wmv类型)(限制文件大小200M)",
|
||||
"PDF_IMAGE": "系列图(限制pdf类型)(限制文件大小10M)(限制子图数量2-30)",
|
||||
|
@ -1,6 +1,18 @@
|
||||
package msg
|
||||
|
||||
const (
|
||||
ErrFileIsEmpty = "未获取到相关文件"
|
||||
ErrCreateClientToken = "创建clientToken失败"
|
||||
ErrFileIsEmpty = "未获取到相关文件"
|
||||
ErrCreateClientToken = "创建clientToken失败"
|
||||
ErrAddDciUser = "著作权人申领DCI信息失败"
|
||||
ErrUpdateDciUser = "著作权人更新DCI信息失败"
|
||||
ErrQueryDciUser = "著作权人查询DCI信息失败"
|
||||
ErrCreateDciPreregistration = "作品申领DCI失败"
|
||||
ErrQueryDciPreregistration = "作品查询DCI失败"
|
||||
ErrCreateDciRegistration = "发起数登申请失败"
|
||||
ErrQueryDciRegistration = "查询数登申请失败"
|
||||
ErrGetDciPayurl = "数登支付链接获取失败"
|
||||
ErrQueryDciPay = "数登支付查询失败"
|
||||
ErrGetDciRegistrationcert = "获取数登证书下载失败"
|
||||
ErrRetryDciRegistration = "补正申请失败"
|
||||
ErrCloseDciRegistration = "数登停止申请失败"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user