batchmsg.go 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. // 发送类型 1-群发消息 2-群发朋友圈
  47. Type int32 `json:"type,omitempty"`
  48. selectValues sql.SelectValues
  49. }
  50. // scanValues returns the types for scanning values from sql.Rows.
  51. func (*BatchMsg) scanValues(columns []string) ([]any, error) {
  52. values := make([]any, len(columns))
  53. for i := range columns {
  54. switch columns[i] {
  55. case batchmsg.FieldID, batchmsg.FieldStatus, batchmsg.FieldTotal, batchmsg.FieldSuccess, batchmsg.FieldFail, batchmsg.FieldType:
  56. values[i] = new(sql.NullInt64)
  57. case batchmsg.FieldBatchNo, batchmsg.FieldTaskName, batchmsg.FieldFromwxid, batchmsg.FieldMsg, batchmsg.FieldTag:
  58. values[i] = new(sql.NullString)
  59. case batchmsg.FieldCreatedAt, batchmsg.FieldUpdatedAt, batchmsg.FieldDeletedAt, batchmsg.FieldStartTime, batchmsg.FieldStopTime, batchmsg.FieldSendTime:
  60. values[i] = new(sql.NullTime)
  61. default:
  62. values[i] = new(sql.UnknownType)
  63. }
  64. }
  65. return values, nil
  66. }
  67. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  68. // to the BatchMsg fields.
  69. func (bm *BatchMsg) assignValues(columns []string, values []any) error {
  70. if m, n := len(values), len(columns); m < n {
  71. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  72. }
  73. for i := range columns {
  74. switch columns[i] {
  75. case batchmsg.FieldID:
  76. value, ok := values[i].(*sql.NullInt64)
  77. if !ok {
  78. return fmt.Errorf("unexpected type %T for field id", value)
  79. }
  80. bm.ID = uint64(value.Int64)
  81. case batchmsg.FieldCreatedAt:
  82. if value, ok := values[i].(*sql.NullTime); !ok {
  83. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  84. } else if value.Valid {
  85. bm.CreatedAt = value.Time
  86. }
  87. case batchmsg.FieldUpdatedAt:
  88. if value, ok := values[i].(*sql.NullTime); !ok {
  89. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  90. } else if value.Valid {
  91. bm.UpdatedAt = value.Time
  92. }
  93. case batchmsg.FieldDeletedAt:
  94. if value, ok := values[i].(*sql.NullTime); !ok {
  95. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  96. } else if value.Valid {
  97. bm.DeletedAt = value.Time
  98. }
  99. case batchmsg.FieldStatus:
  100. if value, ok := values[i].(*sql.NullInt64); !ok {
  101. return fmt.Errorf("unexpected type %T for field status", values[i])
  102. } else if value.Valid {
  103. bm.Status = uint8(value.Int64)
  104. }
  105. case batchmsg.FieldBatchNo:
  106. if value, ok := values[i].(*sql.NullString); !ok {
  107. return fmt.Errorf("unexpected type %T for field batch_no", values[i])
  108. } else if value.Valid {
  109. bm.BatchNo = value.String
  110. }
  111. case batchmsg.FieldTaskName:
  112. if value, ok := values[i].(*sql.NullString); !ok {
  113. return fmt.Errorf("unexpected type %T for field task_name", values[i])
  114. } else if value.Valid {
  115. bm.TaskName = value.String
  116. }
  117. case batchmsg.FieldFromwxid:
  118. if value, ok := values[i].(*sql.NullString); !ok {
  119. return fmt.Errorf("unexpected type %T for field fromwxid", values[i])
  120. } else if value.Valid {
  121. bm.Fromwxid = value.String
  122. }
  123. case batchmsg.FieldMsg:
  124. if value, ok := values[i].(*sql.NullString); !ok {
  125. return fmt.Errorf("unexpected type %T for field msg", values[i])
  126. } else if value.Valid {
  127. bm.Msg = value.String
  128. }
  129. case batchmsg.FieldTag:
  130. if value, ok := values[i].(*sql.NullString); !ok {
  131. return fmt.Errorf("unexpected type %T for field tag", values[i])
  132. } else if value.Valid {
  133. bm.Tag = value.String
  134. }
  135. case batchmsg.FieldTotal:
  136. if value, ok := values[i].(*sql.NullInt64); !ok {
  137. return fmt.Errorf("unexpected type %T for field total", values[i])
  138. } else if value.Valid {
  139. bm.Total = int32(value.Int64)
  140. }
  141. case batchmsg.FieldSuccess:
  142. if value, ok := values[i].(*sql.NullInt64); !ok {
  143. return fmt.Errorf("unexpected type %T for field success", values[i])
  144. } else if value.Valid {
  145. bm.Success = int32(value.Int64)
  146. }
  147. case batchmsg.FieldFail:
  148. if value, ok := values[i].(*sql.NullInt64); !ok {
  149. return fmt.Errorf("unexpected type %T for field fail", values[i])
  150. } else if value.Valid {
  151. bm.Fail = int32(value.Int64)
  152. }
  153. case batchmsg.FieldStartTime:
  154. if value, ok := values[i].(*sql.NullTime); !ok {
  155. return fmt.Errorf("unexpected type %T for field start_time", values[i])
  156. } else if value.Valid {
  157. bm.StartTime = value.Time
  158. }
  159. case batchmsg.FieldStopTime:
  160. if value, ok := values[i].(*sql.NullTime); !ok {
  161. return fmt.Errorf("unexpected type %T for field stop_time", values[i])
  162. } else if value.Valid {
  163. bm.StopTime = value.Time
  164. }
  165. case batchmsg.FieldSendTime:
  166. if value, ok := values[i].(*sql.NullTime); !ok {
  167. return fmt.Errorf("unexpected type %T for field send_time", values[i])
  168. } else if value.Valid {
  169. bm.SendTime = value.Time
  170. }
  171. case batchmsg.FieldType:
  172. if value, ok := values[i].(*sql.NullInt64); !ok {
  173. return fmt.Errorf("unexpected type %T for field type", values[i])
  174. } else if value.Valid {
  175. bm.Type = int32(value.Int64)
  176. }
  177. default:
  178. bm.selectValues.Set(columns[i], values[i])
  179. }
  180. }
  181. return nil
  182. }
  183. // Value returns the ent.Value that was dynamically selected and assigned to the BatchMsg.
  184. // This includes values selected through modifiers, order, etc.
  185. func (bm *BatchMsg) Value(name string) (ent.Value, error) {
  186. return bm.selectValues.Get(name)
  187. }
  188. // Update returns a builder for updating this BatchMsg.
  189. // Note that you need to call BatchMsg.Unwrap() before calling this method if this BatchMsg
  190. // was returned from a transaction, and the transaction was committed or rolled back.
  191. func (bm *BatchMsg) Update() *BatchMsgUpdateOne {
  192. return NewBatchMsgClient(bm.config).UpdateOne(bm)
  193. }
  194. // Unwrap unwraps the BatchMsg entity that was returned from a transaction after it was closed,
  195. // so that all future queries will be executed through the driver which created the transaction.
  196. func (bm *BatchMsg) Unwrap() *BatchMsg {
  197. _tx, ok := bm.config.driver.(*txDriver)
  198. if !ok {
  199. panic("ent: BatchMsg is not a transactional entity")
  200. }
  201. bm.config.driver = _tx.drv
  202. return bm
  203. }
  204. // String implements the fmt.Stringer.
  205. func (bm *BatchMsg) String() string {
  206. var builder strings.Builder
  207. builder.WriteString("BatchMsg(")
  208. builder.WriteString(fmt.Sprintf("id=%v, ", bm.ID))
  209. builder.WriteString("created_at=")
  210. builder.WriteString(bm.CreatedAt.Format(time.ANSIC))
  211. builder.WriteString(", ")
  212. builder.WriteString("updated_at=")
  213. builder.WriteString(bm.UpdatedAt.Format(time.ANSIC))
  214. builder.WriteString(", ")
  215. builder.WriteString("deleted_at=")
  216. builder.WriteString(bm.DeletedAt.Format(time.ANSIC))
  217. builder.WriteString(", ")
  218. builder.WriteString("status=")
  219. builder.WriteString(fmt.Sprintf("%v", bm.Status))
  220. builder.WriteString(", ")
  221. builder.WriteString("batch_no=")
  222. builder.WriteString(bm.BatchNo)
  223. builder.WriteString(", ")
  224. builder.WriteString("task_name=")
  225. builder.WriteString(bm.TaskName)
  226. builder.WriteString(", ")
  227. builder.WriteString("fromwxid=")
  228. builder.WriteString(bm.Fromwxid)
  229. builder.WriteString(", ")
  230. builder.WriteString("msg=")
  231. builder.WriteString(bm.Msg)
  232. builder.WriteString(", ")
  233. builder.WriteString("tag=")
  234. builder.WriteString(bm.Tag)
  235. builder.WriteString(", ")
  236. builder.WriteString("total=")
  237. builder.WriteString(fmt.Sprintf("%v", bm.Total))
  238. builder.WriteString(", ")
  239. builder.WriteString("success=")
  240. builder.WriteString(fmt.Sprintf("%v", bm.Success))
  241. builder.WriteString(", ")
  242. builder.WriteString("fail=")
  243. builder.WriteString(fmt.Sprintf("%v", bm.Fail))
  244. builder.WriteString(", ")
  245. builder.WriteString("start_time=")
  246. builder.WriteString(bm.StartTime.Format(time.ANSIC))
  247. builder.WriteString(", ")
  248. builder.WriteString("stop_time=")
  249. builder.WriteString(bm.StopTime.Format(time.ANSIC))
  250. builder.WriteString(", ")
  251. builder.WriteString("send_time=")
  252. builder.WriteString(bm.SendTime.Format(time.ANSIC))
  253. builder.WriteString(", ")
  254. builder.WriteString("type=")
  255. builder.WriteString(fmt.Sprintf("%v", bm.Type))
  256. builder.WriteByte(')')
  257. return builder.String()
  258. }
  259. // BatchMsgs is a parsable slice of BatchMsg.
  260. type BatchMsgs []*BatchMsg