package bhomedbapi import ( "basic.com/pubsub/protomsg.git" "encoding/json" "strconv" ) type FileAnalysisApi struct{ } func (api FileAnalysisApi) Save(paramBody map[string]interface{}) bool { url := DATA_URL_PREFIX + "/fileAnalysis/save" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { return false } return res.Success } func (api FileAnalysisApi) Show(id string) (bool,interface{}) { url := DATA_URL_PREFIX + "/fileAnalysis/show" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramQuery := map[string]string { "id":id, } body, err := client.DoGetRequest(url, paramQuery, nil) if err != nil { return false, nil } var res Result if err = json.Unmarshal(body, &res); err != nil { return false, nil } return res.Success, res.Data } func (api FileAnalysisApi) FindAllFile(fileName string,fType int, page int, size int) (bool,interface{}){ url := DATA_URL_PREFIX + "/fileAnalysis/findAllFile" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramQuery := map[string]string { "fileName": fileName, "type": strconv.Itoa(fType), "page": strconv.Itoa(page), "size": strconv.Itoa(size), } body, err := client.DoGetRequest(url, paramQuery, nil) if err != nil { return false, nil } var res Result if err = json.Unmarshal(body, &res); err != nil { return false, nil } return res.Success, res.Data } func (api FileAnalysisApi) GetAnalysisFiles() (files []protomsg.FileAnalysis,err error){ url := DATA_URL_PREFIX + "/fileAnalysis/getAnalysisFiles" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) body, err := client.DoGetRequest(url, nil, nil) if err != nil { return files, err } var res Result if err = json.Unmarshal(body, &res); err != nil { return files,err } bytes, _ := json.Marshal(res.Data) err = json.Unmarshal(bytes, &files) return files, err } func (api FileAnalysisApi) FindByStackId(stackId string, typ int,name string, page int, size int) (bool,interface{}) { url := DATA_URL_PREFIX + "/fileAnalysis/findByStackId" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]string { "stackId": stackId, "type": strconv.Itoa(typ), "name": name, "page": strconv.Itoa(page), "size": strconv.Itoa(size), } body, err := client.DoGetRequest(url, paramBody, nil) if err != nil { logPrint("err:",err) return false,nil } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint("unmarshal res err:",err) return false,nil } return res.Success,res.Data } func (api FileAnalysisApi) GetFileAnalysisSet() (set protomsg.FileAnalysisSetting,err error) { url := DATA_URL_PREFIX + "/fileSetting/show" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) body, err := client.DoGetRequest(url, nil, nil) if err != nil { return set, err } var res Result if err = json.Unmarshal(body, &res); err != nil { return set,err } bytes, _ := json.Marshal(res.Data) err = json.Unmarshal(bytes, &set) return set, err } func (api FileAnalysisApi) UpdateProgress(ids []string, progress int) bool { url := DATA_URL_PREFIX + "/fileAnalysis/updateProgress" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "ids":ids, "progress": progress, } body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success } func (api FileAnalysisApi) ChangeEnable(enable bool) bool { url := DATA_URL_PREFIX + "/fileSetting/changeEnable" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "enable":enable, } body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success } func (api FileAnalysisApi) UpdateStatus(idArr []string, status int) bool { url := DATA_URL_PREFIX + "/fileAnalysis/updateStatus" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "ids":idArr, "status": status, } body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success } func (api FileAnalysisApi) Delete(idArr []string) bool { url := DATA_URL_PREFIX + "/fileAnalysis/delete" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "ids":idArr, } body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success } func (api FileAnalysisApi) SortFile(id string,direct int) bool { url := DATA_URL_PREFIX + "/fileAnalysis/sortFile" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "id": id, "direct": direct, } body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success } func (api FileAnalysisApi) Rename(id string,name string) bool { url := DATA_URL_PREFIX + "/fileAnalysis/rename" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "id": id, "name": name, } body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success } func (api FileAnalysisApi) Move(id string,stackId string) bool { url := DATA_URL_PREFIX + "/fileAnalysis/move" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "id": id, "stackId": stackId, } body,err := client.DoPostRequest(url,CONTENT_TYPE_FORM, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success } func (api FileAnalysisApi) Copy(id string,stackIds []string) bool { url := DATA_URL_PREFIX + "/fileAnalysis/copy" netNode := getNetNode(url2Topic(Topic_Stack_Service, url)) client := NewClient(WithNodes(netNode)) paramBody := map[string]interface{} { "id": id, "stackIds": stackIds, } body,err := client.DoPostRequest(url,CONTENT_TYPE_JSON, paramBody,nil,nil) if err != nil { return false } var res Result if err = json.Unmarshal(body, &res); err != nil { logPrint(err) return false } return res.Success }