added
util crawlers
This commit is contained in:
parent
a603587269
commit
662dd4ef70
@ -31,7 +31,7 @@ type Crawler struct {
|
|||||||
func (c *CrawlerService)List() string {
|
func (c *CrawlerService)List() string {
|
||||||
|
|
||||||
|
|
||||||
out := proxy.InvokeDB("crawler", "list", nil)
|
out := proxy.InvokeDB("crawler", "findAll", nil)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
package crawler
|
package crawler
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestList(t *testing.T) {
|
||||||
|
|
||||||
|
cs := NewCrawlerService()
|
||||||
|
|
||||||
|
out := cs.List()
|
||||||
|
|
||||||
|
|
||||||
|
t.Log(out)
|
||||||
|
|
||||||
|
}
|
@ -39,6 +39,16 @@ func (c *CrawlerInputItemMappingService)Create(ciim *CrawlerInputItemMapping) st
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CrawlerInputItemMappingService)Create(ciim *CrawlerInputItemMapping) string {
|
func (c *CrawlerInputItemMappingService)List(cr *crawler.Crawler) string {
|
||||||
|
|
||||||
|
|
||||||
|
out, err := utils.InvokeDBByModel("crawlerInputItemMapping", "findByCrawlerId", cr, "com.loafle.overflow.crawler.model.Crawler")
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return out;
|
||||||
|
|
||||||
}
|
}
|
@ -1 +1,25 @@
|
|||||||
package crawlerinputitemmapping
|
package crawlerinputitemmapping
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.loafle.net/overflow/overflow_proxy_service/proxy/crawler"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestListCrawler(t *testing.T) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
niin := NewCrawlerInputItemMappingService()
|
||||||
|
|
||||||
|
|
||||||
|
cc := &crawler.Crawler{}
|
||||||
|
|
||||||
|
cc.Id = "1";
|
||||||
|
|
||||||
|
out := niin.List(cc)
|
||||||
|
|
||||||
|
|
||||||
|
t.Log(out)
|
||||||
|
|
||||||
|
}
|
@ -19,5 +19,22 @@ func InvokeDB( db string, method string, obj interface{}) (string, error) {
|
|||||||
out := proxy.InvokeDB(db, method, m)
|
out := proxy.InvokeDB(db, method, m)
|
||||||
|
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func InvokeDBByModel( db string, method string, obj interface{}, model string) (string, error) {
|
||||||
|
|
||||||
|
bytes, err := json.Marshal(obj)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
m := make(map[string]string)
|
||||||
|
|
||||||
|
m[model] = string(bytes)
|
||||||
|
|
||||||
|
out := proxy.InvokeDB(db, method, m)
|
||||||
|
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user