contract_operation_record.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package contract
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. //合同操作记录单
  7. type ContractOperationRecord struct {
  8. Id int `orm:"column(id);pk"`
  9. ContractId int `orm:"column(contract_id)";description:"合同id"`
  10. Operation string `description:"操作类型,add:新增,edit:编辑,apply:发起审批,cancel_apply:撤回审批,reject:拒绝审批,approval:审批操作,invalid:作废;长度36位"`
  11. OpUserId int `description:"操作人id"`
  12. OpUserName string `description:"操作人名称"`
  13. Remark string `description:"备注,长度255位"`
  14. ApprovalRecordId int `orm:"column(approval_record_id)";description:"审批流id"`
  15. CreateTime time.Time `description:"日志添加时间"`
  16. }
  17. //根据合同id获取整个合同的操作日志
  18. func GetContractOperationRListByContractId(contractId int) (list []*ContractOperationRecord, err error) {
  19. o := orm.NewOrm()
  20. sql := `select * from contract_operation_record where contract_id = ? order by id desc `
  21. _, err = o.Raw(sql, contractId).QueryRows(&list)
  22. return
  23. }
  24. //添加合同操作日志
  25. func AddContractOperationRecord(contractId, opUserId, approvalRecordId int, operation, opUserName, remark string) (err error) {
  26. o := orm.NewOrm()
  27. contractOperationRecord := &ContractOperationRecord{
  28. ContractId: contractId,
  29. Operation: operation,
  30. OpUserId: opUserId,
  31. OpUserName: opUserName,
  32. Remark: remark,
  33. ApprovalRecordId: approvalRecordId,
  34. CreateTime: time.Now(),
  35. }
  36. _, err = o.Insert(contractOperationRecord)
  37. return
  38. }