batchmsg.go 10.0 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/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. // 要发送的tagids
  35. Tagids string `json:"tagids,omitempty"`
  36. // 总数
  37. Total int32 `json:"total,omitempty"`
  38. // 成功数量
  39. Success int32 `json:"success,omitempty"`
  40. // 失败数量
  41. Fail int32 `json:"fail,omitempty"`
  42. // 开始时间
  43. StartTime time.Time `json:"start_time,omitempty"`
  44. // 结束时间
  45. StopTime time.Time `json:"stop_time,omitempty"`
  46. // 发送时间
  47. SendTime time.Time `json:"send_time,omitempty"`
  48. // 发送类型 1-群发消息 2-群发朋友圈
  49. Type int32 `json:"type,omitempty"`
  50. // organization_id | 租户ID
  51. OrganizationID uint64 `json:"organization_id,omitempty"`
  52. selectValues sql.SelectValues
  53. }
  54. // scanValues returns the types for scanning values from sql.Rows.
  55. func (*BatchMsg) scanValues(columns []string) ([]any, error) {
  56. values := make([]any, len(columns))
  57. for i := range columns {
  58. switch columns[i] {
  59. case batchmsg.FieldID, batchmsg.FieldStatus, batchmsg.FieldTotal, batchmsg.FieldSuccess, batchmsg.FieldFail, batchmsg.FieldType, batchmsg.FieldOrganizationID:
  60. values[i] = new(sql.NullInt64)
  61. case batchmsg.FieldBatchNo, batchmsg.FieldTaskName, batchmsg.FieldFromwxid, batchmsg.FieldMsg, batchmsg.FieldTag, batchmsg.FieldTagids:
  62. values[i] = new(sql.NullString)
  63. case batchmsg.FieldCreatedAt, batchmsg.FieldUpdatedAt, batchmsg.FieldDeletedAt, batchmsg.FieldStartTime, batchmsg.FieldStopTime, batchmsg.FieldSendTime:
  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 BatchMsg fields.
  73. func (bm *BatchMsg) 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 batchmsg.FieldID:
  80. value, ok := values[i].(*sql.NullInt64)
  81. if !ok {
  82. return fmt.Errorf("unexpected type %T for field id", value)
  83. }
  84. bm.ID = uint64(value.Int64)
  85. case batchmsg.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. bm.CreatedAt = value.Time
  90. }
  91. case batchmsg.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. bm.UpdatedAt = value.Time
  96. }
  97. case batchmsg.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. bm.DeletedAt = value.Time
  102. }
  103. case batchmsg.FieldStatus:
  104. if value, ok := values[i].(*sql.NullInt64); !ok {
  105. return fmt.Errorf("unexpected type %T for field status", values[i])
  106. } else if value.Valid {
  107. bm.Status = uint8(value.Int64)
  108. }
  109. case batchmsg.FieldBatchNo:
  110. if value, ok := values[i].(*sql.NullString); !ok {
  111. return fmt.Errorf("unexpected type %T for field batch_no", values[i])
  112. } else if value.Valid {
  113. bm.BatchNo = value.String
  114. }
  115. case batchmsg.FieldTaskName:
  116. if value, ok := values[i].(*sql.NullString); !ok {
  117. return fmt.Errorf("unexpected type %T for field task_name", values[i])
  118. } else if value.Valid {
  119. bm.TaskName = value.String
  120. }
  121. case batchmsg.FieldFromwxid:
  122. if value, ok := values[i].(*sql.NullString); !ok {
  123. return fmt.Errorf("unexpected type %T for field fromwxid", values[i])
  124. } else if value.Valid {
  125. bm.Fromwxid = value.String
  126. }
  127. case batchmsg.FieldMsg:
  128. if value, ok := values[i].(*sql.NullString); !ok {
  129. return fmt.Errorf("unexpected type %T for field msg", values[i])
  130. } else if value.Valid {
  131. bm.Msg = value.String
  132. }
  133. case batchmsg.FieldTag:
  134. if value, ok := values[i].(*sql.NullString); !ok {
  135. return fmt.Errorf("unexpected type %T for field tag", values[i])
  136. } else if value.Valid {
  137. bm.Tag = value.String
  138. }
  139. case batchmsg.FieldTagids:
  140. if value, ok := values[i].(*sql.NullString); !ok {
  141. return fmt.Errorf("unexpected type %T for field tagids", values[i])
  142. } else if value.Valid {
  143. bm.Tagids = value.String
  144. }
  145. case batchmsg.FieldTotal:
  146. if value, ok := values[i].(*sql.NullInt64); !ok {
  147. return fmt.Errorf("unexpected type %T for field total", values[i])
  148. } else if value.Valid {
  149. bm.Total = int32(value.Int64)
  150. }
  151. case batchmsg.FieldSuccess:
  152. if value, ok := values[i].(*sql.NullInt64); !ok {
  153. return fmt.Errorf("unexpected type %T for field success", values[i])
  154. } else if value.Valid {
  155. bm.Success = int32(value.Int64)
  156. }
  157. case batchmsg.FieldFail:
  158. if value, ok := values[i].(*sql.NullInt64); !ok {
  159. return fmt.Errorf("unexpected type %T for field fail", values[i])
  160. } else if value.Valid {
  161. bm.Fail = int32(value.Int64)
  162. }
  163. case batchmsg.FieldStartTime:
  164. if value, ok := values[i].(*sql.NullTime); !ok {
  165. return fmt.Errorf("unexpected type %T for field start_time", values[i])
  166. } else if value.Valid {
  167. bm.StartTime = value.Time
  168. }
  169. case batchmsg.FieldStopTime:
  170. if value, ok := values[i].(*sql.NullTime); !ok {
  171. return fmt.Errorf("unexpected type %T for field stop_time", values[i])
  172. } else if value.Valid {
  173. bm.StopTime = value.Time
  174. }
  175. case batchmsg.FieldSendTime:
  176. if value, ok := values[i].(*sql.NullTime); !ok {
  177. return fmt.Errorf("unexpected type %T for field send_time", values[i])
  178. } else if value.Valid {
  179. bm.SendTime = value.Time
  180. }
  181. case batchmsg.FieldType:
  182. if value, ok := values[i].(*sql.NullInt64); !ok {
  183. return fmt.Errorf("unexpected type %T for field type", values[i])
  184. } else if value.Valid {
  185. bm.Type = int32(value.Int64)
  186. }
  187. case batchmsg.FieldOrganizationID:
  188. if value, ok := values[i].(*sql.NullInt64); !ok {
  189. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  190. } else if value.Valid {
  191. bm.OrganizationID = uint64(value.Int64)
  192. }
  193. default:
  194. bm.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 BatchMsg.
  200. // This includes values selected through modifiers, order, etc.
  201. func (bm *BatchMsg) Value(name string) (ent.Value, error) {
  202. return bm.selectValues.Get(name)
  203. }
  204. // Update returns a builder for updating this BatchMsg.
  205. // Note that you need to call BatchMsg.Unwrap() before calling this method if this BatchMsg
  206. // was returned from a transaction, and the transaction was committed or rolled back.
  207. func (bm *BatchMsg) Update() *BatchMsgUpdateOne {
  208. return NewBatchMsgClient(bm.config).UpdateOne(bm)
  209. }
  210. // Unwrap unwraps the BatchMsg 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 (bm *BatchMsg) Unwrap() *BatchMsg {
  213. _tx, ok := bm.config.driver.(*txDriver)
  214. if !ok {
  215. panic("ent: BatchMsg is not a transactional entity")
  216. }
  217. bm.config.driver = _tx.drv
  218. return bm
  219. }
  220. // String implements the fmt.Stringer.
  221. func (bm *BatchMsg) String() string {
  222. var builder strings.Builder
  223. builder.WriteString("BatchMsg(")
  224. builder.WriteString(fmt.Sprintf("id=%v, ", bm.ID))
  225. builder.WriteString("created_at=")
  226. builder.WriteString(bm.CreatedAt.Format(time.ANSIC))
  227. builder.WriteString(", ")
  228. builder.WriteString("updated_at=")
  229. builder.WriteString(bm.UpdatedAt.Format(time.ANSIC))
  230. builder.WriteString(", ")
  231. builder.WriteString("deleted_at=")
  232. builder.WriteString(bm.DeletedAt.Format(time.ANSIC))
  233. builder.WriteString(", ")
  234. builder.WriteString("status=")
  235. builder.WriteString(fmt.Sprintf("%v", bm.Status))
  236. builder.WriteString(", ")
  237. builder.WriteString("batch_no=")
  238. builder.WriteString(bm.BatchNo)
  239. builder.WriteString(", ")
  240. builder.WriteString("task_name=")
  241. builder.WriteString(bm.TaskName)
  242. builder.WriteString(", ")
  243. builder.WriteString("fromwxid=")
  244. builder.WriteString(bm.Fromwxid)
  245. builder.WriteString(", ")
  246. builder.WriteString("msg=")
  247. builder.WriteString(bm.Msg)
  248. builder.WriteString(", ")
  249. builder.WriteString("tag=")
  250. builder.WriteString(bm.Tag)
  251. builder.WriteString(", ")
  252. builder.WriteString("tagids=")
  253. builder.WriteString(bm.Tagids)
  254. builder.WriteString(", ")
  255. builder.WriteString("total=")
  256. builder.WriteString(fmt.Sprintf("%v", bm.Total))
  257. builder.WriteString(", ")
  258. builder.WriteString("success=")
  259. builder.WriteString(fmt.Sprintf("%v", bm.Success))
  260. builder.WriteString(", ")
  261. builder.WriteString("fail=")
  262. builder.WriteString(fmt.Sprintf("%v", bm.Fail))
  263. builder.WriteString(", ")
  264. builder.WriteString("start_time=")
  265. builder.WriteString(bm.StartTime.Format(time.ANSIC))
  266. builder.WriteString(", ")
  267. builder.WriteString("stop_time=")
  268. builder.WriteString(bm.StopTime.Format(time.ANSIC))
  269. builder.WriteString(", ")
  270. builder.WriteString("send_time=")
  271. builder.WriteString(bm.SendTime.Format(time.ANSIC))
  272. builder.WriteString(", ")
  273. builder.WriteString("type=")
  274. builder.WriteString(fmt.Sprintf("%v", bm.Type))
  275. builder.WriteString(", ")
  276. builder.WriteString("organization_id=")
  277. builder.WriteString(fmt.Sprintf("%v", bm.OrganizationID))
  278. builder.WriteByte(')')
  279. return builder.String()
  280. }
  281. // BatchMsgs is a parsable slice of BatchMsg.
  282. type BatchMsgs []*BatchMsg