batchmsg.go 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/batchmsg"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // BatchMsg is the model entity for the BatchMsg schema.
  12. type BatchMsg 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. // 状态 0 未开始 1 开始发送 2 发送完成 3 发送中止
  23. Status uint8 `json:"status,omitempty"`
  24. // 批次号
  25. BatchNo string `json:"batch_no,omitempty"`
  26. // 任务名称
  27. TaskName string `json:"task_name,omitempty"`
  28. // 发送方微信ID
  29. Fromwxid string `json:"fromwxid,omitempty"`
  30. // 内容
  31. Msg string `json:"msg,omitempty"`
  32. // 发送规则 all 全部 tag1,tag2 按tag发送
  33. Tag string `json:"tag,omitempty"`
  34. // 总数
  35. Total int32 `json:"total,omitempty"`
  36. // 成功数量
  37. Success int32 `json:"success,omitempty"`
  38. // 失败数量
  39. Fail int32 `json:"fail,omitempty"`
  40. // 开始时间
  41. StartTime time.Time `json:"start_time,omitempty"`
  42. // 结束时间
  43. StopTime time.Time `json:"stop_time,omitempty"`
  44. // 发送时间
  45. SendTime time.Time `json:"send_time,omitempty"`
  46. selectValues sql.SelectValues
  47. }
  48. // scanValues returns the types for scanning values from sql.Rows.
  49. func (*BatchMsg) scanValues(columns []string) ([]any, error) {
  50. values := make([]any, len(columns))
  51. for i := range columns {
  52. switch columns[i] {
  53. case batchmsg.FieldID, batchmsg.FieldStatus, batchmsg.FieldTotal, batchmsg.FieldSuccess, batchmsg.FieldFail:
  54. values[i] = new(sql.NullInt64)
  55. case batchmsg.FieldBatchNo, batchmsg.FieldTaskName, batchmsg.FieldFromwxid, batchmsg.FieldMsg, batchmsg.FieldTag:
  56. values[i] = new(sql.NullString)
  57. case batchmsg.FieldCreatedAt, batchmsg.FieldUpdatedAt, batchmsg.FieldDeletedAt, batchmsg.FieldStartTime, batchmsg.FieldStopTime, batchmsg.FieldSendTime:
  58. values[i] = new(sql.NullTime)
  59. default:
  60. values[i] = new(sql.UnknownType)
  61. }
  62. }
  63. return values, nil
  64. }
  65. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  66. // to the BatchMsg fields.
  67. func (bm *BatchMsg) assignValues(columns []string, values []any) error {
  68. if m, n := len(values), len(columns); m < n {
  69. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  70. }
  71. for i := range columns {
  72. switch columns[i] {
  73. case batchmsg.FieldID:
  74. value, ok := values[i].(*sql.NullInt64)
  75. if !ok {
  76. return fmt.Errorf("unexpected type %T for field id", value)
  77. }
  78. bm.ID = uint64(value.Int64)
  79. case batchmsg.FieldCreatedAt:
  80. if value, ok := values[i].(*sql.NullTime); !ok {
  81. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  82. } else if value.Valid {
  83. bm.CreatedAt = value.Time
  84. }
  85. case batchmsg.FieldUpdatedAt:
  86. if value, ok := values[i].(*sql.NullTime); !ok {
  87. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  88. } else if value.Valid {
  89. bm.UpdatedAt = value.Time
  90. }
  91. case batchmsg.FieldDeletedAt:
  92. if value, ok := values[i].(*sql.NullTime); !ok {
  93. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  94. } else if value.Valid {
  95. bm.DeletedAt = value.Time
  96. }
  97. case batchmsg.FieldStatus:
  98. if value, ok := values[i].(*sql.NullInt64); !ok {
  99. return fmt.Errorf("unexpected type %T for field status", values[i])
  100. } else if value.Valid {
  101. bm.Status = uint8(value.Int64)
  102. }
  103. case batchmsg.FieldBatchNo:
  104. if value, ok := values[i].(*sql.NullString); !ok {
  105. return fmt.Errorf("unexpected type %T for field batch_no", values[i])
  106. } else if value.Valid {
  107. bm.BatchNo = value.String
  108. }
  109. case batchmsg.FieldTaskName:
  110. if value, ok := values[i].(*sql.NullString); !ok {
  111. return fmt.Errorf("unexpected type %T for field task_name", values[i])
  112. } else if value.Valid {
  113. bm.TaskName = value.String
  114. }
  115. case batchmsg.FieldFromwxid:
  116. if value, ok := values[i].(*sql.NullString); !ok {
  117. return fmt.Errorf("unexpected type %T for field fromwxid", values[i])
  118. } else if value.Valid {
  119. bm.Fromwxid = value.String
  120. }
  121. case batchmsg.FieldMsg:
  122. if value, ok := values[i].(*sql.NullString); !ok {
  123. return fmt.Errorf("unexpected type %T for field msg", values[i])
  124. } else if value.Valid {
  125. bm.Msg = value.String
  126. }
  127. case batchmsg.FieldTag:
  128. if value, ok := values[i].(*sql.NullString); !ok {
  129. return fmt.Errorf("unexpected type %T for field tag", values[i])
  130. } else if value.Valid {
  131. bm.Tag = value.String
  132. }
  133. case batchmsg.FieldTotal:
  134. if value, ok := values[i].(*sql.NullInt64); !ok {
  135. return fmt.Errorf("unexpected type %T for field total", values[i])
  136. } else if value.Valid {
  137. bm.Total = int32(value.Int64)
  138. }
  139. case batchmsg.FieldSuccess:
  140. if value, ok := values[i].(*sql.NullInt64); !ok {
  141. return fmt.Errorf("unexpected type %T for field success", values[i])
  142. } else if value.Valid {
  143. bm.Success = int32(value.Int64)
  144. }
  145. case batchmsg.FieldFail:
  146. if value, ok := values[i].(*sql.NullInt64); !ok {
  147. return fmt.Errorf("unexpected type %T for field fail", values[i])
  148. } else if value.Valid {
  149. bm.Fail = int32(value.Int64)
  150. }
  151. case batchmsg.FieldStartTime:
  152. if value, ok := values[i].(*sql.NullTime); !ok {
  153. return fmt.Errorf("unexpected type %T for field start_time", values[i])
  154. } else if value.Valid {
  155. bm.StartTime = value.Time
  156. }
  157. case batchmsg.FieldStopTime:
  158. if value, ok := values[i].(*sql.NullTime); !ok {
  159. return fmt.Errorf("unexpected type %T for field stop_time", values[i])
  160. } else if value.Valid {
  161. bm.StopTime = value.Time
  162. }
  163. case batchmsg.FieldSendTime:
  164. if value, ok := values[i].(*sql.NullTime); !ok {
  165. return fmt.Errorf("unexpected type %T for field send_time", values[i])
  166. } else if value.Valid {
  167. bm.SendTime = value.Time
  168. }
  169. default:
  170. bm.selectValues.Set(columns[i], values[i])
  171. }
  172. }
  173. return nil
  174. }
  175. // Value returns the ent.Value that was dynamically selected and assigned to the BatchMsg.
  176. // This includes values selected through modifiers, order, etc.
  177. func (bm *BatchMsg) Value(name string) (ent.Value, error) {
  178. return bm.selectValues.Get(name)
  179. }
  180. // Update returns a builder for updating this BatchMsg.
  181. // Note that you need to call BatchMsg.Unwrap() before calling this method if this BatchMsg
  182. // was returned from a transaction, and the transaction was committed or rolled back.
  183. func (bm *BatchMsg) Update() *BatchMsgUpdateOne {
  184. return NewBatchMsgClient(bm.config).UpdateOne(bm)
  185. }
  186. // Unwrap unwraps the BatchMsg entity that was returned from a transaction after it was closed,
  187. // so that all future queries will be executed through the driver which created the transaction.
  188. func (bm *BatchMsg) Unwrap() *BatchMsg {
  189. _tx, ok := bm.config.driver.(*txDriver)
  190. if !ok {
  191. panic("ent: BatchMsg is not a transactional entity")
  192. }
  193. bm.config.driver = _tx.drv
  194. return bm
  195. }
  196. // String implements the fmt.Stringer.
  197. func (bm *BatchMsg) String() string {
  198. var builder strings.Builder
  199. builder.WriteString("BatchMsg(")
  200. builder.WriteString(fmt.Sprintf("id=%v, ", bm.ID))
  201. builder.WriteString("created_at=")
  202. builder.WriteString(bm.CreatedAt.Format(time.ANSIC))
  203. builder.WriteString(", ")
  204. builder.WriteString("updated_at=")
  205. builder.WriteString(bm.UpdatedAt.Format(time.ANSIC))
  206. builder.WriteString(", ")
  207. builder.WriteString("deleted_at=")
  208. builder.WriteString(bm.DeletedAt.Format(time.ANSIC))
  209. builder.WriteString(", ")
  210. builder.WriteString("status=")
  211. builder.WriteString(fmt.Sprintf("%v", bm.Status))
  212. builder.WriteString(", ")
  213. builder.WriteString("batch_no=")
  214. builder.WriteString(bm.BatchNo)
  215. builder.WriteString(", ")
  216. builder.WriteString("task_name=")
  217. builder.WriteString(bm.TaskName)
  218. builder.WriteString(", ")
  219. builder.WriteString("fromwxid=")
  220. builder.WriteString(bm.Fromwxid)
  221. builder.WriteString(", ")
  222. builder.WriteString("msg=")
  223. builder.WriteString(bm.Msg)
  224. builder.WriteString(", ")
  225. builder.WriteString("tag=")
  226. builder.WriteString(bm.Tag)
  227. builder.WriteString(", ")
  228. builder.WriteString("total=")
  229. builder.WriteString(fmt.Sprintf("%v", bm.Total))
  230. builder.WriteString(", ")
  231. builder.WriteString("success=")
  232. builder.WriteString(fmt.Sprintf("%v", bm.Success))
  233. builder.WriteString(", ")
  234. builder.WriteString("fail=")
  235. builder.WriteString(fmt.Sprintf("%v", bm.Fail))
  236. builder.WriteString(", ")
  237. builder.WriteString("start_time=")
  238. builder.WriteString(bm.StartTime.Format(time.ANSIC))
  239. builder.WriteString(", ")
  240. builder.WriteString("stop_time=")
  241. builder.WriteString(bm.StopTime.Format(time.ANSIC))
  242. builder.WriteString(", ")
  243. builder.WriteString("send_time=")
  244. builder.WriteString(bm.SendTime.Format(time.ANSIC))
  245. builder.WriteByte(')')
  246. return builder.String()
  247. }
  248. // BatchMsgs is a parsable slice of BatchMsg.
  249. type BatchMsgs []*BatchMsg