entity.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package class
  2. import (
  3. "git.sxidc.com/go-framework/baize/convenient/domain/operate_log"
  4. "git.sxidc.com/go-framework/baize/framework/core/domain"
  5. "git.sxidc.com/go-framework/baize/framework/core/domain/entity"
  6. )
  7. const (
  8. FieldName = "Name"
  9. FieldStudentNum = "StudentNum"
  10. )
  11. var (
  12. ColumnName = domain.ColumnName(FieldName)
  13. ColumnStudentNum = domain.ColumnName(FieldStudentNum)
  14. )
  15. var fieldMap = map[string]string{
  16. FieldName: "班名",
  17. FieldStudentNum: "学生数量",
  18. }
  19. type Entity struct {
  20. entity.Base
  21. Name string `sqlmapping:"column:name" sqlresult:"column:name" check:"required,lte=128,when=create/update"`
  22. StudentNum int `sqlmapping:"column:student_num;updateClear;" sqlresult:"column:student_num"`
  23. StudentIDs []string `sqlmapping:"-" sqlresult:"-"`
  24. entity.TimeFields
  25. }
  26. func (e *Entity) DomainCNName() string {
  27. return "班级"
  28. }
  29. func (e *Entity) DomainCamelName() string {
  30. return "Class"
  31. }
  32. func (e *Entity) GetFieldMap() map[string]string {
  33. return fieldMap
  34. }
  35. func (e *Entity) ObjectInfo() operate_log.ObjectInfo {
  36. return operate_log.ObjectInfo{
  37. Resource: e.DomainCamelName(),
  38. ResourceID: e.ID,
  39. }
  40. }
  41. func (e *Entity) OperatorInfo() operate_log.OperatorInfo {
  42. return operate_log.OperatorInfo{}
  43. }
  44. func (e *Entity) LogContent() map[string]any {
  45. return map[string]any{
  46. "name": e.Name,
  47. "student_num": e.StudentNum,
  48. }
  49. }