wxcard.go 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/wxcard"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // WxCard is the model entity for the WxCard schema.
  12. type WxCard struct {
  13. config `json:"-"`
  14. // ID of the ent.
  15. ID uint64 `json:"id,omitempty"`
  16. // Create Time | 创建日期
  17. CreatedAt time.Time `json:"created_at,omitempty"`
  18. // Update Time | 修改日期
  19. UpdatedAt time.Time `json:"updated_at,omitempty"`
  20. // Delete Time | 删除日期
  21. DeletedAt time.Time `json:"deleted_at,omitempty"`
  22. // user表ID
  23. UserID uint64 `json:"user_id,omitempty"`
  24. // wx表ID
  25. WxUserID uint64 `json:"wx_user_id,omitempty"`
  26. // 头像
  27. Avatar string `json:"avatar,omitempty"`
  28. // logo
  29. Logo string `json:"logo,omitempty"`
  30. // 名称
  31. Name string `json:"name,omitempty"`
  32. // 公司
  33. Company string `json:"company,omitempty"`
  34. // 地址
  35. Address string `json:"address,omitempty"`
  36. // 手机号
  37. Phone string `json:"phone,omitempty"`
  38. // 公众号
  39. OfficialAccount string `json:"official_account,omitempty"`
  40. // 微信号
  41. WechatAccount string `json:"wechat_account,omitempty"`
  42. // 邮箱
  43. Email string `json:"email,omitempty"`
  44. // fastgpt-base
  45. APIBase string `json:"api_base,omitempty"`
  46. // fastgpt-key
  47. APIKey string `json:"api_key,omitempty"`
  48. // AI信息
  49. AiInfo string `json:"ai_info,omitempty"`
  50. // 个人介绍
  51. Intro string `json:"intro,omitempty"`
  52. selectValues sql.SelectValues
  53. }
  54. // scanValues returns the types for scanning values from sql.Rows.
  55. func (*WxCard) scanValues(columns []string) ([]any, error) {
  56. values := make([]any, len(columns))
  57. for i := range columns {
  58. switch columns[i] {
  59. case wxcard.FieldID, wxcard.FieldUserID, wxcard.FieldWxUserID:
  60. values[i] = new(sql.NullInt64)
  61. case wxcard.FieldAvatar, wxcard.FieldLogo, wxcard.FieldName, wxcard.FieldCompany, wxcard.FieldAddress, wxcard.FieldPhone, wxcard.FieldOfficialAccount, wxcard.FieldWechatAccount, wxcard.FieldEmail, wxcard.FieldAPIBase, wxcard.FieldAPIKey, wxcard.FieldAiInfo, wxcard.FieldIntro:
  62. values[i] = new(sql.NullString)
  63. case wxcard.FieldCreatedAt, wxcard.FieldUpdatedAt, wxcard.FieldDeletedAt:
  64. values[i] = new(sql.NullTime)
  65. default:
  66. values[i] = new(sql.UnknownType)
  67. }
  68. }
  69. return values, nil
  70. }
  71. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  72. // to the WxCard fields.
  73. func (wc *WxCard) assignValues(columns []string, values []any) error {
  74. if m, n := len(values), len(columns); m < n {
  75. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  76. }
  77. for i := range columns {
  78. switch columns[i] {
  79. case wxcard.FieldID:
  80. value, ok := values[i].(*sql.NullInt64)
  81. if !ok {
  82. return fmt.Errorf("unexpected type %T for field id", value)
  83. }
  84. wc.ID = uint64(value.Int64)
  85. case wxcard.FieldCreatedAt:
  86. if value, ok := values[i].(*sql.NullTime); !ok {
  87. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  88. } else if value.Valid {
  89. wc.CreatedAt = value.Time
  90. }
  91. case wxcard.FieldUpdatedAt:
  92. if value, ok := values[i].(*sql.NullTime); !ok {
  93. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  94. } else if value.Valid {
  95. wc.UpdatedAt = value.Time
  96. }
  97. case wxcard.FieldDeletedAt:
  98. if value, ok := values[i].(*sql.NullTime); !ok {
  99. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  100. } else if value.Valid {
  101. wc.DeletedAt = value.Time
  102. }
  103. case wxcard.FieldUserID:
  104. if value, ok := values[i].(*sql.NullInt64); !ok {
  105. return fmt.Errorf("unexpected type %T for field user_id", values[i])
  106. } else if value.Valid {
  107. wc.UserID = uint64(value.Int64)
  108. }
  109. case wxcard.FieldWxUserID:
  110. if value, ok := values[i].(*sql.NullInt64); !ok {
  111. return fmt.Errorf("unexpected type %T for field wx_user_id", values[i])
  112. } else if value.Valid {
  113. wc.WxUserID = uint64(value.Int64)
  114. }
  115. case wxcard.FieldAvatar:
  116. if value, ok := values[i].(*sql.NullString); !ok {
  117. return fmt.Errorf("unexpected type %T for field avatar", values[i])
  118. } else if value.Valid {
  119. wc.Avatar = value.String
  120. }
  121. case wxcard.FieldLogo:
  122. if value, ok := values[i].(*sql.NullString); !ok {
  123. return fmt.Errorf("unexpected type %T for field logo", values[i])
  124. } else if value.Valid {
  125. wc.Logo = value.String
  126. }
  127. case wxcard.FieldName:
  128. if value, ok := values[i].(*sql.NullString); !ok {
  129. return fmt.Errorf("unexpected type %T for field name", values[i])
  130. } else if value.Valid {
  131. wc.Name = value.String
  132. }
  133. case wxcard.FieldCompany:
  134. if value, ok := values[i].(*sql.NullString); !ok {
  135. return fmt.Errorf("unexpected type %T for field company", values[i])
  136. } else if value.Valid {
  137. wc.Company = value.String
  138. }
  139. case wxcard.FieldAddress:
  140. if value, ok := values[i].(*sql.NullString); !ok {
  141. return fmt.Errorf("unexpected type %T for field address", values[i])
  142. } else if value.Valid {
  143. wc.Address = value.String
  144. }
  145. case wxcard.FieldPhone:
  146. if value, ok := values[i].(*sql.NullString); !ok {
  147. return fmt.Errorf("unexpected type %T for field phone", values[i])
  148. } else if value.Valid {
  149. wc.Phone = value.String
  150. }
  151. case wxcard.FieldOfficialAccount:
  152. if value, ok := values[i].(*sql.NullString); !ok {
  153. return fmt.Errorf("unexpected type %T for field official_account", values[i])
  154. } else if value.Valid {
  155. wc.OfficialAccount = value.String
  156. }
  157. case wxcard.FieldWechatAccount:
  158. if value, ok := values[i].(*sql.NullString); !ok {
  159. return fmt.Errorf("unexpected type %T for field wechat_account", values[i])
  160. } else if value.Valid {
  161. wc.WechatAccount = value.String
  162. }
  163. case wxcard.FieldEmail:
  164. if value, ok := values[i].(*sql.NullString); !ok {
  165. return fmt.Errorf("unexpected type %T for field email", values[i])
  166. } else if value.Valid {
  167. wc.Email = value.String
  168. }
  169. case wxcard.FieldAPIBase:
  170. if value, ok := values[i].(*sql.NullString); !ok {
  171. return fmt.Errorf("unexpected type %T for field api_base", values[i])
  172. } else if value.Valid {
  173. wc.APIBase = value.String
  174. }
  175. case wxcard.FieldAPIKey:
  176. if value, ok := values[i].(*sql.NullString); !ok {
  177. return fmt.Errorf("unexpected type %T for field api_key", values[i])
  178. } else if value.Valid {
  179. wc.APIKey = value.String
  180. }
  181. case wxcard.FieldAiInfo:
  182. if value, ok := values[i].(*sql.NullString); !ok {
  183. return fmt.Errorf("unexpected type %T for field ai_info", values[i])
  184. } else if value.Valid {
  185. wc.AiInfo = value.String
  186. }
  187. case wxcard.FieldIntro:
  188. if value, ok := values[i].(*sql.NullString); !ok {
  189. return fmt.Errorf("unexpected type %T for field intro", values[i])
  190. } else if value.Valid {
  191. wc.Intro = value.String
  192. }
  193. default:
  194. wc.selectValues.Set(columns[i], values[i])
  195. }
  196. }
  197. return nil
  198. }
  199. // Value returns the ent.Value that was dynamically selected and assigned to the WxCard.
  200. // This includes values selected through modifiers, order, etc.
  201. func (wc *WxCard) Value(name string) (ent.Value, error) {
  202. return wc.selectValues.Get(name)
  203. }
  204. // Update returns a builder for updating this WxCard.
  205. // Note that you need to call WxCard.Unwrap() before calling this method if this WxCard
  206. // was returned from a transaction, and the transaction was committed or rolled back.
  207. func (wc *WxCard) Update() *WxCardUpdateOne {
  208. return NewWxCardClient(wc.config).UpdateOne(wc)
  209. }
  210. // Unwrap unwraps the WxCard entity that was returned from a transaction after it was closed,
  211. // so that all future queries will be executed through the driver which created the transaction.
  212. func (wc *WxCard) Unwrap() *WxCard {
  213. _tx, ok := wc.config.driver.(*txDriver)
  214. if !ok {
  215. panic("ent: WxCard is not a transactional entity")
  216. }
  217. wc.config.driver = _tx.drv
  218. return wc
  219. }
  220. // String implements the fmt.Stringer.
  221. func (wc *WxCard) String() string {
  222. var builder strings.Builder
  223. builder.WriteString("WxCard(")
  224. builder.WriteString(fmt.Sprintf("id=%v, ", wc.ID))
  225. builder.WriteString("created_at=")
  226. builder.WriteString(wc.CreatedAt.Format(time.ANSIC))
  227. builder.WriteString(", ")
  228. builder.WriteString("updated_at=")
  229. builder.WriteString(wc.UpdatedAt.Format(time.ANSIC))
  230. builder.WriteString(", ")
  231. builder.WriteString("deleted_at=")
  232. builder.WriteString(wc.DeletedAt.Format(time.ANSIC))
  233. builder.WriteString(", ")
  234. builder.WriteString("user_id=")
  235. builder.WriteString(fmt.Sprintf("%v", wc.UserID))
  236. builder.WriteString(", ")
  237. builder.WriteString("wx_user_id=")
  238. builder.WriteString(fmt.Sprintf("%v", wc.WxUserID))
  239. builder.WriteString(", ")
  240. builder.WriteString("avatar=")
  241. builder.WriteString(wc.Avatar)
  242. builder.WriteString(", ")
  243. builder.WriteString("logo=")
  244. builder.WriteString(wc.Logo)
  245. builder.WriteString(", ")
  246. builder.WriteString("name=")
  247. builder.WriteString(wc.Name)
  248. builder.WriteString(", ")
  249. builder.WriteString("company=")
  250. builder.WriteString(wc.Company)
  251. builder.WriteString(", ")
  252. builder.WriteString("address=")
  253. builder.WriteString(wc.Address)
  254. builder.WriteString(", ")
  255. builder.WriteString("phone=")
  256. builder.WriteString(wc.Phone)
  257. builder.WriteString(", ")
  258. builder.WriteString("official_account=")
  259. builder.WriteString(wc.OfficialAccount)
  260. builder.WriteString(", ")
  261. builder.WriteString("wechat_account=")
  262. builder.WriteString(wc.WechatAccount)
  263. builder.WriteString(", ")
  264. builder.WriteString("email=")
  265. builder.WriteString(wc.Email)
  266. builder.WriteString(", ")
  267. builder.WriteString("api_base=")
  268. builder.WriteString(wc.APIBase)
  269. builder.WriteString(", ")
  270. builder.WriteString("api_key=")
  271. builder.WriteString(wc.APIKey)
  272. builder.WriteString(", ")
  273. builder.WriteString("ai_info=")
  274. builder.WriteString(wc.AiInfo)
  275. builder.WriteString(", ")
  276. builder.WriteString("intro=")
  277. builder.WriteString(wc.Intro)
  278. builder.WriteByte(')')
  279. return builder.String()
  280. }
  281. // WxCards is a parsable slice of WxCard.
  282. type WxCards []*WxCard