feat: Support for Chat Flow & Agent Support for binding a single chat flow (#765)
Co-authored-by: Yu Yang <72337138+tomasyu985@users.noreply.github.com> Co-authored-by: zengxiaohui <csu.zengxiaohui@gmail.com> Co-authored-by: lijunwen.gigoo <lijunwen.gigoo@bytedance.com> Co-authored-by: lvxinyu.1117 <lvxinyu.1117@bytedance.com> Co-authored-by: liuyunchao.0510 <liuyunchao.0510@bytedance.com> Co-authored-by: haozhenfei <37089575+haozhenfei@users.noreply.github.com> Co-authored-by: July <jiangxujin@bytedance.com> Co-authored-by: tecvan-fe <fanwenjie.fe@bytedance.com>
This commit is contained in:
940
backend/domain/workflow/internal/repo/conversation_repository.go
Normal file
940
backend/domain/workflow/internal/repo/conversation_repository.go
Normal file
@@ -0,0 +1,940 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gorm"
|
||||
|
||||
crossconversation "github.com/coze-dev/coze-studio/backend/crossdomain/contract/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
const batchSize = 10
|
||||
|
||||
func (r *RepositoryImpl) CreateDraftConversationTemplate(ctx context.Context, template *vo.CreateConversationTemplateMeta) (int64, error) {
|
||||
id, err := r.GenID(ctx)
|
||||
if err != nil {
|
||||
return 0, vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
m := &model.AppConversationTemplateDraft{
|
||||
ID: id,
|
||||
AppID: template.AppID,
|
||||
SpaceID: template.SpaceID,
|
||||
Name: template.Name,
|
||||
CreatorID: template.UserID,
|
||||
TemplateID: id,
|
||||
}
|
||||
err = r.query.AppConversationTemplateDraft.WithContext(ctx).Create(m)
|
||||
if err != nil {
|
||||
return 0, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetConversationTemplate(ctx context.Context, env vo.Env, policy vo.GetConversationTemplatePolicy) (*entity.ConversationTemplate, bool, error) {
|
||||
var (
|
||||
appID = policy.AppID
|
||||
name = policy.Name
|
||||
version = policy.Version
|
||||
templateID = policy.TemplateID
|
||||
)
|
||||
|
||||
conditions := make([]gen.Condition, 0)
|
||||
if env == vo.Draft {
|
||||
if appID != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateDraft.AppID.Eq(*appID))
|
||||
}
|
||||
if name != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateDraft.Name.Eq(*name))
|
||||
}
|
||||
if templateID != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateDraft.TemplateID.Eq(*templateID))
|
||||
}
|
||||
|
||||
template, err := r.query.AppConversationTemplateDraft.WithContext(ctx).Where(conditions...).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return &entity.ConversationTemplate{
|
||||
AppID: template.AppID,
|
||||
Name: template.Name,
|
||||
TemplateID: template.TemplateID,
|
||||
}, true, nil
|
||||
|
||||
} else if env == vo.Online {
|
||||
if policy.Version != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateOnline.Version.Eq(*version))
|
||||
}
|
||||
if appID != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateOnline.AppID.Eq(*appID))
|
||||
}
|
||||
if name != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateOnline.Name.Eq(*name))
|
||||
}
|
||||
|
||||
if templateID != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateOnline.TemplateID.Eq(*templateID))
|
||||
}
|
||||
|
||||
template, err := r.query.AppConversationTemplateOnline.WithContext(ctx).Where(conditions...).Order(r.query.AppConversationTemplateOnline.CreatedAt.Desc()).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
return &entity.ConversationTemplate{
|
||||
AppID: template.AppID,
|
||||
Name: template.Name,
|
||||
TemplateID: template.TemplateID,
|
||||
}, true, nil
|
||||
}
|
||||
|
||||
return nil, false, fmt.Errorf("unknown env %v", env)
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) UpdateDraftConversationTemplateName(ctx context.Context, templateID int64, name string) error {
|
||||
_, err := r.query.AppConversationTemplateDraft.WithContext(ctx).Where(
|
||||
r.query.AppConversationTemplateDraft.TemplateID.Eq(templateID),
|
||||
).UpdateColumnSimple(r.query.AppConversationTemplateDraft.Name.Value(name))
|
||||
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) DeleteDraftConversationTemplate(ctx context.Context, templateID int64) (int64, error) {
|
||||
resultInfo, err := r.query.AppConversationTemplateDraft.WithContext(ctx).Where(
|
||||
r.query.AppConversationTemplateDraft.TemplateID.Eq(templateID),
|
||||
).Delete()
|
||||
|
||||
if err != nil {
|
||||
return 0, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return resultInfo.RowsAffected, nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) DeleteDynamicConversation(ctx context.Context, env vo.Env, id int64) (int64, error) {
|
||||
if env == vo.Draft {
|
||||
info, err := r.query.AppDynamicConversationDraft.WithContext(ctx).Where(r.query.AppDynamicConversationDraft.ID.Eq(id)).Delete()
|
||||
if err != nil {
|
||||
return 0, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return info.RowsAffected, nil
|
||||
} else if env == vo.Online {
|
||||
info, err := r.query.AppDynamicConversationOnline.WithContext(ctx).Where(r.query.AppDynamicConversationOnline.ID.Eq(id)).Delete()
|
||||
if err != nil {
|
||||
return 0, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return info.RowsAffected, nil
|
||||
} else {
|
||||
return 0, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) ListConversationTemplate(ctx context.Context, env vo.Env, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
|
||||
if env == vo.Draft {
|
||||
return r.listDraftConversationTemplate(ctx, policy)
|
||||
} else if env == vo.Online {
|
||||
return r.listOnlineConversationTemplate(ctx, policy)
|
||||
} else {
|
||||
return nil, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) listDraftConversationTemplate(ctx context.Context, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
|
||||
conditions := make([]gen.Condition, 0)
|
||||
conditions = append(conditions, r.query.AppConversationTemplateDraft.AppID.Eq(policy.AppID))
|
||||
|
||||
if policy.NameLike != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateDraft.Name.Like("%%"+*policy.NameLike+"%%"))
|
||||
}
|
||||
appConversationTemplateDraftDao := r.query.AppConversationTemplateDraft.WithContext(ctx)
|
||||
var (
|
||||
templates []*model.AppConversationTemplateDraft
|
||||
err error
|
||||
)
|
||||
|
||||
if policy.Page != nil {
|
||||
templates, err = appConversationTemplateDraftDao.Where(conditions...).Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
|
||||
} else {
|
||||
templates, err = appConversationTemplateDraftDao.Where(conditions...).Find()
|
||||
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return []*entity.ConversationTemplate{}, nil
|
||||
}
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return slices.Transform(templates, func(a *model.AppConversationTemplateDraft) *entity.ConversationTemplate {
|
||||
return &entity.ConversationTemplate{
|
||||
SpaceID: a.SpaceID,
|
||||
AppID: a.AppID,
|
||||
Name: a.Name,
|
||||
TemplateID: a.TemplateID,
|
||||
}
|
||||
}), nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) listOnlineConversationTemplate(ctx context.Context, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
|
||||
conditions := make([]gen.Condition, 0)
|
||||
conditions = append(conditions, r.query.AppConversationTemplateOnline.AppID.Eq(policy.AppID))
|
||||
if policy.Version == nil {
|
||||
return nil, fmt.Errorf("list online template fail, version is required")
|
||||
}
|
||||
conditions = append(conditions, r.query.AppConversationTemplateOnline.Version.Eq(*policy.Version))
|
||||
|
||||
if policy.NameLike != nil {
|
||||
conditions = append(conditions, r.query.AppConversationTemplateOnline.Name.Like("%%"+*policy.NameLike+"%%"))
|
||||
}
|
||||
appConversationTemplateOnlineDao := r.query.AppConversationTemplateOnline.WithContext(ctx)
|
||||
var (
|
||||
templates []*model.AppConversationTemplateOnline
|
||||
err error
|
||||
)
|
||||
if policy.Page != nil {
|
||||
templates, err = appConversationTemplateOnlineDao.Where(conditions...).Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
|
||||
|
||||
} else {
|
||||
templates, err = appConversationTemplateOnlineDao.Where(conditions...).Find()
|
||||
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return []*entity.ConversationTemplate{}, nil
|
||||
}
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return slices.Transform(templates, func(a *model.AppConversationTemplateOnline) *entity.ConversationTemplate {
|
||||
return &entity.ConversationTemplate{
|
||||
SpaceID: a.SpaceID,
|
||||
AppID: a.AppID,
|
||||
Name: a.Name,
|
||||
TemplateID: a.TemplateID,
|
||||
}
|
||||
}), nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) MGetStaticConversation(ctx context.Context, env vo.Env, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
|
||||
if env == vo.Draft {
|
||||
return r.mGetDraftStaticConversation(ctx, userID, connectorID, templateIDs)
|
||||
} else if env == vo.Online {
|
||||
return r.mGetOnlineStaticConversation(ctx, userID, connectorID, templateIDs)
|
||||
} else {
|
||||
return nil, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) mGetDraftStaticConversation(ctx context.Context, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
|
||||
conditions := make([]gen.Condition, 0, 3)
|
||||
conditions = append(conditions, r.query.AppStaticConversationDraft.UserID.Eq(userID))
|
||||
conditions = append(conditions, r.query.AppStaticConversationDraft.ConnectorID.Eq(connectorID))
|
||||
if len(templateIDs) == 1 {
|
||||
conditions = append(conditions, r.query.AppStaticConversationDraft.TemplateID.Eq(templateIDs[0]))
|
||||
} else {
|
||||
conditions = append(conditions, r.query.AppStaticConversationDraft.TemplateID.In(templateIDs...))
|
||||
}
|
||||
|
||||
cs, err := r.query.AppStaticConversationDraft.WithContext(ctx).Where(conditions...).Find()
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return []*entity.StaticConversation{}, nil
|
||||
}
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return slices.Transform(cs, func(a *model.AppStaticConversationDraft) *entity.StaticConversation {
|
||||
return &entity.StaticConversation{
|
||||
TemplateID: a.TemplateID,
|
||||
ConversationID: a.ConversationID,
|
||||
UserID: a.UserID,
|
||||
ConnectorID: a.ConnectorID,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) mGetOnlineStaticConversation(ctx context.Context, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
|
||||
conditions := make([]gen.Condition, 0, 3)
|
||||
conditions = append(conditions, r.query.AppStaticConversationOnline.UserID.Eq(userID))
|
||||
conditions = append(conditions, r.query.AppStaticConversationOnline.ConnectorID.Eq(connectorID))
|
||||
if len(templateIDs) == 1 {
|
||||
conditions = append(conditions, r.query.AppStaticConversationOnline.TemplateID.Eq(templateIDs[0]))
|
||||
} else {
|
||||
conditions = append(conditions, r.query.AppStaticConversationOnline.TemplateID.In(templateIDs...))
|
||||
}
|
||||
|
||||
cs, err := r.query.AppStaticConversationOnline.WithContext(ctx).Where(conditions...).Find()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return []*entity.StaticConversation{}, nil
|
||||
}
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return slices.Transform(cs, func(a *model.AppStaticConversationOnline) *entity.StaticConversation {
|
||||
return &entity.StaticConversation{
|
||||
TemplateID: a.TemplateID,
|
||||
ConversationID: a.ConversationID,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) ListDynamicConversation(ctx context.Context, env vo.Env, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
|
||||
if env == vo.Draft {
|
||||
return r.listDraftDynamicConversation(ctx, policy)
|
||||
} else if env == vo.Online {
|
||||
return r.listOnlineDynamicConversation(ctx, policy)
|
||||
} else {
|
||||
return nil, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) listDraftDynamicConversation(ctx context.Context, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
|
||||
var (
|
||||
appID = policy.APPID
|
||||
userID = policy.UserID
|
||||
connectorID = policy.ConnectorID
|
||||
)
|
||||
|
||||
conditions := make([]gen.Condition, 0)
|
||||
conditions = append(conditions, r.query.AppDynamicConversationDraft.AppID.Eq(appID))
|
||||
conditions = append(conditions, r.query.AppDynamicConversationDraft.UserID.Eq(userID))
|
||||
conditions = append(conditions, r.query.AppDynamicConversationDraft.ConnectorID.Eq(connectorID))
|
||||
if policy.NameLike != nil {
|
||||
conditions = append(conditions, r.query.AppDynamicConversationDraft.Name.Like("%%"+*policy.NameLike+"%%"))
|
||||
}
|
||||
|
||||
appDynamicConversationDraftDao := r.query.AppDynamicConversationDraft.WithContext(ctx).Where(conditions...)
|
||||
var (
|
||||
dynamicConversations = make([]*model.AppDynamicConversationDraft, 0)
|
||||
err error
|
||||
)
|
||||
|
||||
if policy.Page != nil {
|
||||
dynamicConversations, err = appDynamicConversationDraftDao.Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
|
||||
|
||||
} else {
|
||||
dynamicConversations, err = appDynamicConversationDraftDao.Where(conditions...).Find()
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return []*entity.DynamicConversation{}, nil
|
||||
}
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return slices.Transform(dynamicConversations, func(a *model.AppDynamicConversationDraft) *entity.DynamicConversation {
|
||||
return &entity.DynamicConversation{
|
||||
ID: a.ID,
|
||||
Name: a.Name,
|
||||
UserID: a.UserID,
|
||||
ConnectorID: a.ConnectorID,
|
||||
ConversationID: a.ConversationID,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) listOnlineDynamicConversation(ctx context.Context, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
|
||||
var (
|
||||
appID = policy.APPID
|
||||
userID = policy.UserID
|
||||
connectorID = policy.ConnectorID
|
||||
)
|
||||
|
||||
conditions := make([]gen.Condition, 0)
|
||||
conditions = append(conditions, r.query.AppDynamicConversationOnline.AppID.Eq(appID))
|
||||
conditions = append(conditions, r.query.AppDynamicConversationOnline.UserID.Eq(userID))
|
||||
conditions = append(conditions, r.query.AppDynamicConversationOnline.AppID.Eq(appID))
|
||||
conditions = append(conditions, r.query.AppDynamicConversationOnline.ConnectorID.Eq(connectorID))
|
||||
if policy.NameLike != nil {
|
||||
conditions = append(conditions, r.query.AppDynamicConversationOnline.Name.Like("%%"+*policy.NameLike+"%%"))
|
||||
}
|
||||
|
||||
appDynamicConversationOnlineDao := r.query.AppDynamicConversationOnline.WithContext(ctx).Where(conditions...)
|
||||
var (
|
||||
dynamicConversations = make([]*model.AppDynamicConversationOnline, 0)
|
||||
err error
|
||||
)
|
||||
if policy.Page != nil {
|
||||
dynamicConversations, err = appDynamicConversationOnlineDao.Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
|
||||
} else {
|
||||
dynamicConversations, err = appDynamicConversationOnlineDao.Where(conditions...).Find()
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return []*entity.DynamicConversation{}, nil
|
||||
}
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return slices.Transform(dynamicConversations, func(a *model.AppDynamicConversationOnline) *entity.DynamicConversation {
|
||||
return &entity.DynamicConversation{
|
||||
ID: a.ID,
|
||||
Name: a.Name,
|
||||
UserID: a.UserID,
|
||||
ConnectorID: a.ConnectorID,
|
||||
ConversationID: a.ConversationID,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetOrCreateStaticConversation(ctx context.Context, env vo.Env, idGen workflow.ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, int64, bool, error) {
|
||||
if env == vo.Draft {
|
||||
return r.getOrCreateDraftStaticConversation(ctx, idGen, meta)
|
||||
} else if env == vo.Online {
|
||||
return r.getOrCreateOnlineStaticConversation(ctx, idGen, meta)
|
||||
} else {
|
||||
return 0, 0, false, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
}
|
||||
func (r *RepositoryImpl) GetOrCreateDynamicConversation(ctx context.Context, env vo.Env, idGen workflow.ConversationIDGenerator, meta *vo.CreateDynamicConversation) (int64, int64, bool, error) {
|
||||
if env == vo.Draft {
|
||||
|
||||
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
|
||||
ret, err := appDynamicConversationDraft.WithContext(ctx).Where(
|
||||
appDynamicConversationDraft.AppID.Eq(meta.AppID),
|
||||
appDynamicConversationDraft.ConnectorID.Eq(meta.ConnectorID),
|
||||
appDynamicConversationDraft.UserID.Eq(meta.UserID),
|
||||
appDynamicConversationDraft.Name.Eq(meta.Name),
|
||||
).First()
|
||||
if err == nil {
|
||||
cInfo, err := crossconversation.DefaultSVC().GetByID(ctx, ret.ConversationID)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
if cInfo == nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("conversation not found"))
|
||||
}
|
||||
return ret.ConversationID, cInfo.SectionID, true, nil
|
||||
}
|
||||
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
conv, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
|
||||
if err != nil {
|
||||
return 0, 0, false, err
|
||||
}
|
||||
|
||||
id, err := r.GenID(ctx)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
|
||||
err = r.query.AppDynamicConversationDraft.WithContext(ctx).Create(&model.AppDynamicConversationDraft{
|
||||
ID: id,
|
||||
AppID: meta.AppID,
|
||||
Name: meta.Name,
|
||||
UserID: meta.UserID,
|
||||
ConnectorID: meta.ConnectorID,
|
||||
ConversationID: conv.ID,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return conv.ID, conv.SectionID, false, nil
|
||||
|
||||
} else if env == vo.Online {
|
||||
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
|
||||
ret, err := appDynamicConversationOnline.WithContext(ctx).Where(
|
||||
appDynamicConversationOnline.AppID.Eq(meta.AppID),
|
||||
appDynamicConversationOnline.ConnectorID.Eq(meta.ConnectorID),
|
||||
appDynamicConversationOnline.UserID.Eq(meta.UserID),
|
||||
appDynamicConversationOnline.Name.Eq(meta.Name),
|
||||
).First()
|
||||
if err == nil {
|
||||
cInfo, err := crossconversation.DefaultSVC().GetByID(ctx, ret.ConversationID)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
if cInfo == nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("conversation not found"))
|
||||
}
|
||||
return ret.ConversationID, cInfo.SectionID, true, nil
|
||||
}
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
conv, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
|
||||
if err != nil {
|
||||
return 0, 0, false, err
|
||||
}
|
||||
id, err := r.GenID(ctx)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
|
||||
err = r.query.AppDynamicConversationOnline.WithContext(ctx).Create(&model.AppDynamicConversationOnline{
|
||||
ID: id,
|
||||
AppID: meta.AppID,
|
||||
Name: meta.Name,
|
||||
UserID: meta.UserID,
|
||||
ConnectorID: meta.ConnectorID,
|
||||
ConversationID: conv.ID,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return conv.ID, conv.SectionID, false, nil
|
||||
|
||||
} else {
|
||||
return 0, 0, false, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetStaticConversationByTemplateID(ctx context.Context, env vo.Env, userID, connectorID, templateID int64) (*entity.StaticConversation, bool, error) {
|
||||
if env == vo.Draft {
|
||||
conditions := make([]gen.Condition, 0, 3)
|
||||
conditions = append(conditions, r.query.AppStaticConversationDraft.UserID.Eq(userID))
|
||||
conditions = append(conditions, r.query.AppStaticConversationDraft.ConnectorID.Eq(connectorID))
|
||||
conditions = append(conditions, r.query.AppStaticConversationDraft.TemplateID.Eq(templateID))
|
||||
cs, err := r.query.AppStaticConversationDraft.WithContext(ctx).Where(conditions...).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return &entity.StaticConversation{
|
||||
UserID: cs.UserID,
|
||||
ConnectorID: cs.ConnectorID,
|
||||
TemplateID: cs.TemplateID,
|
||||
ConversationID: cs.ConversationID,
|
||||
}, true, nil
|
||||
} else if env == vo.Online {
|
||||
conditions := make([]gen.Condition, 0, 3)
|
||||
conditions = append(conditions, r.query.AppStaticConversationOnline.UserID.Eq(userID))
|
||||
conditions = append(conditions, r.query.AppStaticConversationOnline.ConnectorID.Eq(connectorID))
|
||||
conditions = append(conditions, r.query.AppStaticConversationOnline.TemplateID.Eq(templateID))
|
||||
cs, err := r.query.AppStaticConversationOnline.WithContext(ctx).Where(conditions...).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return &entity.StaticConversation{
|
||||
UserID: cs.UserID,
|
||||
ConnectorID: cs.ConnectorID,
|
||||
TemplateID: cs.TemplateID,
|
||||
ConversationID: cs.ConversationID,
|
||||
}, true, nil
|
||||
} else {
|
||||
return nil, false, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) getOrCreateDraftStaticConversation(ctx context.Context, idGen workflow.ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, int64, bool, error) {
|
||||
cs, err := r.mGetDraftStaticConversation(ctx, meta.UserID, meta.ConnectorID, []int64{meta.TemplateID})
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
if len(cs) > 0 {
|
||||
cInfo, err := crossconversation.DefaultSVC().GetByID(ctx, cs[0].ConversationID)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
if cInfo == nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("conversation not found"))
|
||||
}
|
||||
return cs[0].ConversationID, cInfo.SectionID, true, nil
|
||||
}
|
||||
|
||||
conv, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
|
||||
if err != nil {
|
||||
return 0, 0, false, err
|
||||
}
|
||||
|
||||
id, err := r.GenID(ctx)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
object := &model.AppStaticConversationDraft{
|
||||
ID: id,
|
||||
UserID: meta.UserID,
|
||||
ConnectorID: meta.ConnectorID,
|
||||
TemplateID: meta.TemplateID,
|
||||
ConversationID: conv.ID,
|
||||
}
|
||||
err = r.query.AppStaticConversationDraft.WithContext(ctx).Create(object)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return conv.ID, conv.SectionID, false, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) getOrCreateOnlineStaticConversation(ctx context.Context, idGen workflow.ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, int64, bool, error) {
|
||||
cs, err := r.mGetOnlineStaticConversation(ctx, meta.UserID, meta.ConnectorID, []int64{meta.TemplateID})
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
if len(cs) > 0 {
|
||||
cInfo, err := crossconversation.DefaultSVC().GetByID(ctx, cs[0].ConversationID)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
if cInfo == nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("conversation not found"))
|
||||
}
|
||||
return cs[0].ConversationID, cInfo.SectionID, true, nil
|
||||
}
|
||||
|
||||
conv, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
|
||||
if err != nil {
|
||||
return 0, 0, false, err
|
||||
}
|
||||
|
||||
id, err := r.GenID(ctx)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
object := &model.AppStaticConversationOnline{
|
||||
ID: id,
|
||||
UserID: meta.UserID,
|
||||
ConnectorID: meta.ConnectorID,
|
||||
TemplateID: meta.TemplateID,
|
||||
ConversationID: conv.ID,
|
||||
}
|
||||
err = r.query.AppStaticConversationOnline.WithContext(ctx).Create(object)
|
||||
if err != nil {
|
||||
return 0, 0, false, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
return conv.ID, conv.SectionID, false, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) BatchCreateOnlineConversationTemplate(ctx context.Context, templates []*entity.ConversationTemplate, version string) error {
|
||||
ids, err := r.GenMultiIDs(ctx, len(templates))
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
|
||||
objects := make([]*model.AppConversationTemplateOnline, 0, len(templates))
|
||||
for idx := range templates {
|
||||
template := templates[idx]
|
||||
objects = append(objects, &model.AppConversationTemplateOnline{
|
||||
ID: ids[idx],
|
||||
SpaceID: template.SpaceID,
|
||||
AppID: template.AppID,
|
||||
TemplateID: template.TemplateID,
|
||||
Name: template.Name,
|
||||
Version: version,
|
||||
})
|
||||
}
|
||||
|
||||
err = r.query.AppConversationTemplateOnline.WithContext(ctx).CreateInBatches(objects, batchSize)
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetDynamicConversationByName(ctx context.Context, env vo.Env, appID, connectorID, userID int64, name string) (*entity.DynamicConversation, bool, error) {
|
||||
if env == vo.Draft {
|
||||
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
|
||||
ret, err := appDynamicConversationDraft.WithContext(ctx).Where(
|
||||
appDynamicConversationDraft.AppID.Eq(appID),
|
||||
appDynamicConversationDraft.ConnectorID.Eq(connectorID),
|
||||
appDynamicConversationDraft.UserID.Eq(userID),
|
||||
appDynamicConversationDraft.Name.Eq(name)).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
return &entity.DynamicConversation{
|
||||
ID: ret.ID,
|
||||
UserID: ret.UserID,
|
||||
ConnectorID: ret.ConnectorID,
|
||||
ConversationID: ret.ConversationID,
|
||||
Name: ret.Name,
|
||||
}, true, nil
|
||||
|
||||
} else if env == vo.Online {
|
||||
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
|
||||
ret, err := appDynamicConversationOnline.WithContext(ctx).Where(
|
||||
appDynamicConversationOnline.AppID.Eq(appID),
|
||||
appDynamicConversationOnline.ConnectorID.Eq(connectorID),
|
||||
appDynamicConversationOnline.UserID.Eq(userID),
|
||||
appDynamicConversationOnline.Name.Eq(name)).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
return &entity.DynamicConversation{
|
||||
ID: ret.ID,
|
||||
UserID: ret.UserID,
|
||||
ConnectorID: ret.ConnectorID,
|
||||
ConversationID: ret.ConversationID,
|
||||
Name: ret.Name,
|
||||
}, true, nil
|
||||
|
||||
} else {
|
||||
return nil, false, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) UpdateDynamicConversationNameByID(ctx context.Context, env vo.Env, templateID int64, name string) error {
|
||||
if env == vo.Draft {
|
||||
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
|
||||
_, err := appDynamicConversationDraft.WithContext(ctx).Where(
|
||||
appDynamicConversationDraft.ID.Eq(templateID),
|
||||
).UpdateColumnSimple(appDynamicConversationDraft.Name.Value(name))
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return nil
|
||||
} else if env == vo.Online {
|
||||
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
|
||||
_, err := appDynamicConversationOnline.WithContext(ctx).Where(
|
||||
appDynamicConversationOnline.ID.Eq(templateID),
|
||||
).UpdateColumnSimple(appDynamicConversationOnline.Name.Value(name))
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
} else {
|
||||
return fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) UpdateStaticConversation(ctx context.Context, env vo.Env, templateID int64, connectorID int64, userID int64, newConversationID int64) error {
|
||||
|
||||
if env == vo.Draft {
|
||||
appStaticConversationDraft := r.query.AppStaticConversationDraft
|
||||
_, err := appStaticConversationDraft.WithContext(ctx).Where(
|
||||
appStaticConversationDraft.TemplateID.Eq(templateID),
|
||||
appStaticConversationDraft.ConnectorID.Eq(connectorID),
|
||||
appStaticConversationDraft.UserID.Eq(userID),
|
||||
).UpdateColumn(appStaticConversationDraft.ConversationID, newConversationID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
|
||||
} else if env == vo.Online {
|
||||
appStaticConversationOnline := r.query.AppStaticConversationOnline
|
||||
_, err := appStaticConversationOnline.WithContext(ctx).Where(
|
||||
appStaticConversationOnline.TemplateID.Eq(templateID),
|
||||
appStaticConversationOnline.ConnectorID.Eq(connectorID),
|
||||
appStaticConversationOnline.UserID.Eq(userID),
|
||||
).UpdateColumn(appStaticConversationOnline.ConversationID, newConversationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) UpdateDynamicConversation(ctx context.Context, env vo.Env, conversationID, newConversationID int64) error {
|
||||
if env == vo.Draft {
|
||||
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
|
||||
_, err := appDynamicConversationDraft.WithContext(ctx).Where(appDynamicConversationDraft.ConversationID.Eq(conversationID)).
|
||||
UpdateColumn(appDynamicConversationDraft.ConversationID, newConversationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
} else if env == vo.Online {
|
||||
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
|
||||
_, err := appDynamicConversationOnline.WithContext(ctx).Where(appDynamicConversationOnline.ConversationID.Eq(conversationID)).
|
||||
UpdateColumn(appDynamicConversationOnline.ConversationID, newConversationID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
} else {
|
||||
return fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) CopyTemplateConversationByAppID(ctx context.Context, appID int64, toAppID int64) error {
|
||||
appConversationTemplateDraft := r.query.AppConversationTemplateDraft
|
||||
templates, err := appConversationTemplateDraft.WithContext(ctx).Where(appConversationTemplateDraft.AppID.Eq(appID), appConversationTemplateDraft.Name.Neq("Default")).Find()
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
|
||||
if len(templates) == 0 {
|
||||
return nil
|
||||
}
|
||||
templateTemplates := make([]*model.AppConversationTemplateDraft, 0, len(templates))
|
||||
ids, err := r.GenMultiIDs(ctx, len(templates))
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
for i := range templates {
|
||||
copiedTemplate := templates[i]
|
||||
copiedTemplate.ID = ids[i]
|
||||
copiedTemplate.TemplateID = ids[i]
|
||||
copiedTemplate.AppID = toAppID
|
||||
templateTemplates = append(templateTemplates, copiedTemplate)
|
||||
}
|
||||
err = appConversationTemplateDraft.WithContext(ctx).CreateInBatches(templateTemplates, batchSize)
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetStaticConversationByID(ctx context.Context, env vo.Env, appID, connectorID, conversationID int64) (string, bool, error) {
|
||||
if env == vo.Draft {
|
||||
appStaticConversationDraft := r.query.AppStaticConversationDraft
|
||||
ret, err := appStaticConversationDraft.WithContext(ctx).Where(
|
||||
appStaticConversationDraft.ConnectorID.Eq(connectorID),
|
||||
appStaticConversationDraft.ConversationID.Eq(conversationID),
|
||||
).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return "", false, nil
|
||||
}
|
||||
return "", false, err
|
||||
}
|
||||
appConversationTemplateDraft := r.query.AppConversationTemplateDraft
|
||||
template, err := appConversationTemplateDraft.WithContext(ctx).Where(
|
||||
appConversationTemplateDraft.TemplateID.Eq(ret.TemplateID),
|
||||
appConversationTemplateDraft.AppID.Eq(appID),
|
||||
).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return "", false, nil
|
||||
}
|
||||
return "", false, err
|
||||
}
|
||||
return template.Name, true, nil
|
||||
} else if env == vo.Online {
|
||||
appStaticConversationOnline := r.query.AppStaticConversationOnline
|
||||
ret, err := appStaticConversationOnline.WithContext(ctx).Where(
|
||||
appStaticConversationOnline.ConnectorID.Eq(connectorID),
|
||||
appStaticConversationOnline.ConversationID.Eq(conversationID),
|
||||
).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return "", false, nil
|
||||
}
|
||||
return "", false, err
|
||||
}
|
||||
appConversationTemplateOnline := r.query.AppConversationTemplateOnline
|
||||
template, err := appConversationTemplateOnline.WithContext(ctx).Where(
|
||||
appConversationTemplateOnline.TemplateID.Eq(ret.TemplateID),
|
||||
appConversationTemplateOnline.AppID.Eq(appID),
|
||||
).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return "", false, nil
|
||||
}
|
||||
return "", false, err
|
||||
}
|
||||
return template.Name, true, nil
|
||||
}
|
||||
return "", false, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetDynamicConversationByID(ctx context.Context, env vo.Env, appID, connectorID, conversationID int64) (*entity.DynamicConversation, bool, error) {
|
||||
if env == vo.Draft {
|
||||
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
|
||||
ret, err := appDynamicConversationDraft.WithContext(ctx).Where(
|
||||
appDynamicConversationDraft.AppID.Eq(appID),
|
||||
appDynamicConversationDraft.ConnectorID.Eq(connectorID),
|
||||
appDynamicConversationDraft.ConversationID.Eq(conversationID),
|
||||
).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
return &entity.DynamicConversation{
|
||||
ID: ret.ID,
|
||||
UserID: ret.UserID,
|
||||
ConnectorID: ret.ConnectorID,
|
||||
ConversationID: ret.ConversationID,
|
||||
Name: ret.Name,
|
||||
}, true, nil
|
||||
} else if env == vo.Online {
|
||||
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
|
||||
ret, err := appDynamicConversationOnline.WithContext(ctx).Where(
|
||||
appDynamicConversationOnline.AppID.Eq(appID),
|
||||
appDynamicConversationOnline.ConnectorID.Eq(connectorID),
|
||||
appDynamicConversationOnline.ConversationID.Eq(conversationID),
|
||||
).First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, false, err
|
||||
}
|
||||
return &entity.DynamicConversation{
|
||||
ID: ret.ID,
|
||||
UserID: ret.UserID,
|
||||
ConnectorID: ret.ConnectorID,
|
||||
ConversationID: ret.ConversationID,
|
||||
Name: ret.Name,
|
||||
}, true, nil
|
||||
}
|
||||
return nil, false, fmt.Errorf("unknown env %v", env)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAppConversationTemplateDraft = "app_conversation_template_draft"
|
||||
|
||||
// AppConversationTemplateDraft mapped from table <app_conversation_template_draft>
|
||||
type AppConversationTemplateDraft struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
|
||||
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
|
||||
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
|
||||
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
|
||||
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime:milli;comment:update time in millisecond" json:"updated_at"` // update time in millisecond
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
|
||||
}
|
||||
|
||||
// TableName AppConversationTemplateDraft's table name
|
||||
func (*AppConversationTemplateDraft) TableName() string {
|
||||
return TableNameAppConversationTemplateDraft
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
const TableNameAppConversationTemplateOnline = "app_conversation_template_online"
|
||||
|
||||
// AppConversationTemplateOnline mapped from table <app_conversation_template_online>
|
||||
type AppConversationTemplateOnline struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
|
||||
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
|
||||
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
|
||||
Version string `gorm:"column:version;not null;comment:version name" json:"version"` // version name
|
||||
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
|
||||
}
|
||||
|
||||
// TableName AppConversationTemplateOnline's table name
|
||||
func (*AppConversationTemplateOnline) TableName() string {
|
||||
return TableNameAppConversationTemplateOnline
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAppDynamicConversationDraft = "app_dynamic_conversation_draft"
|
||||
|
||||
// AppDynamicConversationDraft mapped from table <app_dynamic_conversation_draft>
|
||||
type AppDynamicConversationDraft struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
|
||||
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
|
||||
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
|
||||
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
|
||||
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
|
||||
}
|
||||
|
||||
// TableName AppDynamicConversationDraft's table name
|
||||
func (*AppDynamicConversationDraft) TableName() string {
|
||||
return TableNameAppDynamicConversationDraft
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAppDynamicConversationOnline = "app_dynamic_conversation_online"
|
||||
|
||||
// AppDynamicConversationOnline mapped from table <app_dynamic_conversation_online>
|
||||
type AppDynamicConversationOnline struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
|
||||
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
|
||||
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
|
||||
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
|
||||
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
|
||||
}
|
||||
|
||||
// TableName AppDynamicConversationOnline's table name
|
||||
func (*AppDynamicConversationOnline) TableName() string {
|
||||
return TableNameAppDynamicConversationOnline
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameAppStaticConversationDraft = "app_static_conversation_draft"
|
||||
|
||||
// AppStaticConversationDraft mapped from table <app_static_conversation_draft>
|
||||
type AppStaticConversationDraft struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
|
||||
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
|
||||
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
|
||||
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
|
||||
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
|
||||
}
|
||||
|
||||
// TableName AppStaticConversationDraft's table name
|
||||
func (*AppStaticConversationDraft) TableName() string {
|
||||
return TableNameAppStaticConversationDraft
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
const TableNameAppStaticConversationOnline = "app_static_conversation_online"
|
||||
|
||||
// AppStaticConversationOnline mapped from table <app_static_conversation_online>
|
||||
type AppStaticConversationOnline struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
|
||||
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
|
||||
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
|
||||
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
|
||||
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
|
||||
}
|
||||
|
||||
// TableName AppStaticConversationOnline's table name
|
||||
func (*AppStaticConversationOnline) TableName() string {
|
||||
return TableNameAppStaticConversationOnline
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
const TableNameChatFlowRoleConfig = "chat_flow_role_config"
|
||||
|
||||
// ChatFlowRoleConfig mapped from table <chat_flow_role_config>
|
||||
type ChatFlowRoleConfig struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
|
||||
WorkflowID int64 `gorm:"column:workflow_id;not null;comment:workflow id" json:"workflow_id"` // workflow id
|
||||
Name string `gorm:"column:name;not null;comment:role name" json:"name"` // role name
|
||||
Description string `gorm:"column:description;not null;comment:role description" json:"description"` // role description
|
||||
Version string `gorm:"column:version;not null;comment:version" json:"version"` // version
|
||||
Avatar string `gorm:"column:avatar;not null;comment:avatar uri" json:"avatar"` // avatar uri
|
||||
BackgroundImageInfo string `gorm:"column:background_image_info;not null;comment:background image information, object structure" json:"background_image_info"` // background image information, object structure
|
||||
OnboardingInfo string `gorm:"column:onboarding_info;not null;comment:intro information, object structure" json:"onboarding_info"` // intro information, object structure
|
||||
SuggestReplyInfo string `gorm:"column:suggest_reply_info;not null;comment:user suggestions, object structure" json:"suggest_reply_info"` // user suggestions, object structure
|
||||
AudioConfig string `gorm:"column:audio_config;not null;comment:agent audio config, object structure" json:"audio_config"` // agent audio config, object structure
|
||||
UserInputConfig string `gorm:"column:user_input_config;not null;comment:user input config, object structure" json:"user_input_config"` // user input config, object structure
|
||||
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
|
||||
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime:milli;comment:update time in millisecond" json:"updated_at"` // update time in millisecond
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
|
||||
ConnectorID int64 `gorm:"column:connector_id;comment:connector id" json:"connector_id"` // connector id
|
||||
}
|
||||
|
||||
// TableName ChatFlowRoleConfig's table name
|
||||
func (*ChatFlowRoleConfig) TableName() string {
|
||||
return TableNameChatFlowRoleConfig
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
)
|
||||
|
||||
func newAppConversationTemplateDraft(db *gorm.DB, opts ...gen.DOOption) appConversationTemplateDraft {
|
||||
_appConversationTemplateDraft := appConversationTemplateDraft{}
|
||||
|
||||
_appConversationTemplateDraft.appConversationTemplateDraftDo.UseDB(db, opts...)
|
||||
_appConversationTemplateDraft.appConversationTemplateDraftDo.UseModel(&model.AppConversationTemplateDraft{})
|
||||
|
||||
tableName := _appConversationTemplateDraft.appConversationTemplateDraftDo.TableName()
|
||||
_appConversationTemplateDraft.ALL = field.NewAsterisk(tableName)
|
||||
_appConversationTemplateDraft.ID = field.NewInt64(tableName, "id")
|
||||
_appConversationTemplateDraft.AppID = field.NewInt64(tableName, "app_id")
|
||||
_appConversationTemplateDraft.SpaceID = field.NewInt64(tableName, "space_id")
|
||||
_appConversationTemplateDraft.Name = field.NewString(tableName, "name")
|
||||
_appConversationTemplateDraft.TemplateID = field.NewInt64(tableName, "template_id")
|
||||
_appConversationTemplateDraft.CreatorID = field.NewInt64(tableName, "creator_id")
|
||||
_appConversationTemplateDraft.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
_appConversationTemplateDraft.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
||||
_appConversationTemplateDraft.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_appConversationTemplateDraft.fillFieldMap()
|
||||
|
||||
return _appConversationTemplateDraft
|
||||
}
|
||||
|
||||
type appConversationTemplateDraft struct {
|
||||
appConversationTemplateDraftDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // id
|
||||
AppID field.Int64 // app id
|
||||
SpaceID field.Int64 // space id
|
||||
Name field.String // conversion name
|
||||
TemplateID field.Int64 // template id
|
||||
CreatorID field.Int64 // creator id
|
||||
CreatedAt field.Int64 // create time in millisecond
|
||||
UpdatedAt field.Int64 // update time in millisecond
|
||||
DeletedAt field.Field // delete time in millisecond
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraft) Table(newTableName string) *appConversationTemplateDraft {
|
||||
a.appConversationTemplateDraftDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraft) As(alias string) *appConversationTemplateDraft {
|
||||
a.appConversationTemplateDraftDo.DO = *(a.appConversationTemplateDraftDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateDraft) updateTableName(table string) *appConversationTemplateDraft {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt64(table, "id")
|
||||
a.AppID = field.NewInt64(table, "app_id")
|
||||
a.SpaceID = field.NewInt64(table, "space_id")
|
||||
a.Name = field.NewString(table, "name")
|
||||
a.TemplateID = field.NewInt64(table, "template_id")
|
||||
a.CreatorID = field.NewInt64(table, "creator_id")
|
||||
a.CreatedAt = field.NewInt64(table, "created_at")
|
||||
a.UpdatedAt = field.NewInt64(table, "updated_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateDraft) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateDraft) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 9)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["app_id"] = a.AppID
|
||||
a.fieldMap["space_id"] = a.SpaceID
|
||||
a.fieldMap["name"] = a.Name
|
||||
a.fieldMap["template_id"] = a.TemplateID
|
||||
a.fieldMap["creator_id"] = a.CreatorID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["updated_at"] = a.UpdatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraft) clone(db *gorm.DB) appConversationTemplateDraft {
|
||||
a.appConversationTemplateDraftDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraft) replaceDB(db *gorm.DB) appConversationTemplateDraft {
|
||||
a.appConversationTemplateDraftDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type appConversationTemplateDraftDo struct{ gen.DO }
|
||||
|
||||
type IAppConversationTemplateDraftDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IAppConversationTemplateDraftDo
|
||||
WithContext(ctx context.Context) IAppConversationTemplateDraftDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IAppConversationTemplateDraftDo
|
||||
WriteDB() IAppConversationTemplateDraftDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IAppConversationTemplateDraftDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IAppConversationTemplateDraftDo
|
||||
Not(conds ...gen.Condition) IAppConversationTemplateDraftDo
|
||||
Or(conds ...gen.Condition) IAppConversationTemplateDraftDo
|
||||
Select(conds ...field.Expr) IAppConversationTemplateDraftDo
|
||||
Where(conds ...gen.Condition) IAppConversationTemplateDraftDo
|
||||
Order(conds ...field.Expr) IAppConversationTemplateDraftDo
|
||||
Distinct(cols ...field.Expr) IAppConversationTemplateDraftDo
|
||||
Omit(cols ...field.Expr) IAppConversationTemplateDraftDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo
|
||||
Group(cols ...field.Expr) IAppConversationTemplateDraftDo
|
||||
Having(conds ...gen.Condition) IAppConversationTemplateDraftDo
|
||||
Limit(limit int) IAppConversationTemplateDraftDo
|
||||
Offset(offset int) IAppConversationTemplateDraftDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateDraftDo
|
||||
Unscoped() IAppConversationTemplateDraftDo
|
||||
Create(values ...*model.AppConversationTemplateDraft) error
|
||||
CreateInBatches(values []*model.AppConversationTemplateDraft, batchSize int) error
|
||||
Save(values ...*model.AppConversationTemplateDraft) error
|
||||
First() (*model.AppConversationTemplateDraft, error)
|
||||
Take() (*model.AppConversationTemplateDraft, error)
|
||||
Last() (*model.AppConversationTemplateDraft, error)
|
||||
Find() ([]*model.AppConversationTemplateDraft, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateDraft, err error)
|
||||
FindInBatches(result *[]*model.AppConversationTemplateDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.AppConversationTemplateDraft) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo
|
||||
Assign(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo
|
||||
Joins(fields ...field.RelationField) IAppConversationTemplateDraftDo
|
||||
Preload(fields ...field.RelationField) IAppConversationTemplateDraftDo
|
||||
FirstOrInit() (*model.AppConversationTemplateDraft, error)
|
||||
FirstOrCreate() (*model.AppConversationTemplateDraft, error)
|
||||
FindByPage(offset int, limit int) (result []*model.AppConversationTemplateDraft, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IAppConversationTemplateDraftDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Debug() IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) WithContext(ctx context.Context) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) ReadDB() IAppConversationTemplateDraftDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) WriteDB() IAppConversationTemplateDraftDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Session(config *gorm.Session) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Clauses(conds ...clause.Expression) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Returning(value interface{}, columns ...string) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Not(conds ...gen.Condition) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Or(conds ...gen.Condition) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Select(conds ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Where(conds ...gen.Condition) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Order(conds ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Distinct(cols ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Omit(cols ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Group(cols ...field.Expr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Having(conds ...gen.Condition) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Limit(limit int) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Offset(offset int) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Unscoped() IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Create(values ...*model.AppConversationTemplateDraft) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) CreateInBatches(values []*model.AppConversationTemplateDraft, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a appConversationTemplateDraftDo) Save(values ...*model.AppConversationTemplateDraft) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) First() (*model.AppConversationTemplateDraft, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Take() (*model.AppConversationTemplateDraft, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Last() (*model.AppConversationTemplateDraft, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Find() ([]*model.AppConversationTemplateDraft, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*model.AppConversationTemplateDraft), err
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateDraft, err error) {
|
||||
buf := make([]*model.AppConversationTemplateDraft, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) FindInBatches(result *[]*model.AppConversationTemplateDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Attrs(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Assign(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Joins(fields ...field.RelationField) IAppConversationTemplateDraftDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Preload(fields ...field.RelationField) IAppConversationTemplateDraftDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) FirstOrInit() (*model.AppConversationTemplateDraft, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) FirstOrCreate() (*model.AppConversationTemplateDraft, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) FindByPage(offset int, limit int) (result []*model.AppConversationTemplateDraft, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateDraftDo) Delete(models ...*model.AppConversationTemplateDraft) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateDraftDo) withDO(do gen.Dao) *appConversationTemplateDraftDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
)
|
||||
|
||||
func newAppConversationTemplateOnline(db *gorm.DB, opts ...gen.DOOption) appConversationTemplateOnline {
|
||||
_appConversationTemplateOnline := appConversationTemplateOnline{}
|
||||
|
||||
_appConversationTemplateOnline.appConversationTemplateOnlineDo.UseDB(db, opts...)
|
||||
_appConversationTemplateOnline.appConversationTemplateOnlineDo.UseModel(&model.AppConversationTemplateOnline{})
|
||||
|
||||
tableName := _appConversationTemplateOnline.appConversationTemplateOnlineDo.TableName()
|
||||
_appConversationTemplateOnline.ALL = field.NewAsterisk(tableName)
|
||||
_appConversationTemplateOnline.ID = field.NewInt64(tableName, "id")
|
||||
_appConversationTemplateOnline.AppID = field.NewInt64(tableName, "app_id")
|
||||
_appConversationTemplateOnline.SpaceID = field.NewInt64(tableName, "space_id")
|
||||
_appConversationTemplateOnline.Name = field.NewString(tableName, "name")
|
||||
_appConversationTemplateOnline.TemplateID = field.NewInt64(tableName, "template_id")
|
||||
_appConversationTemplateOnline.Version = field.NewString(tableName, "version")
|
||||
_appConversationTemplateOnline.CreatorID = field.NewInt64(tableName, "creator_id")
|
||||
_appConversationTemplateOnline.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
|
||||
_appConversationTemplateOnline.fillFieldMap()
|
||||
|
||||
return _appConversationTemplateOnline
|
||||
}
|
||||
|
||||
type appConversationTemplateOnline struct {
|
||||
appConversationTemplateOnlineDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // id
|
||||
AppID field.Int64 // app id
|
||||
SpaceID field.Int64 // space id
|
||||
Name field.String // conversion name
|
||||
TemplateID field.Int64 // template id
|
||||
Version field.String // version name
|
||||
CreatorID field.Int64 // creator id
|
||||
CreatedAt field.Int64 // create time in millisecond
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnline) Table(newTableName string) *appConversationTemplateOnline {
|
||||
a.appConversationTemplateOnlineDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnline) As(alias string) *appConversationTemplateOnline {
|
||||
a.appConversationTemplateOnlineDo.DO = *(a.appConversationTemplateOnlineDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateOnline) updateTableName(table string) *appConversationTemplateOnline {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt64(table, "id")
|
||||
a.AppID = field.NewInt64(table, "app_id")
|
||||
a.SpaceID = field.NewInt64(table, "space_id")
|
||||
a.Name = field.NewString(table, "name")
|
||||
a.TemplateID = field.NewInt64(table, "template_id")
|
||||
a.Version = field.NewString(table, "version")
|
||||
a.CreatorID = field.NewInt64(table, "creator_id")
|
||||
a.CreatedAt = field.NewInt64(table, "created_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateOnline) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateOnline) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 8)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["app_id"] = a.AppID
|
||||
a.fieldMap["space_id"] = a.SpaceID
|
||||
a.fieldMap["name"] = a.Name
|
||||
a.fieldMap["template_id"] = a.TemplateID
|
||||
a.fieldMap["version"] = a.Version
|
||||
a.fieldMap["creator_id"] = a.CreatorID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnline) clone(db *gorm.DB) appConversationTemplateOnline {
|
||||
a.appConversationTemplateOnlineDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnline) replaceDB(db *gorm.DB) appConversationTemplateOnline {
|
||||
a.appConversationTemplateOnlineDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type appConversationTemplateOnlineDo struct{ gen.DO }
|
||||
|
||||
type IAppConversationTemplateOnlineDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IAppConversationTemplateOnlineDo
|
||||
WithContext(ctx context.Context) IAppConversationTemplateOnlineDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IAppConversationTemplateOnlineDo
|
||||
WriteDB() IAppConversationTemplateOnlineDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IAppConversationTemplateOnlineDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IAppConversationTemplateOnlineDo
|
||||
Not(conds ...gen.Condition) IAppConversationTemplateOnlineDo
|
||||
Or(conds ...gen.Condition) IAppConversationTemplateOnlineDo
|
||||
Select(conds ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
Where(conds ...gen.Condition) IAppConversationTemplateOnlineDo
|
||||
Order(conds ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
Distinct(cols ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
Omit(cols ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
Group(cols ...field.Expr) IAppConversationTemplateOnlineDo
|
||||
Having(conds ...gen.Condition) IAppConversationTemplateOnlineDo
|
||||
Limit(limit int) IAppConversationTemplateOnlineDo
|
||||
Offset(offset int) IAppConversationTemplateOnlineDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateOnlineDo
|
||||
Unscoped() IAppConversationTemplateOnlineDo
|
||||
Create(values ...*model.AppConversationTemplateOnline) error
|
||||
CreateInBatches(values []*model.AppConversationTemplateOnline, batchSize int) error
|
||||
Save(values ...*model.AppConversationTemplateOnline) error
|
||||
First() (*model.AppConversationTemplateOnline, error)
|
||||
Take() (*model.AppConversationTemplateOnline, error)
|
||||
Last() (*model.AppConversationTemplateOnline, error)
|
||||
Find() ([]*model.AppConversationTemplateOnline, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateOnline, err error)
|
||||
FindInBatches(result *[]*model.AppConversationTemplateOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.AppConversationTemplateOnline) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo
|
||||
Assign(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo
|
||||
Joins(fields ...field.RelationField) IAppConversationTemplateOnlineDo
|
||||
Preload(fields ...field.RelationField) IAppConversationTemplateOnlineDo
|
||||
FirstOrInit() (*model.AppConversationTemplateOnline, error)
|
||||
FirstOrCreate() (*model.AppConversationTemplateOnline, error)
|
||||
FindByPage(offset int, limit int) (result []*model.AppConversationTemplateOnline, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IAppConversationTemplateOnlineDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Debug() IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) WithContext(ctx context.Context) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) ReadDB() IAppConversationTemplateOnlineDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) WriteDB() IAppConversationTemplateOnlineDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Session(config *gorm.Session) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Clauses(conds ...clause.Expression) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Returning(value interface{}, columns ...string) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Not(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Or(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Select(conds ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Where(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Order(conds ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Distinct(cols ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Omit(cols ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Group(cols ...field.Expr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Having(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Limit(limit int) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Offset(offset int) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Unscoped() IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Create(values ...*model.AppConversationTemplateOnline) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) CreateInBatches(values []*model.AppConversationTemplateOnline, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a appConversationTemplateOnlineDo) Save(values ...*model.AppConversationTemplateOnline) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) First() (*model.AppConversationTemplateOnline, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Take() (*model.AppConversationTemplateOnline, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Last() (*model.AppConversationTemplateOnline, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Find() ([]*model.AppConversationTemplateOnline, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*model.AppConversationTemplateOnline), err
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateOnline, err error) {
|
||||
buf := make([]*model.AppConversationTemplateOnline, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) FindInBatches(result *[]*model.AppConversationTemplateOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Attrs(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Assign(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Joins(fields ...field.RelationField) IAppConversationTemplateOnlineDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Preload(fields ...field.RelationField) IAppConversationTemplateOnlineDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) FirstOrInit() (*model.AppConversationTemplateOnline, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) FirstOrCreate() (*model.AppConversationTemplateOnline, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppConversationTemplateOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) FindByPage(offset int, limit int) (result []*model.AppConversationTemplateOnline, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a appConversationTemplateOnlineDo) Delete(models ...*model.AppConversationTemplateOnline) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *appConversationTemplateOnlineDo) withDO(do gen.Dao) *appConversationTemplateOnlineDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
)
|
||||
|
||||
func newAppDynamicConversationDraft(db *gorm.DB, opts ...gen.DOOption) appDynamicConversationDraft {
|
||||
_appDynamicConversationDraft := appDynamicConversationDraft{}
|
||||
|
||||
_appDynamicConversationDraft.appDynamicConversationDraftDo.UseDB(db, opts...)
|
||||
_appDynamicConversationDraft.appDynamicConversationDraftDo.UseModel(&model.AppDynamicConversationDraft{})
|
||||
|
||||
tableName := _appDynamicConversationDraft.appDynamicConversationDraftDo.TableName()
|
||||
_appDynamicConversationDraft.ALL = field.NewAsterisk(tableName)
|
||||
_appDynamicConversationDraft.ID = field.NewInt64(tableName, "id")
|
||||
_appDynamicConversationDraft.AppID = field.NewInt64(tableName, "app_id")
|
||||
_appDynamicConversationDraft.Name = field.NewString(tableName, "name")
|
||||
_appDynamicConversationDraft.UserID = field.NewInt64(tableName, "user_id")
|
||||
_appDynamicConversationDraft.ConnectorID = field.NewInt64(tableName, "connector_id")
|
||||
_appDynamicConversationDraft.ConversationID = field.NewInt64(tableName, "conversation_id")
|
||||
_appDynamicConversationDraft.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
_appDynamicConversationDraft.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_appDynamicConversationDraft.fillFieldMap()
|
||||
|
||||
return _appDynamicConversationDraft
|
||||
}
|
||||
|
||||
type appDynamicConversationDraft struct {
|
||||
appDynamicConversationDraftDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // id
|
||||
AppID field.Int64 // app id
|
||||
Name field.String // conversion name
|
||||
UserID field.Int64 // user id
|
||||
ConnectorID field.Int64 // connector id
|
||||
ConversationID field.Int64 // conversation id
|
||||
CreatedAt field.Int64 // create time in millisecond
|
||||
DeletedAt field.Field // delete time in millisecond
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraft) Table(newTableName string) *appDynamicConversationDraft {
|
||||
a.appDynamicConversationDraftDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraft) As(alias string) *appDynamicConversationDraft {
|
||||
a.appDynamicConversationDraftDo.DO = *(a.appDynamicConversationDraftDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationDraft) updateTableName(table string) *appDynamicConversationDraft {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt64(table, "id")
|
||||
a.AppID = field.NewInt64(table, "app_id")
|
||||
a.Name = field.NewString(table, "name")
|
||||
a.UserID = field.NewInt64(table, "user_id")
|
||||
a.ConnectorID = field.NewInt64(table, "connector_id")
|
||||
a.ConversationID = field.NewInt64(table, "conversation_id")
|
||||
a.CreatedAt = field.NewInt64(table, "created_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationDraft) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationDraft) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 8)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["app_id"] = a.AppID
|
||||
a.fieldMap["name"] = a.Name
|
||||
a.fieldMap["user_id"] = a.UserID
|
||||
a.fieldMap["connector_id"] = a.ConnectorID
|
||||
a.fieldMap["conversation_id"] = a.ConversationID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraft) clone(db *gorm.DB) appDynamicConversationDraft {
|
||||
a.appDynamicConversationDraftDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraft) replaceDB(db *gorm.DB) appDynamicConversationDraft {
|
||||
a.appDynamicConversationDraftDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type appDynamicConversationDraftDo struct{ gen.DO }
|
||||
|
||||
type IAppDynamicConversationDraftDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IAppDynamicConversationDraftDo
|
||||
WithContext(ctx context.Context) IAppDynamicConversationDraftDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IAppDynamicConversationDraftDo
|
||||
WriteDB() IAppDynamicConversationDraftDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IAppDynamicConversationDraftDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IAppDynamicConversationDraftDo
|
||||
Not(conds ...gen.Condition) IAppDynamicConversationDraftDo
|
||||
Or(conds ...gen.Condition) IAppDynamicConversationDraftDo
|
||||
Select(conds ...field.Expr) IAppDynamicConversationDraftDo
|
||||
Where(conds ...gen.Condition) IAppDynamicConversationDraftDo
|
||||
Order(conds ...field.Expr) IAppDynamicConversationDraftDo
|
||||
Distinct(cols ...field.Expr) IAppDynamicConversationDraftDo
|
||||
Omit(cols ...field.Expr) IAppDynamicConversationDraftDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo
|
||||
Group(cols ...field.Expr) IAppDynamicConversationDraftDo
|
||||
Having(conds ...gen.Condition) IAppDynamicConversationDraftDo
|
||||
Limit(limit int) IAppDynamicConversationDraftDo
|
||||
Offset(offset int) IAppDynamicConversationDraftDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationDraftDo
|
||||
Unscoped() IAppDynamicConversationDraftDo
|
||||
Create(values ...*model.AppDynamicConversationDraft) error
|
||||
CreateInBatches(values []*model.AppDynamicConversationDraft, batchSize int) error
|
||||
Save(values ...*model.AppDynamicConversationDraft) error
|
||||
First() (*model.AppDynamicConversationDraft, error)
|
||||
Take() (*model.AppDynamicConversationDraft, error)
|
||||
Last() (*model.AppDynamicConversationDraft, error)
|
||||
Find() ([]*model.AppDynamicConversationDraft, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationDraft, err error)
|
||||
FindInBatches(result *[]*model.AppDynamicConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.AppDynamicConversationDraft) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo
|
||||
Assign(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo
|
||||
Joins(fields ...field.RelationField) IAppDynamicConversationDraftDo
|
||||
Preload(fields ...field.RelationField) IAppDynamicConversationDraftDo
|
||||
FirstOrInit() (*model.AppDynamicConversationDraft, error)
|
||||
FirstOrCreate() (*model.AppDynamicConversationDraft, error)
|
||||
FindByPage(offset int, limit int) (result []*model.AppDynamicConversationDraft, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IAppDynamicConversationDraftDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Debug() IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) WithContext(ctx context.Context) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) ReadDB() IAppDynamicConversationDraftDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) WriteDB() IAppDynamicConversationDraftDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Session(config *gorm.Session) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Clauses(conds ...clause.Expression) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Returning(value interface{}, columns ...string) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Not(conds ...gen.Condition) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Or(conds ...gen.Condition) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Select(conds ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Where(conds ...gen.Condition) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Order(conds ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Distinct(cols ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Omit(cols ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Group(cols ...field.Expr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Having(conds ...gen.Condition) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Limit(limit int) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Offset(offset int) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Unscoped() IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Create(values ...*model.AppDynamicConversationDraft) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) CreateInBatches(values []*model.AppDynamicConversationDraft, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a appDynamicConversationDraftDo) Save(values ...*model.AppDynamicConversationDraft) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) First() (*model.AppDynamicConversationDraft, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Take() (*model.AppDynamicConversationDraft, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Last() (*model.AppDynamicConversationDraft, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Find() ([]*model.AppDynamicConversationDraft, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*model.AppDynamicConversationDraft), err
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationDraft, err error) {
|
||||
buf := make([]*model.AppDynamicConversationDraft, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) FindInBatches(result *[]*model.AppDynamicConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Attrs(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Assign(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Joins(fields ...field.RelationField) IAppDynamicConversationDraftDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Preload(fields ...field.RelationField) IAppDynamicConversationDraftDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) FirstOrInit() (*model.AppDynamicConversationDraft, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) FirstOrCreate() (*model.AppDynamicConversationDraft, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) FindByPage(offset int, limit int) (result []*model.AppDynamicConversationDraft, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationDraftDo) Delete(models ...*model.AppDynamicConversationDraft) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationDraftDo) withDO(do gen.Dao) *appDynamicConversationDraftDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
)
|
||||
|
||||
func newAppDynamicConversationOnline(db *gorm.DB, opts ...gen.DOOption) appDynamicConversationOnline {
|
||||
_appDynamicConversationOnline := appDynamicConversationOnline{}
|
||||
|
||||
_appDynamicConversationOnline.appDynamicConversationOnlineDo.UseDB(db, opts...)
|
||||
_appDynamicConversationOnline.appDynamicConversationOnlineDo.UseModel(&model.AppDynamicConversationOnline{})
|
||||
|
||||
tableName := _appDynamicConversationOnline.appDynamicConversationOnlineDo.TableName()
|
||||
_appDynamicConversationOnline.ALL = field.NewAsterisk(tableName)
|
||||
_appDynamicConversationOnline.ID = field.NewInt64(tableName, "id")
|
||||
_appDynamicConversationOnline.AppID = field.NewInt64(tableName, "app_id")
|
||||
_appDynamicConversationOnline.Name = field.NewString(tableName, "name")
|
||||
_appDynamicConversationOnline.UserID = field.NewInt64(tableName, "user_id")
|
||||
_appDynamicConversationOnline.ConnectorID = field.NewInt64(tableName, "connector_id")
|
||||
_appDynamicConversationOnline.ConversationID = field.NewInt64(tableName, "conversation_id")
|
||||
_appDynamicConversationOnline.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
_appDynamicConversationOnline.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_appDynamicConversationOnline.fillFieldMap()
|
||||
|
||||
return _appDynamicConversationOnline
|
||||
}
|
||||
|
||||
type appDynamicConversationOnline struct {
|
||||
appDynamicConversationOnlineDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // id
|
||||
AppID field.Int64 // app id
|
||||
Name field.String // conversion name
|
||||
UserID field.Int64 // user id
|
||||
ConnectorID field.Int64 // connector id
|
||||
ConversationID field.Int64 // conversation id
|
||||
CreatedAt field.Int64 // create time in millisecond
|
||||
DeletedAt field.Field // delete time in millisecond
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnline) Table(newTableName string) *appDynamicConversationOnline {
|
||||
a.appDynamicConversationOnlineDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnline) As(alias string) *appDynamicConversationOnline {
|
||||
a.appDynamicConversationOnlineDo.DO = *(a.appDynamicConversationOnlineDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationOnline) updateTableName(table string) *appDynamicConversationOnline {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt64(table, "id")
|
||||
a.AppID = field.NewInt64(table, "app_id")
|
||||
a.Name = field.NewString(table, "name")
|
||||
a.UserID = field.NewInt64(table, "user_id")
|
||||
a.ConnectorID = field.NewInt64(table, "connector_id")
|
||||
a.ConversationID = field.NewInt64(table, "conversation_id")
|
||||
a.CreatedAt = field.NewInt64(table, "created_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationOnline) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationOnline) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 8)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["app_id"] = a.AppID
|
||||
a.fieldMap["name"] = a.Name
|
||||
a.fieldMap["user_id"] = a.UserID
|
||||
a.fieldMap["connector_id"] = a.ConnectorID
|
||||
a.fieldMap["conversation_id"] = a.ConversationID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnline) clone(db *gorm.DB) appDynamicConversationOnline {
|
||||
a.appDynamicConversationOnlineDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnline) replaceDB(db *gorm.DB) appDynamicConversationOnline {
|
||||
a.appDynamicConversationOnlineDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type appDynamicConversationOnlineDo struct{ gen.DO }
|
||||
|
||||
type IAppDynamicConversationOnlineDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IAppDynamicConversationOnlineDo
|
||||
WithContext(ctx context.Context) IAppDynamicConversationOnlineDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IAppDynamicConversationOnlineDo
|
||||
WriteDB() IAppDynamicConversationOnlineDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IAppDynamicConversationOnlineDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IAppDynamicConversationOnlineDo
|
||||
Not(conds ...gen.Condition) IAppDynamicConversationOnlineDo
|
||||
Or(conds ...gen.Condition) IAppDynamicConversationOnlineDo
|
||||
Select(conds ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
Where(conds ...gen.Condition) IAppDynamicConversationOnlineDo
|
||||
Order(conds ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
Distinct(cols ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
Omit(cols ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
Group(cols ...field.Expr) IAppDynamicConversationOnlineDo
|
||||
Having(conds ...gen.Condition) IAppDynamicConversationOnlineDo
|
||||
Limit(limit int) IAppDynamicConversationOnlineDo
|
||||
Offset(offset int) IAppDynamicConversationOnlineDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationOnlineDo
|
||||
Unscoped() IAppDynamicConversationOnlineDo
|
||||
Create(values ...*model.AppDynamicConversationOnline) error
|
||||
CreateInBatches(values []*model.AppDynamicConversationOnline, batchSize int) error
|
||||
Save(values ...*model.AppDynamicConversationOnline) error
|
||||
First() (*model.AppDynamicConversationOnline, error)
|
||||
Take() (*model.AppDynamicConversationOnline, error)
|
||||
Last() (*model.AppDynamicConversationOnline, error)
|
||||
Find() ([]*model.AppDynamicConversationOnline, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationOnline, err error)
|
||||
FindInBatches(result *[]*model.AppDynamicConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.AppDynamicConversationOnline) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo
|
||||
Assign(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo
|
||||
Joins(fields ...field.RelationField) IAppDynamicConversationOnlineDo
|
||||
Preload(fields ...field.RelationField) IAppDynamicConversationOnlineDo
|
||||
FirstOrInit() (*model.AppDynamicConversationOnline, error)
|
||||
FirstOrCreate() (*model.AppDynamicConversationOnline, error)
|
||||
FindByPage(offset int, limit int) (result []*model.AppDynamicConversationOnline, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IAppDynamicConversationOnlineDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Debug() IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) WithContext(ctx context.Context) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) ReadDB() IAppDynamicConversationOnlineDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) WriteDB() IAppDynamicConversationOnlineDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Session(config *gorm.Session) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Clauses(conds ...clause.Expression) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Returning(value interface{}, columns ...string) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Not(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Or(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Select(conds ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Where(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Order(conds ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Distinct(cols ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Omit(cols ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Group(cols ...field.Expr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Having(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Limit(limit int) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Offset(offset int) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Unscoped() IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Create(values ...*model.AppDynamicConversationOnline) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) CreateInBatches(values []*model.AppDynamicConversationOnline, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a appDynamicConversationOnlineDo) Save(values ...*model.AppDynamicConversationOnline) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) First() (*model.AppDynamicConversationOnline, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Take() (*model.AppDynamicConversationOnline, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Last() (*model.AppDynamicConversationOnline, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Find() ([]*model.AppDynamicConversationOnline, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*model.AppDynamicConversationOnline), err
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationOnline, err error) {
|
||||
buf := make([]*model.AppDynamicConversationOnline, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) FindInBatches(result *[]*model.AppDynamicConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Attrs(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Assign(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Joins(fields ...field.RelationField) IAppDynamicConversationOnlineDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Preload(fields ...field.RelationField) IAppDynamicConversationOnlineDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) FirstOrInit() (*model.AppDynamicConversationOnline, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) FirstOrCreate() (*model.AppDynamicConversationOnline, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppDynamicConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) FindByPage(offset int, limit int) (result []*model.AppDynamicConversationOnline, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a appDynamicConversationOnlineDo) Delete(models ...*model.AppDynamicConversationOnline) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *appDynamicConversationOnlineDo) withDO(do gen.Dao) *appDynamicConversationOnlineDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
)
|
||||
|
||||
func newAppStaticConversationDraft(db *gorm.DB, opts ...gen.DOOption) appStaticConversationDraft {
|
||||
_appStaticConversationDraft := appStaticConversationDraft{}
|
||||
|
||||
_appStaticConversationDraft.appStaticConversationDraftDo.UseDB(db, opts...)
|
||||
_appStaticConversationDraft.appStaticConversationDraftDo.UseModel(&model.AppStaticConversationDraft{})
|
||||
|
||||
tableName := _appStaticConversationDraft.appStaticConversationDraftDo.TableName()
|
||||
_appStaticConversationDraft.ALL = field.NewAsterisk(tableName)
|
||||
_appStaticConversationDraft.ID = field.NewInt64(tableName, "id")
|
||||
_appStaticConversationDraft.TemplateID = field.NewInt64(tableName, "template_id")
|
||||
_appStaticConversationDraft.UserID = field.NewInt64(tableName, "user_id")
|
||||
_appStaticConversationDraft.ConnectorID = field.NewInt64(tableName, "connector_id")
|
||||
_appStaticConversationDraft.ConversationID = field.NewInt64(tableName, "conversation_id")
|
||||
_appStaticConversationDraft.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
_appStaticConversationDraft.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
|
||||
_appStaticConversationDraft.fillFieldMap()
|
||||
|
||||
return _appStaticConversationDraft
|
||||
}
|
||||
|
||||
type appStaticConversationDraft struct {
|
||||
appStaticConversationDraftDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // id
|
||||
TemplateID field.Int64 // template id
|
||||
UserID field.Int64 // user id
|
||||
ConnectorID field.Int64 // connector id
|
||||
ConversationID field.Int64 // conversation id
|
||||
CreatedAt field.Int64 // create time in millisecond
|
||||
DeletedAt field.Field // delete time in millisecond
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraft) Table(newTableName string) *appStaticConversationDraft {
|
||||
a.appStaticConversationDraftDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraft) As(alias string) *appStaticConversationDraft {
|
||||
a.appStaticConversationDraftDo.DO = *(a.appStaticConversationDraftDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *appStaticConversationDraft) updateTableName(table string) *appStaticConversationDraft {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt64(table, "id")
|
||||
a.TemplateID = field.NewInt64(table, "template_id")
|
||||
a.UserID = field.NewInt64(table, "user_id")
|
||||
a.ConnectorID = field.NewInt64(table, "connector_id")
|
||||
a.ConversationID = field.NewInt64(table, "conversation_id")
|
||||
a.CreatedAt = field.NewInt64(table, "created_at")
|
||||
a.DeletedAt = field.NewField(table, "deleted_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *appStaticConversationDraft) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *appStaticConversationDraft) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 7)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["template_id"] = a.TemplateID
|
||||
a.fieldMap["user_id"] = a.UserID
|
||||
a.fieldMap["connector_id"] = a.ConnectorID
|
||||
a.fieldMap["conversation_id"] = a.ConversationID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
a.fieldMap["deleted_at"] = a.DeletedAt
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraft) clone(db *gorm.DB) appStaticConversationDraft {
|
||||
a.appStaticConversationDraftDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraft) replaceDB(db *gorm.DB) appStaticConversationDraft {
|
||||
a.appStaticConversationDraftDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type appStaticConversationDraftDo struct{ gen.DO }
|
||||
|
||||
type IAppStaticConversationDraftDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IAppStaticConversationDraftDo
|
||||
WithContext(ctx context.Context) IAppStaticConversationDraftDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IAppStaticConversationDraftDo
|
||||
WriteDB() IAppStaticConversationDraftDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IAppStaticConversationDraftDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IAppStaticConversationDraftDo
|
||||
Not(conds ...gen.Condition) IAppStaticConversationDraftDo
|
||||
Or(conds ...gen.Condition) IAppStaticConversationDraftDo
|
||||
Select(conds ...field.Expr) IAppStaticConversationDraftDo
|
||||
Where(conds ...gen.Condition) IAppStaticConversationDraftDo
|
||||
Order(conds ...field.Expr) IAppStaticConversationDraftDo
|
||||
Distinct(cols ...field.Expr) IAppStaticConversationDraftDo
|
||||
Omit(cols ...field.Expr) IAppStaticConversationDraftDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo
|
||||
Group(cols ...field.Expr) IAppStaticConversationDraftDo
|
||||
Having(conds ...gen.Condition) IAppStaticConversationDraftDo
|
||||
Limit(limit int) IAppStaticConversationDraftDo
|
||||
Offset(offset int) IAppStaticConversationDraftDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationDraftDo
|
||||
Unscoped() IAppStaticConversationDraftDo
|
||||
Create(values ...*model.AppStaticConversationDraft) error
|
||||
CreateInBatches(values []*model.AppStaticConversationDraft, batchSize int) error
|
||||
Save(values ...*model.AppStaticConversationDraft) error
|
||||
First() (*model.AppStaticConversationDraft, error)
|
||||
Take() (*model.AppStaticConversationDraft, error)
|
||||
Last() (*model.AppStaticConversationDraft, error)
|
||||
Find() ([]*model.AppStaticConversationDraft, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationDraft, err error)
|
||||
FindInBatches(result *[]*model.AppStaticConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.AppStaticConversationDraft) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IAppStaticConversationDraftDo
|
||||
Assign(attrs ...field.AssignExpr) IAppStaticConversationDraftDo
|
||||
Joins(fields ...field.RelationField) IAppStaticConversationDraftDo
|
||||
Preload(fields ...field.RelationField) IAppStaticConversationDraftDo
|
||||
FirstOrInit() (*model.AppStaticConversationDraft, error)
|
||||
FirstOrCreate() (*model.AppStaticConversationDraft, error)
|
||||
FindByPage(offset int, limit int) (result []*model.AppStaticConversationDraft, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IAppStaticConversationDraftDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Debug() IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) WithContext(ctx context.Context) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) ReadDB() IAppStaticConversationDraftDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) WriteDB() IAppStaticConversationDraftDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Session(config *gorm.Session) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Clauses(conds ...clause.Expression) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Returning(value interface{}, columns ...string) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Not(conds ...gen.Condition) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Or(conds ...gen.Condition) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Select(conds ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Where(conds ...gen.Condition) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Order(conds ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Distinct(cols ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Omit(cols ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Group(cols ...field.Expr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Having(conds ...gen.Condition) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Limit(limit int) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Offset(offset int) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Unscoped() IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Create(values ...*model.AppStaticConversationDraft) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) CreateInBatches(values []*model.AppStaticConversationDraft, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a appStaticConversationDraftDo) Save(values ...*model.AppStaticConversationDraft) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) First() (*model.AppStaticConversationDraft, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Take() (*model.AppStaticConversationDraft, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Last() (*model.AppStaticConversationDraft, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Find() ([]*model.AppStaticConversationDraft, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*model.AppStaticConversationDraft), err
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationDraft, err error) {
|
||||
buf := make([]*model.AppStaticConversationDraft, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) FindInBatches(result *[]*model.AppStaticConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Attrs(attrs ...field.AssignExpr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Assign(attrs ...field.AssignExpr) IAppStaticConversationDraftDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Joins(fields ...field.RelationField) IAppStaticConversationDraftDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Preload(fields ...field.RelationField) IAppStaticConversationDraftDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) FirstOrInit() (*model.AppStaticConversationDraft, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) FirstOrCreate() (*model.AppStaticConversationDraft, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationDraft), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) FindByPage(offset int, limit int) (result []*model.AppStaticConversationDraft, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a appStaticConversationDraftDo) Delete(models ...*model.AppStaticConversationDraft) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *appStaticConversationDraftDo) withDO(do gen.Dao) *appStaticConversationDraftDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
)
|
||||
|
||||
func newAppStaticConversationOnline(db *gorm.DB, opts ...gen.DOOption) appStaticConversationOnline {
|
||||
_appStaticConversationOnline := appStaticConversationOnline{}
|
||||
|
||||
_appStaticConversationOnline.appStaticConversationOnlineDo.UseDB(db, opts...)
|
||||
_appStaticConversationOnline.appStaticConversationOnlineDo.UseModel(&model.AppStaticConversationOnline{})
|
||||
|
||||
tableName := _appStaticConversationOnline.appStaticConversationOnlineDo.TableName()
|
||||
_appStaticConversationOnline.ALL = field.NewAsterisk(tableName)
|
||||
_appStaticConversationOnline.ID = field.NewInt64(tableName, "id")
|
||||
_appStaticConversationOnline.TemplateID = field.NewInt64(tableName, "template_id")
|
||||
_appStaticConversationOnline.UserID = field.NewInt64(tableName, "user_id")
|
||||
_appStaticConversationOnline.ConnectorID = field.NewInt64(tableName, "connector_id")
|
||||
_appStaticConversationOnline.ConversationID = field.NewInt64(tableName, "conversation_id")
|
||||
_appStaticConversationOnline.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
|
||||
_appStaticConversationOnline.fillFieldMap()
|
||||
|
||||
return _appStaticConversationOnline
|
||||
}
|
||||
|
||||
type appStaticConversationOnline struct {
|
||||
appStaticConversationOnlineDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // id
|
||||
TemplateID field.Int64 // template id
|
||||
UserID field.Int64 // user id
|
||||
ConnectorID field.Int64 // connector id
|
||||
ConversationID field.Int64 // conversation id
|
||||
CreatedAt field.Int64 // create time in millisecond
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnline) Table(newTableName string) *appStaticConversationOnline {
|
||||
a.appStaticConversationOnlineDo.UseTable(newTableName)
|
||||
return a.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnline) As(alias string) *appStaticConversationOnline {
|
||||
a.appStaticConversationOnlineDo.DO = *(a.appStaticConversationOnlineDo.As(alias).(*gen.DO))
|
||||
return a.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (a *appStaticConversationOnline) updateTableName(table string) *appStaticConversationOnline {
|
||||
a.ALL = field.NewAsterisk(table)
|
||||
a.ID = field.NewInt64(table, "id")
|
||||
a.TemplateID = field.NewInt64(table, "template_id")
|
||||
a.UserID = field.NewInt64(table, "user_id")
|
||||
a.ConnectorID = field.NewInt64(table, "connector_id")
|
||||
a.ConversationID = field.NewInt64(table, "conversation_id")
|
||||
a.CreatedAt = field.NewInt64(table, "created_at")
|
||||
|
||||
a.fillFieldMap()
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
func (a *appStaticConversationOnline) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := a.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (a *appStaticConversationOnline) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 6)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["template_id"] = a.TemplateID
|
||||
a.fieldMap["user_id"] = a.UserID
|
||||
a.fieldMap["connector_id"] = a.ConnectorID
|
||||
a.fieldMap["conversation_id"] = a.ConversationID
|
||||
a.fieldMap["created_at"] = a.CreatedAt
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnline) clone(db *gorm.DB) appStaticConversationOnline {
|
||||
a.appStaticConversationOnlineDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return a
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnline) replaceDB(db *gorm.DB) appStaticConversationOnline {
|
||||
a.appStaticConversationOnlineDo.ReplaceDB(db)
|
||||
return a
|
||||
}
|
||||
|
||||
type appStaticConversationOnlineDo struct{ gen.DO }
|
||||
|
||||
type IAppStaticConversationOnlineDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IAppStaticConversationOnlineDo
|
||||
WithContext(ctx context.Context) IAppStaticConversationOnlineDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IAppStaticConversationOnlineDo
|
||||
WriteDB() IAppStaticConversationOnlineDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IAppStaticConversationOnlineDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IAppStaticConversationOnlineDo
|
||||
Not(conds ...gen.Condition) IAppStaticConversationOnlineDo
|
||||
Or(conds ...gen.Condition) IAppStaticConversationOnlineDo
|
||||
Select(conds ...field.Expr) IAppStaticConversationOnlineDo
|
||||
Where(conds ...gen.Condition) IAppStaticConversationOnlineDo
|
||||
Order(conds ...field.Expr) IAppStaticConversationOnlineDo
|
||||
Distinct(cols ...field.Expr) IAppStaticConversationOnlineDo
|
||||
Omit(cols ...field.Expr) IAppStaticConversationOnlineDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo
|
||||
Group(cols ...field.Expr) IAppStaticConversationOnlineDo
|
||||
Having(conds ...gen.Condition) IAppStaticConversationOnlineDo
|
||||
Limit(limit int) IAppStaticConversationOnlineDo
|
||||
Offset(offset int) IAppStaticConversationOnlineDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationOnlineDo
|
||||
Unscoped() IAppStaticConversationOnlineDo
|
||||
Create(values ...*model.AppStaticConversationOnline) error
|
||||
CreateInBatches(values []*model.AppStaticConversationOnline, batchSize int) error
|
||||
Save(values ...*model.AppStaticConversationOnline) error
|
||||
First() (*model.AppStaticConversationOnline, error)
|
||||
Take() (*model.AppStaticConversationOnline, error)
|
||||
Last() (*model.AppStaticConversationOnline, error)
|
||||
Find() ([]*model.AppStaticConversationOnline, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationOnline, err error)
|
||||
FindInBatches(result *[]*model.AppStaticConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.AppStaticConversationOnline) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo
|
||||
Assign(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo
|
||||
Joins(fields ...field.RelationField) IAppStaticConversationOnlineDo
|
||||
Preload(fields ...field.RelationField) IAppStaticConversationOnlineDo
|
||||
FirstOrInit() (*model.AppStaticConversationOnline, error)
|
||||
FirstOrCreate() (*model.AppStaticConversationOnline, error)
|
||||
FindByPage(offset int, limit int) (result []*model.AppStaticConversationOnline, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IAppStaticConversationOnlineDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Debug() IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Debug())
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) WithContext(ctx context.Context) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) ReadDB() IAppStaticConversationOnlineDo {
|
||||
return a.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) WriteDB() IAppStaticConversationOnlineDo {
|
||||
return a.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Session(config *gorm.Session) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Session(config))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Clauses(conds ...clause.Expression) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Returning(value interface{}, columns ...string) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Not(conds ...gen.Condition) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Or(conds ...gen.Condition) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Select(conds ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Where(conds ...gen.Condition) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Order(conds ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Distinct(cols ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Omit(cols ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Group(cols ...field.Expr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Having(conds ...gen.Condition) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Limit(limit int) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Offset(offset int) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Unscoped() IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Create(values ...*model.AppStaticConversationOnline) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Create(values)
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) CreateInBatches(values []*model.AppStaticConversationOnline, batchSize int) error {
|
||||
return a.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (a appStaticConversationOnlineDo) Save(values ...*model.AppStaticConversationOnline) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return a.DO.Save(values)
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) First() (*model.AppStaticConversationOnline, error) {
|
||||
if result, err := a.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Take() (*model.AppStaticConversationOnline, error) {
|
||||
if result, err := a.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Last() (*model.AppStaticConversationOnline, error) {
|
||||
if result, err := a.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Find() ([]*model.AppStaticConversationOnline, error) {
|
||||
result, err := a.DO.Find()
|
||||
return result.([]*model.AppStaticConversationOnline), err
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationOnline, err error) {
|
||||
buf := make([]*model.AppStaticConversationOnline, 0, batchSize)
|
||||
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) FindInBatches(result *[]*model.AppStaticConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return a.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Attrs(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Assign(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo {
|
||||
return a.withDO(a.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Joins(fields ...field.RelationField) IAppStaticConversationOnlineDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Joins(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Preload(fields ...field.RelationField) IAppStaticConversationOnlineDo {
|
||||
for _, _f := range fields {
|
||||
a = *a.withDO(a.DO.Preload(_f))
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) FirstOrInit() (*model.AppStaticConversationOnline, error) {
|
||||
if result, err := a.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) FirstOrCreate() (*model.AppStaticConversationOnline, error) {
|
||||
if result, err := a.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.AppStaticConversationOnline), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) FindByPage(offset int, limit int) (result []*model.AppStaticConversationOnline, count int64, err error) {
|
||||
result, err = a.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = a.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = a.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = a.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Scan(result interface{}) (err error) {
|
||||
return a.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (a appStaticConversationOnlineDo) Delete(models ...*model.AppStaticConversationOnline) (result gen.ResultInfo, err error) {
|
||||
return a.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (a *appStaticConversationOnlineDo) withDO(do gen.Dao) *appStaticConversationOnlineDo {
|
||||
a.DO = *do.(*gen.DO)
|
||||
return a
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
// Code generated by gorm.io/gen. DO NOT EDIT.
|
||||
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"gorm.io/gorm/schema"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gen/field"
|
||||
|
||||
"gorm.io/plugin/dbresolver"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||
)
|
||||
|
||||
func newChatFlowRoleConfig(db *gorm.DB, opts ...gen.DOOption) chatFlowRoleConfig {
|
||||
_chatFlowRoleConfig := chatFlowRoleConfig{}
|
||||
|
||||
_chatFlowRoleConfig.chatFlowRoleConfigDo.UseDB(db, opts...)
|
||||
_chatFlowRoleConfig.chatFlowRoleConfigDo.UseModel(&model.ChatFlowRoleConfig{})
|
||||
|
||||
tableName := _chatFlowRoleConfig.chatFlowRoleConfigDo.TableName()
|
||||
_chatFlowRoleConfig.ALL = field.NewAsterisk(tableName)
|
||||
_chatFlowRoleConfig.ID = field.NewInt64(tableName, "id")
|
||||
_chatFlowRoleConfig.WorkflowID = field.NewInt64(tableName, "workflow_id")
|
||||
_chatFlowRoleConfig.Name = field.NewString(tableName, "name")
|
||||
_chatFlowRoleConfig.Description = field.NewString(tableName, "description")
|
||||
_chatFlowRoleConfig.Version = field.NewString(tableName, "version")
|
||||
_chatFlowRoleConfig.Avatar = field.NewString(tableName, "avatar")
|
||||
_chatFlowRoleConfig.BackgroundImageInfo = field.NewString(tableName, "background_image_info")
|
||||
_chatFlowRoleConfig.OnboardingInfo = field.NewString(tableName, "onboarding_info")
|
||||
_chatFlowRoleConfig.SuggestReplyInfo = field.NewString(tableName, "suggest_reply_info")
|
||||
_chatFlowRoleConfig.AudioConfig = field.NewString(tableName, "audio_config")
|
||||
_chatFlowRoleConfig.UserInputConfig = field.NewString(tableName, "user_input_config")
|
||||
_chatFlowRoleConfig.CreatorID = field.NewInt64(tableName, "creator_id")
|
||||
_chatFlowRoleConfig.CreatedAt = field.NewInt64(tableName, "created_at")
|
||||
_chatFlowRoleConfig.UpdatedAt = field.NewInt64(tableName, "updated_at")
|
||||
_chatFlowRoleConfig.DeletedAt = field.NewField(tableName, "deleted_at")
|
||||
_chatFlowRoleConfig.ConnectorID = field.NewInt64(tableName, "connector_id")
|
||||
|
||||
_chatFlowRoleConfig.fillFieldMap()
|
||||
|
||||
return _chatFlowRoleConfig
|
||||
}
|
||||
|
||||
type chatFlowRoleConfig struct {
|
||||
chatFlowRoleConfigDo
|
||||
|
||||
ALL field.Asterisk
|
||||
ID field.Int64 // id
|
||||
WorkflowID field.Int64 // workflow id
|
||||
Name field.String // role name
|
||||
Description field.String // role description
|
||||
Version field.String // version
|
||||
Avatar field.String // avatar uri
|
||||
BackgroundImageInfo field.String // background image information, object structure
|
||||
OnboardingInfo field.String // intro information, object structure
|
||||
SuggestReplyInfo field.String // user suggestions, object structure
|
||||
AudioConfig field.String // agent audio config, object structure
|
||||
UserInputConfig field.String // user input config, object structure
|
||||
CreatorID field.Int64 // creator id
|
||||
CreatedAt field.Int64 // create time in millisecond
|
||||
UpdatedAt field.Int64 // update time in millisecond
|
||||
DeletedAt field.Field // delete time in millisecond
|
||||
ConnectorID field.Int64 // connector id
|
||||
|
||||
fieldMap map[string]field.Expr
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfig) Table(newTableName string) *chatFlowRoleConfig {
|
||||
c.chatFlowRoleConfigDo.UseTable(newTableName)
|
||||
return c.updateTableName(newTableName)
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfig) As(alias string) *chatFlowRoleConfig {
|
||||
c.chatFlowRoleConfigDo.DO = *(c.chatFlowRoleConfigDo.As(alias).(*gen.DO))
|
||||
return c.updateTableName(alias)
|
||||
}
|
||||
|
||||
func (c *chatFlowRoleConfig) updateTableName(table string) *chatFlowRoleConfig {
|
||||
c.ALL = field.NewAsterisk(table)
|
||||
c.ID = field.NewInt64(table, "id")
|
||||
c.WorkflowID = field.NewInt64(table, "workflow_id")
|
||||
c.Name = field.NewString(table, "name")
|
||||
c.Description = field.NewString(table, "description")
|
||||
c.Version = field.NewString(table, "version")
|
||||
c.Avatar = field.NewString(table, "avatar")
|
||||
c.BackgroundImageInfo = field.NewString(table, "background_image_info")
|
||||
c.OnboardingInfo = field.NewString(table, "onboarding_info")
|
||||
c.SuggestReplyInfo = field.NewString(table, "suggest_reply_info")
|
||||
c.AudioConfig = field.NewString(table, "audio_config")
|
||||
c.UserInputConfig = field.NewString(table, "user_input_config")
|
||||
c.CreatorID = field.NewInt64(table, "creator_id")
|
||||
c.CreatedAt = field.NewInt64(table, "created_at")
|
||||
c.UpdatedAt = field.NewInt64(table, "updated_at")
|
||||
c.DeletedAt = field.NewField(table, "deleted_at")
|
||||
c.ConnectorID = field.NewInt64(table, "connector_id")
|
||||
|
||||
c.fillFieldMap()
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *chatFlowRoleConfig) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
_f, ok := c.fieldMap[fieldName]
|
||||
if !ok || _f == nil {
|
||||
return nil, false
|
||||
}
|
||||
_oe, ok := _f.(field.OrderExpr)
|
||||
return _oe, ok
|
||||
}
|
||||
|
||||
func (c *chatFlowRoleConfig) fillFieldMap() {
|
||||
c.fieldMap = make(map[string]field.Expr, 16)
|
||||
c.fieldMap["id"] = c.ID
|
||||
c.fieldMap["workflow_id"] = c.WorkflowID
|
||||
c.fieldMap["name"] = c.Name
|
||||
c.fieldMap["description"] = c.Description
|
||||
c.fieldMap["version"] = c.Version
|
||||
c.fieldMap["avatar"] = c.Avatar
|
||||
c.fieldMap["background_image_info"] = c.BackgroundImageInfo
|
||||
c.fieldMap["onboarding_info"] = c.OnboardingInfo
|
||||
c.fieldMap["suggest_reply_info"] = c.SuggestReplyInfo
|
||||
c.fieldMap["audio_config"] = c.AudioConfig
|
||||
c.fieldMap["user_input_config"] = c.UserInputConfig
|
||||
c.fieldMap["creator_id"] = c.CreatorID
|
||||
c.fieldMap["created_at"] = c.CreatedAt
|
||||
c.fieldMap["updated_at"] = c.UpdatedAt
|
||||
c.fieldMap["deleted_at"] = c.DeletedAt
|
||||
c.fieldMap["connector_id"] = c.ConnectorID
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfig) clone(db *gorm.DB) chatFlowRoleConfig {
|
||||
c.chatFlowRoleConfigDo.ReplaceConnPool(db.Statement.ConnPool)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfig) replaceDB(db *gorm.DB) chatFlowRoleConfig {
|
||||
c.chatFlowRoleConfigDo.ReplaceDB(db)
|
||||
return c
|
||||
}
|
||||
|
||||
type chatFlowRoleConfigDo struct{ gen.DO }
|
||||
|
||||
type IChatFlowRoleConfigDo interface {
|
||||
gen.SubQuery
|
||||
Debug() IChatFlowRoleConfigDo
|
||||
WithContext(ctx context.Context) IChatFlowRoleConfigDo
|
||||
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
|
||||
ReplaceDB(db *gorm.DB)
|
||||
ReadDB() IChatFlowRoleConfigDo
|
||||
WriteDB() IChatFlowRoleConfigDo
|
||||
As(alias string) gen.Dao
|
||||
Session(config *gorm.Session) IChatFlowRoleConfigDo
|
||||
Columns(cols ...field.Expr) gen.Columns
|
||||
Clauses(conds ...clause.Expression) IChatFlowRoleConfigDo
|
||||
Not(conds ...gen.Condition) IChatFlowRoleConfigDo
|
||||
Or(conds ...gen.Condition) IChatFlowRoleConfigDo
|
||||
Select(conds ...field.Expr) IChatFlowRoleConfigDo
|
||||
Where(conds ...gen.Condition) IChatFlowRoleConfigDo
|
||||
Order(conds ...field.Expr) IChatFlowRoleConfigDo
|
||||
Distinct(cols ...field.Expr) IChatFlowRoleConfigDo
|
||||
Omit(cols ...field.Expr) IChatFlowRoleConfigDo
|
||||
Join(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo
|
||||
LeftJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo
|
||||
RightJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo
|
||||
Group(cols ...field.Expr) IChatFlowRoleConfigDo
|
||||
Having(conds ...gen.Condition) IChatFlowRoleConfigDo
|
||||
Limit(limit int) IChatFlowRoleConfigDo
|
||||
Offset(offset int) IChatFlowRoleConfigDo
|
||||
Count() (count int64, err error)
|
||||
Scopes(funcs ...func(gen.Dao) gen.Dao) IChatFlowRoleConfigDo
|
||||
Unscoped() IChatFlowRoleConfigDo
|
||||
Create(values ...*model.ChatFlowRoleConfig) error
|
||||
CreateInBatches(values []*model.ChatFlowRoleConfig, batchSize int) error
|
||||
Save(values ...*model.ChatFlowRoleConfig) error
|
||||
First() (*model.ChatFlowRoleConfig, error)
|
||||
Take() (*model.ChatFlowRoleConfig, error)
|
||||
Last() (*model.ChatFlowRoleConfig, error)
|
||||
Find() ([]*model.ChatFlowRoleConfig, error)
|
||||
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChatFlowRoleConfig, err error)
|
||||
FindInBatches(result *[]*model.ChatFlowRoleConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error
|
||||
Pluck(column field.Expr, dest interface{}) error
|
||||
Delete(...*model.ChatFlowRoleConfig) (info gen.ResultInfo, err error)
|
||||
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
Updates(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
|
||||
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
|
||||
UpdateFrom(q gen.SubQuery) gen.Dao
|
||||
Attrs(attrs ...field.AssignExpr) IChatFlowRoleConfigDo
|
||||
Assign(attrs ...field.AssignExpr) IChatFlowRoleConfigDo
|
||||
Joins(fields ...field.RelationField) IChatFlowRoleConfigDo
|
||||
Preload(fields ...field.RelationField) IChatFlowRoleConfigDo
|
||||
FirstOrInit() (*model.ChatFlowRoleConfig, error)
|
||||
FirstOrCreate() (*model.ChatFlowRoleConfig, error)
|
||||
FindByPage(offset int, limit int) (result []*model.ChatFlowRoleConfig, count int64, err error)
|
||||
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
|
||||
Scan(result interface{}) (err error)
|
||||
Returning(value interface{}, columns ...string) IChatFlowRoleConfigDo
|
||||
UnderlyingDB() *gorm.DB
|
||||
schema.Tabler
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Debug() IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Debug())
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) WithContext(ctx context.Context) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.WithContext(ctx))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) ReadDB() IChatFlowRoleConfigDo {
|
||||
return c.Clauses(dbresolver.Read)
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) WriteDB() IChatFlowRoleConfigDo {
|
||||
return c.Clauses(dbresolver.Write)
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Session(config *gorm.Session) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Session(config))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Clauses(conds ...clause.Expression) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Clauses(conds...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Returning(value interface{}, columns ...string) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Returning(value, columns...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Not(conds ...gen.Condition) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Not(conds...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Or(conds ...gen.Condition) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Or(conds...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Select(conds ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Select(conds...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Where(conds ...gen.Condition) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Where(conds...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Order(conds ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Order(conds...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Distinct(cols ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Distinct(cols...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Omit(cols ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Omit(cols...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Join(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Join(table, on...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) LeftJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.LeftJoin(table, on...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) RightJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.RightJoin(table, on...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Group(cols ...field.Expr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Group(cols...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Having(conds ...gen.Condition) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Having(conds...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Limit(limit int) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Limit(limit))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Offset(offset int) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Offset(offset))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Scopes(funcs...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Unscoped() IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Unscoped())
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Create(values ...*model.ChatFlowRoleConfig) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.DO.Create(values)
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) CreateInBatches(values []*model.ChatFlowRoleConfig, batchSize int) error {
|
||||
return c.DO.CreateInBatches(values, batchSize)
|
||||
}
|
||||
|
||||
// Save : !!! underlying implementation is different with GORM
|
||||
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
||||
func (c chatFlowRoleConfigDo) Save(values ...*model.ChatFlowRoleConfig) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
return c.DO.Save(values)
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) First() (*model.ChatFlowRoleConfig, error) {
|
||||
if result, err := c.DO.First(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ChatFlowRoleConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Take() (*model.ChatFlowRoleConfig, error) {
|
||||
if result, err := c.DO.Take(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ChatFlowRoleConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Last() (*model.ChatFlowRoleConfig, error) {
|
||||
if result, err := c.DO.Last(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ChatFlowRoleConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Find() ([]*model.ChatFlowRoleConfig, error) {
|
||||
result, err := c.DO.Find()
|
||||
return result.([]*model.ChatFlowRoleConfig), err
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChatFlowRoleConfig, err error) {
|
||||
buf := make([]*model.ChatFlowRoleConfig, 0, batchSize)
|
||||
err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
||||
defer func() { results = append(results, buf...) }()
|
||||
return fc(tx, batch)
|
||||
})
|
||||
return results, err
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) FindInBatches(result *[]*model.ChatFlowRoleConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
||||
return c.DO.FindInBatches(result, batchSize, fc)
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Attrs(attrs ...field.AssignExpr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Attrs(attrs...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Assign(attrs ...field.AssignExpr) IChatFlowRoleConfigDo {
|
||||
return c.withDO(c.DO.Assign(attrs...))
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Joins(fields ...field.RelationField) IChatFlowRoleConfigDo {
|
||||
for _, _f := range fields {
|
||||
c = *c.withDO(c.DO.Joins(_f))
|
||||
}
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Preload(fields ...field.RelationField) IChatFlowRoleConfigDo {
|
||||
for _, _f := range fields {
|
||||
c = *c.withDO(c.DO.Preload(_f))
|
||||
}
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) FirstOrInit() (*model.ChatFlowRoleConfig, error) {
|
||||
if result, err := c.DO.FirstOrInit(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ChatFlowRoleConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) FirstOrCreate() (*model.ChatFlowRoleConfig, error) {
|
||||
if result, err := c.DO.FirstOrCreate(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*model.ChatFlowRoleConfig), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) FindByPage(offset int, limit int) (result []*model.ChatFlowRoleConfig, count int64, err error) {
|
||||
result, err = c.Offset(offset).Limit(limit).Find()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if size := len(result); 0 < limit && 0 < size && size < limit {
|
||||
count = int64(size + offset)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = c.Offset(-1).Limit(-1).Count()
|
||||
return
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
||||
count, err = c.Count()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = c.Offset(offset).Limit(limit).Scan(result)
|
||||
return
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Scan(result interface{}) (err error) {
|
||||
return c.DO.Scan(result)
|
||||
}
|
||||
|
||||
func (c chatFlowRoleConfigDo) Delete(models ...*model.ChatFlowRoleConfig) (result gen.ResultInfo, err error) {
|
||||
return c.DO.Delete(models)
|
||||
}
|
||||
|
||||
func (c *chatFlowRoleConfigDo) withDO(do gen.Dao) *chatFlowRoleConfigDo {
|
||||
c.DO = *do.(*gen.DO)
|
||||
return c
|
||||
}
|
||||
@@ -16,20 +16,34 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
Q = new(Query)
|
||||
ConnectorWorkflowVersion *connectorWorkflowVersion
|
||||
NodeExecution *nodeExecution
|
||||
WorkflowDraft *workflowDraft
|
||||
WorkflowExecution *workflowExecution
|
||||
WorkflowMeta *workflowMeta
|
||||
WorkflowReference *workflowReference
|
||||
WorkflowSnapshot *workflowSnapshot
|
||||
WorkflowVersion *workflowVersion
|
||||
Q = new(Query)
|
||||
ConnectorWorkflowVersion *connectorWorkflowVersion
|
||||
AppConversationTemplateDraft *appConversationTemplateDraft
|
||||
AppConversationTemplateOnline *appConversationTemplateOnline
|
||||
AppDynamicConversationDraft *appDynamicConversationDraft
|
||||
AppDynamicConversationOnline *appDynamicConversationOnline
|
||||
AppStaticConversationDraft *appStaticConversationDraft
|
||||
AppStaticConversationOnline *appStaticConversationOnline
|
||||
ChatFlowRoleConfig *chatFlowRoleConfig
|
||||
NodeExecution *nodeExecution
|
||||
WorkflowDraft *workflowDraft
|
||||
WorkflowExecution *workflowExecution
|
||||
WorkflowMeta *workflowMeta
|
||||
WorkflowReference *workflowReference
|
||||
WorkflowSnapshot *workflowSnapshot
|
||||
WorkflowVersion *workflowVersion
|
||||
)
|
||||
|
||||
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
*Q = *Use(db, opts...)
|
||||
ConnectorWorkflowVersion = &Q.ConnectorWorkflowVersion
|
||||
AppConversationTemplateDraft = &Q.AppConversationTemplateDraft
|
||||
AppConversationTemplateOnline = &Q.AppConversationTemplateOnline
|
||||
AppDynamicConversationDraft = &Q.AppDynamicConversationDraft
|
||||
AppDynamicConversationOnline = &Q.AppDynamicConversationOnline
|
||||
AppStaticConversationDraft = &Q.AppStaticConversationDraft
|
||||
AppStaticConversationOnline = &Q.AppStaticConversationOnline
|
||||
ChatFlowRoleConfig = &Q.ChatFlowRoleConfig
|
||||
NodeExecution = &Q.NodeExecution
|
||||
WorkflowDraft = &Q.WorkflowDraft
|
||||
WorkflowExecution = &Q.WorkflowExecution
|
||||
@@ -41,44 +55,65 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
|
||||
|
||||
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
ConnectorWorkflowVersion: newConnectorWorkflowVersion(db, opts...),
|
||||
NodeExecution: newNodeExecution(db, opts...),
|
||||
WorkflowDraft: newWorkflowDraft(db, opts...),
|
||||
WorkflowExecution: newWorkflowExecution(db, opts...),
|
||||
WorkflowMeta: newWorkflowMeta(db, opts...),
|
||||
WorkflowReference: newWorkflowReference(db, opts...),
|
||||
WorkflowSnapshot: newWorkflowSnapshot(db, opts...),
|
||||
WorkflowVersion: newWorkflowVersion(db, opts...),
|
||||
db: db,
|
||||
ConnectorWorkflowVersion: newConnectorWorkflowVersion(db, opts...),
|
||||
AppConversationTemplateDraft: newAppConversationTemplateDraft(db, opts...),
|
||||
AppConversationTemplateOnline: newAppConversationTemplateOnline(db, opts...),
|
||||
AppDynamicConversationDraft: newAppDynamicConversationDraft(db, opts...),
|
||||
AppDynamicConversationOnline: newAppDynamicConversationOnline(db, opts...),
|
||||
AppStaticConversationDraft: newAppStaticConversationDraft(db, opts...),
|
||||
AppStaticConversationOnline: newAppStaticConversationOnline(db, opts...),
|
||||
ChatFlowRoleConfig: newChatFlowRoleConfig(db, opts...),
|
||||
NodeExecution: newNodeExecution(db, opts...),
|
||||
WorkflowDraft: newWorkflowDraft(db, opts...),
|
||||
WorkflowExecution: newWorkflowExecution(db, opts...),
|
||||
WorkflowMeta: newWorkflowMeta(db, opts...),
|
||||
WorkflowReference: newWorkflowReference(db, opts...),
|
||||
WorkflowSnapshot: newWorkflowSnapshot(db, opts...),
|
||||
WorkflowVersion: newWorkflowVersion(db, opts...),
|
||||
}
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
db *gorm.DB
|
||||
|
||||
ConnectorWorkflowVersion connectorWorkflowVersion
|
||||
NodeExecution nodeExecution
|
||||
WorkflowDraft workflowDraft
|
||||
WorkflowExecution workflowExecution
|
||||
WorkflowMeta workflowMeta
|
||||
WorkflowReference workflowReference
|
||||
WorkflowSnapshot workflowSnapshot
|
||||
WorkflowVersion workflowVersion
|
||||
ConnectorWorkflowVersion connectorWorkflowVersion
|
||||
AppConversationTemplateDraft appConversationTemplateDraft
|
||||
AppConversationTemplateOnline appConversationTemplateOnline
|
||||
AppDynamicConversationDraft appDynamicConversationDraft
|
||||
AppDynamicConversationOnline appDynamicConversationOnline
|
||||
AppStaticConversationDraft appStaticConversationDraft
|
||||
AppStaticConversationOnline appStaticConversationOnline
|
||||
ChatFlowRoleConfig chatFlowRoleConfig
|
||||
NodeExecution nodeExecution
|
||||
WorkflowDraft workflowDraft
|
||||
WorkflowExecution workflowExecution
|
||||
WorkflowMeta workflowMeta
|
||||
WorkflowReference workflowReference
|
||||
WorkflowSnapshot workflowSnapshot
|
||||
WorkflowVersion workflowVersion
|
||||
}
|
||||
|
||||
func (q *Query) Available() bool { return q.db != nil }
|
||||
|
||||
func (q *Query) clone(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.clone(db),
|
||||
NodeExecution: q.NodeExecution.clone(db),
|
||||
WorkflowDraft: q.WorkflowDraft.clone(db),
|
||||
WorkflowExecution: q.WorkflowExecution.clone(db),
|
||||
WorkflowMeta: q.WorkflowMeta.clone(db),
|
||||
WorkflowReference: q.WorkflowReference.clone(db),
|
||||
WorkflowSnapshot: q.WorkflowSnapshot.clone(db),
|
||||
WorkflowVersion: q.WorkflowVersion.clone(db),
|
||||
db: db,
|
||||
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.clone(db),
|
||||
AppConversationTemplateDraft: q.AppConversationTemplateDraft.clone(db),
|
||||
AppConversationTemplateOnline: q.AppConversationTemplateOnline.clone(db),
|
||||
AppDynamicConversationDraft: q.AppDynamicConversationDraft.clone(db),
|
||||
AppDynamicConversationOnline: q.AppDynamicConversationOnline.clone(db),
|
||||
AppStaticConversationDraft: q.AppStaticConversationDraft.clone(db),
|
||||
AppStaticConversationOnline: q.AppStaticConversationOnline.clone(db),
|
||||
ChatFlowRoleConfig: q.ChatFlowRoleConfig.clone(db),
|
||||
NodeExecution: q.NodeExecution.clone(db),
|
||||
WorkflowDraft: q.WorkflowDraft.clone(db),
|
||||
WorkflowExecution: q.WorkflowExecution.clone(db),
|
||||
WorkflowMeta: q.WorkflowMeta.clone(db),
|
||||
WorkflowReference: q.WorkflowReference.clone(db),
|
||||
WorkflowSnapshot: q.WorkflowSnapshot.clone(db),
|
||||
WorkflowVersion: q.WorkflowVersion.clone(db),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,39 +127,60 @@ func (q *Query) WriteDB() *Query {
|
||||
|
||||
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
db: db,
|
||||
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.replaceDB(db),
|
||||
NodeExecution: q.NodeExecution.replaceDB(db),
|
||||
WorkflowDraft: q.WorkflowDraft.replaceDB(db),
|
||||
WorkflowExecution: q.WorkflowExecution.replaceDB(db),
|
||||
WorkflowMeta: q.WorkflowMeta.replaceDB(db),
|
||||
WorkflowReference: q.WorkflowReference.replaceDB(db),
|
||||
WorkflowSnapshot: q.WorkflowSnapshot.replaceDB(db),
|
||||
WorkflowVersion: q.WorkflowVersion.replaceDB(db),
|
||||
db: db,
|
||||
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.replaceDB(db),
|
||||
AppConversationTemplateDraft: q.AppConversationTemplateDraft.replaceDB(db),
|
||||
AppConversationTemplateOnline: q.AppConversationTemplateOnline.replaceDB(db),
|
||||
AppDynamicConversationDraft: q.AppDynamicConversationDraft.replaceDB(db),
|
||||
AppDynamicConversationOnline: q.AppDynamicConversationOnline.replaceDB(db),
|
||||
AppStaticConversationDraft: q.AppStaticConversationDraft.replaceDB(db),
|
||||
AppStaticConversationOnline: q.AppStaticConversationOnline.replaceDB(db),
|
||||
ChatFlowRoleConfig: q.ChatFlowRoleConfig.replaceDB(db),
|
||||
NodeExecution: q.NodeExecution.replaceDB(db),
|
||||
WorkflowDraft: q.WorkflowDraft.replaceDB(db),
|
||||
WorkflowExecution: q.WorkflowExecution.replaceDB(db),
|
||||
WorkflowMeta: q.WorkflowMeta.replaceDB(db),
|
||||
WorkflowReference: q.WorkflowReference.replaceDB(db),
|
||||
WorkflowSnapshot: q.WorkflowSnapshot.replaceDB(db),
|
||||
WorkflowVersion: q.WorkflowVersion.replaceDB(db),
|
||||
}
|
||||
}
|
||||
|
||||
type queryCtx struct {
|
||||
ConnectorWorkflowVersion IConnectorWorkflowVersionDo
|
||||
NodeExecution INodeExecutionDo
|
||||
WorkflowDraft IWorkflowDraftDo
|
||||
WorkflowExecution IWorkflowExecutionDo
|
||||
WorkflowMeta IWorkflowMetaDo
|
||||
WorkflowReference IWorkflowReferenceDo
|
||||
WorkflowSnapshot IWorkflowSnapshotDo
|
||||
WorkflowVersion IWorkflowVersionDo
|
||||
ConnectorWorkflowVersion IConnectorWorkflowVersionDo
|
||||
AppConversationTemplateDraft IAppConversationTemplateDraftDo
|
||||
AppConversationTemplateOnline IAppConversationTemplateOnlineDo
|
||||
AppDynamicConversationDraft IAppDynamicConversationDraftDo
|
||||
AppDynamicConversationOnline IAppDynamicConversationOnlineDo
|
||||
AppStaticConversationDraft IAppStaticConversationDraftDo
|
||||
AppStaticConversationOnline IAppStaticConversationOnlineDo
|
||||
ChatFlowRoleConfig IChatFlowRoleConfigDo
|
||||
NodeExecution INodeExecutionDo
|
||||
WorkflowDraft IWorkflowDraftDo
|
||||
WorkflowExecution IWorkflowExecutionDo
|
||||
WorkflowMeta IWorkflowMetaDo
|
||||
WorkflowReference IWorkflowReferenceDo
|
||||
WorkflowSnapshot IWorkflowSnapshotDo
|
||||
WorkflowVersion IWorkflowVersionDo
|
||||
}
|
||||
|
||||
func (q *Query) WithContext(ctx context.Context) *queryCtx {
|
||||
return &queryCtx{
|
||||
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.WithContext(ctx),
|
||||
NodeExecution: q.NodeExecution.WithContext(ctx),
|
||||
WorkflowDraft: q.WorkflowDraft.WithContext(ctx),
|
||||
WorkflowExecution: q.WorkflowExecution.WithContext(ctx),
|
||||
WorkflowMeta: q.WorkflowMeta.WithContext(ctx),
|
||||
WorkflowReference: q.WorkflowReference.WithContext(ctx),
|
||||
WorkflowSnapshot: q.WorkflowSnapshot.WithContext(ctx),
|
||||
WorkflowVersion: q.WorkflowVersion.WithContext(ctx),
|
||||
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.WithContext(ctx),
|
||||
AppConversationTemplateDraft: q.AppConversationTemplateDraft.WithContext(ctx),
|
||||
AppConversationTemplateOnline: q.AppConversationTemplateOnline.WithContext(ctx),
|
||||
AppDynamicConversationDraft: q.AppDynamicConversationDraft.WithContext(ctx),
|
||||
AppDynamicConversationOnline: q.AppDynamicConversationOnline.WithContext(ctx),
|
||||
AppStaticConversationDraft: q.AppStaticConversationDraft.WithContext(ctx),
|
||||
AppStaticConversationOnline: q.AppStaticConversationOnline.WithContext(ctx),
|
||||
ChatFlowRoleConfig: q.ChatFlowRoleConfig.WithContext(ctx),
|
||||
NodeExecution: q.NodeExecution.WithContext(ctx),
|
||||
WorkflowDraft: q.WorkflowDraft.WithContext(ctx),
|
||||
WorkflowExecution: q.WorkflowExecution.WithContext(ctx),
|
||||
WorkflowMeta: q.WorkflowMeta.WithContext(ctx),
|
||||
WorkflowReference: q.WorkflowReference.WithContext(ctx),
|
||||
WorkflowSnapshot: q.WorkflowSnapshot.WithContext(ctx),
|
||||
WorkflowVersion: q.WorkflowVersion.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
@@ -38,6 +40,7 @@ const (
|
||||
interruptEventListKeyPattern = "interrupt_event_list:%d"
|
||||
interruptEventTTL = 24 * time.Hour // Example: expire after 24 hours
|
||||
previousResumedEventKeyPattern = "previous_resumed_event:%d"
|
||||
ConvToEventExecFormat = "conv_relate_info:%d"
|
||||
)
|
||||
|
||||
// SaveInterruptEvents saves multiple interrupt events to the end of a Redis list.
|
||||
@@ -246,3 +249,33 @@ func (i *interruptEventStoreImpl) ListInterruptEvents(ctx context.Context, wfExe
|
||||
|
||||
return events, nil
|
||||
}
|
||||
|
||||
func (i *interruptEventStoreImpl) BindConvRelatedInfo(ctx context.Context, convID int64, info entity.ConvRelatedInfo) error {
|
||||
data, err := sonic.Marshal(info)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result := i.redis.Set(ctx, fmt.Sprintf(ConvToEventExecFormat, convID), data, interruptEventTTL)
|
||||
if result.Err() != nil {
|
||||
return result.Err()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *interruptEventStoreImpl) GetConvRelatedInfo(ctx context.Context, convID int64) (*entity.ConvRelatedInfo, bool, func() error, error) {
|
||||
data, err := i.redis.Get(ctx, fmt.Sprintf(ConvToEventExecFormat, convID)).Bytes()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
return nil, false, nil, nil
|
||||
}
|
||||
return nil, false, nil, err
|
||||
}
|
||||
rInfo := &entity.ConvRelatedInfo{}
|
||||
err = sonic.UnmarshalString(string(data), rInfo)
|
||||
if err != nil {
|
||||
return nil, false, nil, err
|
||||
}
|
||||
return rInfo, true, func() error {
|
||||
return i.redis.Del(ctx, fmt.Sprintf(ConvToEventExecFormat, convID)).Err()
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -70,10 +70,15 @@ type RepositoryImpl struct {
|
||||
workflow.ExecuteHistoryStore
|
||||
builtinModel cm.BaseChatModel
|
||||
workflow.WorkflowConfig
|
||||
workflow.Suggester
|
||||
}
|
||||
|
||||
func NewRepository(idgen idgen.IDGenerator, db *gorm.DB, redis cache.Cmdable, tos storage.Storage,
|
||||
cpStore einoCompose.CheckPointStore, chatModel cm.BaseChatModel, workflowConfig workflow.WorkflowConfig) workflow.Repository {
|
||||
cpStore einoCompose.CheckPointStore, chatModel cm.BaseChatModel, workflowConfig workflow.WorkflowConfig) (workflow.Repository, error) {
|
||||
sg, err := NewSuggester(chatModel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &RepositoryImpl{
|
||||
IDGenerator: idgen,
|
||||
query: query.Use(db),
|
||||
@@ -90,9 +95,12 @@ func NewRepository(idgen idgen.IDGenerator, db *gorm.DB, redis cache.Cmdable, to
|
||||
query: query.Use(db),
|
||||
redis: redis,
|
||||
},
|
||||
|
||||
builtinModel: chatModel,
|
||||
Suggester: sg,
|
||||
WorkflowConfig: workflowConfig,
|
||||
}
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) CreateMeta(ctx context.Context, meta *vo.Meta) (int64, error) {
|
||||
@@ -320,13 +328,16 @@ func (r *RepositoryImpl) CreateVersion(ctx context.Context, id int64, info *vo.V
|
||||
|
||||
func (r *RepositoryImpl) CreateOrUpdateDraft(ctx context.Context, id int64, draft *vo.DraftInfo) error {
|
||||
d := &model.WorkflowDraft{
|
||||
ID: id,
|
||||
Canvas: draft.Canvas,
|
||||
InputParams: draft.InputParamsStr,
|
||||
OutputParams: draft.OutputParamsStr,
|
||||
Modified: draft.Modified,
|
||||
TestRunSuccess: draft.TestRunSuccess,
|
||||
CommitID: draft.CommitID,
|
||||
ID: id,
|
||||
Canvas: draft.Canvas,
|
||||
InputParams: draft.InputParamsStr,
|
||||
OutputParams: draft.OutputParamsStr,
|
||||
CommitID: draft.CommitID,
|
||||
}
|
||||
|
||||
if draft.DraftMeta != nil {
|
||||
d.Modified = draft.DraftMeta.Modified
|
||||
d.TestRunSuccess = draft.DraftMeta.TestRunSuccess
|
||||
}
|
||||
|
||||
if err := r.query.WorkflowDraft.WithContext(ctx).Save(d); err != nil {
|
||||
@@ -500,6 +511,10 @@ func (r *RepositoryImpl) UpdateMeta(ctx context.Context, id int64, metaUpdate *v
|
||||
expressions = append(expressions, r.query.WorkflowMeta.LatestVersion.Value(*metaUpdate.LatestPublishedVersion))
|
||||
}
|
||||
|
||||
if metaUpdate.WorkflowMode != nil {
|
||||
expressions = append(expressions, r.query.WorkflowMeta.Mode.Value(int32(*metaUpdate.WorkflowMode)))
|
||||
}
|
||||
|
||||
if len(expressions) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -551,10 +566,13 @@ func (r *RepositoryImpl) GetEntity(ctx context.Context, policy *vo.GetPolicy) (_
|
||||
draftMeta = draft.DraftMeta
|
||||
commitID = draft.CommitID
|
||||
case workflowModel.FromSpecificVersion:
|
||||
v, err := r.GetVersion(ctx, policy.ID, policy.Version)
|
||||
v, existed, err := r.GetVersion(ctx, policy.ID, policy.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !existed {
|
||||
return nil, vo.WrapError(errno.ErrWorkflowNotFound, fmt.Errorf("workflow version %s not found for ID %d: %w", policy.Version, policy.ID, err), errorx.KV("id", strconv.FormatInt(policy.ID, 10)))
|
||||
}
|
||||
canvas = v.Canvas
|
||||
inputParams = v.InputParamsStr
|
||||
outputParams = v.OutputParamsStr
|
||||
@@ -604,7 +622,117 @@ func (r *RepositoryImpl) GetEntity(ctx context.Context, policy *vo.GetPolicy) (_
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetVersion(ctx context.Context, id int64, version string) (_ *vo.VersionInfo, err error) {
|
||||
func (r *RepositoryImpl) CreateChatFlowRoleConfig(ctx context.Context, chatFlowRole *entity.ChatFlowRole) (int64, error) {
|
||||
id, err := r.GenID(ctx)
|
||||
if err != nil {
|
||||
return 0, vo.WrapError(errno.ErrIDGenError, err)
|
||||
}
|
||||
chatFlowRoleConfig := &model.ChatFlowRoleConfig{
|
||||
ID: id,
|
||||
WorkflowID: chatFlowRole.WorkflowID,
|
||||
Name: chatFlowRole.Name,
|
||||
Description: chatFlowRole.Description,
|
||||
Avatar: chatFlowRole.AvatarUri,
|
||||
AudioConfig: chatFlowRole.AudioConfig,
|
||||
BackgroundImageInfo: chatFlowRole.BackgroundImageInfo,
|
||||
OnboardingInfo: chatFlowRole.OnboardingInfo,
|
||||
SuggestReplyInfo: chatFlowRole.SuggestReplyInfo,
|
||||
UserInputConfig: chatFlowRole.UserInputConfig,
|
||||
CreatorID: chatFlowRole.CreatorID,
|
||||
Version: chatFlowRole.Version,
|
||||
}
|
||||
|
||||
if err := r.query.ChatFlowRoleConfig.WithContext(ctx).Create(chatFlowRoleConfig); err != nil {
|
||||
return 0, vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("create chat flow role: %w", err))
|
||||
}
|
||||
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) UpdateChatFlowRoleConfig(ctx context.Context, workflowID int64, chatFlowRole *vo.ChatFlowRoleUpdate) error {
|
||||
var expressions []field.AssignExpr
|
||||
if chatFlowRole.Name != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.Name.Value(*chatFlowRole.Name))
|
||||
}
|
||||
if chatFlowRole.Description != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.Description.Value(*chatFlowRole.Description))
|
||||
}
|
||||
if chatFlowRole.AvatarUri != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.Avatar.Value(*chatFlowRole.AvatarUri))
|
||||
}
|
||||
if chatFlowRole.AudioConfig != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.AudioConfig.Value(*chatFlowRole.AudioConfig))
|
||||
}
|
||||
if chatFlowRole.BackgroundImageInfo != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.BackgroundImageInfo.Value(*chatFlowRole.BackgroundImageInfo))
|
||||
}
|
||||
if chatFlowRole.OnboardingInfo != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.OnboardingInfo.Value(*chatFlowRole.OnboardingInfo))
|
||||
}
|
||||
if chatFlowRole.SuggestReplyInfo != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.SuggestReplyInfo.Value(*chatFlowRole.SuggestReplyInfo))
|
||||
}
|
||||
if chatFlowRole.UserInputConfig != nil {
|
||||
expressions = append(expressions, r.query.ChatFlowRoleConfig.UserInputConfig.Value(*chatFlowRole.UserInputConfig))
|
||||
}
|
||||
|
||||
if len(expressions) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID)).
|
||||
UpdateColumnSimple(expressions...)
|
||||
if err != nil {
|
||||
return vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("update chat flow role: %w", err))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetChatFlowRoleConfig(ctx context.Context, workflowID int64, version string) (_ *entity.ChatFlowRole, err error, isExist bool) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
err = vo.WrapIfNeeded(errno.ErrDatabaseError, err)
|
||||
}
|
||||
}()
|
||||
role := &model.ChatFlowRoleConfig{}
|
||||
if version != "" {
|
||||
role, err = r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID), r.query.ChatFlowRoleConfig.Version.Eq(version)).First()
|
||||
} else {
|
||||
role, err = r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID)).First()
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, err, false
|
||||
}
|
||||
return nil, fmt.Errorf("failed to get chat flow role for chatflowID %d: %w", workflowID, err), true
|
||||
}
|
||||
res := &entity.ChatFlowRole{
|
||||
ID: role.ID,
|
||||
WorkflowID: role.WorkflowID,
|
||||
Name: role.Name,
|
||||
Description: role.Description,
|
||||
AvatarUri: role.Avatar,
|
||||
AudioConfig: role.AudioConfig,
|
||||
BackgroundImageInfo: role.BackgroundImageInfo,
|
||||
OnboardingInfo: role.OnboardingInfo,
|
||||
SuggestReplyInfo: role.SuggestReplyInfo,
|
||||
UserInputConfig: role.UserInputConfig,
|
||||
CreatorID: role.CreatorID,
|
||||
CreatedAt: time.UnixMilli(role.CreatedAt),
|
||||
}
|
||||
if role.UpdatedAt > 0 {
|
||||
res.UpdatedAt = time.UnixMilli(role.UpdatedAt)
|
||||
}
|
||||
return res, err, true
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) DeleteChatFlowRoleConfig(ctx context.Context, id int64, workflowID int64) error {
|
||||
_, err := r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.ID.Eq(id), r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID)).Delete()
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetVersion(ctx context.Context, id int64, version string) (_ *vo.VersionInfo, existed bool, err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
err = vo.WrapIfNeeded(errno.ErrDatabaseError, err)
|
||||
@@ -616,9 +744,9 @@ func (r *RepositoryImpl) GetVersion(ctx context.Context, id int64, version strin
|
||||
First()
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, vo.WrapError(errno.ErrWorkflowNotFound, fmt.Errorf("workflow version %s not found for ID %d: %w", version, id, err), errorx.KV("id", strconv.FormatInt(id, 10)))
|
||||
return nil, false, nil
|
||||
}
|
||||
return nil, fmt.Errorf("failed to get workflow version %s for ID %d: %w", version, id, err)
|
||||
return nil, false, fmt.Errorf("failed to get workflow version %s for ID %d: %w", version, id, err)
|
||||
}
|
||||
|
||||
return &vo.VersionInfo{
|
||||
@@ -634,7 +762,29 @@ func (r *RepositoryImpl) GetVersion(ctx context.Context, id int64, version strin
|
||||
OutputParamsStr: wfVersion.OutputParams,
|
||||
},
|
||||
CommitID: wfVersion.CommitID,
|
||||
}, nil
|
||||
}, true, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetVersionListByConnectorAndWorkflowID(ctx context.Context, connectorID, workflowID int64, limit int) (_ []string, err error) {
|
||||
if limit <= 0 {
|
||||
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("limit must be greater than 0"))
|
||||
}
|
||||
|
||||
connectorWorkflowVersion := r.query.ConnectorWorkflowVersion
|
||||
vl, err := connectorWorkflowVersion.WithContext(ctx).
|
||||
Where(connectorWorkflowVersion.ConnectorID.Eq(connectorID),
|
||||
connectorWorkflowVersion.WorkflowID.Eq(workflowID)).
|
||||
Order(connectorWorkflowVersion.CreatedAt.Desc()).
|
||||
Limit(limit).
|
||||
Find()
|
||||
if err != nil {
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
var versionList []string
|
||||
for _, v := range vl {
|
||||
versionList = append(versionList, v.Version)
|
||||
}
|
||||
return versionList, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) IsApplicationConnectorWorkflowVersion(ctx context.Context, connectorID, workflowID int64, version string) (b bool, err error) {
|
||||
@@ -767,6 +917,10 @@ func (r *RepositoryImpl) MGetDrafts(ctx context.Context, policy *vo.MGetPolicy)
|
||||
conditions = append(conditions, r.query.WorkflowMeta.AppID.Eq(0))
|
||||
}
|
||||
|
||||
if q.Mode != nil {
|
||||
conditions = append(conditions, r.query.WorkflowMeta.Mode.Eq(int32(*q.Mode)))
|
||||
}
|
||||
|
||||
type combinedDraft struct {
|
||||
model.WorkflowDraft
|
||||
Name string `gorm:"column:name"`
|
||||
@@ -933,6 +1087,10 @@ func (r *RepositoryImpl) MGetLatestVersion(ctx context.Context, policy *vo.MGetP
|
||||
conditions = append(conditions, r.query.WorkflowMeta.AppID.Eq(0))
|
||||
}
|
||||
|
||||
if q.Mode != nil {
|
||||
conditions = append(conditions, r.query.WorkflowMeta.Mode.Eq(int32(*q.Mode)))
|
||||
}
|
||||
|
||||
type combinedVersion struct {
|
||||
model.WorkflowMeta
|
||||
Version string `gorm:"column:version"` // release version
|
||||
@@ -1157,6 +1315,10 @@ func (r *RepositoryImpl) MGetMetas(ctx context.Context, query *vo.MetaQuery) (
|
||||
conditions = append(conditions, r.query.WorkflowMeta.AppID.Eq(0))
|
||||
}
|
||||
|
||||
if query.Mode != nil {
|
||||
conditions = append(conditions, r.query.WorkflowMeta.Mode.Eq(int32(*query.Mode)))
|
||||
}
|
||||
|
||||
var result []*model.WorkflowMeta
|
||||
|
||||
workflowMetaDo := r.query.WorkflowMeta.WithContext(ctx).Debug().Where(conditions...)
|
||||
@@ -1520,6 +1682,7 @@ func (r *RepositoryImpl) CopyWorkflow(ctx context.Context, workflowID int64, pol
|
||||
IconURI: wfMeta.IconURI,
|
||||
Desc: wfMeta.Description,
|
||||
AppID: ternary.IFElse(wfMeta.AppID == 0, (*int64)(nil), ptr.Of(wfMeta.AppID)),
|
||||
Mode: workflowModel.WorkflowMode(wfMeta.Mode),
|
||||
},
|
||||
CanvasInfo: &vo.CanvasInfo{
|
||||
Canvas: wfDraft.Canvas,
|
||||
@@ -1594,6 +1757,10 @@ func (r *RepositoryImpl) GetKnowledgeRecallChatModel() cm.BaseChatModel {
|
||||
return r.builtinModel
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetObjectUrl(ctx context.Context, objectKey string, opts ...storage.GetOptFn) (string, error) {
|
||||
return r.tos.GetObjectUrl(ctx, objectKey, opts...)
|
||||
}
|
||||
|
||||
func filterDisabledAPIParameters(parametersCfg []*workflow3.APIParameter, m map[string]any) map[string]any {
|
||||
result := make(map[string]any, len(m))
|
||||
responseParameterMap := slices.ToMap(parametersCfg, func(p *workflow3.APIParameter) (string, *workflow3.APIParameter) {
|
||||
|
||||
104
backend/domain/workflow/internal/repo/suggest.go
Normal file
104
backend/domain/workflow/internal/repo/suggest.go
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2025 coze-dev Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"regexp"
|
||||
|
||||
"github.com/cloudwego/eino/components/model"
|
||||
"github.com/cloudwego/eino/components/prompt"
|
||||
"github.com/cloudwego/eino/compose"
|
||||
einoCompose "github.com/cloudwego/eino/compose"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
||||
)
|
||||
|
||||
const SUGGESTION_PROMPT = `
|
||||
# Role
|
||||
You are an AI assistant that quickly generates 3 relevant follow-up questions.
|
||||
|
||||
# Task
|
||||
Analyze the user's question and the assistant's answer to suggest 3 unique, concise follow-up questions.
|
||||
|
||||
**IMPORTANT**: The assistant's answer can be very long. To be fast, focus only on the main ideas and topics in the answer. Do not analyze the full text in detail.
|
||||
|
||||
### Persona
|
||||
{{ suggest_persona }}
|
||||
|
||||
## Output Format
|
||||
- Return **only** a single JSON string array.
|
||||
- Example: ["What is the history?", "How does it work?", "What are the benefits?"]
|
||||
- The questions must be in the same language as the user's input.
|
||||
`
|
||||
|
||||
type suggesterV3 struct {
|
||||
r einoCompose.Runnable[*vo.SuggestInfo, []string]
|
||||
}
|
||||
type state struct {
|
||||
userMessage *schema.Message
|
||||
answer *schema.Message
|
||||
}
|
||||
|
||||
var suggestRegexp = regexp.MustCompile(`\[(.*?)\]`)
|
||||
|
||||
func NewSuggester(chatModel model.BaseChatModel) (workflow.Suggester, error) {
|
||||
chain := einoCompose.NewChain[*vo.SuggestInfo, []string](einoCompose.WithGenLocalState(func(ctx context.Context) (s *state) {
|
||||
return &state{}
|
||||
}))
|
||||
r, err := chain.AppendLambda(einoCompose.InvokableLambda(func(ctx context.Context, input *vo.SuggestInfo) (output map[string]any, err error) {
|
||||
_ = compose.ProcessState(ctx, func(ctx context.Context, s *state) error {
|
||||
s.userMessage = input.UserInput
|
||||
s.answer = input.AnswerInput
|
||||
return nil
|
||||
})
|
||||
output = map[string]any{}
|
||||
if input.PersonaInput != nil {
|
||||
output["persona_input"] = *input.PersonaInput
|
||||
}
|
||||
return
|
||||
})).AppendChatTemplate(prompt.FromMessages(schema.Jinja2, schema.SystemMessage(SUGGESTION_PROMPT))).AppendChatModel(chatModel,
|
||||
compose.WithStatePreHandler(func(ctx context.Context, in []*schema.Message, state *state) ([]*schema.Message, error) {
|
||||
return append(in, []*schema.Message{state.userMessage, state.answer}...), nil
|
||||
})).AppendLambda(einoCompose.InvokableLambda(func(ctx context.Context, input *schema.Message) (output []string, err error) {
|
||||
content := suggestRegexp.FindString(input.Content)
|
||||
if len(content) == 0 {
|
||||
return
|
||||
}
|
||||
suggests := make([]string, 0)
|
||||
err = sonic.UnmarshalString(content, &suggests)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "Failed unmarshalling suggestions: %s", input.Content)
|
||||
|
||||
}
|
||||
return suggests, nil
|
||||
})).Compile(context.Background())
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &suggesterV3{r: r}, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *suggesterV3) Suggest(ctx context.Context, info *vo.SuggestInfo) ([]string, error) {
|
||||
return s.r.Invoke(ctx, info)
|
||||
}
|
||||
Reference in New Issue
Block a user