compositemodelroute.go 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "entgo.io/ent"
  8. "entgo.io/ent/dialect/sql"
  9. "github.com/Wei-Shaw/sub2api/ent/compositemodelroute"
  10. "github.com/Wei-Shaw/sub2api/ent/group"
  11. )
  12. // CompositeModelRoute is the model entity for the CompositeModelRoute schema.
  13. type CompositeModelRoute struct {
  14. config `json:"-"`
  15. // ID of the ent.
  16. ID int64 `json:"id,omitempty"`
  17. // CreatedAt holds the value of the "created_at" field.
  18. CreatedAt time.Time `json:"created_at,omitempty"`
  19. // UpdatedAt holds the value of the "updated_at" field.
  20. UpdatedAt time.Time `json:"updated_at,omitempty"`
  21. // DeletedAt holds the value of the "deleted_at" field.
  22. DeletedAt *time.Time `json:"deleted_at,omitempty"`
  23. // GroupID holds the value of the "group_id" field.
  24. GroupID int64 `json:"group_id,omitempty"`
  25. // Client-facing model identifier or prefix.
  26. PublicModel string `json:"public_model,omitempty"`
  27. // exact or prefix.
  28. MatchType string `json:"match_type,omitempty"`
  29. // Concrete provider platform.
  30. TargetPlatform string `json:"target_platform,omitempty"`
  31. // Provider model identifier; empty means public_model.
  32. UpstreamModel string `json:"upstream_model,omitempty"`
  33. // Endpoint scope such as any, messages, responses, chat_completions.
  34. Endpoint string `json:"endpoint,omitempty"`
  35. // Lower values win within the same match strength.
  36. Priority int `json:"priority,omitempty"`
  37. // Enabled holds the value of the "enabled" field.
  38. Enabled bool `json:"enabled,omitempty"`
  39. // Notes holds the value of the "notes" field.
  40. Notes *string `json:"notes,omitempty"`
  41. // Edges holds the relations/edges for other nodes in the graph.
  42. // The values are being populated by the CompositeModelRouteQuery when eager-loading is set.
  43. Edges CompositeModelRouteEdges `json:"edges"`
  44. selectValues sql.SelectValues
  45. }
  46. // CompositeModelRouteEdges holds the relations/edges for other nodes in the graph.
  47. type CompositeModelRouteEdges struct {
  48. // Group holds the value of the group edge.
  49. Group *Group `json:"group,omitempty"`
  50. // loadedTypes holds the information for reporting if a
  51. // type was loaded (or requested) in eager-loading or not.
  52. loadedTypes [1]bool
  53. }
  54. // GroupOrErr returns the Group value or an error if the edge
  55. // was not loaded in eager-loading, or loaded but was not found.
  56. func (e CompositeModelRouteEdges) GroupOrErr() (*Group, error) {
  57. if e.Group != nil {
  58. return e.Group, nil
  59. } else if e.loadedTypes[0] {
  60. return nil, &NotFoundError{label: group.Label}
  61. }
  62. return nil, &NotLoadedError{edge: "group"}
  63. }
  64. // scanValues returns the types for scanning values from sql.Rows.
  65. func (*CompositeModelRoute) scanValues(columns []string) ([]any, error) {
  66. values := make([]any, len(columns))
  67. for i := range columns {
  68. switch columns[i] {
  69. case compositemodelroute.FieldEnabled:
  70. values[i] = new(sql.NullBool)
  71. case compositemodelroute.FieldID, compositemodelroute.FieldGroupID, compositemodelroute.FieldPriority:
  72. values[i] = new(sql.NullInt64)
  73. case compositemodelroute.FieldPublicModel, compositemodelroute.FieldMatchType, compositemodelroute.FieldTargetPlatform, compositemodelroute.FieldUpstreamModel, compositemodelroute.FieldEndpoint, compositemodelroute.FieldNotes:
  74. values[i] = new(sql.NullString)
  75. case compositemodelroute.FieldCreatedAt, compositemodelroute.FieldUpdatedAt, compositemodelroute.FieldDeletedAt:
  76. values[i] = new(sql.NullTime)
  77. default:
  78. values[i] = new(sql.UnknownType)
  79. }
  80. }
  81. return values, nil
  82. }
  83. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  84. // to the CompositeModelRoute fields.
  85. func (_m *CompositeModelRoute) assignValues(columns []string, values []any) error {
  86. if m, n := len(values), len(columns); m < n {
  87. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  88. }
  89. for i := range columns {
  90. switch columns[i] {
  91. case compositemodelroute.FieldID:
  92. value, ok := values[i].(*sql.NullInt64)
  93. if !ok {
  94. return fmt.Errorf("unexpected type %T for field id", value)
  95. }
  96. _m.ID = int64(value.Int64)
  97. case compositemodelroute.FieldCreatedAt:
  98. if value, ok := values[i].(*sql.NullTime); !ok {
  99. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  100. } else if value.Valid {
  101. _m.CreatedAt = value.Time
  102. }
  103. case compositemodelroute.FieldUpdatedAt:
  104. if value, ok := values[i].(*sql.NullTime); !ok {
  105. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  106. } else if value.Valid {
  107. _m.UpdatedAt = value.Time
  108. }
  109. case compositemodelroute.FieldDeletedAt:
  110. if value, ok := values[i].(*sql.NullTime); !ok {
  111. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  112. } else if value.Valid {
  113. _m.DeletedAt = new(time.Time)
  114. *_m.DeletedAt = value.Time
  115. }
  116. case compositemodelroute.FieldGroupID:
  117. if value, ok := values[i].(*sql.NullInt64); !ok {
  118. return fmt.Errorf("unexpected type %T for field group_id", values[i])
  119. } else if value.Valid {
  120. _m.GroupID = value.Int64
  121. }
  122. case compositemodelroute.FieldPublicModel:
  123. if value, ok := values[i].(*sql.NullString); !ok {
  124. return fmt.Errorf("unexpected type %T for field public_model", values[i])
  125. } else if value.Valid {
  126. _m.PublicModel = value.String
  127. }
  128. case compositemodelroute.FieldMatchType:
  129. if value, ok := values[i].(*sql.NullString); !ok {
  130. return fmt.Errorf("unexpected type %T for field match_type", values[i])
  131. } else if value.Valid {
  132. _m.MatchType = value.String
  133. }
  134. case compositemodelroute.FieldTargetPlatform:
  135. if value, ok := values[i].(*sql.NullString); !ok {
  136. return fmt.Errorf("unexpected type %T for field target_platform", values[i])
  137. } else if value.Valid {
  138. _m.TargetPlatform = value.String
  139. }
  140. case compositemodelroute.FieldUpstreamModel:
  141. if value, ok := values[i].(*sql.NullString); !ok {
  142. return fmt.Errorf("unexpected type %T for field upstream_model", values[i])
  143. } else if value.Valid {
  144. _m.UpstreamModel = value.String
  145. }
  146. case compositemodelroute.FieldEndpoint:
  147. if value, ok := values[i].(*sql.NullString); !ok {
  148. return fmt.Errorf("unexpected type %T for field endpoint", values[i])
  149. } else if value.Valid {
  150. _m.Endpoint = value.String
  151. }
  152. case compositemodelroute.FieldPriority:
  153. if value, ok := values[i].(*sql.NullInt64); !ok {
  154. return fmt.Errorf("unexpected type %T for field priority", values[i])
  155. } else if value.Valid {
  156. _m.Priority = int(value.Int64)
  157. }
  158. case compositemodelroute.FieldEnabled:
  159. if value, ok := values[i].(*sql.NullBool); !ok {
  160. return fmt.Errorf("unexpected type %T for field enabled", values[i])
  161. } else if value.Valid {
  162. _m.Enabled = value.Bool
  163. }
  164. case compositemodelroute.FieldNotes:
  165. if value, ok := values[i].(*sql.NullString); !ok {
  166. return fmt.Errorf("unexpected type %T for field notes", values[i])
  167. } else if value.Valid {
  168. _m.Notes = new(string)
  169. *_m.Notes = value.String
  170. }
  171. default:
  172. _m.selectValues.Set(columns[i], values[i])
  173. }
  174. }
  175. return nil
  176. }
  177. // Value returns the ent.Value that was dynamically selected and assigned to the CompositeModelRoute.
  178. // This includes values selected through modifiers, order, etc.
  179. func (_m *CompositeModelRoute) Value(name string) (ent.Value, error) {
  180. return _m.selectValues.Get(name)
  181. }
  182. // QueryGroup queries the "group" edge of the CompositeModelRoute entity.
  183. func (_m *CompositeModelRoute) QueryGroup() *GroupQuery {
  184. return NewCompositeModelRouteClient(_m.config).QueryGroup(_m)
  185. }
  186. // Update returns a builder for updating this CompositeModelRoute.
  187. // Note that you need to call CompositeModelRoute.Unwrap() before calling this method if this CompositeModelRoute
  188. // was returned from a transaction, and the transaction was committed or rolled back.
  189. func (_m *CompositeModelRoute) Update() *CompositeModelRouteUpdateOne {
  190. return NewCompositeModelRouteClient(_m.config).UpdateOne(_m)
  191. }
  192. // Unwrap unwraps the CompositeModelRoute entity that was returned from a transaction after it was closed,
  193. // so that all future queries will be executed through the driver which created the transaction.
  194. func (_m *CompositeModelRoute) Unwrap() *CompositeModelRoute {
  195. _tx, ok := _m.config.driver.(*txDriver)
  196. if !ok {
  197. panic("ent: CompositeModelRoute is not a transactional entity")
  198. }
  199. _m.config.driver = _tx.drv
  200. return _m
  201. }
  202. // String implements the fmt.Stringer.
  203. func (_m *CompositeModelRoute) String() string {
  204. var builder strings.Builder
  205. builder.WriteString("CompositeModelRoute(")
  206. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  207. builder.WriteString("created_at=")
  208. builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
  209. builder.WriteString(", ")
  210. builder.WriteString("updated_at=")
  211. builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
  212. builder.WriteString(", ")
  213. if v := _m.DeletedAt; v != nil {
  214. builder.WriteString("deleted_at=")
  215. builder.WriteString(v.Format(time.ANSIC))
  216. }
  217. builder.WriteString(", ")
  218. builder.WriteString("group_id=")
  219. builder.WriteString(fmt.Sprintf("%v", _m.GroupID))
  220. builder.WriteString(", ")
  221. builder.WriteString("public_model=")
  222. builder.WriteString(_m.PublicModel)
  223. builder.WriteString(", ")
  224. builder.WriteString("match_type=")
  225. builder.WriteString(_m.MatchType)
  226. builder.WriteString(", ")
  227. builder.WriteString("target_platform=")
  228. builder.WriteString(_m.TargetPlatform)
  229. builder.WriteString(", ")
  230. builder.WriteString("upstream_model=")
  231. builder.WriteString(_m.UpstreamModel)
  232. builder.WriteString(", ")
  233. builder.WriteString("endpoint=")
  234. builder.WriteString(_m.Endpoint)
  235. builder.WriteString(", ")
  236. builder.WriteString("priority=")
  237. builder.WriteString(fmt.Sprintf("%v", _m.Priority))
  238. builder.WriteString(", ")
  239. builder.WriteString("enabled=")
  240. builder.WriteString(fmt.Sprintf("%v", _m.Enabled))
  241. builder.WriteString(", ")
  242. if v := _m.Notes; v != nil {
  243. builder.WriteString("notes=")
  244. builder.WriteString(*v)
  245. }
  246. builder.WriteByte(')')
  247. return builder.String()
  248. }
  249. // CompositeModelRoutes is a parsable slice of CompositeModelRoute.
  250. type CompositeModelRoutes []*CompositeModelRoute