Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
scm_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
c85161e6
authored
May 07, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
精简优化代码
parent
ad0068b2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
33 deletions
cmd/queue/sync_customer/main.go
cmd/queue/sync_goods/main.go
cmd/queue/sync_in_store/main.go
cmd/queue/sync_out_store/main.go
cmd/queue/sync_supplier/main.go
internal/logic/sync_log.go
cmd/queue/sync_customer/main.go
View file @
c85161e6
...
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product"
...
...
@@ -27,17 +26,12 @@ type CustomerQueueMessage struct {
}
}
func
init
()
{
log
.
Init
(
nil
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
var
(
message
CustomerQueueMessage
err
error
customer
model
.
Customer
operateType
string
)
//先去转换队列消息的json,如果失败,记录起来
if
err
=
json
.
Unmarshal
(
dataByte
,
&
message
);
err
!=
nil
{
...
...
cmd/queue/sync_goods/main.go
View file @
c85161e6
...
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product"
...
...
@@ -28,17 +27,12 @@ type GoodsQueueMessage struct {
}
}
func
init
()
{
log
.
Init
(
nil
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
var
(
message
GoodsQueueMessage
err
error
goods
model
.
Goods
operateType
string
)
//先去转换队列消息的json,如果失败,记录起来
if
err
=
json
.
Unmarshal
(
dataByte
,
&
message
);
err
!=
nil
{
...
...
cmd/queue/sync_in_store/main.go
View file @
c85161e6
...
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product"
...
...
@@ -49,17 +48,13 @@ type InStoreFEntrys struct {
FRemark
string
}
func
init
()
{
log
.
Init
(
nil
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
var
(
message
InStoreMessage
err
error
inStore
model
.
InStore
operateType
string
messageData
[]
byte
messageData
[]
byte
)
//先去转换队列消息的json,如果失败,记录起来
if
err
=
json
.
Unmarshal
(
dataByte
,
&
message
);
err
!=
nil
{
...
...
cmd/queue/sync_out_store/main.go
View file @
c85161e6
...
...
@@ -3,7 +3,6 @@ package sync_out_store
import
(
"encoding/json"
"fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"github.com/pkg/errors"
...
...
@@ -49,16 +48,12 @@ type OutStoreFEntrys struct {
FOriginCountry
string
}
func
init
()
{
log
.
Init
(
nil
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
var
(
message
OutStoreMessage
err
error
outStore
model
.
OutStore
operateType
string
message
OutStoreMessage
err
error
outStore
model
.
OutStore
operateType
string
messageData
[]
byte
)
fmt
.
Println
(
string
(
dataByte
))
...
...
cmd/queue/sync_supplier/main.go
View file @
c85161e6
...
...
@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product"
...
...
@@ -27,17 +26,12 @@ type SupplierQueueMessage struct {
}
}
func
init
()
{
log
.
Init
(
nil
)
}
func
(
t
*
RecvPro
)
Consumer
(
dataByte
[]
byte
)
error
{
var
(
message
SupplierQueueMessage
err
error
supplier
model
.
Supplier
operateType
string
)
//先去转换队列消息的json,如果失败,记录起来
if
err
=
json
.
Unmarshal
(
dataByte
,
&
message
);
err
!=
nil
{
...
...
internal/logic/sync_log.go
View file @
c85161e6
...
...
@@ -9,6 +9,12 @@ import (
"time"
)
func
init
(){
var
config
log
.
Config
config
.
Dir
=
"logs"
log
.
Init
(
&
config
)
}
const
InsertSyncLogSql
=
"INSERT INTO `lie_sync_log` (`sync_name`,`sync_time`,`sync_error`,`unique_id`,`queue_message`,`add_time`) VALUES (?,?,?,?,?,?)"
//插入错误日志
...
...
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