client.go 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package client
  2. import (
  3. "time"
  4. )
  5. const (
  6. columnCreateUserID = "create_user_id"
  7. columnLastUpdateUserID = "last_update_user_id"
  8. columnCreatedTime = "created_time"
  9. columnLastEventTime = "last_event_time"
  10. )
  11. func ColumnCreateUserID(tableRow *TableRow) string {
  12. return tableRow.ColumnValueString(columnCreateUserID)
  13. }
  14. func ColumnLastUpdateUserID(tableRow *TableRow) string {
  15. return tableRow.ColumnValueString(columnLastUpdateUserID)
  16. }
  17. func ColumnCreatedTime(tableRow *TableRow) time.Time {
  18. return tableRow.ColumnValueTime(columnCreatedTime)
  19. }
  20. func ColumnLastEventTime(tableRow *TableRow) time.Time {
  21. return tableRow.ColumnValueTime(columnLastEventTime)
  22. }
  23. func FormatColumnCreatedTime(tableRow *TableRow, format string) string {
  24. return tableRow.ColumnValueTime(columnCreatedTime).Format(format)
  25. }
  26. func FormatColumnLastEventTime(tableRow *TableRow, format string) string {
  27. return tableRow.ColumnValueTime(columnLastEventTime).Format(format)
  28. }
  29. type Client interface {
  30. AutoMigrate(request *AutoMigrateRequest) error
  31. Transaction(txFunc TransactionFunc) error
  32. Insert(request *InsertRequest) (string, error)
  33. InsertBatch(request *InsertBatchRequest) (string, error)
  34. Delete(request *DeleteRequest) (string, error)
  35. DeleteWhere(request *DeleteWhereRequest) (string, error)
  36. Update(request *UpdateRequest) (string, error)
  37. UpdateWhere(request *UpdateWhereRequest) (string, error)
  38. Replay(request *ReplayRequest) (string, error)
  39. QueryByWhereAndOrderBy(request *QueryByWhereAndOrderByRequest) (string, []TableRow, int64, error)
  40. CommonQuery(request *CommonQueryRequest) (string, []TableRow, int64, error)
  41. QueryOnlyByWhereAndOrderBy(request *QueryByWhereAndOrderByRequest) (string, []TableRow, error)
  42. CommonQueryOnly(request *CommonQueryRequest) (string, []TableRow, error)
  43. QueryByKeys(request *QueryByKeysRequest) (string, *TableRow, error)
  44. CountWhere(request *CountWhereRequest) (string, int64, error)
  45. CommonCount(request *CommonCountRequest) (string, int64, error)
  46. EventQueryByKeys(request *EventQueryByKeysRequest) (string, []EventInfo, int64, error)
  47. CommonEventQuery(request *CommonEventQueryRequest) (string, []EventInfo, int64, error)
  48. EventQueryOnlyByKeys(request *EventQueryByKeysRequest) (string, []EventInfo, error)
  49. CommonEventQueryOnly(request *CommonEventQueryRequest) (string, []EventInfo, error)
  50. CountEventByKeys(request *CountEventByKeysRequest) (string, int64, error)
  51. CommonCountEvent(request *CommonCountEventRequest) (string, int64, error)
  52. EventHistoryQueryByKeys(request *EventQueryByKeysRequest) (string, []EventInfo, int64, error)
  53. CommonEventHistoryQuery(request *CommonEventQueryRequest) (string, []EventInfo, int64, error)
  54. EventHistoryQueryOnlyByKeys(request *EventQueryByKeysRequest) (string, []EventInfo, error)
  55. CommonEventHistoryQueryOnly(request *CommonEventQueryRequest) (string, []EventInfo, error)
  56. CountEventHistoryByKeys(request *CountEventByKeysRequest) (string, int64, error)
  57. CommonCountEventHistory(request *CommonCountEventRequest) (string, int64, error)
  58. }