songchuang 代码提交
This commit is contained in:
parent
ee087e77f8
commit
4d45a4c4cc
@ -3,6 +3,7 @@ package controller
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
||||||
"github.com/fonchain/fonchain-artistinfo/pb/artistInfoUser"
|
"github.com/fonchain/fonchain-artistinfo/pb/artistInfoUser"
|
||||||
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
||||||
|
@ -13,47 +13,55 @@ type ContractProvider struct {
|
|||||||
contractLogic *logic.Contract
|
contractLogic *logic.Contract
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ContractProvider) FinishContract(ctx context.Context, req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error) {
|
func (c *ContractProvider) CreateContract(ctx context.Context, req *contract.CreateContractRequest) (rep *contract.CreateContractRespond, err error) {
|
||||||
fmt.Println("第一处")
|
fmt.Println("第一处")
|
||||||
if rep, err = c.contractLogic.FinishContract(req); err != nil {
|
if rep, err = c.contractLogic.CreateContract(req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rep, nil
|
return rep, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ContractProvider) ContractList(ctx context.Context, req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error) {
|
// func (c *ContractProvider) FinishContract(ctx context.Context, req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error) {
|
||||||
fmt.Println("第一处")
|
// fmt.Println("第一处")
|
||||||
if rep, err = c.contractLogic.ContractList(req); err != nil {
|
// if rep, err = c.contractLogic.FinishContract(req); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return rep, nil
|
// return rep, nil
|
||||||
}
|
// }
|
||||||
func (c *ContractProvider) GetContract(ctx context.Context, req *contract.GetContractRequest) (rep *contract.ContractData, err error) {
|
|
||||||
fmt.Println("第一处")
|
|
||||||
if rep, err = c.contractLogic.GetContract(req); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rep, nil
|
|
||||||
}
|
|
||||||
func (c *ContractProvider) ContractTxList(ctx context.Context, req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error) {
|
|
||||||
fmt.Println("第一处")
|
|
||||||
if rep, err = c.contractLogic.ContractTxList(req); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return rep, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ContractProvider) UpdateContract(ctx context.Context, req *contract.UpdateContractRequest) (rep *contract.UpdateContractRespond, err error) {
|
// func (c *ContractProvider) ContractList(ctx context.Context, req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error) {
|
||||||
fmt.Println("第一处")
|
// fmt.Println("第一处")
|
||||||
if rep, err = c.contractLogic.UpdateContract(req); err != nil {
|
// if rep, err = c.contractLogic.ContractList(req); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return rep, nil
|
// return rep, nil
|
||||||
}
|
// }
|
||||||
func (c *ContractProvider) UpdateContractTx(ctx context.Context, req *contract.UpdateContractTxRequest) (rep *contract.UpdateContractTxRespond, err error) {
|
// func (c *ContractProvider) GetContract(ctx context.Context, req *contract.GetContractRequest) (rep *contract.ContractData, err error) {
|
||||||
fmt.Println("第一处")
|
// fmt.Println("第一处")
|
||||||
if rep, err = c.contractLogic.UpdateContractTx(req); err != nil {
|
// if rep, err = c.contractLogic.GetContract(req); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
return rep, nil
|
// return rep, nil
|
||||||
}
|
// }
|
||||||
|
// func (c *ContractProvider) ContractTxList(ctx context.Context, req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error) {
|
||||||
|
// fmt.Println("第一处")
|
||||||
|
// if rep, err = c.contractLogic.ContractTxList(req); err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// return rep, nil
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func (c *ContractProvider) UpdateContract(ctx context.Context, req *contract.UpdateContractRequest) (rep *contract.UpdateContractRespond, err error) {
|
||||||
|
// fmt.Println("第一处")
|
||||||
|
// if rep, err = c.contractLogic.UpdateContract(req); err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// return rep, nil
|
||||||
|
// }
|
||||||
|
// func (c *ContractProvider) UpdateContractTx(ctx context.Context, req *contract.UpdateContractTxRequest) (rep *contract.UpdateContractTxRespond, err error) {
|
||||||
|
// fmt.Println("第一处")
|
||||||
|
// if rep, err = c.contractLogic.UpdateContractTx(req); err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// return rep, nil
|
||||||
|
// }
|
||||||
|
@ -2,195 +2,275 @@ package dao
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
||||||
"github.com/fonchain/fonchain-artistinfo/pb/contract"
|
|
||||||
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
||||||
"github.com/fonchain/fonchain-artistinfo/pkg/m"
|
"github.com/fonchain/fonchain-artistinfo/pkg/m"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FinishContract(id string) (err error) {
|
func GetMgmtContractByArtistUid(artistUid string, contractType int32) (err error) {
|
||||||
var contracts model.Contract
|
var contract model.Contract
|
||||||
if err = db.DB.Where("transaction_id = ?", id).First(&contracts).Error; err != nil {
|
if err = db.DB.Where("artist_uid = ? AND type = ?", artistUid, contractType).First(&contract).Error; err != nil && err != gorm.ErrRecordNotFound {
|
||||||
zap.L().Error("get contract info err", zap.Error(err))
|
zap.L().Error("get contract info err", zap.Error(err))
|
||||||
err = errors.New(m.ERROR_SELECT)
|
err = errors.New(m.ERROR_SELECT)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = db.DB.Model(&contracts).Update("state", 3).Error; err != nil {
|
|
||||||
zap.L().Error("user contract failed", zap.Error(err))
|
|
||||||
err = errors.New(m.UPDATE_FAILED)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error) {
|
func CreateArtistContract(tx *gorm.DB, contract *model.Contract) (err error) {
|
||||||
rep = &contract.ContractListRespond{}
|
if err = tx.Create(contract).Error; err != nil {
|
||||||
var Data []*contract.ContractData
|
zap.L().Error("create contract err", zap.Error(err))
|
||||||
|
err = errors.New(m.CREATE_ERROR)
|
||||||
var user model.User
|
|
||||||
if err = db.DB.Where("id = ? ", int32(req.ID)).First(&user).Error; err != nil {
|
|
||||||
zap.L().Error("get user info err", zap.Error(err))
|
|
||||||
err = errors.New(m.ERROR_SELECT)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo
|
|
||||||
//var realName model.RealName
|
|
||||||
//if err = db.DB.Where("id = ? ", user.RealNameID).First(&realName).Error; err != nil {
|
|
||||||
// zap.L().Error("get realName info err", zap.Error(err))
|
|
||||||
// err = errors.New(m.ERROR_SELECT)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
var args []interface{}
|
|
||||||
var sqlWhere = "user_id = ? and type !=4 "
|
|
||||||
args = append(args, req.ID)
|
|
||||||
|
|
||||||
if req.State != 0 {
|
|
||||||
sqlWhere += " and state = ? "
|
|
||||||
if req.State == 2 {
|
|
||||||
req.State = 3
|
|
||||||
}
|
|
||||||
args = append(args, req.State)
|
|
||||||
}
|
|
||||||
|
|
||||||
var contractModel []model.Contract
|
|
||||||
if err = db.DB.Where(sqlWhere, args...).Find(&contractModel).Error; err != nil {
|
|
||||||
zap.L().Error("get contractModels info err", zap.Error(err))
|
|
||||||
err = errors.New(m.ERROR_SELECT)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range contractModel {
|
|
||||||
contract := &contract.ContractData{}
|
|
||||||
contract.ID = uint64(v.ID)
|
|
||||||
contract.ContractId = v.ContractId
|
|
||||||
contract.DownloadUrl = v.DownloadUrl
|
|
||||||
contract.MgmtUserId = v.MgmtUserId
|
|
||||||
contract.State = int64(v.State)
|
|
||||||
contract.TransactionId = v.TransactionId
|
|
||||||
contract.Type = int64(v.Type)
|
|
||||||
contract.UserId = int64(v.UserId)
|
|
||||||
contract.ViewUrl = v.ViewUrl
|
|
||||||
contract.ExpirationTime = v.CreatedAt.Add(86400 * time.Second).Format("2006-01-02 15:04:05")
|
|
||||||
contract.SignTime = v.UpdatedAt.Format("2006-01-02")
|
|
||||||
Data = append(Data, contract)
|
|
||||||
}
|
|
||||||
|
|
||||||
rep.Data = Data
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func ContractTxList(req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error) {
|
func GetMgmtContractByArtworkUid(artworkUid string, artworkType int32) (err error) {
|
||||||
rep = &contract.ContractTxListRespond{}
|
//画作有合同类型是2,6的都是 点击过"著作权代理转让服务合同"的
|
||||||
var Data []*contract.ContractData
|
var contract model.Contract
|
||||||
|
if err = db.DB.Where("artwork_uid = ? AND type = ?", artworkUid, 2).First(&contract).Error; err != nil && err != gorm.ErrRecordNotFound {
|
||||||
var user model.User
|
|
||||||
if err = db.DB.Where("id = ? ", int32(req.ID)).First(&user).Error; err != nil {
|
|
||||||
zap.L().Error("get user info err", zap.Error(err))
|
|
||||||
err = errors.New(m.ERROR_SELECT)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// todo
|
|
||||||
//var realName model.RealName
|
|
||||||
//if err = db.DB.Where("id = ? ", user.RealNameID).First(&realName).Error; err != nil {
|
|
||||||
// zap.L().Error("get realName info err", zap.Error(err))
|
|
||||||
// err = errors.New(m.ERROR_SELECT)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//var args []interface{}
|
|
||||||
//var sqlWhere = " card_id = ? and (type = 4 or type = 7) "
|
|
||||||
//args = append(args, realName.IDNum)
|
|
||||||
//if req.State != 0 {
|
|
||||||
// sqlWhere += " and state = ? "
|
|
||||||
// args = append(args, req.State)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//var contractModel []model.Contract
|
|
||||||
//if err = db.DB.Where(sqlWhere, args...).Find(&contractModel).Error; err != nil {
|
|
||||||
// zap.L().Error("get contractModels info err", zap.Error(err))
|
|
||||||
// err = errors.New(m.ERROR_SELECT)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//for _, v := range contractModel {
|
|
||||||
// contractTmp := &contract.ContractData{}
|
|
||||||
// contractTmp.ID = uint64(v.ID)
|
|
||||||
// contractTmp.ContractId = v.ContractId
|
|
||||||
// contractTmp.DownloadUrl = v.DownloadUrl
|
|
||||||
// contractTmp.MgmtUserId = v.MgmtUserId
|
|
||||||
// contractTmp.State = int64(v.State)
|
|
||||||
// contractTmp.TransactionId = v.TransactionId
|
|
||||||
// contractTmp.Type = int64(v.Type)
|
|
||||||
// var b string
|
|
||||||
// if v.Type == 4 {
|
|
||||||
// b = "物权"
|
|
||||||
// }
|
|
||||||
// if v.Type == 7 {
|
|
||||||
// b = "版权"
|
|
||||||
// }
|
|
||||||
// contractTmp.BatchName = b + v.BatchName[0:4] + "年" + v.BatchName[4:6] + "月" + v.BatchName[6:11] + "年" + v.BatchName[11:13] + "月"
|
|
||||||
// contractTmp.UserId = int64(v.UserId)
|
|
||||||
// contractTmp.ViewUrl = v.ViewUrl
|
|
||||||
// contractTmp.ExpirationTime = v.CreatedAt.Add(86400 * time.Second).Format("2006-01-02 15:04:05")
|
|
||||||
// contractTmp.SignTime = v.UpdatedAt.Format("2006-01-02")
|
|
||||||
// Data = append(Data, contractTmp)
|
|
||||||
//}
|
|
||||||
|
|
||||||
rep.Data = Data
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetContract(id int32) (rep *contract.ContractData, err error) {
|
|
||||||
var con model.Contract
|
|
||||||
if err = db.DB.Where("id = ? ", id).First(&con).Error; err != nil {
|
|
||||||
zap.L().Error("get contract info err", zap.Error(err))
|
zap.L().Error("get contract info err", zap.Error(err))
|
||||||
err = errors.New(m.ERROR_SELECT)
|
err = errors.New(m.ERROR_SELECT)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rep.ID = uint64(con.ID)
|
return
|
||||||
rep.UserId = int64(con.UserId)
|
}
|
||||||
rep.CardId = con.CardId
|
|
||||||
rep.MgmtUserId = con.MgmtUserId
|
func CreateArtworkContract(tx *gorm.DB, artworkUid string, artistUid string, contractType int32) (err error) {
|
||||||
rep.ArtworkId = con.ArtworkId
|
var uid uuid.UUID
|
||||||
rep.ContractId = con.ContractId
|
if uid, err = uuid.NewV4(); err != nil {
|
||||||
rep.TransactionId = con.TransactionId
|
err = errors.New(m.ERROR_UID)
|
||||||
rep.Type = int64(con.Type)
|
return
|
||||||
rep.BatchName = con.BatchName
|
}
|
||||||
rep.ViewUrl = con.ViewUrl
|
|
||||||
rep.DownloadUrl = con.DownloadUrl
|
contract := &model.Contract{
|
||||||
rep.State = int64(con.State)
|
Uid: uid.String(),
|
||||||
|
ArtistUid: artistUid,
|
||||||
|
ArtworkUid: artworkUid,
|
||||||
|
Type: contractType,
|
||||||
|
State: 1,
|
||||||
|
}
|
||||||
|
if err = tx.Create(contract).Error; err != nil {
|
||||||
|
zap.L().Error("create contract err", zap.Error(err))
|
||||||
|
err = errors.New(m.CREATE_ERROR)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新交易id
|
// func FinishContract(tx *gorm.DB, id string) (contract model.Contract, err error) {
|
||||||
func UpdateContract(req *contract.UpdateContractRequest) error {
|
// if err = tx.Where("transaction_id = ?", id).First(&contract).Error; err != nil {
|
||||||
//数据库操作异常
|
// zap.L().Error("get contract info err", zap.Error(err))
|
||||||
var con model.Contract
|
// err = errors.New(m.ERROR_SELECT)
|
||||||
if err := db.DB.Model(&con).Updates(&model.Contract{ContractId: req.ContractId, ViewUrl: req.ViewUrl, DownloadUrl: req.DownloadUrl}).Error; err != nil {
|
// return
|
||||||
return err
|
// }
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新交易id
|
// if err = db.DB.Model(&contract).Update("state", 3).Error; err != nil {
|
||||||
func UpdateContractTx(txId string, contractId int32) (err error) {
|
// zap.L().Error("user contract failed", zap.Error(err))
|
||||||
var con model.Contract
|
// err = errors.New(m.UPDATE_FAILED)
|
||||||
con.ID = contractId
|
// return
|
||||||
if err = db.DB.Model(&con).Update("transaction_id", txId).Error; err != nil {
|
// }
|
||||||
return
|
|
||||||
}
|
// return
|
||||||
if err = db.DB.Model(&con).Update("state", 1).Error; err != nil {
|
// }
|
||||||
return
|
|
||||||
}
|
// func UpdateArtworkState(tx *gorm.DB, id int32) (err error) { //无用
|
||||||
return
|
// var artworkState model.ArtworkState
|
||||||
}
|
// if err = tx.Where("artwork_id = ? and state = ? ", id, 7).First(&artworkState).Error; err != nil {
|
||||||
|
// if err == gorm.ErrRecordNotFound {
|
||||||
|
// artworkState.ArtworkId = id
|
||||||
|
// artworkState.State = 7
|
||||||
|
// if err = tx.Create(&artworkState).Error; err != nil {
|
||||||
|
// zap.L().Error("create artworkState err", zap.Error(err))
|
||||||
|
// err = errors.New(m.CREATE_ERROR)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// zap.L().Error("find artworkState info err", zap.Error(err))
|
||||||
|
// err = errors.New(m.ERROR_DATA_NOT_EXISTS)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if err = tx.Model(&model.Artwork{}).Where("id = ? ", id).Update("flow_state", 7).Error; err != nil {
|
||||||
|
// zap.L().Error("Artwork Update Err", zap.Error(err))
|
||||||
|
// err = errors.New(m.ERROR_DATA_NOT_EXISTS)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error) {
|
||||||
|
// rep = &contract.ContractListRespond{}
|
||||||
|
// var Data []*contract.ContractData
|
||||||
|
|
||||||
|
// var user model.User
|
||||||
|
// if err = db.DB.Where("id = ? ", req.ID).First(&user).Error; err != nil {
|
||||||
|
// zap.L().Error("get user info err", zap.Error(err))
|
||||||
|
// err = errors.New(m.ERROR_SELECT)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var realName model.RealName
|
||||||
|
// if err = db.DB.Where("id = ? ", user.RealNameId).First(&realName).Error; err != nil {
|
||||||
|
// zap.L().Error("get realName info err", zap.Error(err))
|
||||||
|
// err = errors.New(m.ERROR_SELECT)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var args []interface{}
|
||||||
|
// var sqlWhere = "user_id = ? and type !=4 "
|
||||||
|
// args = append(args, req.ID)
|
||||||
|
|
||||||
|
// if req.State != 0 {
|
||||||
|
// sqlWhere += " and state = ? "
|
||||||
|
// if req.State == 2 {
|
||||||
|
// req.State = 3
|
||||||
|
// }
|
||||||
|
// args = append(args, req.State)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var contractModel []model.Contract
|
||||||
|
// if err = db.DB.Where(sqlWhere, args...).Find(&contractModel).Error; err != nil {
|
||||||
|
// zap.L().Error("get contractModels info err", zap.Error(err))
|
||||||
|
// err = errors.New(m.ERROR_SELECT)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for _, v := range contractModel {
|
||||||
|
// contract := &contract.ContractData{}
|
||||||
|
// contract.ID = uint64(v.ID)
|
||||||
|
// contract.ContractId = v.ContractId
|
||||||
|
// contract.DownloadUrl = v.DownloadUrl
|
||||||
|
// contract.MgmtUserId = v.MgmtUserId
|
||||||
|
// contract.State = int64(v.State)
|
||||||
|
// contract.TransactionId = v.TransactionId
|
||||||
|
// contract.Type = int64(v.Type)
|
||||||
|
// contract.UserId = int64(v.UserId)
|
||||||
|
// contract.ViewUrl = v.ViewUrl
|
||||||
|
// contract.ExpirationTime = v.CreatedAt.Add(86400 * time.Second).Format("2006-01-02 15:04:05")
|
||||||
|
// contract.SignTime = v.UpdatedAt.Format("2006-01-02")
|
||||||
|
// Data = append(Data, contract)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// rep.Data = Data
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func ContractTxList(req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error) {
|
||||||
|
// rep = &contract.ContractTxListRespond{}
|
||||||
|
// var Data []*contract.ContractData
|
||||||
|
|
||||||
|
// var user model.User
|
||||||
|
// if err = db.DB.Where("id = ? ", int32(req.ID)).First(&user).Error; err != nil {
|
||||||
|
// zap.L().Error("get user info err", zap.Error(err))
|
||||||
|
// err = errors.New(m.ERROR_SELECT)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// // todo
|
||||||
|
// //var realName model.RealName
|
||||||
|
// //if err = db.DB.Where("id = ? ", user.RealNameID).First(&realName).Error; err != nil {
|
||||||
|
// // zap.L().Error("get realName info err", zap.Error(err))
|
||||||
|
// // err = errors.New(m.ERROR_SELECT)
|
||||||
|
// // return
|
||||||
|
// //}
|
||||||
|
// //
|
||||||
|
// //var args []interface{}
|
||||||
|
// //var sqlWhere = " card_id = ? and (type = 4 or type = 7) "
|
||||||
|
// //args = append(args, realName.IDNum)
|
||||||
|
// //if req.State != 0 {
|
||||||
|
// // sqlWhere += " and state = ? "
|
||||||
|
// // args = append(args, req.State)
|
||||||
|
// //}
|
||||||
|
// //
|
||||||
|
// //var contractModel []model.Contract
|
||||||
|
// //if err = db.DB.Where(sqlWhere, args...).Find(&contractModel).Error; err != nil {
|
||||||
|
// // zap.L().Error("get contractModels info err", zap.Error(err))
|
||||||
|
// // err = errors.New(m.ERROR_SELECT)
|
||||||
|
// // return
|
||||||
|
// //}
|
||||||
|
// //
|
||||||
|
// //for _, v := range contractModel {
|
||||||
|
// // contractTmp := &contract.ContractData{}
|
||||||
|
// // contractTmp.ID = uint64(v.ID)
|
||||||
|
// // contractTmp.ContractId = v.ContractId
|
||||||
|
// // contractTmp.DownloadUrl = v.DownloadUrl
|
||||||
|
// // contractTmp.MgmtUserId = v.MgmtUserId
|
||||||
|
// // contractTmp.State = int64(v.State)
|
||||||
|
// // contractTmp.TransactionId = v.TransactionId
|
||||||
|
// // contractTmp.Type = int64(v.Type)
|
||||||
|
// // var b string
|
||||||
|
// // if v.Type == 4 {
|
||||||
|
// // b = "物权"
|
||||||
|
// // }
|
||||||
|
// // if v.Type == 7 {
|
||||||
|
// // b = "版权"
|
||||||
|
// // }
|
||||||
|
// // contractTmp.BatchName = b + v.BatchName[0:4] + "年" + v.BatchName[4:6] + "月" + v.BatchName[6:11] + "年" + v.BatchName[11:13] + "月"
|
||||||
|
// // contractTmp.UserId = int64(v.UserId)
|
||||||
|
// // contractTmp.ViewUrl = v.ViewUrl
|
||||||
|
// // contractTmp.ExpirationTime = v.CreatedAt.Add(86400 * time.Second).Format("2006-01-02 15:04:05")
|
||||||
|
// // contractTmp.SignTime = v.UpdatedAt.Format("2006-01-02")
|
||||||
|
// // Data = append(Data, contractTmp)
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// rep.Data = Data
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func GetContract(id int32) (rep *contract.ContractData, err error) {
|
||||||
|
// var con model.Contract
|
||||||
|
// if err = db.DB.Where("id = ? ", id).First(&con).Error; err != nil {
|
||||||
|
// zap.L().Error("get contract info err", zap.Error(err))
|
||||||
|
// err = errors.New(m.ERROR_SELECT)
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// rep.ID = uint64(con.ID)
|
||||||
|
// rep.UserId = int64(con.UserId)
|
||||||
|
// rep.CardId = con.CardId
|
||||||
|
// rep.MgmtUserId = con.MgmtUserId
|
||||||
|
// rep.ArtworkId = con.ArtworkId
|
||||||
|
// rep.ContractId = con.ContractId
|
||||||
|
// rep.TransactionId = con.TransactionId
|
||||||
|
// rep.Type = int64(con.Type)
|
||||||
|
// rep.BatchName = con.BatchName
|
||||||
|
// rep.ViewUrl = con.ViewUrl
|
||||||
|
// rep.DownloadUrl = con.DownloadUrl
|
||||||
|
// rep.State = int64(con.State)
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 更新交易id
|
||||||
|
// func UpdateContract(req *contract.UpdateContractRequest) error {
|
||||||
|
// //数据库操作异常
|
||||||
|
// var con model.Contract
|
||||||
|
// if err := db.DB.Model(&con).Updates(&model.Contract{ContractId: req.ContractId, ViewUrl: req.ViewUrl, DownloadUrl: req.DownloadUrl}).Error; err != nil {
|
||||||
|
// //在线和下载的链接
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 更新交易id
|
||||||
|
// func UpdateContractTx(txId string, contractId int32) (err error) {
|
||||||
|
// var con model.Contract
|
||||||
|
// con.ID = contractId
|
||||||
|
// if err = db.DB.Model(&con).Update("transaction_id", txId).Error; err != nil { //改变交易id
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// if err = db.DB.Model(&con).Update("state", 1).Error; err != nil { //更新合约状态 // 1:待生成 2 待签署 3 签署完成
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
@ -1,11 +1,23 @@
|
|||||||
package logic
|
package logic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/fonchain/fonchain-artistinfo/cmd/internal/dao"
|
"github.com/fonchain/fonchain-artistinfo/cmd/internal/dao"
|
||||||
|
"github.com/fonchain/fonchain-artistinfo/cmd/model"
|
||||||
|
"github.com/fonchain/fonchain-artistinfo/pb/artist"
|
||||||
"github.com/fonchain/fonchain-artistinfo/pb/contract"
|
"github.com/fonchain/fonchain-artistinfo/pb/contract"
|
||||||
|
db "github.com/fonchain/fonchain-artistinfo/pkg/db"
|
||||||
|
"github.com/fonchain/fonchain-artistinfo/pkg/m"
|
||||||
|
"github.com/fonchain/fonchain-artistinfo/pkg/service"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IContract interface {
|
type IContract interface {
|
||||||
|
CreateContract(req *contract.CreateContractRequest) (rep *contract.CreateContractRespond, err error)
|
||||||
FinishContract(req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error)
|
FinishContract(req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error)
|
||||||
ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error)
|
ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error)
|
||||||
ContractTxList(req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error)
|
ContractTxList(req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error)
|
||||||
@ -21,47 +33,157 @@ func NewContract() IContract {
|
|||||||
type Contract struct {
|
type Contract struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Contract) FinishContract(req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error) {
|
func (a *Contract) CreateContract(req *contract.CreateContractRequest) (rep *contract.CreateContractRespond, err error) {
|
||||||
rep = &contract.FinishContractRespond{}
|
rep = &contract.CreateContractRespond{}
|
||||||
|
//查看画家是否存在
|
||||||
err = dao.FinishContract(req.TransactionId)
|
if _, err := service.GrpcArtistImpl.ArtistInfo(context.Background(), &artist.ArtistInfoRequest{Uid: req.ArtistUid}); err != nil {
|
||||||
if err != nil {
|
zap.L().Error("update airDrop err", zap.Error(err))
|
||||||
return nil, err
|
return rep, errors.New(m.ERROR_UPDATE + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//遇到错误数据库回滚
|
||||||
|
tx := db.DB.Begin()
|
||||||
|
|
||||||
|
switch req.Type {
|
||||||
|
//1 画家合同(不涉及画家的画作)
|
||||||
|
case 1:
|
||||||
|
|
||||||
|
//查看画家合同是否已经存在,不存在继续
|
||||||
|
if err = dao.GetMgmtContractByArtistUid(req.ArtistUid, req.Type); err == gorm.ErrRecordNotFound {
|
||||||
|
var uid uuid.UUID
|
||||||
|
if uid, err = uuid.NewV4(); err != nil {
|
||||||
|
err = errors.New(m.ERROR_UID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建画家合同
|
||||||
|
contract := &model.Contract{
|
||||||
|
Uid: uid.String(),
|
||||||
|
ArtistUid: req.ArtistUid,
|
||||||
|
Type: 1,
|
||||||
|
State: 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = dao.CreateArtistContract(tx, contract); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
for _, v := range req.ArtworkUid {
|
||||||
|
//查看画作合同是否已经存在,不存在继续,类型2、6
|
||||||
|
if err = dao.GetMgmtContractByArtworkUid(v, 2); err == gorm.ErrRecordNotFound {
|
||||||
|
if err = dao.GetMgmtContractByArtworkUid(v, 6); err == gorm.ErrRecordNotFound {
|
||||||
|
|
||||||
|
//创建画家画作合同,类型2
|
||||||
|
if err = dao.CreateArtworkContract(tx, v, req.ArtistUid, 2); err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建画家画作合同,类型6
|
||||||
|
if err = dao.CreateArtworkContract(tx, v, req.ArtistUid, 6); err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
|
||||||
|
default:
|
||||||
|
err = errors.New("type值出错!")
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
tx.Commit()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Contract) ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error) {
|
// func (a *Contract) FinishContract(req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error) {
|
||||||
|
// rep = &contract.FinishContractRespond{}
|
||||||
|
|
||||||
rep, err = dao.ContractList(req)
|
// tx := db.DB.Begin()
|
||||||
|
// //更新合同状态并获取合同信息
|
||||||
|
// contract, err := dao.FinishContract(tx, req.TransactionId)
|
||||||
|
// if err != nil {
|
||||||
|
// tx.Rollback()
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
|
||||||
return
|
// //查看画作是否已经状态改变,没有则改变 无用
|
||||||
}
|
// if err = dao.UpdateArtworkState(tx, contract.ID); err != nil {
|
||||||
|
// tx.Rollback()
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
func (a *Contract) GetContract(req *contract.GetContractRequest) (rep *contract.ContractData, err error) {
|
// var tmp struct {
|
||||||
|
// Uid int32 `json:"uid"`
|
||||||
|
// }
|
||||||
|
// tmp.Uid = contract.BatchId
|
||||||
|
// tmpByte, _ := json.Marshal(&tmp)
|
||||||
|
|
||||||
rep, err = dao.GetContract(int32(req.Id))
|
// if contract.Type == 4 {
|
||||||
|
// _, err = util.Post("https://ms.fontree.cn/mgmt/artworktx/updatebatchtype", string(tmpByte))
|
||||||
|
// if err != nil {
|
||||||
|
// zap.L().Error("post request err", zap.Error(err))
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
return
|
// if contract.Type == 7 {
|
||||||
}
|
// _, err = util.Post("https://ms.fontree.cn/mgmt/artworktx/updatebatchtypecopy", string(tmpByte))
|
||||||
func (a *Contract) ContractTxList(req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error) {
|
// if err != nil {
|
||||||
|
// zap.L().Error("post request err", zap.Error(err))
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
rep, err = dao.ContractTxList(req)
|
// tx.Commit()
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
return
|
// func (a *Contract) ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error) {
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Contract) UpdateContract(req *contract.UpdateContractRequest) (rep *contract.UpdateContractRespond, err error) {
|
// rep, err = dao.ContractList(req)
|
||||||
rep = &contract.UpdateContractRespond{}
|
|
||||||
err = dao.UpdateContract(req)
|
|
||||||
|
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (a *Contract) UpdateContractTx(req *contract.UpdateContractTxRequest) (rep *contract.UpdateContractTxRespond, err error) {
|
// func (a *Contract) GetContract(req *contract.GetContractRequest) (rep *contract.ContractData, err error) {
|
||||||
rep = &contract.UpdateContractTxRespond{}
|
|
||||||
err = dao.UpdateContractTx(req.TransactionId, int32(req.ID))
|
|
||||||
|
|
||||||
return
|
// rep, err = dao.GetContract(int32(req.Id))
|
||||||
}
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// func (a *Contract) ContractTxList(req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error) {
|
||||||
|
|
||||||
|
// rep, err = dao.ContractTxList(req)
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func (a *Contract) UpdateContract(req *contract.UpdateContractRequest) (rep *contract.UpdateContractRespond, err error) {
|
||||||
|
// rep = &contract.UpdateContractRespond{}
|
||||||
|
// err = dao.UpdateContract(req)
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func (a *Contract) UpdateContractTx(req *contract.UpdateContractTxRequest) (rep *contract.UpdateContractTxRespond, err error) {
|
||||||
|
// rep = &contract.UpdateContractTxRespond{}
|
||||||
|
// err = dao.UpdateContractTx(req.TransactionId, int32(req.ID))
|
||||||
|
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
|
import "gorm.io/plugin/soft_delete"
|
||||||
|
|
||||||
// Contract 用户模型
|
// Contract 用户模型
|
||||||
type Contract struct {
|
type Contract struct {
|
||||||
Model
|
ID int32 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"`
|
||||||
ID int32 `gorm:"not null"`
|
Uid string `gorm:"column:uid;type:varchar(100);comment:合同表的唯一表示;NOT NULL" json:"uid"`
|
||||||
UserId int32 `gorm:"not null"`
|
ArtistUid string `gorm:"column:artist_uid;type:varchar(100);comment:画家uid;NOT NULL" json:"artist_uid"`
|
||||||
CardId string `gorm:"type:varchar(256) default ''"`
|
ArtworkUid string `gorm:"column:artwork_uid;type:varchar(100);comment:画作uid" json:"artwork_uid"`
|
||||||
MgmtUserId string `gorm:"not null"`
|
ContractId string `gorm:"column:contract_id;type:varchar(100);comment:合同id" json:"contract_id"`
|
||||||
ArtworkId string `gorm:"type:varchar(256) default ''"`
|
TransactionId string `gorm:"column:transaction_id;type:varchar(100);comment:交易id" json:"transaction_id"`
|
||||||
ContractId string `gorm:"type:varchar(256) default ''"`
|
Type int32 `gorm:"column:type;type:int(1);comment:合同类型;NOT NULL" json:"type"`
|
||||||
TransactionId string `gorm:"type:varchar(256) default '' "`
|
ViewUrl string `gorm:"column:view_url;type:varchar(500);comment:在线查看合同链接" json:"view_url"`
|
||||||
Type int32 `gorm:"not null"`
|
DownloadUrl string `gorm:"column:download_url;type:varchar(500);comment:合同下载链接" json:"download_url"`
|
||||||
BatchId int32 `gorm:"not null"`
|
State int32 `gorm:"column:state;type:int(1);comment:合同状态;NOT NULL" json:"state"`
|
||||||
BatchName string `gorm:"type:varchar(256) default '' "`
|
CreatedAt int32 `gorm:"column:created_at;autoCreateTime"`
|
||||||
ViewUrl string `gorm:"type:varchar(256) default ''"`
|
UpdatedAt int32 `gorm:"column:updated_at;autoCreateTime"`
|
||||||
DownloadUrl string `gorm:"type:varchar(256) default ''"`
|
DeletedAt soft_delete.DeletedAt
|
||||||
State int32 `gorm:"not null"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Reply struct {
|
type Reply struct {
|
||||||
|
2
go.mod
2
go.mod
@ -28,6 +28,7 @@ require (
|
|||||||
github.com/golang/protobuf v1.5.2
|
github.com/golang/protobuf v1.5.2
|
||||||
github.com/mwitkow/go-proto-validators v0.3.2
|
github.com/mwitkow/go-proto-validators v0.3.2
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
|
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
|
||||||
go.uber.org/zap v1.21.0
|
go.uber.org/zap v1.21.0
|
||||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
|
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
|
||||||
google.golang.org/protobuf v1.28.1
|
google.golang.org/protobuf v1.28.1
|
||||||
@ -122,7 +123,6 @@ require (
|
|||||||
github.com/prometheus/procfs v0.7.3 // indirect
|
github.com/prometheus/procfs v0.7.3 // indirect
|
||||||
github.com/prometheus/statsd_exporter v0.21.0 // indirect
|
github.com/prometheus/statsd_exporter v0.21.0 // indirect
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
|
|
||||||
github.com/shirou/gopsutil v3.20.11+incompatible // indirect
|
github.com/shirou/gopsutil v3.20.11+incompatible // indirect
|
||||||
github.com/shirou/gopsutil/v3 v3.21.6 // indirect
|
github.com/shirou/gopsutil/v3 v3.21.6 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,8 @@ package Contract;
|
|||||||
option go_package = "./;contract";
|
option go_package = "./;contract";
|
||||||
//$ protoc --proto_path=. --go_out=./api/contract --go-triple_out=./api/contract ./api/contract/contract.proto
|
//$ protoc --proto_path=. --go_out=./api/contract --go-triple_out=./api/contract ./api/contract/contract.proto
|
||||||
service Contract {
|
service Contract {
|
||||||
|
|
||||||
|
rpc CreateContract (CreateContractRequest) returns (CreateContractRespond) {}
|
||||||
rpc FinishContract (FinishContractRequest) returns (FinishContractRespond) {}
|
rpc FinishContract (FinishContractRequest) returns (FinishContractRespond) {}
|
||||||
rpc ContractList (ContractListRequest) returns (ContractListRespond) {}
|
rpc ContractList (ContractListRequest) returns (ContractListRespond) {}
|
||||||
rpc GetContract (GetContractRequest) returns (ContractData) {}
|
rpc GetContract (GetContractRequest) returns (ContractData) {}
|
||||||
@ -12,7 +14,15 @@ service Contract {
|
|||||||
rpc UpdateContractTx(UpdateContractTxRequest) returns (UpdateContractTxRespond) {}
|
rpc UpdateContractTx(UpdateContractTxRequest) returns (UpdateContractTxRespond) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message CreateContractRequest {
|
||||||
|
string ArtistUid = 1 [json_name="artist_uid"];
|
||||||
|
repeated string ArtworkUid = 2 [json_name="artwork_uid"];
|
||||||
|
int32 Type = 3 [json_name="type"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateContractRespond{
|
||||||
|
string Msg = 1 [json_name = "msg"];
|
||||||
|
}
|
||||||
|
|
||||||
message FinishContractRequest {
|
message FinishContractRequest {
|
||||||
string TransactionId = 1 [json_name="transactionId"];
|
string TransactionId = 1 [json_name="transactionId"];
|
||||||
|
79
pb/contract/contract.validator.pb.go
Normal file
79
pb/contract/contract.validator.pb.go
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: contract.proto
|
||||||
|
|
||||||
|
package contract
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
math "math"
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
func (this *CreateContractRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *CreateContractRespond) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *FinishContractRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *FinishContractRespond) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *ContractListRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *ContractListRespond) Validate() error {
|
||||||
|
for _, item := range this.Data {
|
||||||
|
if item != nil {
|
||||||
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *ContractData) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *ContractTxListRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *ContractTxListRespond) Validate() error {
|
||||||
|
for _, item := range this.Data {
|
||||||
|
if item != nil {
|
||||||
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *SignContractRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *SignContractRespond) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *GetContractRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *UpdateContractRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *UpdateContractRespond) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *UpdateContractTxRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *UpdateContractTxRespond) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-triple v1.0.5
|
// - protoc-gen-go-triple v1.0.8
|
||||||
// - protoc v3.9.0
|
// - protoc v3.21.8
|
||||||
// source: api/contract/contract.proto
|
// source: contract.proto
|
||||||
|
|
||||||
package contract
|
package contract
|
||||||
|
|
||||||
@ -28,6 +28,7 @@ const _ = grpc_go.SupportPackageIsVersion7
|
|||||||
//
|
//
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
type ContractClient interface {
|
type ContractClient interface {
|
||||||
|
CreateContract(ctx context.Context, in *CreateContractRequest, opts ...grpc_go.CallOption) (*CreateContractRespond, common.ErrorWithAttachment)
|
||||||
FinishContract(ctx context.Context, in *FinishContractRequest, opts ...grpc_go.CallOption) (*FinishContractRespond, common.ErrorWithAttachment)
|
FinishContract(ctx context.Context, in *FinishContractRequest, opts ...grpc_go.CallOption) (*FinishContractRespond, common.ErrorWithAttachment)
|
||||||
ContractList(ctx context.Context, in *ContractListRequest, opts ...grpc_go.CallOption) (*ContractListRespond, common.ErrorWithAttachment)
|
ContractList(ctx context.Context, in *ContractListRequest, opts ...grpc_go.CallOption) (*ContractListRespond, common.ErrorWithAttachment)
|
||||||
GetContract(ctx context.Context, in *GetContractRequest, opts ...grpc_go.CallOption) (*ContractData, common.ErrorWithAttachment)
|
GetContract(ctx context.Context, in *GetContractRequest, opts ...grpc_go.CallOption) (*ContractData, common.ErrorWithAttachment)
|
||||||
@ -42,6 +43,7 @@ type contractClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ContractClientImpl struct {
|
type ContractClientImpl struct {
|
||||||
|
CreateContract func(ctx context.Context, in *CreateContractRequest) (*CreateContractRespond, error)
|
||||||
FinishContract func(ctx context.Context, in *FinishContractRequest) (*FinishContractRespond, error)
|
FinishContract func(ctx context.Context, in *FinishContractRequest) (*FinishContractRespond, error)
|
||||||
ContractList func(ctx context.Context, in *ContractListRequest) (*ContractListRespond, error)
|
ContractList func(ctx context.Context, in *ContractListRequest) (*ContractListRespond, error)
|
||||||
GetContract func(ctx context.Context, in *GetContractRequest) (*ContractData, error)
|
GetContract func(ctx context.Context, in *GetContractRequest) (*ContractData, error)
|
||||||
@ -63,6 +65,12 @@ func NewContractClient(cc *triple.TripleConn) ContractClient {
|
|||||||
return &contractClient{cc}
|
return &contractClient{cc}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *contractClient) CreateContract(ctx context.Context, in *CreateContractRequest, opts ...grpc_go.CallOption) (*CreateContractRespond, common.ErrorWithAttachment) {
|
||||||
|
out := new(CreateContractRespond)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CreateContract", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *contractClient) FinishContract(ctx context.Context, in *FinishContractRequest, opts ...grpc_go.CallOption) (*FinishContractRespond, common.ErrorWithAttachment) {
|
func (c *contractClient) FinishContract(ctx context.Context, in *FinishContractRequest, opts ...grpc_go.CallOption) (*FinishContractRespond, common.ErrorWithAttachment) {
|
||||||
out := new(FinishContractRespond)
|
out := new(FinishContractRespond)
|
||||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
@ -109,6 +117,7 @@ func (c *contractClient) UpdateContractTx(ctx context.Context, in *UpdateContrac
|
|||||||
// All implementations must embed UnimplementedContractServer
|
// All implementations must embed UnimplementedContractServer
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
type ContractServer interface {
|
type ContractServer interface {
|
||||||
|
CreateContract(context.Context, *CreateContractRequest) (*CreateContractRespond, error)
|
||||||
FinishContract(context.Context, *FinishContractRequest) (*FinishContractRespond, error)
|
FinishContract(context.Context, *FinishContractRequest) (*FinishContractRespond, error)
|
||||||
ContractList(context.Context, *ContractListRequest) (*ContractListRespond, error)
|
ContractList(context.Context, *ContractListRequest) (*ContractListRespond, error)
|
||||||
GetContract(context.Context, *GetContractRequest) (*ContractData, error)
|
GetContract(context.Context, *GetContractRequest) (*ContractData, error)
|
||||||
@ -124,6 +133,9 @@ type UnimplementedContractServer struct {
|
|||||||
proxyImpl protocol.Invoker
|
proxyImpl protocol.Invoker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (UnimplementedContractServer) CreateContract(context.Context, *CreateContractRequest) (*CreateContractRespond, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CreateContract not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedContractServer) FinishContract(context.Context, *FinishContractRequest) (*FinishContractRespond, error) {
|
func (UnimplementedContractServer) FinishContract(context.Context, *FinishContractRequest) (*FinishContractRespond, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method FinishContract not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method FinishContract not implemented")
|
||||||
}
|
}
|
||||||
@ -173,6 +185,35 @@ func RegisterContractServer(s grpc_go.ServiceRegistrar, srv ContractServer) {
|
|||||||
s.RegisterService(&Contract_ServiceDesc, srv)
|
s.RegisterService(&Contract_ServiceDesc, srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Contract_CreateContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CreateContractRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||||
|
args := []interface{}{}
|
||||||
|
args = append(args, in)
|
||||||
|
md, _ := metadata.FromIncomingContext(ctx)
|
||||||
|
invAttachment := make(map[string]interface{}, len(md))
|
||||||
|
for k, v := range md {
|
||||||
|
invAttachment[k] = v
|
||||||
|
}
|
||||||
|
invo := invocation.NewRPCInvocation("CreateContract", args, invAttachment)
|
||||||
|
if interceptor == nil {
|
||||||
|
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||||
|
return result, result.Error()
|
||||||
|
}
|
||||||
|
info := &grpc_go.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||||
|
return result, result.Error()
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
func _Contract_FinishContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
func _Contract_FinishContract_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(FinishContractRequest)
|
in := new(FinishContractRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@ -383,6 +424,10 @@ var Contract_ServiceDesc = grpc_go.ServiceDesc{
|
|||||||
ServiceName: "Contract.Contract",
|
ServiceName: "Contract.Contract",
|
||||||
HandlerType: (*ContractServer)(nil),
|
HandlerType: (*ContractServer)(nil),
|
||||||
Methods: []grpc_go.MethodDesc{
|
Methods: []grpc_go.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "CreateContract",
|
||||||
|
Handler: _Contract_CreateContract_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "FinishContract",
|
MethodName: "FinishContract",
|
||||||
Handler: _Contract_FinishContract_Handler,
|
Handler: _Contract_FinishContract_Handler,
|
||||||
@ -413,5 +458,5 @@ var Contract_ServiceDesc = grpc_go.ServiceDesc{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc_go.StreamDesc{},
|
Streams: []grpc_go.StreamDesc{},
|
||||||
Metadata: "api/contract/contract.proto",
|
Metadata: "contract.proto",
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ message UpdateMsgRespond {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
message ListInterfaceRespond {
|
message ListInterfaceRespond {
|
||||||
int64 Total = 1 [json_name = "total"];
|
int64 Total = 1 [json_name = "total"];
|
||||||
|
Loading…
Reference in New Issue
Block a user