/
debug-invoke.go
39 lines (32 loc) · 1.08 KB
/
debug-invoke.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package repo
import (
"github.com/aaronchen2k/deeptest/internal/pkg/consts"
"github.com/aaronchen2k/deeptest/internal/server/modules/model"
"gorm.io/gorm"
)
type DebugInvokeRepo struct {
*BaseRepo `inject:""`
DB *gorm.DB `inject:""`
}
func (r *DebugInvokeRepo) Get(tenantId consts.TenantId, id uint) (po model.DebugInvoke, err error) {
err = r.GetDB(tenantId).
Where("id=?", id).
Where("NOT deleted").
First(&po).Error
return
}
func (r *DebugInvokeRepo) Save(tenantId consts.TenantId, invocation *model.DebugInvoke) (err error) {
err = r.GetDB(tenantId).Save(invocation).Error
return
}
func (r *DebugInvokeRepo) ChangeProcessorOwner(tenantId consts.TenantId, oldProcessId, newProcessId, debugInterfaceId, endpointInterfaceId uint) (err error) {
values := map[string]interface{}{
"scenario_processor_id": newProcessId,
"debug_interface_id": debugInterfaceId,
"endpoint_interface_id": endpointInterfaceId,
}
err = r.GetDB(tenantId).Model(&model.DebugInvoke{}).
Where("scenario_processor_id = ? AND NOT deleted", oldProcessId).
Updates(values).Error
return
}