2023-01-18 09:03:15 +00:00
|
|
|
package logic
|
|
|
|
|
|
|
|
import (
|
2023-02-06 01:33:09 +00:00
|
|
|
"github.com/fonchain/fonchain-artistinfo/cmd/internal/dao"
|
|
|
|
"github.com/fonchain/fonchain-artistinfo/pb/contract"
|
2023-01-18 09:03:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type IContract interface {
|
|
|
|
FinishContract(req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error)
|
|
|
|
ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error)
|
|
|
|
ContractTxList(req *contract.ContractTxListRequest) (rep *contract.ContractTxListRespond, err error)
|
|
|
|
UpdateContract(req *contract.UpdateContractRequest) (rep *contract.UpdateContractRespond, err error)
|
|
|
|
UpdateContractTx(req *contract.UpdateContractTxRequest) (rep *contract.UpdateContractTxRespond, err error)
|
|
|
|
GetContract(req *contract.GetContractRequest) (rep *contract.ContractData, err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewContract() IContract {
|
|
|
|
return &Contract{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Contract struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Contract) FinishContract(req *contract.FinishContractRequest) (rep *contract.FinishContractRespond, err error) {
|
|
|
|
rep = &contract.FinishContractRespond{}
|
|
|
|
|
|
|
|
err = dao.FinishContract(req.TransactionId)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Contract) ContractList(req *contract.ContractListRequest) (rep *contract.ContractListRespond, err error) {
|
|
|
|
|
|
|
|
rep, err = dao.ContractList(req)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Contract) GetContract(req *contract.GetContractRequest) (rep *contract.ContractData, err error) {
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|