Commit 14fd8cb0 by wang

更改返回参数格式类型

parent 78f1c240
......@@ -11,6 +11,8 @@ cmd.exe~
/conf/prod/*.ini
/go.mod
/conf
/logs
/mylogs
/doc/test
;存放数据库连接信息
[xorm]
ShowSQL = true
ShowSQL = false
[spu]
user_name = spu
......
......@@ -3,6 +3,7 @@ package controller
import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/gogf/gf/util/gconv"
"go_sku_server/model/saveModel"
"go_sku_server/pkg/common"
"go_sku_server/pkg/e"
......@@ -59,13 +60,13 @@ func SaveSku(ctx *gin.Context) {
}
common.NResponse(errMsg,code).SetLogHandel(saveLogHandle).OpenParamLog().OutPut(ctx)
}else {//执行成功
res:=saveModel.LySaveResponse{0,"ok",skuId}
res:=saveModel.LySaveResponse{0,"ok",gconv.Int64(skuId)}
common.NResponse(&res).OutPut(ctx)
}
return
}
//修改
//修改(暂时废弃,大数据那边没调用)
func SkuEdit(ctx *gin.Context) {
//参数验证
......@@ -85,7 +86,8 @@ func SkuEdit(ctx *gin.Context) {
common.NResponse(err.Error()).SetLogHandel(editLogHandle).OutPut(ctx)
}
}else {//执行成功
res:=saveModel.LySaveResponse{0,"ok",skuId}
res:=saveModel.LySaveResponse{0,"ok",gconv.Int64(skuId)}
common.NResponse(&res).OutPut(ctx)
}
return
......
......@@ -17,7 +17,7 @@ type LySaveRequest struct {
Mpq int `json:"mpq" form:"mpq" binding:"required"`//标准包装量
Canal string `json:"canal" form:"canal" `//渠道开发员ID
BatchSn int `json:"batch_sn" form:"batch_sn" `//批次
BatchSn string `json:"batch_sn" form:"batch_sn" `//批次
Stock int `json:"stock" form:"stock" `//库存
HkDeliveryTime string `json:"hk_delivery_time" form:"hk_delivery_time" `//香港货期
CnDeliveryTime string `json:"cn_delivery_time" form:"cn_delivery_time" `//大陆货期
......
......@@ -11,10 +11,10 @@ poolskuSave 返回是这样的格式
type LySaveResponse struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
GoodsId string `json:"goods_id"`
GoodsId int64 `json:"goods_id"`
}
func ResponseSucess(GoodsId string) LySaveResponse {
func ResponseSucess(GoodsId int64) LySaveResponse {
return LySaveResponse{0,"ok",GoodsId}
}
......
package common
import (
"fmt"
"github.com/gin-gonic/gin"
"reflect"
)
......@@ -214,8 +213,6 @@ func (NR *NewResponse )createoutPutData(opt []interface{}) {
valueR:=reflect.ValueOf(opt[0])
if(valueR.Kind()==reflect.Ptr ){
a:=valueR.Elem().Kind()
fmt.Print(a)
if(valueR.Elem().Kind()==reflect.Struct){
if newOutPut,ok:=opt[0].(NewOutPut);ok{
NR.outPutData=newOutPut
......
......@@ -11,7 +11,7 @@ var (
func SetUp(path string) (err error) {
//引入多个文件
Cfg, err = ini.LooseLoad(path+"/config.ini", path+"/database.ini", path+"/redis.ini", path+"/rabmq.ini", path+"/mongo.ini")
Cfg, err = ini.LooseLoad(path+"/config.ini", path+"/database.ini", path+"/redis.ini", path+"/rabmq.ini", path+"/mongo.ini",path+"/log.ini")
return
}
......
......@@ -94,7 +94,7 @@ func (S *LySaveService)SaveSku(lySaveRequest saveModel.LySaveRequest,ctx *gin.Co
/**
供应商处理流程(内部方法)
1.判断供应商是否存在,是否被禁用
2.供应商为专卖,参数 cannal(供应商编码)是必传的
2.如果供应商为专卖,参数 cannal(供应商编码)是必传的
3.得到 新增sku所需的 TypeId 和 Encoded(渠道员内部编码)
*/
func (S *LySaveService) supplierHandle(SupplierId int,Canal string,lySkuEntity *saveModel.LySkuEntity) (error) {
......@@ -181,13 +181,8 @@ spu处理(内部方法)
func (S *LySaveService) spuHandle(lySpuRequest saveModel.LySpuRequest,lySkuEntity *saveModel.LySkuEntity) (error) {
lySpuResponse:=saveModel.LySpuResponse{}
j,_:=json.Marshal(lySpuRequest)
m:=make(map[string]interface{})
err:=json.Unmarshal(j, &m)
if(err!=nil){
return e.NewApiError("请求spu接口参数有误 map化报错"+err.Error())
}
err=gout.POST(config.Get("spu_server.api_domain").String()+"/saveSpu").Debug(true).SetJSON(&m).BindJSON(&lySpuResponse).Do()
err:=gout.POST(config.Get("spu_server.api_domain").String()+"/saveSpu").Debug(false).SetJSON(&lySpuRequest).BindJSON(&lySpuResponse).Do()
if(err!=nil){
return e.NewApiError("调用spu server saveSpu接口报错"+err.Error())
......
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