mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-28 17:50:56 +01:00
refactor: removed unnecessary code
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
const (
|
||||
ControllerIdNode = iota << 1
|
||||
ControllerIdProject
|
||||
ControllerIdSpider
|
||||
ControllerIdTask
|
||||
ControllerIdJob
|
||||
ControllerIdSchedule
|
||||
ControllerIdUser
|
||||
ControllerIdSetting
|
||||
ControllerIdToken
|
||||
ControllerIdVariable
|
||||
ControllerIdTag
|
||||
ControllerIdLogin
|
||||
ControllerIdColor
|
||||
ControllerIdDataSource
|
||||
ControllerIdDataCollection
|
||||
ControllerIdResult
|
||||
ControllerIdStats
|
||||
ControllerIdFiler
|
||||
ControllerIdGit
|
||||
ControllerIdRole
|
||||
ControllerIdPermission
|
||||
ControllerIdExport
|
||||
ControllerIdNotification
|
||||
ControllerIdFilter
|
||||
ControllerIdEnvironment
|
||||
ControllerIdSync
|
||||
|
||||
ControllerIdVersion
|
||||
ControllerIdI18n
|
||||
ControllerIdSystemInfo
|
||||
ControllerIdDemo
|
||||
)
|
||||
|
||||
type ControllerId int
|
||||
|
||||
type BasicController interface {
|
||||
Get(c *gin.Context)
|
||||
Post(c *gin.Context)
|
||||
Put(c *gin.Context)
|
||||
Delete(c *gin.Context)
|
||||
}
|
||||
|
||||
type ListController interface {
|
||||
BasicController
|
||||
GetList(c *gin.Context)
|
||||
PutList(c *gin.Context)
|
||||
PostList(c *gin.Context)
|
||||
DeleteList(c *gin.Context)
|
||||
}
|
||||
|
||||
type Action struct {
|
||||
Method string
|
||||
Path string
|
||||
HandlerFunc gin.HandlerFunc
|
||||
}
|
||||
|
||||
type ActionController interface {
|
||||
Actions() (actions []Action)
|
||||
}
|
||||
|
||||
type ListActionController interface {
|
||||
ListController
|
||||
ActionController
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/entity"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type BinderInterface interface {
|
||||
Bind(c *gin.Context) (res interfaces.Model, err error)
|
||||
BindList(c *gin.Context) (res []interfaces.Model, err error)
|
||||
BindBatchRequestPayload(c *gin.Context) (payload entity.BatchRequestPayload, err error)
|
||||
BindBatchRequestPayloadWithStringData(c *gin.Context) (payload entity.BatchRequestPayloadWithStringData, res interfaces.Model, err error)
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/crawlab-team/crawlab/core/entity"
|
||||
"github.com/crawlab-team/crawlab/core/errors"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func NewJsonBinder(id ControllerId) (b *JsonBinder) {
|
||||
return &JsonBinder{
|
||||
id: id,
|
||||
}
|
||||
}
|
||||
|
||||
type JsonBinder struct {
|
||||
id ControllerId
|
||||
}
|
||||
|
||||
func (b *JsonBinder) Bind(c *gin.Context) (res interfaces.Model, err error) {
|
||||
// declare
|
||||
m := models.NewModelMap()
|
||||
|
||||
switch b.id {
|
||||
case ControllerIdNode:
|
||||
err = c.ShouldBindJSON(&m.Node)
|
||||
return &m.Node, err
|
||||
case ControllerIdProject:
|
||||
err = c.ShouldBindJSON(&m.Project)
|
||||
return &m.Project, err
|
||||
case ControllerIdSpider:
|
||||
err = c.ShouldBindJSON(&m.Spider)
|
||||
return &m.Spider, err
|
||||
case ControllerIdTask:
|
||||
err = c.ShouldBindJSON(&m.Task)
|
||||
return &m.Task, err
|
||||
case ControllerIdJob:
|
||||
err = c.ShouldBindJSON(&m.Job)
|
||||
return &m.Job, err
|
||||
case ControllerIdSchedule:
|
||||
err = c.ShouldBindJSON(&m.Schedule)
|
||||
return &m.Schedule, err
|
||||
case ControllerIdUser:
|
||||
err = c.ShouldBindJSON(&m.User)
|
||||
return &m.User, nil
|
||||
case ControllerIdSetting:
|
||||
err = c.ShouldBindJSON(&m.Setting)
|
||||
return &m.Setting, nil
|
||||
case ControllerIdToken:
|
||||
err = c.ShouldBindJSON(&m.Token)
|
||||
return &m.Token, nil
|
||||
case ControllerIdVariable:
|
||||
err = c.ShouldBindJSON(&m.Variable)
|
||||
return &m.Variable, nil
|
||||
case ControllerIdTag:
|
||||
err = c.ShouldBindJSON(&m.Tag)
|
||||
return &m.Tag, nil
|
||||
case ControllerIdDataSource:
|
||||
err = c.ShouldBindJSON(&m.DataSource)
|
||||
return &m.DataSource, nil
|
||||
case ControllerIdDataCollection:
|
||||
err = c.ShouldBindJSON(&m.DataCollection)
|
||||
return &m.DataCollection, nil
|
||||
case ControllerIdGit:
|
||||
err = c.ShouldBindJSON(&m.Git)
|
||||
return &m.Git, nil
|
||||
case ControllerIdRole:
|
||||
err = c.ShouldBindJSON(&m.Role)
|
||||
return &m.Role, nil
|
||||
case ControllerIdPermission:
|
||||
err = c.ShouldBindJSON(&m.Permission)
|
||||
return &m.Permission, nil
|
||||
case ControllerIdEnvironment:
|
||||
err = c.ShouldBindJSON(&m.Environment)
|
||||
return &m.Environment, nil
|
||||
default:
|
||||
return nil, errors.ErrorControllerInvalidControllerId
|
||||
}
|
||||
}
|
||||
|
||||
func (b *JsonBinder) BindList(c *gin.Context) (res interface{}, err error) {
|
||||
// declare
|
||||
m := models.NewModelListMap()
|
||||
|
||||
// bind
|
||||
switch b.id {
|
||||
case ControllerIdNode:
|
||||
err = c.ShouldBindJSON(&m.Nodes)
|
||||
return m.Nodes, err
|
||||
case ControllerIdProject:
|
||||
err = c.ShouldBindJSON(&m.Projects)
|
||||
return m.Projects, err
|
||||
case ControllerIdSpider:
|
||||
err = c.ShouldBindJSON(&m.Spiders)
|
||||
return m.Spiders, err
|
||||
case ControllerIdTask:
|
||||
err = c.ShouldBindJSON(&m.Tasks)
|
||||
return m.Tasks, err
|
||||
case ControllerIdJob:
|
||||
err = c.ShouldBindJSON(&m.Jobs)
|
||||
return m.Jobs, err
|
||||
case ControllerIdSchedule:
|
||||
err = c.ShouldBindJSON(&m.Schedules)
|
||||
return m.Schedules, err
|
||||
case ControllerIdUser:
|
||||
err = c.ShouldBindJSON(&m.Users)
|
||||
return m.Users, nil
|
||||
case ControllerIdSetting:
|
||||
err = c.ShouldBindJSON(&m.Settings)
|
||||
return m.Settings, nil
|
||||
case ControllerIdToken:
|
||||
err = c.ShouldBindJSON(&m.Tokens)
|
||||
return m.Tokens, nil
|
||||
case ControllerIdVariable:
|
||||
err = c.ShouldBindJSON(&m.Variables)
|
||||
return m.Variables, nil
|
||||
case ControllerIdTag:
|
||||
err = c.ShouldBindJSON(&m.Tags)
|
||||
return m.Tags, nil
|
||||
case ControllerIdDataSource:
|
||||
err = c.ShouldBindJSON(&m.DataSources)
|
||||
return m.DataSources, nil
|
||||
case ControllerIdDataCollection:
|
||||
err = c.ShouldBindJSON(&m.DataCollections)
|
||||
return m.DataCollections, nil
|
||||
case ControllerIdGit:
|
||||
err = c.ShouldBindJSON(&m.Gits)
|
||||
return m.Gits, nil
|
||||
case ControllerIdRole:
|
||||
err = c.ShouldBindJSON(&m.Roles)
|
||||
return m.Roles, nil
|
||||
case ControllerIdEnvironment:
|
||||
err = c.ShouldBindJSON(&m.Environments)
|
||||
return m.Environments, nil
|
||||
default:
|
||||
return nil, errors.ErrorControllerInvalidControllerId
|
||||
}
|
||||
}
|
||||
|
||||
func (b *JsonBinder) BindBatchRequestPayload(c *gin.Context) (payload entity.BatchRequestPayload, err error) {
|
||||
if err := c.ShouldBindJSON(&payload); err != nil {
|
||||
return payload, err
|
||||
}
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
func (b *JsonBinder) BindBatchRequestPayloadWithStringData(c *gin.Context) (payload entity.BatchRequestPayloadWithStringData, res interfaces.Model, err error) {
|
||||
// declare
|
||||
m := models.NewModelMap()
|
||||
|
||||
// bind
|
||||
if err := c.ShouldBindJSON(&payload); err != nil {
|
||||
return payload, nil, err
|
||||
}
|
||||
|
||||
// validate
|
||||
if len(payload.Ids) == 0 ||
|
||||
len(payload.Fields) == 0 {
|
||||
return payload, nil, errors.ErrorControllerRequestPayloadInvalid
|
||||
}
|
||||
|
||||
// unmarshall
|
||||
switch b.id {
|
||||
case ControllerIdNode:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Node)
|
||||
return payload, &m.Node, err
|
||||
case ControllerIdProject:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Project)
|
||||
return payload, &m.Project, err
|
||||
case ControllerIdSpider:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Spider)
|
||||
return payload, &m.Spider, err
|
||||
case ControllerIdTask:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Task)
|
||||
return payload, &m.Task, err
|
||||
case ControllerIdJob:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Job)
|
||||
return payload, &m.Job, err
|
||||
case ControllerIdSchedule:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Schedule)
|
||||
return payload, &m.Schedule, err
|
||||
case ControllerIdUser:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.User)
|
||||
return payload, &m.User, err
|
||||
case ControllerIdSetting:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Setting)
|
||||
return payload, &m.Setting, err
|
||||
case ControllerIdToken:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Token)
|
||||
return payload, &m.Token, err
|
||||
case ControllerIdVariable:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Variable)
|
||||
return payload, &m.Variable, err
|
||||
case ControllerIdDataSource:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.DataSource)
|
||||
return payload, &m.DataSource, err
|
||||
case ControllerIdDataCollection:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.DataCollection)
|
||||
return payload, &m.DataCollection, err
|
||||
case ControllerIdEnvironment:
|
||||
err = json.Unmarshal([]byte(payload.Data), &m.Environment)
|
||||
return payload, &m.Environment, err
|
||||
default:
|
||||
return payload, nil, errors.ErrorControllerInvalidControllerId
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package controllers
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/ds"
|
||||
"github.com/crawlab-team/crawlab/core/errors"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package controllers
|
||||
|
||||
func NewActionControllerDelegate(id ControllerId, actions []Action) (d *ActionControllerDelegate) {
|
||||
return &ActionControllerDelegate{
|
||||
id: id,
|
||||
actions: actions,
|
||||
}
|
||||
}
|
||||
|
||||
type ActionControllerDelegate struct {
|
||||
id ControllerId
|
||||
actions []Action
|
||||
}
|
||||
|
||||
func (ctr *ActionControllerDelegate) Actions() (actions []Action) {
|
||||
return ctr.actions
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/errors"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
delegate2 "github.com/crawlab-team/crawlab/core/models/delegate"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
mongo2 "go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
func NewBasicControllerDelegate(id ControllerId, svc interfaces.ModelBaseService) (d *BasicControllerDelegate) {
|
||||
return &BasicControllerDelegate{
|
||||
id: id,
|
||||
svc: svc,
|
||||
}
|
||||
}
|
||||
|
||||
type BasicControllerDelegate struct {
|
||||
id ControllerId
|
||||
svc interfaces.ModelBaseService
|
||||
}
|
||||
|
||||
func (d *BasicControllerDelegate) Get(c *gin.Context) {
|
||||
id, err := primitive.ObjectIDFromHex(c.Param("id"))
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
doc, err := d.svc.GetById(id)
|
||||
if err == mongo2.ErrNoDocuments {
|
||||
HandleErrorNotFound(c, err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
HandleSuccessWithData(c, doc)
|
||||
}
|
||||
|
||||
func (d *BasicControllerDelegate) Post(c *gin.Context) {
|
||||
doc, err := NewJsonBinder(d.id).Bind(c)
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
if err := delegate2.NewModelDelegate(doc, GetUserFromContext(c)).Add(); err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
HandleSuccessWithData(c, doc)
|
||||
}
|
||||
|
||||
func (d *BasicControllerDelegate) Put(c *gin.Context) {
|
||||
id, err := primitive.ObjectIDFromHex(c.Param("id"))
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
doc, err := NewJsonBinder(d.id).Bind(c)
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
if doc.GetId() != id {
|
||||
HandleErrorBadRequest(c, errors.ErrorHttpBadRequest)
|
||||
return
|
||||
}
|
||||
_, err = d.svc.GetById(id)
|
||||
if err != nil {
|
||||
HandleErrorNotFound(c, err)
|
||||
return
|
||||
}
|
||||
if err := delegate2.NewModelDelegate(doc, GetUserFromContext(c)).Save(); err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
HandleSuccessWithData(c, doc)
|
||||
}
|
||||
|
||||
func (d *BasicControllerDelegate) Delete(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
oid, err := primitive.ObjectIDFromHex(id)
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
doc, err := d.svc.GetById(oid)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
if err := delegate2.NewModelDelegate(doc, GetUserFromContext(c)).Delete(); err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
HandleSuccess(c)
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/apex/log"
|
||||
"github.com/crawlab-team/crawlab/core/errors"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/models/delegate"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
"github.com/crawlab-team/crawlab/db/mongo"
|
||||
"github.com/crawlab-team/crawlab/trace"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
mongo2 "go.mongodb.org/mongo-driver/mongo"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewListControllerDelegate(id ControllerId, svc interfaces.ModelBaseService) (d *ListControllerDelegate) {
|
||||
if svc == nil {
|
||||
panic(errors.ErrorControllerNoModelService)
|
||||
}
|
||||
|
||||
return &ListControllerDelegate{
|
||||
id: id,
|
||||
svc: svc,
|
||||
bc: NewBasicControllerDelegate(id, svc),
|
||||
}
|
||||
}
|
||||
|
||||
type ListControllerDelegate struct {
|
||||
id ControllerId
|
||||
svc interfaces.ModelBaseService
|
||||
bc BasicController
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) Get(c *gin.Context) {
|
||||
d.bc.Get(c)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) Post(c *gin.Context) {
|
||||
d.bc.Post(c)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) Put(c *gin.Context) {
|
||||
d.bc.Put(c)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) Delete(c *gin.Context) {
|
||||
d.bc.Delete(c)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) GetList(c *gin.Context) {
|
||||
// get all if query field "all" is set true
|
||||
all := MustGetFilterAll(c)
|
||||
if all {
|
||||
d.getAll(c)
|
||||
return
|
||||
}
|
||||
|
||||
// get list and total
|
||||
l, total, err := d.getList(c)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// response
|
||||
HandleSuccessWithListData(c, l, total)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) PostList(c *gin.Context) {
|
||||
// bind
|
||||
docs, err := NewJsonBinder(d.id).BindList(c)
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// success ids
|
||||
var ids []primitive.ObjectID
|
||||
|
||||
// reflect
|
||||
switch reflect.TypeOf(docs).Kind() {
|
||||
case reflect.Slice, reflect.Array:
|
||||
s := reflect.ValueOf(docs)
|
||||
for i := 0; i < s.Len(); i++ {
|
||||
item := s.Index(i)
|
||||
if !item.CanAddr() {
|
||||
HandleErrorInternalServerError(c, errors.ErrorModelInvalidType)
|
||||
return
|
||||
}
|
||||
ptr := item.Addr()
|
||||
doc, ok := ptr.Interface().(interfaces.Model)
|
||||
if !ok {
|
||||
HandleErrorInternalServerError(c, errors.ErrorModelInvalidType)
|
||||
return
|
||||
}
|
||||
if err := delegate.NewModelDelegate(doc, GetUserFromContext(c)).Add(); err != nil {
|
||||
_ = trace.TraceError(err)
|
||||
continue
|
||||
}
|
||||
ids = append(ids, doc.GetId())
|
||||
}
|
||||
}
|
||||
|
||||
// check
|
||||
items, err := utils.GetArrayItems(docs)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
if len(ids) < len(items) {
|
||||
HandleErrorInternalServerError(c, errors.ErrorControllerAddError)
|
||||
return
|
||||
}
|
||||
|
||||
// success
|
||||
HandleSuccessWithData(c, docs)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) PutList(c *gin.Context) {
|
||||
payload, doc, err := NewJsonBinder(d.id).BindBatchRequestPayloadWithStringData(c)
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// query
|
||||
query := bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": payload.Ids,
|
||||
},
|
||||
}
|
||||
|
||||
// update
|
||||
if err := d.svc.UpdateDoc(query, doc, payload.Fields); err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
HandleSuccess(c)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) DeleteList(c *gin.Context) {
|
||||
payload, err := NewJsonBinder(d.id).BindBatchRequestPayload(c)
|
||||
if err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
if err := d.svc.DeleteList(bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": payload.Ids,
|
||||
},
|
||||
}); err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
HandleSuccess(c)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) getAll(c *gin.Context) {
|
||||
// get list
|
||||
tic := time.Now()
|
||||
log.Debugf("getAll -> d.svc.GetMany:start")
|
||||
list, err := d.svc.GetList(nil, &mongo.FindOptions{
|
||||
Sort: bson.D{{"_id", -1}},
|
||||
})
|
||||
if err != nil {
|
||||
if err == mongo2.ErrNoDocuments {
|
||||
HandleErrorNotFound(c, err)
|
||||
} else {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
log.Debugf("getAll -> d.svc.GetMany:end. elapsed: %d ms", time.Now().Sub(tic).Milliseconds())
|
||||
tic = time.Now()
|
||||
|
||||
// total count
|
||||
tic = time.Now()
|
||||
log.Debugf("getAll -> d.svc.Count:start")
|
||||
total, err := d.svc.Count(nil)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
log.Debugf("getAll -> d.svc.Count:end. elapsed: %d ms", time.Now().Sub(tic).Milliseconds())
|
||||
|
||||
// response
|
||||
HandleSuccessWithListData(c, list, total)
|
||||
}
|
||||
|
||||
func (d *ListControllerDelegate) getList(c *gin.Context) (l interfaces.List, total int, err error) {
|
||||
// params
|
||||
pagination := MustGetPagination(c)
|
||||
query := MustGetFilterQuery(c)
|
||||
sort := MustGetSortOption(c)
|
||||
|
||||
// get list
|
||||
l, err = d.svc.GetList(query, &mongo.FindOptions{
|
||||
Sort: sort,
|
||||
Skip: pagination.Size * (pagination.Page - 1),
|
||||
Limit: pagination.Size,
|
||||
})
|
||||
if err != nil {
|
||||
if err.Error() == mongo2.ErrNoDocuments.Error() {
|
||||
HandleSuccessWithListData(c, nil, 0)
|
||||
} else {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// total count
|
||||
total, err = d.svc.Count(query)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
return l, total, nil
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
)
|
||||
|
||||
func NewListPostActionControllerDelegate(id ControllerId, svc interfaces.ModelBaseService, actions []Action) (d *ListActionControllerDelegate) {
|
||||
return &ListActionControllerDelegate{
|
||||
NewListControllerDelegate(id, svc),
|
||||
NewActionControllerDelegate(id, actions),
|
||||
}
|
||||
}
|
||||
|
||||
type ListActionControllerDelegate struct {
|
||||
ListController
|
||||
ActionController
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/container"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
)
|
||||
|
||||
var EnvironmentController *environmentController
|
||||
|
||||
var EnvironmentActions []Action
|
||||
|
||||
type environmentController struct {
|
||||
ListActionControllerDelegate
|
||||
d ListActionControllerDelegate
|
||||
ctx *environmentContext
|
||||
}
|
||||
|
||||
type environmentContext struct {
|
||||
modelSvc service.ModelService
|
||||
userSvc interfaces.UserService
|
||||
}
|
||||
|
||||
func newEnvironmentContext() *environmentContext {
|
||||
// context
|
||||
ctx := &environmentContext{}
|
||||
|
||||
// dependency injection
|
||||
if err := container.GetContainer().Invoke(func(
|
||||
modelSvc service.ModelService,
|
||||
userSvc interfaces.UserService,
|
||||
) {
|
||||
ctx.modelSvc = modelSvc
|
||||
ctx.userSvc = userSvc
|
||||
}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
func newEnvironmentController() *environmentController {
|
||||
modelSvc, err := service.GetService()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
ctr := NewListPostActionControllerDelegate(ControllerIdEnvironment, modelSvc.GetBaseService(interfaces.ModelIdEnvironment), EnvironmentActions)
|
||||
d := NewListPostActionControllerDelegate(ControllerIdEnvironment, modelSvc.GetBaseService(interfaces.ModelIdEnvironment), EnvironmentActions)
|
||||
ctx := newEnvironmentContext()
|
||||
|
||||
return &environmentController{
|
||||
ListActionControllerDelegate: *ctr,
|
||||
d: *d,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/errors"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
models2 "github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/crawlab-team/crawlab/db/mongo"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -15,7 +15,7 @@ func GetProjectList(c *gin.Context) {
|
||||
// get all list
|
||||
all := MustGetFilterAll(c)
|
||||
if all {
|
||||
NewControllerV2[models.ProjectV2]().getAll(c)
|
||||
NewControllerV2[models2.ProjectV2]().getAll(c)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func GetProjectList(c *gin.Context) {
|
||||
sort := MustGetSortOption(c)
|
||||
|
||||
// get list
|
||||
projects, err := service.NewModelServiceV2[models.ProjectV2]().GetMany(query, &mongo.FindOptions{
|
||||
projects, err := service.NewModelServiceV2[models2.ProjectV2]().GetMany(query, &mongo.FindOptions{
|
||||
Sort: sort,
|
||||
Skip: pagination.Size * (pagination.Page - 1),
|
||||
Limit: pagination.Size,
|
||||
@@ -37,12 +37,12 @@ func GetProjectList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if len(projects) == 0 {
|
||||
HandleSuccessWithListData(c, []models.ProjectV2{}, 0)
|
||||
HandleSuccessWithListData(c, []models2.ProjectV2{}, 0)
|
||||
return
|
||||
}
|
||||
|
||||
// total count
|
||||
total, err := service.NewModelServiceV2[models.ProjectV2]().Count(query)
|
||||
total, err := service.NewModelServiceV2[models2.ProjectV2]().Count(query)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -61,7 +61,7 @@ func GetProjectList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// spiders
|
||||
spiders, err := service.NewModelServiceV2[models.SpiderV2]().GetMany(bson.M{
|
||||
spiders, err := service.NewModelServiceV2[models2.SpiderV2]().GetMany(bson.M{
|
||||
"project_id": bson.M{
|
||||
"$in": ids,
|
||||
},
|
||||
@@ -80,7 +80,7 @@ func GetProjectList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// assign
|
||||
var data []models.ProjectV2
|
||||
var data []models2.ProjectV2
|
||||
for _, p := range projects {
|
||||
p.Spiders = cache[p.Id]
|
||||
data = append(data, p)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
models2 "github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/crawlab-team/crawlab/core/result"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
@@ -32,17 +32,17 @@ func GetResultList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// data collection
|
||||
dc, err := service.NewModelServiceV2[models.DataCollectionV2]().GetById(dcId)
|
||||
dc, err := service.NewModelServiceV2[models2.DataCollectionV2]().GetById(dcId)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// data source
|
||||
ds, err := service.NewModelServiceV2[models.DataSourceV2]().GetById(dsId)
|
||||
ds, err := service.NewModelServiceV2[models2.DataSourceV2]().GetById(dsId)
|
||||
if err != nil {
|
||||
if err.Error() == mongo2.ErrNoDocuments.Error() {
|
||||
ds = &models.DataSourceV2{}
|
||||
ds = &models2.DataSourceV2{}
|
||||
} else {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -54,7 +54,7 @@ func GetResultList(c *gin.Context) {
|
||||
"col_id": dc.Id,
|
||||
"data_source_id": ds.Id,
|
||||
}
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetOne(sq, nil)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetOne(sq, nil)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/middlewares"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
models2 "github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
@@ -55,8 +55,8 @@ func InitRoutes(app *gin.Engine) (err error) {
|
||||
// routes groups
|
||||
groups := NewRouterGroups(app)
|
||||
|
||||
RegisterController(groups.AuthGroup, "/data/collections", NewControllerV2[models.DataCollectionV2]())
|
||||
RegisterController(groups.AuthGroup, "/data-sources", NewControllerV2[models.DataSourceV2]([]Action{
|
||||
RegisterController(groups.AuthGroup, "/data/collections", NewControllerV2[models2.DataCollectionV2]())
|
||||
RegisterController(groups.AuthGroup, "/data-sources", NewControllerV2[models2.DataSourceV2]([]Action{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "",
|
||||
@@ -73,16 +73,16 @@ func InitRoutes(app *gin.Engine) (err error) {
|
||||
HandlerFunc: PostDataSourceChangePassword,
|
||||
},
|
||||
}...))
|
||||
RegisterController(groups.AuthGroup, "/environments", NewControllerV2[models.EnvironmentV2]())
|
||||
RegisterController(groups.AuthGroup, "/nodes", NewControllerV2[models.NodeV2]())
|
||||
RegisterController(groups.AuthGroup, "/projects", NewControllerV2[models.ProjectV2]([]Action{
|
||||
RegisterController(groups.AuthGroup, "/environments", NewControllerV2[models2.EnvironmentV2]())
|
||||
RegisterController(groups.AuthGroup, "/nodes", NewControllerV2[models2.NodeV2]())
|
||||
RegisterController(groups.AuthGroup, "/projects", NewControllerV2[models2.ProjectV2]([]Action{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "",
|
||||
HandlerFunc: GetProjectList,
|
||||
},
|
||||
}...))
|
||||
RegisterController(groups.AuthGroup, "/schedules", NewControllerV2[models.ScheduleV2]([]Action{
|
||||
RegisterController(groups.AuthGroup, "/schedules", NewControllerV2[models2.ScheduleV2]([]Action{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "",
|
||||
@@ -104,7 +104,7 @@ func InitRoutes(app *gin.Engine) (err error) {
|
||||
HandlerFunc: PostScheduleDisable,
|
||||
},
|
||||
}...))
|
||||
RegisterController(groups.AuthGroup, "/spiders", NewControllerV2[models.SpiderV2]([]Action{
|
||||
RegisterController(groups.AuthGroup, "/spiders", NewControllerV2[models2.SpiderV2]([]Action{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/:id",
|
||||
@@ -202,7 +202,7 @@ func InitRoutes(app *gin.Engine) (err error) {
|
||||
HandlerFunc: PostSpiderDataSource,
|
||||
},
|
||||
}...))
|
||||
RegisterController(groups.AuthGroup, "/tasks", NewControllerV2[models.TaskV2]([]Action{
|
||||
RegisterController(groups.AuthGroup, "/tasks", NewControllerV2[models2.TaskV2]([]Action{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/:id",
|
||||
@@ -249,14 +249,14 @@ func InitRoutes(app *gin.Engine) (err error) {
|
||||
HandlerFunc: GetTaskData,
|
||||
},
|
||||
}...))
|
||||
RegisterController(groups.AuthGroup, "/tokens", NewControllerV2[models.TokenV2]([]Action{
|
||||
RegisterController(groups.AuthGroup, "/tokens", NewControllerV2[models2.TokenV2]([]Action{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "",
|
||||
HandlerFunc: PostToken,
|
||||
},
|
||||
}...))
|
||||
RegisterController(groups.AuthGroup, "/users", NewControllerV2[models.UserV2]([]Action{
|
||||
RegisterController(groups.AuthGroup, "/users", NewControllerV2[models2.UserV2]([]Action{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "",
|
||||
|
||||
@@ -2,7 +2,7 @@ package controllers_test
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/controllers"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
@@ -28,7 +28,7 @@ func TestRouterGroups(t *testing.T) {
|
||||
func TestRegisterController_Routes(t *testing.T) {
|
||||
router := gin.Default()
|
||||
groups := controllers.NewRouterGroups(router)
|
||||
ctr := controllers.NewControllerV2[models.TestModel]()
|
||||
ctr := controllers.NewControllerV2[models.TestModelV2]()
|
||||
basePath := "/testmodels"
|
||||
|
||||
controllers.RegisterController(groups.AuthGroup, basePath, ctr)
|
||||
|
||||
@@ -2,7 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/errors"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/crawlab-team/crawlab/core/schedule"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
models2 "github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
@@ -12,7 +13,7 @@ func GetSetting(c *gin.Context) {
|
||||
key := c.Param("id")
|
||||
|
||||
// setting
|
||||
s, err := service.NewModelServiceV2[models.SettingV2]().GetOne(bson.M{"key": key}, nil)
|
||||
s, err := service.NewModelServiceV2[models2.SettingV2]().GetOne(bson.M{"key": key}, nil)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -32,7 +33,7 @@ func PutSetting(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
modelSvc := service.NewModelServiceV2[models.SettingV2]()
|
||||
modelSvc := service.NewModelServiceV2[models2.SettingV2]()
|
||||
|
||||
// setting
|
||||
_s, err := modelSvc.GetOne(bson.M{"key": key}, nil)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/crawlab-team/crawlab/core/constants"
|
||||
"github.com/crawlab-team/crawlab/core/fs"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
models2 "github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/crawlab-team/crawlab/core/spider/admin"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
@@ -29,7 +29,7 @@ func GetSpiderById(c *gin.Context) {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
}
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(id)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(id)
|
||||
if errors.Is(err, mongo2.ErrNoDocuments) {
|
||||
HandleErrorNotFound(c, err)
|
||||
return
|
||||
@@ -40,7 +40,7 @@ func GetSpiderById(c *gin.Context) {
|
||||
}
|
||||
|
||||
// stat
|
||||
s.Stat, err = service.NewModelServiceV2[models.SpiderStatV2]().GetById(s.Id)
|
||||
s.Stat, err = service.NewModelServiceV2[models2.SpiderStatV2]().GetById(s.Id)
|
||||
if err != nil {
|
||||
if !errors.Is(err, mongo2.ErrNoDocuments) {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
@@ -50,7 +50,7 @@ func GetSpiderById(c *gin.Context) {
|
||||
|
||||
// data collection
|
||||
if !s.ColId.IsZero() {
|
||||
col, err := service.NewModelServiceV2[models.DataCollectionV2]().GetById(s.ColId)
|
||||
col, err := service.NewModelServiceV2[models2.DataCollectionV2]().GetById(s.ColId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, mongo2.ErrNoDocuments) {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
@@ -63,7 +63,7 @@ func GetSpiderById(c *gin.Context) {
|
||||
|
||||
// git
|
||||
if utils.IsPro() && !s.GitId.IsZero() {
|
||||
s.Git, err = service.NewModelServiceV2[models.GitV2]().GetById(s.GitId)
|
||||
s.Git, err = service.NewModelServiceV2[models2.GitV2]().GetById(s.GitId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, mongo2.ErrNoDocuments) {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
@@ -79,14 +79,14 @@ func GetSpiderList(c *gin.Context) {
|
||||
// get all list
|
||||
all := MustGetFilterAll(c)
|
||||
if all {
|
||||
NewControllerV2[models.SpiderV2]().getAll(c)
|
||||
NewControllerV2[models2.SpiderV2]().getAll(c)
|
||||
return
|
||||
}
|
||||
|
||||
// get list
|
||||
withStats := c.Query("stats")
|
||||
if withStats == "" {
|
||||
NewControllerV2[models.SpiderV2]().GetList(c)
|
||||
NewControllerV2[models2.SpiderV2]().GetList(c)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
sort := MustGetSortOption(c)
|
||||
|
||||
// get list
|
||||
spiders, err := service.NewModelServiceV2[models.SpiderV2]().GetMany(query, &mongo.FindOptions{
|
||||
spiders, err := service.NewModelServiceV2[models2.SpiderV2]().GetMany(query, &mongo.FindOptions{
|
||||
Sort: sort,
|
||||
Skip: pagination.Size * (pagination.Page - 1),
|
||||
Limit: pagination.Size,
|
||||
@@ -113,7 +113,7 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if len(spiders) == 0 {
|
||||
HandleSuccessWithListData(c, []models.SpiderV2{}, 0)
|
||||
HandleSuccessWithListData(c, []models2.SpiderV2{}, 0)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -128,21 +128,21 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
}
|
||||
|
||||
// total count
|
||||
total, err := service.NewModelServiceV2[models.SpiderV2]().Count(query)
|
||||
total, err := service.NewModelServiceV2[models2.SpiderV2]().Count(query)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// stat list
|
||||
spiderStats, err := service.NewModelServiceV2[models.SpiderStatV2]().GetMany(bson.M{"_id": bson.M{"$in": ids}}, nil)
|
||||
spiderStats, err := service.NewModelServiceV2[models2.SpiderStatV2]().GetMany(bson.M{"_id": bson.M{"$in": ids}}, nil)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// cache stat list to dict
|
||||
dict := map[primitive.ObjectID]models.SpiderStatV2{}
|
||||
dict := map[primitive.ObjectID]models2.SpiderStatV2{}
|
||||
var taskIds []primitive.ObjectID
|
||||
for _, st := range spiderStats {
|
||||
if st.Tasks > 0 {
|
||||
@@ -159,9 +159,9 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
}
|
||||
|
||||
// task list and stats
|
||||
var tasks []models.TaskV2
|
||||
dictTask := map[primitive.ObjectID]models.TaskV2{}
|
||||
dictTaskStat := map[primitive.ObjectID]models.TaskStatV2{}
|
||||
var tasks []models2.TaskV2
|
||||
dictTask := map[primitive.ObjectID]models2.TaskV2{}
|
||||
dictTaskStat := map[primitive.ObjectID]models2.TaskStatV2{}
|
||||
if len(taskIds) > 0 {
|
||||
// task list
|
||||
queryTask := bson.M{
|
||||
@@ -169,14 +169,14 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
"$in": taskIds,
|
||||
},
|
||||
}
|
||||
tasks, err = service.NewModelServiceV2[models.TaskV2]().GetMany(queryTask, nil)
|
||||
tasks, err = service.NewModelServiceV2[models2.TaskV2]().GetMany(queryTask, nil)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// task stats list
|
||||
taskStats, err := service.NewModelServiceV2[models.TaskStatV2]().GetMany(queryTask, nil)
|
||||
taskStats, err := service.NewModelServiceV2[models2.TaskStatV2]().GetMany(queryTask, nil)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -198,9 +198,9 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
}
|
||||
|
||||
// git list
|
||||
var gits []models.GitV2
|
||||
var gits []models2.GitV2
|
||||
if len(gitIds) > 0 && utils.IsPro() {
|
||||
gits, err = service.NewModelServiceV2[models.GitV2]().GetMany(bson.M{"_id": bson.M{"$in": gitIds}}, nil)
|
||||
gits, err = service.NewModelServiceV2[models2.GitV2]().GetMany(bson.M{"_id": bson.M{"$in": gitIds}}, nil)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -208,13 +208,13 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
}
|
||||
|
||||
// cache git list to dict
|
||||
dictGit := map[primitive.ObjectID]models.GitV2{}
|
||||
dictGit := map[primitive.ObjectID]models2.GitV2{}
|
||||
for _, g := range gits {
|
||||
dictGit[g.Id] = g
|
||||
}
|
||||
|
||||
// iterate list again
|
||||
var data []models.SpiderV2
|
||||
var data []models2.SpiderV2
|
||||
for _, s := range spiders {
|
||||
// spider stat
|
||||
st, ok := dict[s.Id]
|
||||
@@ -246,7 +246,7 @@ func getSpiderListWithStats(c *gin.Context) {
|
||||
|
||||
func PostSpider(c *gin.Context) {
|
||||
// bind
|
||||
var s models.SpiderV2
|
||||
var s models2.SpiderV2
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
@@ -264,7 +264,7 @@ func PostSpider(c *gin.Context) {
|
||||
// add
|
||||
s.SetCreated(u.Id)
|
||||
s.SetUpdated(u.Id)
|
||||
id, err := service.NewModelServiceV2[models.SpiderV2]().InsertOne(s)
|
||||
id, err := service.NewModelServiceV2[models2.SpiderV2]().InsertOne(s)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -272,11 +272,11 @@ func PostSpider(c *gin.Context) {
|
||||
s.SetId(id)
|
||||
|
||||
// add stat
|
||||
st := models.SpiderStatV2{}
|
||||
st := models2.SpiderStatV2{}
|
||||
st.SetId(id)
|
||||
st.SetCreated(u.Id)
|
||||
st.SetUpdated(u.Id)
|
||||
_, err = service.NewModelServiceV2[models.SpiderStatV2]().InsertOne(st)
|
||||
_, err = service.NewModelServiceV2[models2.SpiderStatV2]().InsertOne(st)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -305,7 +305,7 @@ func PutSpiderById(c *gin.Context) {
|
||||
}
|
||||
|
||||
// bind
|
||||
var s models.SpiderV2
|
||||
var s models2.SpiderV2
|
||||
if err := c.ShouldBindJSON(&s); err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
@@ -319,7 +319,7 @@ func PutSpiderById(c *gin.Context) {
|
||||
|
||||
u := GetUserFromContextV2(c)
|
||||
|
||||
modelSvc := service.NewModelServiceV2[models.SpiderV2]()
|
||||
modelSvc := service.NewModelServiceV2[models2.SpiderV2]()
|
||||
|
||||
// save
|
||||
s.SetUpdated(u.Id)
|
||||
@@ -348,19 +348,19 @@ func DeleteSpiderById(c *gin.Context) {
|
||||
|
||||
if err := mongo.RunTransaction(func(context mongo2.SessionContext) (err error) {
|
||||
// delete spider
|
||||
err = service.NewModelServiceV2[models.SpiderV2]().DeleteById(id)
|
||||
err = service.NewModelServiceV2[models2.SpiderV2]().DeleteById(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete spider stat
|
||||
err = service.NewModelServiceV2[models.SpiderStatV2]().DeleteById(id)
|
||||
err = service.NewModelServiceV2[models2.SpiderStatV2]().DeleteById(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// related tasks
|
||||
tasks, err := service.NewModelServiceV2[models.TaskV2]().GetMany(bson.M{"spider_id": id}, nil)
|
||||
tasks, err := service.NewModelServiceV2[models2.TaskV2]().GetMany(bson.M{"spider_id": id}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -376,13 +376,13 @@ func DeleteSpiderById(c *gin.Context) {
|
||||
}
|
||||
|
||||
// delete related tasks
|
||||
err = service.NewModelServiceV2[models.TaskV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}})
|
||||
err = service.NewModelServiceV2[models2.TaskV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete related task stats
|
||||
err = service.NewModelServiceV2[models.TaskStatV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}})
|
||||
err = service.NewModelServiceV2[models2.TaskStatV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func DeleteSpiderById(c *gin.Context) {
|
||||
|
||||
go func() {
|
||||
// spider
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(id)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(id)
|
||||
if err != nil {
|
||||
log.Errorf("failed to get spider: %s", err.Error())
|
||||
trace.PrintError(err)
|
||||
@@ -451,7 +451,7 @@ func DeleteSpiderList(c *gin.Context) {
|
||||
|
||||
if err := mongo.RunTransaction(func(context mongo2.SessionContext) (err error) {
|
||||
// delete spiders
|
||||
if err := service.NewModelServiceV2[models.SpiderV2]().DeleteMany(bson.M{
|
||||
if err := service.NewModelServiceV2[models2.SpiderV2]().DeleteMany(bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": payload.Ids,
|
||||
},
|
||||
@@ -460,7 +460,7 @@ func DeleteSpiderList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// delete spider stats
|
||||
if err := service.NewModelServiceV2[models.SpiderStatV2]().DeleteMany(bson.M{
|
||||
if err := service.NewModelServiceV2[models2.SpiderStatV2]().DeleteMany(bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": payload.Ids,
|
||||
},
|
||||
@@ -469,7 +469,7 @@ func DeleteSpiderList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// related tasks
|
||||
tasks, err := service.NewModelServiceV2[models.TaskV2]().GetMany(bson.M{"spider_id": bson.M{"$in": payload.Ids}}, nil)
|
||||
tasks, err := service.NewModelServiceV2[models2.TaskV2]().GetMany(bson.M{"spider_id": bson.M{"$in": payload.Ids}}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -485,12 +485,12 @@ func DeleteSpiderList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// delete related tasks
|
||||
if err := service.NewModelServiceV2[models.TaskV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}}); err != nil {
|
||||
if err := service.NewModelServiceV2[models2.TaskV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete related task stats
|
||||
if err := service.NewModelServiceV2[models.TaskStatV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}}); err != nil {
|
||||
if err := service.NewModelServiceV2[models2.TaskStatV2]().DeleteMany(bson.M{"_id": bson.M{"$in": taskIds}}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ func DeleteSpiderList(c *gin.Context) {
|
||||
defer wg.Done()
|
||||
|
||||
// spider
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(id)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(id)
|
||||
if err != nil {
|
||||
log.Errorf("failed to get spider: %s", err.Error())
|
||||
trace.PrintError(err)
|
||||
@@ -692,14 +692,14 @@ func GetSpiderDataSource(c *gin.Context) {
|
||||
}
|
||||
|
||||
// spider
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(id)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(id)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// data source
|
||||
ds, err := service.NewModelServiceV2[models.DataSourceV2]().GetById(s.DataSourceId)
|
||||
ds, err := service.NewModelServiceV2[models2.DataSourceV2]().GetById(s.DataSourceId)
|
||||
if err != nil {
|
||||
if err.Error() == mongo2.ErrNoDocuments.Error() {
|
||||
HandleSuccess(c)
|
||||
@@ -728,7 +728,7 @@ func PostSpiderDataSource(c *gin.Context) {
|
||||
}
|
||||
|
||||
// spider
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(id)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(id)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -736,7 +736,7 @@ func PostSpiderDataSource(c *gin.Context) {
|
||||
|
||||
// data source
|
||||
if !dsId.IsZero() {
|
||||
_, err = service.NewModelServiceV2[models.DataSourceV2]().GetById(dsId)
|
||||
_, err = service.NewModelServiceV2[models2.DataSourceV2]().GetById(dsId)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -747,7 +747,7 @@ func PostSpiderDataSource(c *gin.Context) {
|
||||
u := GetUserFromContextV2(c)
|
||||
s.DataSourceId = dsId
|
||||
s.SetUpdatedBy(u.Id)
|
||||
_, err = service.NewModelServiceV2[models.SpiderV2]().InsertOne(*s)
|
||||
_, err = service.NewModelServiceV2[models2.SpiderV2]().InsertOne(*s)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -756,7 +756,7 @@ func PostSpiderDataSource(c *gin.Context) {
|
||||
HandleSuccess(c)
|
||||
}
|
||||
|
||||
func getSpiderFsSvc(s *models.SpiderV2) (svc interfaces.FsServiceV2, err error) {
|
||||
func getSpiderFsSvc(s *models2.SpiderV2) (svc interfaces.FsServiceV2, err error) {
|
||||
workspacePath := viper.GetString("workspace")
|
||||
fsSvc := fs.NewFsServiceV2(filepath.Join(workspacePath, s.Id.Hex()))
|
||||
|
||||
@@ -764,7 +764,7 @@ func getSpiderFsSvc(s *models.SpiderV2) (svc interfaces.FsServiceV2, err error)
|
||||
}
|
||||
|
||||
func getSpiderFsSvcById(id primitive.ObjectID) (svc interfaces.FsServiceV2, err error) {
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(id)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(id)
|
||||
if err != nil {
|
||||
log.Errorf("failed to get spider: %s", err.Error())
|
||||
trace.PrintError(err)
|
||||
@@ -773,8 +773,8 @@ func getSpiderFsSvcById(id primitive.ObjectID) (svc interfaces.FsServiceV2, err
|
||||
return getSpiderFsSvc(s)
|
||||
}
|
||||
|
||||
func upsertSpiderDataCollection(s *models.SpiderV2) (err error) {
|
||||
modelSvc := service.NewModelServiceV2[models.DataCollectionV2]()
|
||||
func upsertSpiderDataCollection(s *models2.SpiderV2) (err error) {
|
||||
modelSvc := service.NewModelServiceV2[models2.DataCollectionV2]()
|
||||
if s.ColId.IsZero() {
|
||||
// validate
|
||||
if s.ColName == "" {
|
||||
@@ -785,7 +785,7 @@ func upsertSpiderDataCollection(s *models.SpiderV2) (err error) {
|
||||
if err != nil {
|
||||
if errors.Is(err, mongo2.ErrNoDocuments) {
|
||||
// not exists, add new
|
||||
dc = &models.DataCollectionV2{Name: s.ColName}
|
||||
dc = &models2.DataCollectionV2{Name: s.ColName}
|
||||
dcId, err := modelSvc.InsertOne(*dc)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -812,7 +812,7 @@ func upsertSpiderDataCollection(s *models.SpiderV2) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpsertSpiderDataCollection(s *models.SpiderV2) (err error) {
|
||||
func UpsertSpiderDataCollection(s *models2.SpiderV2) (err error) {
|
||||
return upsertSpiderDataCollection(s)
|
||||
}
|
||||
|
||||
@@ -824,7 +824,7 @@ func getSpiderRootPath(c *gin.Context) (rootPath string, err error) {
|
||||
}
|
||||
|
||||
// spider
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(id)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
log2 "github.com/apex/log"
|
||||
"github.com/crawlab-team/crawlab/core/constants"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
models2 "github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/crawlab-team/crawlab/core/result"
|
||||
"github.com/crawlab-team/crawlab/core/spider/admin"
|
||||
@@ -34,7 +34,7 @@ func GetTaskById(c *gin.Context) {
|
||||
}
|
||||
|
||||
// task
|
||||
t, err := service.NewModelServiceV2[models.TaskV2]().GetById(id)
|
||||
t, err := service.NewModelServiceV2[models2.TaskV2]().GetById(id)
|
||||
if errors.Is(err, mongo2.ErrNoDocuments) {
|
||||
HandleErrorNotFound(c, err)
|
||||
return
|
||||
@@ -45,7 +45,7 @@ func GetTaskById(c *gin.Context) {
|
||||
}
|
||||
|
||||
// spider
|
||||
t.Spider, _ = service.NewModelServiceV2[models.SpiderV2]().GetById(t.SpiderId)
|
||||
t.Spider, _ = service.NewModelServiceV2[models2.SpiderV2]().GetById(t.SpiderId)
|
||||
|
||||
// skip if task status is pending
|
||||
if t.Status == constants.TaskStatusPending {
|
||||
@@ -54,7 +54,7 @@ func GetTaskById(c *gin.Context) {
|
||||
}
|
||||
|
||||
// task stat
|
||||
t.Stat, _ = service.NewModelServiceV2[models.TaskStatV2]().GetById(id)
|
||||
t.Stat, _ = service.NewModelServiceV2[models2.TaskStatV2]().GetById(id)
|
||||
|
||||
HandleSuccessWithData(c, t)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func GetTaskById(c *gin.Context) {
|
||||
func GetTaskList(c *gin.Context) {
|
||||
withStats := c.Query("stats")
|
||||
if withStats == "" {
|
||||
NewControllerV2[models.TaskV2]().GetList(c)
|
||||
NewControllerV2[models2.TaskV2]().GetList(c)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func GetTaskList(c *gin.Context) {
|
||||
sort := MustGetSortOption(c)
|
||||
|
||||
// get tasks
|
||||
tasks, err := service.NewModelServiceV2[models.TaskV2]().GetMany(query, &mongo.FindOptions{
|
||||
tasks, err := service.NewModelServiceV2[models2.TaskV2]().GetMany(query, &mongo.FindOptions{
|
||||
Sort: sort,
|
||||
Skip: pagination.Size * (pagination.Page - 1),
|
||||
Limit: pagination.Size,
|
||||
@@ -101,14 +101,14 @@ func GetTaskList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// total count
|
||||
total, err := service.NewModelServiceV2[models.TaskV2]().Count(query)
|
||||
total, err := service.NewModelServiceV2[models2.TaskV2]().Count(query)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
// stat list
|
||||
stats, err := service.NewModelServiceV2[models.TaskStatV2]().GetMany(bson.M{
|
||||
stats, err := service.NewModelServiceV2[models2.TaskStatV2]().GetMany(bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": taskIds,
|
||||
},
|
||||
@@ -119,13 +119,13 @@ func GetTaskList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// cache stat list to dict
|
||||
statsDict := map[primitive.ObjectID]models.TaskStatV2{}
|
||||
statsDict := map[primitive.ObjectID]models2.TaskStatV2{}
|
||||
for _, s := range stats {
|
||||
statsDict[s.Id] = s
|
||||
}
|
||||
|
||||
// spider list
|
||||
spiders, err := service.NewModelServiceV2[models.SpiderV2]().GetMany(bson.M{
|
||||
spiders, err := service.NewModelServiceV2[models2.SpiderV2]().GetMany(bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": spiderIds,
|
||||
},
|
||||
@@ -136,7 +136,7 @@ func GetTaskList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// cache spider list to dict
|
||||
spiderDict := map[primitive.ObjectID]models.SpiderV2{}
|
||||
spiderDict := map[primitive.ObjectID]models2.SpiderV2{}
|
||||
for _, s := range spiders {
|
||||
spiderDict[s.Id] = s
|
||||
}
|
||||
@@ -170,22 +170,22 @@ func DeleteTaskById(c *gin.Context) {
|
||||
// delete in db
|
||||
if err := mongo.RunTransaction(func(context mongo2.SessionContext) (err error) {
|
||||
// delete task
|
||||
_, err = service.NewModelServiceV2[models.TaskV2]().GetById(id)
|
||||
_, err = service.NewModelServiceV2[models2.TaskV2]().GetById(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = service.NewModelServiceV2[models.TaskV2]().DeleteById(id)
|
||||
err = service.NewModelServiceV2[models2.TaskV2]().DeleteById(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// delete task stat
|
||||
_, err = service.NewModelServiceV2[models.TaskStatV2]().GetById(id)
|
||||
_, err = service.NewModelServiceV2[models2.TaskStatV2]().GetById(id)
|
||||
if err != nil {
|
||||
log2.Warnf("delete task stat error: %s", err.Error())
|
||||
return nil
|
||||
}
|
||||
err = service.NewModelServiceV2[models.TaskStatV2]().DeleteById(id)
|
||||
err = service.NewModelServiceV2[models2.TaskStatV2]().DeleteById(id)
|
||||
if err != nil {
|
||||
log2.Warnf("delete task stat error: %s", err.Error())
|
||||
return nil
|
||||
@@ -217,7 +217,7 @@ func DeleteList(c *gin.Context) {
|
||||
|
||||
if err := mongo.RunTransaction(func(context mongo2.SessionContext) error {
|
||||
// delete tasks
|
||||
if err := service.NewModelServiceV2[models.TaskV2]().DeleteMany(bson.M{
|
||||
if err := service.NewModelServiceV2[models2.TaskV2]().DeleteMany(bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": payload.Ids,
|
||||
},
|
||||
@@ -226,7 +226,7 @@ func DeleteList(c *gin.Context) {
|
||||
}
|
||||
|
||||
// delete task stats
|
||||
if err := service.NewModelServiceV2[models.TaskV2]().DeleteMany(bson.M{
|
||||
if err := service.NewModelServiceV2[models2.TaskV2]().DeleteMany(bson.M{
|
||||
"_id": bson.M{
|
||||
"$in": payload.Ids,
|
||||
},
|
||||
@@ -261,7 +261,7 @@ func DeleteList(c *gin.Context) {
|
||||
|
||||
func PostTaskRun(c *gin.Context) {
|
||||
// task
|
||||
var t models.TaskV2
|
||||
var t models2.TaskV2
|
||||
if err := c.ShouldBindJSON(&t); err != nil {
|
||||
HandleErrorBadRequest(c, err)
|
||||
return
|
||||
@@ -274,7 +274,7 @@ func PostTaskRun(c *gin.Context) {
|
||||
}
|
||||
|
||||
// spider
|
||||
s, err := service.NewModelServiceV2[models.SpiderV2]().GetById(t.SpiderId)
|
||||
s, err := service.NewModelServiceV2[models2.SpiderV2]().GetById(t.SpiderId)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -319,7 +319,7 @@ func PostTaskRestart(c *gin.Context) {
|
||||
}
|
||||
|
||||
// task
|
||||
t, err := service.NewModelServiceV2[models.TaskV2]().GetById(id)
|
||||
t, err := service.NewModelServiceV2[models2.TaskV2]().GetById(id)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -363,7 +363,7 @@ func PostTaskCancel(c *gin.Context) {
|
||||
}
|
||||
|
||||
// task
|
||||
t, err := service.NewModelServiceV2[models.TaskV2]().GetById(id)
|
||||
t, err := service.NewModelServiceV2[models2.TaskV2]().GetById(id)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
@@ -446,7 +446,7 @@ func GetTaskData(c *gin.Context) {
|
||||
}
|
||||
|
||||
// task
|
||||
t, err := service.NewModelServiceV2[models.TaskV2]().GetById(id)
|
||||
t, err := service.NewModelServiceV2[models2.TaskV2]().GetById(id)
|
||||
if err != nil {
|
||||
HandleErrorInternalServerError(c, err)
|
||||
return
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/crawlab-team/crawlab/core/user"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -3,7 +3,7 @@ package controllers_test
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/controllers"
|
||||
"github.com/crawlab-team/crawlab/core/middlewares"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -3,7 +3,7 @@ package controllers
|
||||
import (
|
||||
"github.com/crawlab-team/crawlab/core/constants"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/models/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user