Commit c85161e6 by mushishixian

精简优化代码

parent ad0068b2
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq" "github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req" "github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product" "scm_server/cmd/queue/sync_status/product"
...@@ -27,17 +26,12 @@ type CustomerQueueMessage struct { ...@@ -27,17 +26,12 @@ type CustomerQueueMessage struct {
} }
} }
func init() {
log.Init(nil)
}
func (t *RecvPro) Consumer(dataByte []byte) error { func (t *RecvPro) Consumer(dataByte []byte) error {
var ( var (
message CustomerQueueMessage message CustomerQueueMessage
err error err error
customer model.Customer customer model.Customer
operateType string operateType string
) )
//先去转换队列消息的json,如果失败,记录起来 //先去转换队列消息的json,如果失败,记录起来
if err = json.Unmarshal(dataByte, &message); err != nil { if err = json.Unmarshal(dataByte, &message); err != nil {
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq" "github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req" "github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product" "scm_server/cmd/queue/sync_status/product"
...@@ -28,17 +27,12 @@ type GoodsQueueMessage struct { ...@@ -28,17 +27,12 @@ type GoodsQueueMessage struct {
} }
} }
func init() {
log.Init(nil)
}
func (t *RecvPro) Consumer(dataByte []byte) error { func (t *RecvPro) Consumer(dataByte []byte) error {
var ( var (
message GoodsQueueMessage message GoodsQueueMessage
err error err error
goods model.Goods goods model.Goods
operateType string operateType string
) )
//先去转换队列消息的json,如果失败,记录起来 //先去转换队列消息的json,如果失败,记录起来
if err = json.Unmarshal(dataByte, &message); err != nil { if err = json.Unmarshal(dataByte, &message); err != nil {
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq" "github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req" "github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product" "scm_server/cmd/queue/sync_status/product"
...@@ -49,17 +48,13 @@ type InStoreFEntrys struct { ...@@ -49,17 +48,13 @@ type InStoreFEntrys struct {
FRemark string FRemark string
} }
func init() {
log.Init(nil)
}
func (t *RecvPro) Consumer(dataByte []byte) error { func (t *RecvPro) Consumer(dataByte []byte) error {
var ( var (
message InStoreMessage message InStoreMessage
err error err error
inStore model.InStore inStore model.InStore
operateType string operateType string
messageData []byte messageData []byte
) )
//先去转换队列消息的json,如果失败,记录起来 //先去转换队列消息的json,如果失败,记录起来
if err = json.Unmarshal(dataByte, &message); err != nil { if err = json.Unmarshal(dataByte, &message); err != nil {
......
...@@ -3,7 +3,6 @@ package sync_out_store ...@@ -3,7 +3,6 @@ package sync_out_store
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq" "github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req" "github.com/imroc/req"
"github.com/pkg/errors" "github.com/pkg/errors"
...@@ -49,16 +48,12 @@ type OutStoreFEntrys struct { ...@@ -49,16 +48,12 @@ type OutStoreFEntrys struct {
FOriginCountry string FOriginCountry string
} }
func init() {
log.Init(nil)
}
func (t *RecvPro) Consumer(dataByte []byte) error { func (t *RecvPro) Consumer(dataByte []byte) error {
var ( var (
message OutStoreMessage message OutStoreMessage
err error err error
outStore model.OutStore outStore model.OutStore
operateType string operateType string
messageData []byte messageData []byte
) )
fmt.Println(string(dataByte)) fmt.Println(string(dataByte))
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/go-kratos/kratos/pkg/log"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq" "github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
"github.com/imroc/req" "github.com/imroc/req"
"scm_server/cmd/queue/sync_status/product" "scm_server/cmd/queue/sync_status/product"
...@@ -27,17 +26,12 @@ type SupplierQueueMessage struct { ...@@ -27,17 +26,12 @@ type SupplierQueueMessage struct {
} }
} }
func init() {
log.Init(nil)
}
func (t *RecvPro) Consumer(dataByte []byte) error { func (t *RecvPro) Consumer(dataByte []byte) error {
var ( var (
message SupplierQueueMessage message SupplierQueueMessage
err error err error
supplier model.Supplier supplier model.Supplier
operateType string operateType string
) )
//先去转换队列消息的json,如果失败,记录起来 //先去转换队列消息的json,如果失败,记录起来
if err = json.Unmarshal(dataByte, &message); err != nil { if err = json.Unmarshal(dataByte, &message); err != nil {
......
...@@ -9,6 +9,12 @@ import ( ...@@ -9,6 +9,12 @@ import (
"time" "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 (?,?,?,?,?,?)" const InsertSyncLogSql = "INSERT INTO `lie_sync_log` (`sync_name`,`sync_time`,`sync_error`,`unique_id`,`queue_message`,`add_time`) VALUES (?,?,?,?,?,?)"
//插入错误日志 //插入错误日志
......
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