30 lines
950 B
Go
30 lines
950 B
Go
package v1
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/IceWhaleTech/CasaOS/model"
|
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
|
"github.com/IceWhaleTech/CasaOS/service"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func GetSearchResult(c *gin.Context) {
|
|
json := make(map[string]string)
|
|
c.ShouldBind(&json)
|
|
url := json["url"]
|
|
|
|
if url == "" {
|
|
c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS), Data: "key is empty"})
|
|
return
|
|
}
|
|
//data, err := service.MyService.Other().Search(key)
|
|
data, err := service.MyService.Other().AgentSearch(url)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
|
|
}
|