68 lines
2.0 KiB
Go
68 lines
2.0 KiB
Go
|
package logic
|
||
|
|
||
|
import (
|
||
|
"github.com/fonchain-artistserver/cmd/internal/dao"
|
||
|
"github.com/fonchain-artistserver/pb/contract"
|
||
|
)
|
||
|
|
||
|
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
|
||
|
}
|