added
util crawlers
This commit is contained in:
parent
0aeac2c1fb
commit
a603587269
@ -41,7 +41,7 @@ func (c *CrawlerService)Create(ct * Crawler) string {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
out, err := utils.InvokeDB("crawler", "create", ct, "")
|
out, err := utils.InvokeDB("crawler", "create", ct)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -25,7 +25,7 @@ func NewCrawlerInputItemService() *CrawlerInputItemSerivce {
|
|||||||
|
|
||||||
func (c *CrawlerInputItemSerivce)Create(cii * CrawlerInputItem) string {
|
func (c *CrawlerInputItemSerivce)Create(cii * CrawlerInputItem) string {
|
||||||
|
|
||||||
out, err := utils.InvokeDB("crawlerInputItem", "create", cii, "")
|
out, err := utils.InvokeDB("crawlerInputItem", "create", cii)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -28,7 +28,7 @@ func NewCrawlerInputItemMappingService() *CrawlerInputItemMappingService {
|
|||||||
|
|
||||||
func (c *CrawlerInputItemMappingService)Create(ciim *CrawlerInputItemMapping) string {
|
func (c *CrawlerInputItemMappingService)Create(ciim *CrawlerInputItemMapping) string {
|
||||||
|
|
||||||
out, err := utils.InvokeDB("crawlerInputItemMapping", "create", ciim, "")
|
out, err := utils.InvokeDB("crawlerInputItemMapping", "create", ciim)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
@ -38,3 +38,7 @@ func (c *CrawlerInputItemMappingService)Create(ciim *CrawlerInputItemMapping) st
|
|||||||
return out;
|
return out;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CrawlerInputItemMappingService)Create(ciim *CrawlerInputItemMapping) string {
|
||||||
|
|
||||||
|
}
|
@ -69,7 +69,7 @@ func (t *TargetService)Create(tm *Target) string {
|
|||||||
//
|
//
|
||||||
//out := proxy.InvokeDB("target", "create", m)
|
//out := proxy.InvokeDB("target", "create", m)
|
||||||
|
|
||||||
out, err := utils.InvokeDB("target", "create", tm, "com.loafle.overflow.target.model.Target")
|
out, err := utils.InvokeDB("target", "create", tm)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"git.loafle.net/overflow/overflow_proxy_service/proxy"
|
"git.loafle.net/overflow/overflow_proxy_service/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InvokeDB( db string, method string, obj interface{}, model string) (string, error) {
|
func InvokeDB( db string, method string, obj interface{}) (string, error) {
|
||||||
|
|
||||||
bytes, err := json.Marshal(obj)
|
bytes, err := json.Marshal(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -14,7 +14,7 @@ func InvokeDB( db string, method string, obj interface{}, model string) (string,
|
|||||||
|
|
||||||
m := make(map[string]string)
|
m := make(map[string]string)
|
||||||
|
|
||||||
m[model] = string(bytes)
|
m[GenerateModelStr(db)] = string(bytes)
|
||||||
|
|
||||||
out := proxy.InvokeDB(db, method, m)
|
out := proxy.InvokeDB(db, method, m)
|
||||||
|
|
||||||
|
21
proxy/utils/string.go
Normal file
21
proxy/utils/string.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import "strings"
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultPackage = "com.loafle.overflow."
|
||||||
|
modelPackageName = ".model."
|
||||||
|
)
|
||||||
|
|
||||||
|
func GenerateModelStr(model string) string {
|
||||||
|
|
||||||
|
tm := strings.Title(model)
|
||||||
|
|
||||||
|
|
||||||
|
res := defaultPackage
|
||||||
|
res += model
|
||||||
|
res += modelPackageName
|
||||||
|
res += tm
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
24
proxy/utils/string_test.go
Normal file
24
proxy/utils/string_test.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStringUpper(t *testing.T) {
|
||||||
|
|
||||||
|
res := "crawlerInputItem"
|
||||||
|
|
||||||
|
aa := strings.Title(res)
|
||||||
|
|
||||||
|
|
||||||
|
t.Log(aa)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGM(t *testing.T) {
|
||||||
|
|
||||||
|
t.Log(GenerateModelStr("target"))
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user