entity.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package student
  2. import (
  3. "git.sxidc.com/go-framework/baize/convenient/domain/query_rule/definition"
  4. "git.sxidc.com/go-framework/baize/framework/core/domain"
  5. "git.sxidc.com/go-framework/baize/framework/core/domain/entity"
  6. "git.sxidc.com/go-tools/utils/strutils"
  7. )
  8. const (
  9. FieldName = "Name"
  10. )
  11. var (
  12. ColumnName = domain.ColumnName(FieldName)
  13. )
  14. var fieldMap = map[string]string{
  15. FieldName: "学生姓名",
  16. }
  17. type Entity struct {
  18. entity.Base
  19. Name string `sqlmapping:"column:name" sqlresult:"column:name" check:"required,lte=128,when=create/update" rule:"column:name"`
  20. FamilyID string `sqlmapping:"column:family_id" sqlresult:"column:family_id" check:"required,len=32"`
  21. ClassID string `sqlmapping:"column:class_id" sqlresult:"column:class_id" check:"required,len=32"`
  22. IdentityIDs []string `sqlmapping:"-" sqlresult:"-"`
  23. HobbyIDs []string `sqlmapping:"-" sqlresult:"-"`
  24. entity.TimeFields
  25. }
  26. func RegisterQueryRule() error {
  27. return definition.RegisterByDomainEntity(definition.RegisterByEntityItem{
  28. Entity: &Entity{},
  29. FieldMap: fieldMap,
  30. })
  31. }
  32. func (e *Entity) DomainCNName() string {
  33. return "学生"
  34. }
  35. func (e *Entity) DomainCamelName() string {
  36. return "Student"
  37. }
  38. func (e *Entity) GetFieldMap() map[string]string {
  39. return fieldMap
  40. }
  41. func (e *Entity) FormQueryRuleParams() map[string]any {
  42. ruleParams := make(map[string]any)
  43. if strutils.IsStringNotEmpty(e.Name) {
  44. ruleParams[ColumnName] = e.Name
  45. }
  46. return ruleParams
  47. }