Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
go_sku_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
14fd8cb0
authored
Dec 15, 2020
by
wang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更改返回参数格式类型
parent
78f1c240
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
16 additions
and
20 deletions
.gitignore
conf/dev/database.ini
controller/sku_save_controller.go
model/saveModel/save_request.go
model/saveModel/save_response.go
pkg/common/new_output.go
pkg/config/config.go
service/service_ly_save.go
.gitignore
View file @
14fd8cb0
...
@@ -11,6 +11,8 @@ cmd.exe~
...
@@ -11,6 +11,8 @@ cmd.exe~
/conf/prod/*.ini
/conf/prod/*.ini
/go.mod
/go.mod
/conf
/conf
/logs
/mylogs
/doc/test
conf/dev/database.ini
View file @
14fd8cb0
;存放数据库连接信息
;存放数据库连接信息
[xorm]
[xorm]
ShowSQL
=
tru
e
ShowSQL
=
fals
e
[spu]
[spu]
user_name
=
spu
user_name
=
spu
...
...
controller/sku_save_controller.go
View file @
14fd8cb0
...
@@ -3,6 +3,7 @@ package controller
...
@@ -3,6 +3,7 @@ package controller
import
(
import
(
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/gin-gonic/gin/binding"
"github.com/gogf/gf/util/gconv"
"go_sku_server/model/saveModel"
"go_sku_server/model/saveModel"
"go_sku_server/pkg/common"
"go_sku_server/pkg/common"
"go_sku_server/pkg/e"
"go_sku_server/pkg/e"
...
@@ -59,13 +60,13 @@ func SaveSku(ctx *gin.Context) {
...
@@ -59,13 +60,13 @@ func SaveSku(ctx *gin.Context) {
}
}
common
.
NResponse
(
errMsg
,
code
)
.
SetLogHandel
(
saveLogHandle
)
.
OpenParamLog
()
.
OutPut
(
ctx
)
common
.
NResponse
(
errMsg
,
code
)
.
SetLogHandel
(
saveLogHandle
)
.
OpenParamLog
()
.
OutPut
(
ctx
)
}
else
{
//执行成功
}
else
{
//执行成功
res
:=
saveModel
.
LySaveResponse
{
0
,
"ok"
,
skuId
}
res
:=
saveModel
.
LySaveResponse
{
0
,
"ok"
,
gconv
.
Int64
(
skuId
)
}
common
.
NResponse
(
&
res
)
.
OutPut
(
ctx
)
common
.
NResponse
(
&
res
)
.
OutPut
(
ctx
)
}
}
return
return
}
}
//修改
//修改
(暂时废弃,大数据那边没调用)
func
SkuEdit
(
ctx
*
gin
.
Context
)
{
func
SkuEdit
(
ctx
*
gin
.
Context
)
{
//参数验证
//参数验证
...
@@ -85,7 +86,8 @@ func SkuEdit(ctx *gin.Context) {
...
@@ -85,7 +86,8 @@ func SkuEdit(ctx *gin.Context) {
common
.
NResponse
(
err
.
Error
())
.
SetLogHandel
(
editLogHandle
)
.
OutPut
(
ctx
)
common
.
NResponse
(
err
.
Error
())
.
SetLogHandel
(
editLogHandle
)
.
OutPut
(
ctx
)
}
}
}
else
{
//执行成功
}
else
{
//执行成功
res
:=
saveModel
.
LySaveResponse
{
0
,
"ok"
,
skuId
}
res
:=
saveModel
.
LySaveResponse
{
0
,
"ok"
,
gconv
.
Int64
(
skuId
)}
common
.
NResponse
(
&
res
)
.
OutPut
(
ctx
)
common
.
NResponse
(
&
res
)
.
OutPut
(
ctx
)
}
}
return
return
...
...
model/saveModel/save_request.go
View file @
14fd8cb0
...
@@ -17,7 +17,7 @@ type LySaveRequest struct {
...
@@ -17,7 +17,7 @@ type LySaveRequest struct {
Mpq
int
`json:"mpq" form:"mpq" binding:"required"`
//标准包装量
Mpq
int
`json:"mpq" form:"mpq" binding:"required"`
//标准包装量
Canal
string
`json:"canal" form:"canal" `
//渠道开发员ID
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" `
//库存
Stock
int
`json:"stock" form:"stock" `
//库存
HkDeliveryTime
string
`json:"hk_delivery_time" form:"hk_delivery_time" `
//香港货期
HkDeliveryTime
string
`json:"hk_delivery_time" form:"hk_delivery_time" `
//香港货期
CnDeliveryTime
string
`json:"cn_delivery_time" form:"cn_delivery_time" `
//大陆货期
CnDeliveryTime
string
`json:"cn_delivery_time" form:"cn_delivery_time" `
//大陆货期
...
...
model/saveModel/save_response.go
View file @
14fd8cb0
...
@@ -11,10 +11,10 @@ poolskuSave 返回是这样的格式
...
@@ -11,10 +11,10 @@ poolskuSave 返回是这样的格式
type
LySaveResponse
struct
{
type
LySaveResponse
struct
{
ErrCode
int
`json:"errcode"`
ErrCode
int
`json:"errcode"`
ErrMsg
string
`json:"errmsg"`
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
}
return
LySaveResponse
{
0
,
"ok"
,
GoodsId
}
}
}
...
...
pkg/common/new_output.go
View file @
14fd8cb0
package
common
package
common
import
(
import
(
"fmt"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"reflect"
"reflect"
)
)
...
@@ -214,8 +213,6 @@ func (NR *NewResponse )createoutPutData(opt []interface{}) {
...
@@ -214,8 +213,6 @@ func (NR *NewResponse )createoutPutData(opt []interface{}) {
valueR
:=
reflect
.
ValueOf
(
opt
[
0
])
valueR
:=
reflect
.
ValueOf
(
opt
[
0
])
if
(
valueR
.
Kind
()
==
reflect
.
Ptr
){
if
(
valueR
.
Kind
()
==
reflect
.
Ptr
){
a
:=
valueR
.
Elem
()
.
Kind
()
fmt
.
Print
(
a
)
if
(
valueR
.
Elem
()
.
Kind
()
==
reflect
.
Struct
){
if
(
valueR
.
Elem
()
.
Kind
()
==
reflect
.
Struct
){
if
newOutPut
,
ok
:=
opt
[
0
]
.
(
NewOutPut
);
ok
{
if
newOutPut
,
ok
:=
opt
[
0
]
.
(
NewOutPut
);
ok
{
NR
.
outPutData
=
newOutPut
NR
.
outPutData
=
newOutPut
...
...
pkg/config/config.go
View file @
14fd8cb0
...
@@ -11,7 +11,7 @@ var (
...
@@ -11,7 +11,7 @@ var (
func
SetUp
(
path
string
)
(
err
error
)
{
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
return
}
}
...
...
service/service_ly_save.go
View file @
14fd8cb0
...
@@ -94,7 +94,7 @@ func (S *LySaveService)SaveSku(lySaveRequest saveModel.LySaveRequest,ctx *gin.Co
...
@@ -94,7 +94,7 @@ func (S *LySaveService)SaveSku(lySaveRequest saveModel.LySaveRequest,ctx *gin.Co
/**
/**
供应商处理流程(内部方法)
供应商处理流程(内部方法)
1.判断供应商是否存在,是否被禁用
1.判断供应商是否存在,是否被禁用
2.供应商为专卖,参数 cannal(供应商编码)是必传的
2.
如果
供应商为专卖,参数 cannal(供应商编码)是必传的
3.得到 新增sku所需的 TypeId 和 Encoded(渠道员内部编码)
3.得到 新增sku所需的 TypeId 和 Encoded(渠道员内部编码)
*/
*/
func
(
S
*
LySaveService
)
supplierHandle
(
SupplierId
int
,
Canal
string
,
lySkuEntity
*
saveModel
.
LySkuEntity
)
(
error
)
{
func
(
S
*
LySaveService
)
supplierHandle
(
SupplierId
int
,
Canal
string
,
lySkuEntity
*
saveModel
.
LySkuEntity
)
(
error
)
{
...
@@ -181,13 +181,8 @@ spu处理(内部方法)
...
@@ -181,13 +181,8 @@ spu处理(内部方法)
func
(
S
*
LySaveService
)
spuHandle
(
lySpuRequest
saveModel
.
LySpuRequest
,
lySkuEntity
*
saveModel
.
LySkuEntity
)
(
error
)
{
func
(
S
*
LySaveService
)
spuHandle
(
lySpuRequest
saveModel
.
LySpuRequest
,
lySkuEntity
*
saveModel
.
LySkuEntity
)
(
error
)
{
lySpuResponse
:=
saveModel
.
LySpuResponse
{}
lySpuResponse
:=
saveModel
.
LySpuResponse
{}
j
,
_
:=
json
.
Marshal
(
lySpuRequest
)
m
:=
make
(
map
[
string
]
interface
{})
err
:=
gout
.
POST
(
config
.
Get
(
"spu_server.api_domain"
)
.
String
()
+
"/saveSpu"
)
.
Debug
(
false
)
.
SetJSON
(
&
lySpuRequest
)
.
BindJSON
(
&
lySpuResponse
)
.
Do
()
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
()
if
(
err
!=
nil
){
if
(
err
!=
nil
){
return
e
.
NewApiError
(
"调用spu server saveSpu接口报错"
+
err
.
Error
())
return
e
.
NewApiError
(
"调用spu server saveSpu接口报错"
+
err
.
Error
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment