seal_operation_record.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package seal
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type SealOperationRecord struct {
  7. Id int `orm:"column(id);pk"`
  8. SealId int `orm:"column(seal_id)";description:"用印ID"`
  9. Operation string `description:"操作类型,add:新增,edit:编辑,apply:发起审批,cancel:撤回审批,reject:拒绝审批,approval:审批操作,invalid:作废;长度36位"`
  10. OpUserId int `description:"操作人id"`
  11. OpUserName string `description:"操作人名称"`
  12. Remark string `description:"备注,长度255位"`
  13. ApprovalRecordId int `orm:"column(approval_record_id)";description:"审批流id"`
  14. ApprovalRemark string `description:"审批备注"`
  15. CreateTime time.Time `description:"日志添加时间"`
  16. }
  17. type SealOperationRecordList struct {
  18. SealOperationRecord
  19. CreateTimeStr string `description:"日志添加时间标准格式"`
  20. }
  21. // GetSealOperationListBySealId 根据用印ID获取所有操作日志
  22. func GetSealOperationListBySealId(sealId int) (list []*SealOperationRecordList, err error) {
  23. o := orm.NewOrm()
  24. sql := `SELECT * FROM seal_operation_record WHERE seal_id = ? ORDER BY id DESC`
  25. _, err = o.Raw(sql, sealId).QueryRows(&list)
  26. return
  27. }
  28. // AddContractOperationRecord 添加用印操作日志
  29. func AddSealOperationRecord(sealId, opUserId, approvalRecordId int, operation, opUserName, remark, approvalRemark string) (err error) {
  30. o := orm.NewOrm()
  31. item := &SealOperationRecord{
  32. SealId: sealId,
  33. Operation: operation,
  34. OpUserId: opUserId,
  35. OpUserName: opUserName,
  36. Remark: remark,
  37. ApprovalRecordId: approvalRecordId,
  38. ApprovalRemark: approvalRemark,
  39. CreateTime: time.Now(),
  40. }
  41. _, err = o.Insert(item)
  42. return
  43. }