entity.go 951 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package hobby
  2. import (
  3. "git.sxidc.com/go-framework/baize/framework/core/domain/entity"
  4. "git.sxidc.com/go-tools/utils/strutils"
  5. )
  6. type Entity struct {
  7. ID string `sqlmapping:"-" sqlresult:"-"`
  8. StudentIDs []string `sqlmapping:"-" sqlresult:"-"`
  9. }
  10. func (e *Entity) DBSchema() string {
  11. return ""
  12. }
  13. func (e *Entity) GenerateID() error {
  14. e.ID = strutils.SimpleUUID()
  15. return nil
  16. }
  17. func (e *Entity) GetID() string {
  18. return e.ID
  19. }
  20. func (e *Entity) CheckFieldID() error {
  21. return entity.CheckID(e.DomainCNName(), "ID", e.ID)
  22. }
  23. func (e *Entity) DomainCNName() string {
  24. return "爱好"
  25. }
  26. func (e *Entity) DomainCamelName() string {
  27. return "Hobby"
  28. }
  29. func (e *Entity) ForCreate() error {
  30. err := e.CheckFieldID()
  31. if err != nil {
  32. return err
  33. }
  34. return nil
  35. }
  36. func (e *Entity) ForDelete() error {
  37. return e.CheckFieldID()
  38. }
  39. func (e *Entity) ForUpdate() error {
  40. err := e.CheckFieldID()
  41. if err != nil {
  42. return err
  43. }
  44. return nil
  45. }