SmartMurphytt/chainmaker_go/controller/transferOwnershipController.go

59 lines
1.5 KiB
Go
Raw Normal View History

2023-11-29 21:48:12 +08:00
package controller
import (
"chainmaker_go/database"
"chainmaker_go/model"
"github.com/gin-gonic/gin"
)
var old_user_id = ""
var new_user_id = ""
var contract = ""
func TransferOwnershipNotice(ctx *gin.Context) {
//获取数据库
DB := database.GetDB()
//绑定 资源 模型
var requestTransferOwnership = model.TransferOwnership{}
ctx.Bind(&requestTransferOwnership)
//获取参数
resource_id = requestTransferOwnership.Resource_uniqueid
old_user_id = requestTransferOwnership.Origin_userid
new_user_id = requestTransferOwnership.Authorized_userid
right_type = requestTransferOwnership.Right_type
contract = requestTransferOwnership.Contract_describe
time = requestTransferOwnership.Time
//签名处理 todo
data_sign := requestTransferOwnership.Data_sign
//获取Resource_name和Resource_describe
var resource model.Resource
DB.Where("resource_uniqueid = ? ", resource_id).First(&resource)
resource_name = resource.Resource_name
resource_describe = resource.Resource_describe
//直接注册
//创建
newTransferOwnership := model.TransferOwnership{
Resource_uniqueid: resource_id,
Origin_userid: old_user_id,
Authorized_userid: new_user_id,
Right_type: right_type,
Resource_name: resource_name,
Resource_describe: resource_describe,
Contract_describe: contract,
Time: time,
Data_sign: data_sign,
}
DB.Create(&newTransferOwnership)
//返回结果
ctx.JSON(200, gin.H{
"code": 200,
"msg": "权属转让请求已创建",
})
}