Commit 9c68f844 by huangchengyi

Merge branch 'dev' of http://119.23.72.7/mushishixian/search_server into dev

# Conflicts:
#	service/common_ly_service.go
parents 38ca63d0 e7bb14bb
...@@ -8,3 +8,4 @@ cmd.exe~ ...@@ -8,3 +8,4 @@ cmd.exe~
/cmd/logs/ /cmd/logs/
/cmd/*.exe~ /cmd/*.exe~
/cmd/logs /cmd/logs
/bat/logs/
set MICRO_REGISTRY=etcd
set MICRO_REGISTRY_ADDRESS=192.168.2.232:2379
go run ../cmd/search_server.go -config=../conf/config.ini
\ No newline at end of file
set MICRO_REGISTRY=etcd ::set MICRO_REGISTRY=etcd
set MICRO_REGISTRY_ADDRESS=192.168.2.232:2379 ::set MICRO_REGISTRY_ADDRESS=192.168.2.232:2379
go run ../cmd/search_http_server.go -config=../conf/config.ini go run ../cmd/search_http_server.go -config=../conf
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
func main() { func main() {
cService:=micro.NewService( cService:=micro.NewService(
micro.Name("go.micro.server.search")) micro.Name("go.micro.grpc.search"))
cService.Init() cService.Init()
err:=bom.RegisterBomServiceHandler(cService.Server(),service.NewBomServiceImpl()) err:=bom.RegisterBomServiceHandler(cService.Server(),service.NewBomServiceImpl())
......
package controller
import (
"github.com/gin-gonic/gin"
"net/http"
"search_server/model"
"search_server/service"
)
func Zyh(ctx *gin.Context){
zyServiceImpl := service.NewZyServiceImpl()
zyhRequest := &model.ZyhRequest{}
zyhResponse := &model.ZyhResponse{}
if err := ctx.ShouldBind(zyhRequest); err != nil{
ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
err := zyServiceImpl.Zyh(ctx,zyhRequest,zyhResponse)
if err != nil{
}
}
...@@ -33,6 +33,7 @@ require ( ...@@ -33,6 +33,7 @@ require (
github.com/stretchr/testify v1.5.1 // indirect github.com/stretchr/testify v1.5.1 // indirect
github.com/syyongx/php2go v0.9.4 github.com/syyongx/php2go v0.9.4
github.com/tidwall/gjson v1.6.0 github.com/tidwall/gjson v1.6.0
github.com/urfave/cli v1.22.4 // indirect
github.com/uniplaces/carbon v0.1.6 github.com/uniplaces/carbon v0.1.6
go.uber.org/zap v1.14.1 // indirect go.uber.org/zap v1.14.1 // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
......
package model
type ZyhRequest struct {
Yo4tewUid string `form:"Yo4teW_uid"`
ClassIdcondition int64 `form:"class_id/condition"`
Brand_idCondition string `form:"brand_id/condition"`
StockRank string `form:"stock_rank"` //库存排序
AvailRank string `form:"avail_rank"` //显示有货的
ComRank string `form:"com_rank"` //综合排序
SingleRank string `form:"single_rank"` //价格排序
PackingCondition string `form:"packing/condition"`
EncapCondition string `form:"encap/condition"`
P string `form:"p"`
NeedAggs string `form:"need_aggs"`
}
type ZyhResponse struct {
error_code int64 `json:"error_code"`
error_msg string `json:"error_msg"`
data interface{}
}
\ No newline at end of file
...@@ -14,6 +14,7 @@ func InitRouter() *gin.Engine { ...@@ -14,6 +14,7 @@ func InitRouter() *gin.Engine {
//路由 //路由
r.POST("/search/bom/autospu", controller.AutoSpu) r.POST("/search/bom/autospu", controller.AutoSpu)
r.POST("/search/bom/recommend", controller.Recommend) r.POST("/search/bom/recommend", controller.Recommend)
r.POST("search/ZiYing/zyh", controller.Zyh)
//快手平台相关 //快手平台相关
r.GET("/search/quote", controller.QuoteIndex) r.GET("/search/quote", controller.QuoteIndex)
......
package service
import (
"fmt"
"github.com/gin-gonic/gin"
"reflect"
"search_server/model"
"search_server/pkg/config"
)
type ZyServiceImpl struct{}
/*
自营搜索
*/
func (this *ZyServiceImpl) Zyh(ctx *gin.Context, req *model.ZyhRequest, rsp *model.ZyhResponse) error {
//fmt.Printf("%+v",req)
fmt.Println(req.NeedAggs)
fmt.Println(5566)
var (
need_aggs bool
_type byte
)
if req.NeedAggs != ""{
need_aggs = false
}else{
need_aggs = true
}
need_aggs = need_aggs
if need_aggs {
_type = 1
}else{
_type = 1
}
//设置cookie
setCookie(ctx,req)
rsp = zy(ctx , req ,_type,0)
return nil
}
func NewZyServiceImpl() *ZyServiceImpl {
return &ZyServiceImpl{}
}
func setCookie(ctx *gin.Context, req *model.ZyhRequest) error{
//接收用户id
if req.Yo4tewUid != "" && req.Yo4tewUid != "false" {
domain := config.Get("web.domain").String()
ctx.SetCookie("Yo4teW_uid", req.Yo4tewUid, 3600, "/", domain, false, true)
}
return nil
}
//自营筛选接口数据输出
//@param _type 1:输出所有(属性统计+分类+数据详情),2 只输出属性(属性统计)
func zy(ctx *gin.Context, req *model.ZyhRequest,_type byte,isCheck byte) (rsp *model.ZyhResponse){
fmt.Printf("%+v",req)
fmt.Println(reflect.TypeOf(req.ClassIdcondition))
fmt.Println(req.ClassIdcondition)
return nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment