batchmsg.go 7.9 KB

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