workexperience.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/employee"
  8. "wechat-api/ent/workexperience"
  9. "entgo.io/ent"
  10. "entgo.io/ent/dialect/sql"
  11. )
  12. // WorkExperience is the model entity for the WorkExperience schema.
  13. type WorkExperience struct {
  14. config `json:"-"`
  15. // ID of the ent.
  16. ID uint64 `json:"id,omitempty"`
  17. // Create Time | 创建日期
  18. CreatedAt time.Time `json:"created_at,omitempty"`
  19. // Update Time | 修改日期
  20. UpdatedAt time.Time `json:"updated_at,omitempty"`
  21. // Delete Time | 删除日期
  22. DeletedAt time.Time `json:"deleted_at,omitempty"`
  23. // employee_id | 员工ID
  24. EmployeeID uint64 `json:"employee_id,omitempty"`
  25. // start_date | 开始时间
  26. StartDate time.Time `json:"start_date,omitempty"`
  27. // end_date | 结束时间
  28. EndDate time.Time `json:"end_date,omitempty"`
  29. // company | 公司名
  30. Company string `json:"company,omitempty"`
  31. // experience | 工作内容
  32. Experience string `json:"experience,omitempty"`
  33. // organization_id | 租户ID
  34. OrganizationID uint64 `json:"organization_id,omitempty"`
  35. // Edges holds the relations/edges for other nodes in the graph.
  36. // The values are being populated by the WorkExperienceQuery when eager-loading is set.
  37. Edges WorkExperienceEdges `json:"edges"`
  38. selectValues sql.SelectValues
  39. }
  40. // WorkExperienceEdges holds the relations/edges for other nodes in the graph.
  41. type WorkExperienceEdges struct {
  42. // Employee holds the value of the employee edge.
  43. Employee *Employee `json:"employee,omitempty"`
  44. // loadedTypes holds the information for reporting if a
  45. // type was loaded (or requested) in eager-loading or not.
  46. loadedTypes [1]bool
  47. }
  48. // EmployeeOrErr returns the Employee value or an error if the edge
  49. // was not loaded in eager-loading, or loaded but was not found.
  50. func (e WorkExperienceEdges) EmployeeOrErr() (*Employee, error) {
  51. if e.Employee != nil {
  52. return e.Employee, nil
  53. } else if e.loadedTypes[0] {
  54. return nil, &NotFoundError{label: employee.Label}
  55. }
  56. return nil, &NotLoadedError{edge: "employee"}
  57. }
  58. // scanValues returns the types for scanning values from sql.Rows.
  59. func (*WorkExperience) scanValues(columns []string) ([]any, error) {
  60. values := make([]any, len(columns))
  61. for i := range columns {
  62. switch columns[i] {
  63. case workexperience.FieldID, workexperience.FieldEmployeeID, workexperience.FieldOrganizationID:
  64. values[i] = new(sql.NullInt64)
  65. case workexperience.FieldCompany, workexperience.FieldExperience:
  66. values[i] = new(sql.NullString)
  67. case workexperience.FieldCreatedAt, workexperience.FieldUpdatedAt, workexperience.FieldDeletedAt, workexperience.FieldStartDate, workexperience.FieldEndDate:
  68. values[i] = new(sql.NullTime)
  69. default:
  70. values[i] = new(sql.UnknownType)
  71. }
  72. }
  73. return values, nil
  74. }
  75. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  76. // to the WorkExperience fields.
  77. func (we *WorkExperience) assignValues(columns []string, values []any) error {
  78. if m, n := len(values), len(columns); m < n {
  79. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  80. }
  81. for i := range columns {
  82. switch columns[i] {
  83. case workexperience.FieldID:
  84. value, ok := values[i].(*sql.NullInt64)
  85. if !ok {
  86. return fmt.Errorf("unexpected type %T for field id", value)
  87. }
  88. we.ID = uint64(value.Int64)
  89. case workexperience.FieldCreatedAt:
  90. if value, ok := values[i].(*sql.NullTime); !ok {
  91. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  92. } else if value.Valid {
  93. we.CreatedAt = value.Time
  94. }
  95. case workexperience.FieldUpdatedAt:
  96. if value, ok := values[i].(*sql.NullTime); !ok {
  97. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  98. } else if value.Valid {
  99. we.UpdatedAt = value.Time
  100. }
  101. case workexperience.FieldDeletedAt:
  102. if value, ok := values[i].(*sql.NullTime); !ok {
  103. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  104. } else if value.Valid {
  105. we.DeletedAt = value.Time
  106. }
  107. case workexperience.FieldEmployeeID:
  108. if value, ok := values[i].(*sql.NullInt64); !ok {
  109. return fmt.Errorf("unexpected type %T for field employee_id", values[i])
  110. } else if value.Valid {
  111. we.EmployeeID = uint64(value.Int64)
  112. }
  113. case workexperience.FieldStartDate:
  114. if value, ok := values[i].(*sql.NullTime); !ok {
  115. return fmt.Errorf("unexpected type %T for field start_date", values[i])
  116. } else if value.Valid {
  117. we.StartDate = value.Time
  118. }
  119. case workexperience.FieldEndDate:
  120. if value, ok := values[i].(*sql.NullTime); !ok {
  121. return fmt.Errorf("unexpected type %T for field end_date", values[i])
  122. } else if value.Valid {
  123. we.EndDate = value.Time
  124. }
  125. case workexperience.FieldCompany:
  126. if value, ok := values[i].(*sql.NullString); !ok {
  127. return fmt.Errorf("unexpected type %T for field company", values[i])
  128. } else if value.Valid {
  129. we.Company = value.String
  130. }
  131. case workexperience.FieldExperience:
  132. if value, ok := values[i].(*sql.NullString); !ok {
  133. return fmt.Errorf("unexpected type %T for field experience", values[i])
  134. } else if value.Valid {
  135. we.Experience = value.String
  136. }
  137. case workexperience.FieldOrganizationID:
  138. if value, ok := values[i].(*sql.NullInt64); !ok {
  139. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  140. } else if value.Valid {
  141. we.OrganizationID = uint64(value.Int64)
  142. }
  143. default:
  144. we.selectValues.Set(columns[i], values[i])
  145. }
  146. }
  147. return nil
  148. }
  149. // Value returns the ent.Value that was dynamically selected and assigned to the WorkExperience.
  150. // This includes values selected through modifiers, order, etc.
  151. func (we *WorkExperience) Value(name string) (ent.Value, error) {
  152. return we.selectValues.Get(name)
  153. }
  154. // QueryEmployee queries the "employee" edge of the WorkExperience entity.
  155. func (we *WorkExperience) QueryEmployee() *EmployeeQuery {
  156. return NewWorkExperienceClient(we.config).QueryEmployee(we)
  157. }
  158. // Update returns a builder for updating this WorkExperience.
  159. // Note that you need to call WorkExperience.Unwrap() before calling this method if this WorkExperience
  160. // was returned from a transaction, and the transaction was committed or rolled back.
  161. func (we *WorkExperience) Update() *WorkExperienceUpdateOne {
  162. return NewWorkExperienceClient(we.config).UpdateOne(we)
  163. }
  164. // Unwrap unwraps the WorkExperience entity that was returned from a transaction after it was closed,
  165. // so that all future queries will be executed through the driver which created the transaction.
  166. func (we *WorkExperience) Unwrap() *WorkExperience {
  167. _tx, ok := we.config.driver.(*txDriver)
  168. if !ok {
  169. panic("ent: WorkExperience is not a transactional entity")
  170. }
  171. we.config.driver = _tx.drv
  172. return we
  173. }
  174. // String implements the fmt.Stringer.
  175. func (we *WorkExperience) String() string {
  176. var builder strings.Builder
  177. builder.WriteString("WorkExperience(")
  178. builder.WriteString(fmt.Sprintf("id=%v, ", we.ID))
  179. builder.WriteString("created_at=")
  180. builder.WriteString(we.CreatedAt.Format(time.ANSIC))
  181. builder.WriteString(", ")
  182. builder.WriteString("updated_at=")
  183. builder.WriteString(we.UpdatedAt.Format(time.ANSIC))
  184. builder.WriteString(", ")
  185. builder.WriteString("deleted_at=")
  186. builder.WriteString(we.DeletedAt.Format(time.ANSIC))
  187. builder.WriteString(", ")
  188. builder.WriteString("employee_id=")
  189. builder.WriteString(fmt.Sprintf("%v", we.EmployeeID))
  190. builder.WriteString(", ")
  191. builder.WriteString("start_date=")
  192. builder.WriteString(we.StartDate.Format(time.ANSIC))
  193. builder.WriteString(", ")
  194. builder.WriteString("end_date=")
  195. builder.WriteString(we.EndDate.Format(time.ANSIC))
  196. builder.WriteString(", ")
  197. builder.WriteString("company=")
  198. builder.WriteString(we.Company)
  199. builder.WriteString(", ")
  200. builder.WriteString("experience=")
  201. builder.WriteString(we.Experience)
  202. builder.WriteString(", ")
  203. builder.WriteString("organization_id=")
  204. builder.WriteString(fmt.Sprintf("%v", we.OrganizationID))
  205. builder.WriteByte(')')
  206. return builder.String()
  207. }
  208. // WorkExperiences is a parsable slice of WorkExperience.
  209. type WorkExperiences []*WorkExperience