util
  crawlers
This commit is contained in:
snoop 2017-06-08 19:05:43 +09:00
parent a603587269
commit 662dd4ef70
5 changed files with 64 additions and 2 deletions

View File

@ -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
} }

View File

@ -1,3 +1,14 @@
package crawler package crawler
import "testing"
func TestList(t *testing.T) {
cs := NewCrawlerService()
out := cs.List()
t.Log(out)
}

View File

@ -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;
} }

View File

@ -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)
}

View File

@ -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
} }