123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/batchmsg"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // BatchMsg is the model entity for the BatchMsg schema.
- type BatchMsg struct {
- config `json:"-"`
- // ID of the ent.
- ID uint64 `json:"id,omitempty"`
- // Create Time | 创建日期
- CreatedAt time.Time `json:"created_at,omitempty"`
- // Update Time | 修改日期
- UpdatedAt time.Time `json:"updated_at,omitempty"`
- // Delete Time | 删除日期
- DeletedAt time.Time `json:"deleted_at,omitempty"`
- // 状态 0 未开始 1 开始发送 2 发送完成 3 发送中止
- Status uint8 `json:"status,omitempty"`
- // 批次号
- BatchNo string `json:"batch_no,omitempty"`
- // 任务名称
- TaskName string `json:"task_name,omitempty"`
- // 发送方微信ID
- Fromwxid string `json:"fromwxid,omitempty"`
- // 内容
- Msg string `json:"msg,omitempty"`
- // 发送规则 all 全部 tag1,tag2 按tag发送
- Tag string `json:"tag,omitempty"`
- // 要发送的tagids
- Tagids string `json:"tagids,omitempty"`
- // 总数
- Total int32 `json:"total,omitempty"`
- // 成功数量
- Success int32 `json:"success,omitempty"`
- // 失败数量
- Fail int32 `json:"fail,omitempty"`
- // 开始时间
- StartTime time.Time `json:"start_time,omitempty"`
- // 结束时间
- StopTime time.Time `json:"stop_time,omitempty"`
- // 发送时间
- SendTime time.Time `json:"send_time,omitempty"`
- // 发送类型 1-群发消息 2-群发朋友圈
- Type int32 `json:"type,omitempty"`
- // organization_id | 租户ID
- OrganizationID uint64 `json:"organization_id,omitempty"`
- selectValues sql.SelectValues
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*BatchMsg) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case batchmsg.FieldID, batchmsg.FieldStatus, batchmsg.FieldTotal, batchmsg.FieldSuccess, batchmsg.FieldFail, batchmsg.FieldType, batchmsg.FieldOrganizationID:
- values[i] = new(sql.NullInt64)
- case batchmsg.FieldBatchNo, batchmsg.FieldTaskName, batchmsg.FieldFromwxid, batchmsg.FieldMsg, batchmsg.FieldTag, batchmsg.FieldTagids:
- values[i] = new(sql.NullString)
- case batchmsg.FieldCreatedAt, batchmsg.FieldUpdatedAt, batchmsg.FieldDeletedAt, batchmsg.FieldStartTime, batchmsg.FieldStopTime, batchmsg.FieldSendTime:
- values[i] = new(sql.NullTime)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- // assignValues assigns the values that were returned from sql.Rows (after scanning)
- // to the BatchMsg fields.
- func (bm *BatchMsg) assignValues(columns []string, values []any) error {
- if m, n := len(values), len(columns); m < n {
- return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
- }
- for i := range columns {
- switch columns[i] {
- case batchmsg.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- bm.ID = uint64(value.Int64)
- case batchmsg.FieldCreatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field created_at", values[i])
- } else if value.Valid {
- bm.CreatedAt = value.Time
- }
- case batchmsg.FieldUpdatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field updated_at", values[i])
- } else if value.Valid {
- bm.UpdatedAt = value.Time
- }
- case batchmsg.FieldDeletedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
- } else if value.Valid {
- bm.DeletedAt = value.Time
- }
- case batchmsg.FieldStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- bm.Status = uint8(value.Int64)
- }
- case batchmsg.FieldBatchNo:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field batch_no", values[i])
- } else if value.Valid {
- bm.BatchNo = value.String
- }
- case batchmsg.FieldTaskName:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field task_name", values[i])
- } else if value.Valid {
- bm.TaskName = value.String
- }
- case batchmsg.FieldFromwxid:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field fromwxid", values[i])
- } else if value.Valid {
- bm.Fromwxid = value.String
- }
- case batchmsg.FieldMsg:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field msg", values[i])
- } else if value.Valid {
- bm.Msg = value.String
- }
- case batchmsg.FieldTag:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field tag", values[i])
- } else if value.Valid {
- bm.Tag = value.String
- }
- case batchmsg.FieldTagids:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field tagids", values[i])
- } else if value.Valid {
- bm.Tagids = value.String
- }
- case batchmsg.FieldTotal:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field total", values[i])
- } else if value.Valid {
- bm.Total = int32(value.Int64)
- }
- case batchmsg.FieldSuccess:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field success", values[i])
- } else if value.Valid {
- bm.Success = int32(value.Int64)
- }
- case batchmsg.FieldFail:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field fail", values[i])
- } else if value.Valid {
- bm.Fail = int32(value.Int64)
- }
- case batchmsg.FieldStartTime:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field start_time", values[i])
- } else if value.Valid {
- bm.StartTime = value.Time
- }
- case batchmsg.FieldStopTime:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field stop_time", values[i])
- } else if value.Valid {
- bm.StopTime = value.Time
- }
- case batchmsg.FieldSendTime:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field send_time", values[i])
- } else if value.Valid {
- bm.SendTime = value.Time
- }
- case batchmsg.FieldType:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field type", values[i])
- } else if value.Valid {
- bm.Type = int32(value.Int64)
- }
- case batchmsg.FieldOrganizationID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field organization_id", values[i])
- } else if value.Valid {
- bm.OrganizationID = uint64(value.Int64)
- }
- default:
- bm.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the BatchMsg.
- // This includes values selected through modifiers, order, etc.
- func (bm *BatchMsg) Value(name string) (ent.Value, error) {
- return bm.selectValues.Get(name)
- }
- // Update returns a builder for updating this BatchMsg.
- // Note that you need to call BatchMsg.Unwrap() before calling this method if this BatchMsg
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (bm *BatchMsg) Update() *BatchMsgUpdateOne {
- return NewBatchMsgClient(bm.config).UpdateOne(bm)
- }
- // Unwrap unwraps the BatchMsg entity that was returned from a transaction after it was closed,
- // so that all future queries will be executed through the driver which created the transaction.
- func (bm *BatchMsg) Unwrap() *BatchMsg {
- _tx, ok := bm.config.driver.(*txDriver)
- if !ok {
- panic("ent: BatchMsg is not a transactional entity")
- }
- bm.config.driver = _tx.drv
- return bm
- }
- // String implements the fmt.Stringer.
- func (bm *BatchMsg) String() string {
- var builder strings.Builder
- builder.WriteString("BatchMsg(")
- builder.WriteString(fmt.Sprintf("id=%v, ", bm.ID))
- builder.WriteString("created_at=")
- builder.WriteString(bm.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(bm.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(bm.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("status=")
- builder.WriteString(fmt.Sprintf("%v", bm.Status))
- builder.WriteString(", ")
- builder.WriteString("batch_no=")
- builder.WriteString(bm.BatchNo)
- builder.WriteString(", ")
- builder.WriteString("task_name=")
- builder.WriteString(bm.TaskName)
- builder.WriteString(", ")
- builder.WriteString("fromwxid=")
- builder.WriteString(bm.Fromwxid)
- builder.WriteString(", ")
- builder.WriteString("msg=")
- builder.WriteString(bm.Msg)
- builder.WriteString(", ")
- builder.WriteString("tag=")
- builder.WriteString(bm.Tag)
- builder.WriteString(", ")
- builder.WriteString("tagids=")
- builder.WriteString(bm.Tagids)
- builder.WriteString(", ")
- builder.WriteString("total=")
- builder.WriteString(fmt.Sprintf("%v", bm.Total))
- builder.WriteString(", ")
- builder.WriteString("success=")
- builder.WriteString(fmt.Sprintf("%v", bm.Success))
- builder.WriteString(", ")
- builder.WriteString("fail=")
- builder.WriteString(fmt.Sprintf("%v", bm.Fail))
- builder.WriteString(", ")
- builder.WriteString("start_time=")
- builder.WriteString(bm.StartTime.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("stop_time=")
- builder.WriteString(bm.StopTime.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("send_time=")
- builder.WriteString(bm.SendTime.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("type=")
- builder.WriteString(fmt.Sprintf("%v", bm.Type))
- builder.WriteString(", ")
- builder.WriteString("organization_id=")
- builder.WriteString(fmt.Sprintf("%v", bm.OrganizationID))
- builder.WriteByte(')')
- return builder.String()
- }
- // BatchMsgs is a parsable slice of BatchMsg.
- type BatchMsgs []*BatchMsg
|