Commit cfd95623 by 孙龙

up

parent df8c2603
...@@ -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=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/config.ini
\ No newline at end of file
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{
}
}
...@@ -27,11 +27,13 @@ require ( ...@@ -27,11 +27,13 @@ require (
github.com/prometheus/client_golang v1.5.1 // indirect github.com/prometheus/client_golang v1.5.1 // indirect
github.com/prometheus/common v0.10.0 github.com/prometheus/common v0.10.0
github.com/prometheus/procfs v0.0.11 // indirect github.com/prometheus/procfs v0.0.11 // indirect
github.com/silenceper/gowatch v0.0.0-20200624073703-8e473a9db258 // indirect
github.com/sirupsen/logrus v1.5.0 // indirect github.com/sirupsen/logrus v1.5.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect github.com/smartystreets/goconvey v1.6.4 // indirect
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
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
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect golang.org/x/sys v0.0.0-20200523222454-059865788121 // 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)
return r return r
} }
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