123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- package ent
- import (
- "encoding/json"
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/custom_types"
- "wechat-api/ent/sopstage"
- "wechat-api/ent/soptask"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- type SopStage struct {
- config `json:"-"`
-
- ID uint64 `json:"id,omitempty"`
-
- CreatedAt time.Time `json:"created_at,omitempty"`
-
- UpdatedAt time.Time `json:"updated_at,omitempty"`
-
- Status uint8 `json:"status,omitempty"`
-
- DeletedAt time.Time `json:"deleted_at,omitempty"`
-
- TaskID uint64 `json:"task_id,omitempty"`
-
- Name string `json:"name,omitempty"`
-
- ConditionType int `json:"condition_type,omitempty"`
-
- ConditionOperator int `json:"condition_operator,omitempty"`
-
- ConditionList []custom_types.Condition `json:"condition_list,omitempty"`
-
- ActionMessage []custom_types.Action `json:"action_message,omitempty"`
-
- ActionLabel []uint64 `json:"action_label,omitempty"`
-
- IndexSort int `json:"index_sort,omitempty"`
-
-
- Edges SopStageEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- type SopStageEdges struct {
-
- SopTask *SopTask `json:"sop_task,omitempty"`
-
- StageNodes []*SopNode `json:"stage_nodes,omitempty"`
-
- StageMessages []*MessageRecords `json:"stage_messages,omitempty"`
-
-
- loadedTypes [3]bool
- }
- func (e SopStageEdges) SopTaskOrErr() (*SopTask, error) {
- if e.SopTask != nil {
- return e.SopTask, nil
- } else if e.loadedTypes[0] {
- return nil, &NotFoundError{label: soptask.Label}
- }
- return nil, &NotLoadedError{edge: "sop_task"}
- }
- func (e SopStageEdges) StageNodesOrErr() ([]*SopNode, error) {
- if e.loadedTypes[1] {
- return e.StageNodes, nil
- }
- return nil, &NotLoadedError{edge: "stage_nodes"}
- }
- func (e SopStageEdges) StageMessagesOrErr() ([]*MessageRecords, error) {
- if e.loadedTypes[2] {
- return e.StageMessages, nil
- }
- return nil, &NotLoadedError{edge: "stage_messages"}
- }
- func (*SopStage) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case sopstage.FieldConditionList, sopstage.FieldActionMessage, sopstage.FieldActionLabel:
- values[i] = new([]byte)
- case sopstage.FieldID, sopstage.FieldStatus, sopstage.FieldTaskID, sopstage.FieldConditionType, sopstage.FieldConditionOperator, sopstage.FieldIndexSort:
- values[i] = new(sql.NullInt64)
- case sopstage.FieldName:
- values[i] = new(sql.NullString)
- case sopstage.FieldCreatedAt, sopstage.FieldUpdatedAt, sopstage.FieldDeletedAt:
- values[i] = new(sql.NullTime)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- func (ss *SopStage) 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 sopstage.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- ss.ID = uint64(value.Int64)
- case sopstage.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 {
- ss.CreatedAt = value.Time
- }
- case sopstage.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 {
- ss.UpdatedAt = value.Time
- }
- case sopstage.FieldStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- ss.Status = uint8(value.Int64)
- }
- case sopstage.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 {
- ss.DeletedAt = value.Time
- }
- case sopstage.FieldTaskID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field task_id", values[i])
- } else if value.Valid {
- ss.TaskID = uint64(value.Int64)
- }
- case sopstage.FieldName:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field name", values[i])
- } else if value.Valid {
- ss.Name = value.String
- }
- case sopstage.FieldConditionType:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field condition_type", values[i])
- } else if value.Valid {
- ss.ConditionType = int(value.Int64)
- }
- case sopstage.FieldConditionOperator:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field condition_operator", values[i])
- } else if value.Valid {
- ss.ConditionOperator = int(value.Int64)
- }
- case sopstage.FieldConditionList:
- if value, ok := values[i].(*[]byte); !ok {
- return fmt.Errorf("unexpected type %T for field condition_list", values[i])
- } else if value != nil && len(*value) > 0 {
- if err := json.Unmarshal(*value, &ss.ConditionList); err != nil {
- return fmt.Errorf("unmarshal field condition_list: %w", err)
- }
- }
- case sopstage.FieldActionMessage:
- if value, ok := values[i].(*[]byte); !ok {
- return fmt.Errorf("unexpected type %T for field action_message", values[i])
- } else if value != nil && len(*value) > 0 {
- if err := json.Unmarshal(*value, &ss.ActionMessage); err != nil {
- return fmt.Errorf("unmarshal field action_message: %w", err)
- }
- }
- case sopstage.FieldActionLabel:
- if value, ok := values[i].(*[]byte); !ok {
- return fmt.Errorf("unexpected type %T for field action_label", values[i])
- } else if value != nil && len(*value) > 0 {
- if err := json.Unmarshal(*value, &ss.ActionLabel); err != nil {
- return fmt.Errorf("unmarshal field action_label: %w", err)
- }
- }
- case sopstage.FieldIndexSort:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field index_sort", values[i])
- } else if value.Valid {
- ss.IndexSort = int(value.Int64)
- }
- default:
- ss.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- func (ss *SopStage) Value(name string) (ent.Value, error) {
- return ss.selectValues.Get(name)
- }
- func (ss *SopStage) QuerySopTask() *SopTaskQuery {
- return NewSopStageClient(ss.config).QuerySopTask(ss)
- }
- func (ss *SopStage) QueryStageNodes() *SopNodeQuery {
- return NewSopStageClient(ss.config).QueryStageNodes(ss)
- }
- func (ss *SopStage) QueryStageMessages() *MessageRecordsQuery {
- return NewSopStageClient(ss.config).QueryStageMessages(ss)
- }
- func (ss *SopStage) Update() *SopStageUpdateOne {
- return NewSopStageClient(ss.config).UpdateOne(ss)
- }
- func (ss *SopStage) Unwrap() *SopStage {
- _tx, ok := ss.config.driver.(*txDriver)
- if !ok {
- panic("ent: SopStage is not a transactional entity")
- }
- ss.config.driver = _tx.drv
- return ss
- }
- func (ss *SopStage) String() string {
- var builder strings.Builder
- builder.WriteString("SopStage(")
- builder.WriteString(fmt.Sprintf("id=%v, ", ss.ID))
- builder.WriteString("created_at=")
- builder.WriteString(ss.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(ss.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("status=")
- builder.WriteString(fmt.Sprintf("%v", ss.Status))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(ss.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("task_id=")
- builder.WriteString(fmt.Sprintf("%v", ss.TaskID))
- builder.WriteString(", ")
- builder.WriteString("name=")
- builder.WriteString(ss.Name)
- builder.WriteString(", ")
- builder.WriteString("condition_type=")
- builder.WriteString(fmt.Sprintf("%v", ss.ConditionType))
- builder.WriteString(", ")
- builder.WriteString("condition_operator=")
- builder.WriteString(fmt.Sprintf("%v", ss.ConditionOperator))
- builder.WriteString(", ")
- builder.WriteString("condition_list=")
- builder.WriteString(fmt.Sprintf("%v", ss.ConditionList))
- builder.WriteString(", ")
- builder.WriteString("action_message=")
- builder.WriteString(fmt.Sprintf("%v", ss.ActionMessage))
- builder.WriteString(", ")
- builder.WriteString("action_label=")
- builder.WriteString(fmt.Sprintf("%v", ss.ActionLabel))
- builder.WriteString(", ")
- builder.WriteString("index_sort=")
- builder.WriteString(fmt.Sprintf("%v", ss.IndexSort))
- builder.WriteByte(')')
- return builder.String()
- }
- type SopStages []*SopStage
|