Commit d62003c2 by huangchengyi

1.0

parent 61058135
......@@ -3,6 +3,7 @@ package main
import (
"flag"
"go_sku_server/boot"
"go_sku_server/pkg/logger"
"go_sku_server/service"
)
......@@ -19,7 +20,8 @@ func main() {
panic(err)
}
logger.Log("dddd","3333",1)
ZyCronService := service.ZyCronService{}
ZyCronService.ZyDiscount(goods_id)
}
2020-10-13 16:38:11----dddd
\ No newline at end of file
2020-10-13 16:44:56----dddd
2020-10-13 16:59:28----dddd
\ No newline at end of file
;存放数据库连接信息
[gorm]
mode = debug
[xorm]
ShowSQL = false
[spu]
user_name = spu
......
;总配置信息
[web]
port = 9000
mode = debug
cors_domain = http://bom.liexin.com
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
api_md5_str = fh6y5t4rr351d2c3bryi
;钉钉配置信息
[DINGDING]
SEARCH_API_MONITOR = 6d0fa85e01a02c39347d011ae973fd21b76c6c7ce582d3ea470c6b65a318848d
;存放数据库连接信息
[gorm]
mode = debug
[spu]
user_name = spu
password = spu
host = 192.168.1.235
database = liexin_spu
table_prefix =lie_
type = mysql
[liexin_data]
user_name = spu
password = spu
host = 192.168.1.235
database = liexin_data
table_prefix =lie_
type = mysql
#线上地址
#SupDbUser:Supssy2@@!!@$#yxy@172.18.137.21:3306/liexin_supp
[supp]
user_name = liexin_ass
password = `liexin_ass#zsyM`
host = 192.168.2.232
database = liexin_ass
table_prefix =lie_
type = mysql
[cms]
user_name = ichuntcms
password = `ichuntcms#zsyM`
host = 192.168.2.232
database = ichuntcms
table_prefix =
type = mysql
;存放mongodb连接信息
[mongo]
host = 192.168.1.237:27017
username = "ichunt"
password = "huntmon6699"
database = ichunt
maxPoolSize=100
\ No newline at end of file
;存放rabmq连接信息
[rabmq]
url = amqp://guest:guest@192.168.2.232:5672/
;存放本系统所有的队列名称
[rabmq_all]
; bom任务id
MQ_BOM_ITEMS_LIST=bom_items_list
;redis连接信息
[default_redis_read]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 5000
max_active = 3000
idle_timeout = 20
[default_redis_write]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 5000
max_active = 3000
idle_timeout = 20
;存放redis所有键
[redis_all]
\ No newline at end of file
......@@ -2,7 +2,6 @@
[web]
port = 9000
mode = debug
cors_domain = http://bom.liexin.com
[message]
api_domain = http://api.ichunt.com/msg/sendMessageByAuto
......
;存放数据库连接信息
[gorm]
mode = debug
[xorm]
ShowSQL = false
[spu]
user_name = spu
password = spu
host = 192.168.1.235
user_name = LxiCSpu
password = `Mysx3Tyzlo00oxlmlly`
host = 172.18.137.21
database = liexin_spu
table_prefix =lie_
type = mysql
[liexin_data]
user_name = spu
password = spu
host = 192.168.1.235
user_name = LxDDUsedRead
password = `0o9u0Ux2oAoYddflmxXtZss`
host = 172.18.137.33
database = liexin_data
table_prefix =lie_
type = mysql
#线上地址
#SupDbUser:Supssy2@@!!@$#yxy@172.18.137.21:3306/liexin_supp
[supp]
user_name = liexin_ass
password = `liexin_ass#zsyM`
host = 192.168.2.232
database = liexin_ass
user_name = SupDbUser
password = `Supssy2@@!!@$#yxy`
host = 172.18.137.21
database = liexin_supp
table_prefix =lie_
type = mysql
[cms]
user_name = ichuntcms
password = `ichuntcms#zsyM`
host = 192.168.2.232
database = ichuntcms
user_name = dtuser
password = `dAtaL#ym2902m2lLX2y33`
host = appdb-master.ichunt.db
database = icdata
table_prefix =
type = mysql
;存放mongodb连接信息
[mongo]
host = 192.168.1.237:27017
host = 172.18.137.23:27017
username = "ichunt"
password = "huntmon6699"
password = "huntmon66499"
database = ichunt
maxPoolSize=100
\ No newline at end of file
;redis连接信息
[default_redis_read]
host = 192.168.1.235:6379
host = 172.18.137.38:6379
password = icDb29mLy2s
max_idle = 5000
max_active = 3000
max_idle = 500
max_active = 500
idle_timeout = 20
[default_redis_write]
host = 192.168.1.235:6379
host = 172.18.137.39:6379
password = icDb29mLy2s
max_idle = 5000
max_active = 3000
max_idle = 500
max_active = 500
idle_timeout = 20
;存放redis所有键
......
......@@ -3,12 +3,14 @@ package main
import (
"fmt"
"github.com/tidwall/gjson"
"os"
"reflect"
"math"
)
func main() {
fmt.Print(round(1.163,1))
path,_:=os.Getwd()
fmt.Print(path)
return
......
*
!.gitignore
\ No newline at end of file
......@@ -4,8 +4,9 @@ import (
"fmt"
"io"
"os"
"time"
"path/filepath"
"strings"
"time"
)
func check(e error) {
......@@ -32,8 +33,9 @@ func Log(writeString string,log_file_pre string,types int) {
log_file_pre = "_"+log_file_pre
date := time.Now().Format("2006-01-02")
date2 := time.Now().Format("2006-01-02 15:04:05")
var filename = "./logs/"+date+log_file_pre+".txt"
path,_:=os.Getwd()
CreateDateDir(path,"mylogs")
var filename = path+"/mylogs/"+date+log_file_pre+".txt"
var f *os.File
var err1 error
if checkFileIsExist(filename) { //如果文件存在
......@@ -49,6 +51,21 @@ func Log(writeString string,log_file_pre string,types int) {
}
//fmt.Print(err)
}
// CreateDateDir 根据当前日期来创建文件夹
func CreateDateDir(Path string,folderName string) string {
if folderName == "" {
folderName = time.Now().Format("20060102")
}
folderPath := filepath.Join(Path, folderName)
if _, err := os.Stat(folderPath); os.IsNotExist(err) {
// 必须分成两步:先创建文件夹、再修改权限
os.Mkdir(folderPath, 0755) //0777也可以os.ModePerm
os.Chmod(folderPath, 0755)
}
return folderPath
}
// StrReplace str_replace()
func StrReplace(search, replace, subject string, count int) string {
return strings.Replace(subject, search, replace, count)
......
......@@ -29,7 +29,8 @@ func Setup() error {
}
//日志打印SQL
DatabaseConMap[conName].ShowSQL(true)
ShowSql,_ := config.Get("xorm.ShowSQL").Bool()
DatabaseConMap[conName].ShowSQL(ShowSql)
//设置连接池的空闲数大小
DatabaseConMap[conName].SetMaxIdleConns(db.MaxIdleCons)
......
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: bom.proto
package bom
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
api "github.com/micro/go-micro/v2/api"
client "github.com/micro/go-micro/v2/client"
server "github.com/micro/go-micro/v2/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for BomService service
func NewBomServiceEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for BomService service
type BomService interface {
AutoSpu(ctx context.Context, in *AutoSpuRequest, opts ...client.CallOption) (*AutoSpuResponse, error)
}
type bomService struct {
c client.Client
name string
}
func NewBomService(name string, c client.Client) BomService {
return &bomService{
c: c,
name: name,
}
}
func (c *bomService) AutoSpu(ctx context.Context, in *AutoSpuRequest, opts ...client.CallOption) (*AutoSpuResponse, error) {
req := c.c.NewRequest(c.name, "BomService.AutoSpu", in)
out := new(AutoSpuResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for BomService service
type BomServiceHandler interface {
AutoSpu(context.Context, *AutoSpuRequest, *AutoSpuResponse) error
}
func RegisterBomServiceHandler(s server.Server, hdlr BomServiceHandler, opts ...server.HandlerOption) error {
type bomService interface {
AutoSpu(ctx context.Context, in *AutoSpuRequest, out *AutoSpuResponse) error
}
type BomService struct {
bomService
}
h := &bomServiceHandler{hdlr}
return s.Handle(s.NewHandler(&BomService{h}, opts...))
}
type bomServiceHandler struct {
BomServiceHandler
}
func (h *bomServiceHandler) AutoSpu(ctx context.Context, in *AutoSpuRequest, out *AutoSpuResponse) error {
return h.BomServiceHandler.AutoSpu(ctx, in, out)
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: common.proto
package common
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Timestamp struct {
Timestamp *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Timestr string `protobuf:"bytes,2,opt,name=timestr,proto3" json:"timestr,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Timestamp) Reset() { *m = Timestamp{} }
func (m *Timestamp) String() string { return proto.CompactTextString(m) }
func (*Timestamp) ProtoMessage() {}
func (*Timestamp) Descriptor() ([]byte, []int) {
return fileDescriptor_555bd8c177793206, []int{0}
}
func (m *Timestamp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Timestamp.Unmarshal(m, b)
}
func (m *Timestamp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Timestamp.Marshal(b, m, deterministic)
}
func (m *Timestamp) XXX_Merge(src proto.Message) {
xxx_messageInfo_Timestamp.Merge(m, src)
}
func (m *Timestamp) XXX_Size() int {
return xxx_messageInfo_Timestamp.Size(m)
}
func (m *Timestamp) XXX_DiscardUnknown() {
xxx_messageInfo_Timestamp.DiscardUnknown(m)
}
var xxx_messageInfo_Timestamp proto.InternalMessageInfo
func (m *Timestamp) GetTimestamp() *timestamp.Timestamp {
if m != nil {
return m.Timestamp
}
return nil
}
func (m *Timestamp) GetTimestr() string {
if m != nil {
return m.Timestr
}
return ""
}
func init() {
proto.RegisterType((*Timestamp)(nil), "common.Timestamp")
}
func init() { proto.RegisterFile("common.proto", fileDescriptor_555bd8c177793206) }
var fileDescriptor_555bd8c177793206 = []byte{
// 121 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xce, 0xcf, 0xcd,
0xcd, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x83, 0xf0, 0xa4, 0xe4, 0xd3, 0xf3,
0xf3, 0xd3, 0x73, 0x52, 0xf5, 0xc1, 0xa2, 0x49, 0xa5, 0x69, 0xfa, 0x25, 0x99, 0xb9, 0xa9, 0xc5,
0x25, 0x89, 0xb9, 0x05, 0x10, 0x85, 0x4a, 0xf1, 0x5c, 0x9c, 0x21, 0x30, 0x21, 0x21, 0x0b, 0x2e,
0x4e, 0xb8, 0xbc, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x94, 0x1e, 0xc4, 0x04, 0x3d, 0x98,
0x09, 0x7a, 0x70, 0xe5, 0x41, 0x08, 0xc5, 0x42, 0x12, 0x5c, 0xec, 0x10, 0x4e, 0x91, 0x04, 0x93,
0x02, 0xa3, 0x06, 0x67, 0x10, 0x8c, 0x9b, 0xc4, 0x06, 0xd6, 0x68, 0x0c, 0x08, 0x00, 0x00, 0xff,
0xff, 0x1b, 0x45, 0x2b, 0x0e, 0xa0, 0x00, 0x00, 0x00,
}
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: common.proto
package common
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
_ "github.com/golang/protobuf/ptypes/timestamp"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: course.proto
package course
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
api "github.com/micro/go-micro/v2/api"
client "github.com/micro/go-micro/v2/client"
server "github.com/micro/go-micro/v2/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for CourseService service
func NewCourseServiceEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for CourseService service
type CourseService interface {
ListForTop(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
GetDetail(ctx context.Context, in *DetailRequest, opts ...client.CallOption) (*DetailResponse, error)
}
type courseService struct {
c client.Client
name string
}
func NewCourseService(name string, c client.Client) CourseService {
return &courseService{
c: c,
name: name,
}
}
func (c *courseService) ListForTop(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error) {
req := c.c.NewRequest(c.name, "CourseService.ListForTop", in)
out := new(ListResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *courseService) GetDetail(ctx context.Context, in *DetailRequest, opts ...client.CallOption) (*DetailResponse, error) {
req := c.c.NewRequest(c.name, "CourseService.GetDetail", in)
out := new(DetailResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for CourseService service
type CourseServiceHandler interface {
ListForTop(context.Context, *ListRequest, *ListResponse) error
GetDetail(context.Context, *DetailRequest, *DetailResponse) error
}
func RegisterCourseServiceHandler(s server.Server, hdlr CourseServiceHandler, opts ...server.HandlerOption) error {
type courseService interface {
ListForTop(ctx context.Context, in *ListRequest, out *ListResponse) error
GetDetail(ctx context.Context, in *DetailRequest, out *DetailResponse) error
}
type CourseService struct {
courseService
}
h := &courseServiceHandler{hdlr}
return s.Handle(s.NewHandler(&CourseService{h}, opts...))
}
type courseServiceHandler struct {
CourseServiceHandler
}
func (h *courseServiceHandler) ListForTop(ctx context.Context, in *ListRequest, out *ListResponse) error {
return h.CourseServiceHandler.ListForTop(ctx, in, out)
}
func (h *courseServiceHandler) GetDetail(ctx context.Context, in *DetailRequest, out *DetailResponse) error {
return h.CourseServiceHandler.GetDetail(ctx, in, out)
}
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: course_topic.proto
package course
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
api "github.com/micro/go-micro/v2/api"
client "github.com/micro/go-micro/v2/client"
server "github.com/micro/go-micro/v2/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for CourseTopicService service
func NewCourseTopicServiceEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for CourseTopicService service
type CourseTopicService interface {
GetTopic(ctx context.Context, in *TopicRequest, opts ...client.CallOption) (*TopicResponse, error)
}
type courseTopicService struct {
c client.Client
name string
}
func NewCourseTopicService(name string, c client.Client) CourseTopicService {
return &courseTopicService{
c: c,
name: name,
}
}
func (c *courseTopicService) GetTopic(ctx context.Context, in *TopicRequest, opts ...client.CallOption) (*TopicResponse, error) {
req := c.c.NewRequest(c.name, "CourseTopicService.GetTopic", in)
out := new(TopicResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for CourseTopicService service
type CourseTopicServiceHandler interface {
GetTopic(context.Context, *TopicRequest, *TopicResponse) error
}
func RegisterCourseTopicServiceHandler(s server.Server, hdlr CourseTopicServiceHandler, opts ...server.HandlerOption) error {
type courseTopicService interface {
GetTopic(ctx context.Context, in *TopicRequest, out *TopicResponse) error
}
type CourseTopicService struct {
courseTopicService
}
h := &courseTopicServiceHandler{hdlr}
return s.Handle(s.NewHandler(&CourseTopicService{h}, opts...))
}
type courseTopicServiceHandler struct {
CourseTopicServiceHandler
}
func (h *courseTopicServiceHandler) GetTopic(ctx context.Context, in *TopicRequest, out *TopicResponse) error {
return h.CourseTopicServiceHandler.GetTopic(ctx, in, out)
}
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: goods.proto
package goods
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: mouser.proto
package mouser
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
client "github.com/micro/go-micro/client"
server "github.com/micro/go-micro/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ client.Option
var _ server.Option
// Client API for MouserService service
type MouserService interface {
MouserGetData(ctx context.Context, in *MouserRequest, opts ...client.CallOption) (*MouserResponse, error)
}
type mouserService struct {
c client.Client
name string
}
func NewMouserService(name string, c client.Client) MouserService {
if c == nil {
c = client.NewClient()
}
if len(name) == 0 {
name = "mouser"
}
return &mouserService{
c: c,
name: name,
}
}
func (c *mouserService) MouserGetData(ctx context.Context, in *MouserRequest, opts ...client.CallOption) (*MouserResponse, error) {
req := c.c.NewRequest(c.name, "MouserService.MouserGetData", in)
out := new(MouserResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for MouserService service
type MouserServiceHandler interface {
MouserGetData(context.Context, *MouserRequest, *MouserResponse) error
}
func RegisterMouserServiceHandler(s server.Server, hdlr MouserServiceHandler, opts ...server.HandlerOption) error {
type mouserService interface {
MouserGetData(ctx context.Context, in *MouserRequest, out *MouserResponse) error
}
type MouserService struct {
mouserService
}
h := &mouserServiceHandler{hdlr}
return s.Handle(s.NewHandler(&MouserService{h}, opts...))
}
type mouserServiceHandler struct {
MouserServiceHandler
}
func (h *mouserServiceHandler) MouserGetData(ctx context.Context, in *MouserRequest, out *MouserResponse) error {
return h.MouserServiceHandler.MouserGetData(ctx, in, out)
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: users.proto
package users
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type UserRequest struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UserRequest) Reset() { *m = UserRequest{} }
func (m *UserRequest) String() string { return proto.CompactTextString(m) }
func (*UserRequest) ProtoMessage() {}
func (*UserRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_030765f334c86cea, []int{0}
}
func (m *UserRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UserRequest.Unmarshal(m, b)
}
func (m *UserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UserRequest.Marshal(b, m, deterministic)
}
func (m *UserRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_UserRequest.Merge(m, src)
}
func (m *UserRequest) XXX_Size() int {
return xxx_messageInfo_UserRequest.Size(m)
}
func (m *UserRequest) XXX_DiscardUnknown() {
xxx_messageInfo_UserRequest.DiscardUnknown(m)
}
var xxx_messageInfo_UserRequest proto.InternalMessageInfo
func (m *UserRequest) GetId() string {
if m != nil {
return m.Id
}
return ""
}
type UserResponse struct {
Ret string `protobuf:"bytes,2,opt,name=ret,proto3" json:"ret,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *UserResponse) Reset() { *m = UserResponse{} }
func (m *UserResponse) String() string { return proto.CompactTextString(m) }
func (*UserResponse) ProtoMessage() {}
func (*UserResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_030765f334c86cea, []int{1}
}
func (m *UserResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_UserResponse.Unmarshal(m, b)
}
func (m *UserResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_UserResponse.Marshal(b, m, deterministic)
}
func (m *UserResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_UserResponse.Merge(m, src)
}
func (m *UserResponse) XXX_Size() int {
return xxx_messageInfo_UserResponse.Size(m)
}
func (m *UserResponse) XXX_DiscardUnknown() {
xxx_messageInfo_UserResponse.DiscardUnknown(m)
}
var xxx_messageInfo_UserResponse proto.InternalMessageInfo
func (m *UserResponse) GetRet() string {
if m != nil {
return m.Ret
}
return ""
}
func init() {
proto.RegisterType((*UserRequest)(nil), "users.UserRequest")
proto.RegisterType((*UserResponse)(nil), "users.UserResponse")
}
func init() { proto.RegisterFile("users.proto", fileDescriptor_030765f334c86cea) }
var fileDescriptor_030765f334c86cea = []byte{
// 134 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2e, 0x2d, 0x4e, 0x2d,
0x2a, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x73, 0x94, 0x64, 0xb9, 0xb8, 0x43,
0x8b, 0x53, 0x8b, 0x82, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, 0x84, 0xf8, 0xb8, 0x98, 0x32, 0x53,
0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x98, 0x32, 0x53, 0x94, 0x14, 0xb8, 0x78, 0x20, 0xd2,
0xc5, 0x05, 0xf9, 0x79, 0xc5, 0xa9, 0x42, 0x02, 0x5c, 0xcc, 0x45, 0xa9, 0x25, 0x12, 0x4c, 0x60,
0x05, 0x20, 0xa6, 0x91, 0x03, 0xc4, 0x80, 0xe0, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0x54, 0x21, 0x43,
0x2e, 0x96, 0x10, 0x90, 0x41, 0x42, 0x7a, 0x10, 0xcb, 0x90, 0x0c, 0x97, 0x12, 0x46, 0x11, 0x83,
0x98, 0xa8, 0xc4, 0x90, 0xc4, 0x06, 0x76, 0x90, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x35, 0x8a,
0xe3, 0x2d, 0x9f, 0x00, 0x00, 0x00,
}
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: users.proto
package users
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
import (
context "context"
api "github.com/micro/go-micro/v2/api"
client "github.com/micro/go-micro/v2/client"
server "github.com/micro/go-micro/v2/server"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// Reference imports to suppress errors if they are not otherwise used.
var _ api.Endpoint
var _ context.Context
var _ client.Option
var _ server.Option
// Api Endpoints for UserService service
func NewUserServiceEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for UserService service
type UserService interface {
Test(ctx context.Context, in *UserRequest, opts ...client.CallOption) (*UserResponse, error)
}
type userService struct {
c client.Client
name string
}
func NewUserService(name string, c client.Client) UserService {
return &userService{
c: c,
name: name,
}
}
func (c *userService) Test(ctx context.Context, in *UserRequest, opts ...client.CallOption) (*UserResponse, error) {
req := c.c.NewRequest(c.name, "UserService.Test", in)
out := new(UserResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for UserService service
type UserServiceHandler interface {
Test(context.Context, *UserRequest, *UserResponse) error
}
func RegisterUserServiceHandler(s server.Server, hdlr UserServiceHandler, opts ...server.HandlerOption) error {
type userService interface {
Test(ctx context.Context, in *UserRequest, out *UserResponse) error
}
type UserService struct {
userService
}
h := &userServiceHandler{hdlr}
return s.Handle(s.NewHandler(&UserService{h}, opts...))
}
type userServiceHandler struct {
UserServiceHandler
}
func (h *userServiceHandler) Test(ctx context.Context, in *UserRequest, out *UserResponse) error {
return h.UserServiceHandler.Test(ctx, in, out)
}
syntax = "proto3";
package bom;
service BomService {
rpc AutoSpu(AutoSpuRequest) returns (AutoSpuResponse);
}
message AutoSpuRequest {
// @inject_tag: uri:"goods_name"
string goods_name = 1;
}
message AutoSpuResponse{
// @inject_tag: json:"error_code"
int32 error_code = 1;
// @inject_tag: json:"error_message"
string error_message = 2;
// @inject_tag: json:"data"
repeated string data = 3;
}
message RecommendRequest{
// @inject_tag: form:"goods_name"
string goods_name = 1;
// @inject_tag: form:"attrs"
string attrs = 2;
// @inject_tag: form:"encap"
string encap = 3;
// @inject_tag: form:"num"
int32 num = 4;
// @inject_tag: form:"delivery_type"
int32 delivery_type = 5;
// @inject_tag: form:"flag"
int32 flag = 6;
// @inject_tag: form:"brand_name"
string brand_name = 7;
}
message ResponseData{
// @inject_tag: json:"total"
int64 total = 1;
// @inject_tag: json:"flag"
int32 flag = 2;
// @inject_tag: json:"data"
repeated GoodsModel data = 3;
}
message RecommendResponse{
// @inject_tag: json:"error_code"
int32 error_code = 1;
// @inject_tag: json:"error_message"
string error_message = 2;
// @inject_tag: json:"data"
ResponseData data = 3;
}
message OtherAttrs {
string gross_wegiht = 1;
}
message LadderPrice {
int64 purchases = 1;
float price_cn = 2;
float price_us = 3;
float price_ac = 4;
}
message GoodsModel {
// @inject_tag: json:"other_attrs"
OtherAttrs other_attrs = 1;
// @inject_tag: json:"pick_type"
int64 pick_type = 2;
// @inject_tag: json:"barcode"
string barcode = 3;
// @inject_tag: json:"goods_id"
string goods_id = 4;
// @inject_tag: json:"goods_type
int64 goods_type = 5;
// @inject_tag: json:"supplier_id"
int64 supplier_id = 6;
// @inject_tag: json:"brand_id"
int64 brand_id = 7;
// @inject_tag: json:"class_id1"
int64 class_id1 = 8;
// @inject_tag: json:"class_id2"
int64 class_id2 = 9;
// @inject_tag: json:"goods_name"
string goods_name = 10;
// @inject_tag: json:"status"
int64 status = 11;
// @inject_tag: json:"encoded"
string encoded = 12;
// @inject_tag: json:"encap"
string encap = 13;
// @inject_tag: json:"packing"
int64 packing = 14;
// @inject_tag: json:"goods_unit"
int64 goods_unit = 15;
// @inject_tag: json:"goods_images"
bool goods_images = 16;
// @inject_tag: json:"pdf"
string pdf = 17;
// @inject_tag: json:"goods_brief"
string goods_brief = 18;
// @inject_tag: json:"moq"
int64 moq = 19;
// @inject_tag: json:"mpq"
int64 mpq = 20;
// @inject_tag: json:"ladder_price"
repeated LadderPrice ladder_price = 21;
// @inject_tag: json:"update_time"
int64 update_time = 22;
// @inject_tag: json:"sku_name"
string sku_name = 23;
// @inject_tag: json:"mpl"
int64 mpl = 24;
// @inject_tag: json:"stock"
int64 stock = 25;
// @inject_tag: json:"attrs"
string attrs = 26;
// @inject_tag: json:"cost"
string cost = 27;
// @inject_tag: json:"new_cost"
string new_cost = 28;
// @inject_tag: json:"supplier_stock"
int64 supplier_stock = 29;
// @inject_tag: json:"self_supplier_type"
int64 self_supplier_type = 30;
// @inject_tag: json:"cn_delivery_time"
string cn_delivery_time = 31;
// @inject_tag: json:"brand_name"
string brand_name = 32;
// @inject_tag: json:"supplier_name"
string supplier_name = 33;
string goods_unit_name = 34;
string packing_name = 35;
string mpq_unit_name = 36;
// @inject_tag: json:"ac_type"
int64 ac_type = 37;
int64 allow_coupon = 38;
string class_id1_name = 39;
string class_id2_name = 40;
// @inject_tag: json:"otheis_buyr_attrs"
int64 is_buy = 41;
// @inject_tag: json:"hk_delivery_type"
string hk_delivery_type = 42;
}
\ No newline at end of file
syntax = "proto3";
import "google/protobuf/timestamp.proto";
package common;
message Timestamp {
google.protobuf.Timestamp timestamp = 1;
string timestr=2;
}
\ No newline at end of file
syntax = "proto3";
package course;
service CourseService {
rpc ListForTop(ListRequest) returns (ListResponse);
rpc GetDetail(DetailRequest) returns(DetailResponse);
}
message CourseModel{
int32 course_id=1;
string course_name=2;
string course_disp_name=3;
string course_intr=4;
float course_price=5;
float course_price2=6;
// @inject_tag: gorm:"type:timestamp"
int64 addtime=7;
}
message ListRequest {
// @inject_tag: form:"size"
int32 size = 1;
}
message DetailRequest{
// @inject_tag: uri:"course_id"
int32 course_id=1;
// @inject_tag: header:"fetch_type"
int32 fetch_type=2;
}
//计数
message CourseCounts{
// @inject_tag: json:"-"
int32 count_id=1;
// @inject_tag: json:"-"
int32 course_id=2;
string count_key=3;
int32 count_value=4;
}
message ListResponse {
repeated CourseModel result = 1;
}
message DetailResponse{
CourseModel course=1;
repeated CourseCounts counts=2;
}
syntax = "proto3";
package course;
message CourseTopic{
int32 Id = 1;
int32 CourseId = 2;
int32 CourseDid = 3;
int32 Likes = 4;
int32 Unlikes = 5;
string Title = 6;
string Content = 7;
int32 UserId = 8;
int64 Addtime = 9;
int64 Updatetime = 10;
}
message CourseTopicReply{
int32 Id = 1;
int32 TopicId = 2;
string Content = 3;
int32 UserId = 4;
int32 Likes = 5;
int32 Unlikes = 6;
int64 Addtime = 7;
}
message TopicRequest{
int32 CourseId = 1;
}
message TopicResponse{
repeated CourseTopic result = 1;
}
service CourseTopicService {
rpc GetTopic(TopicRequest) returns (TopicResponse);
}
\ No newline at end of file
syntax = "proto3";
package mouser;
service MouserService {
rpc MouserGetData(MouserRequest) returns (MouserResponse);
}
message MouserRequest {
// @inject_tag: uri:"goods_name"
string goods_name = 1;
}
message ResponseData{
// @inject_tag: json:"total"
int64 total = 1;
// @inject_tag: json:"flag"
int32 flag = 2;
// @inject_tag: json:"data"
repeated GoodsModel data = 3;
}
message MouserResponse{
// @inject_tag: json:"error_code"
int32 error_code = 1;
// @inject_tag: json:"error_message"
string error_message = 2;
// @inject_tag: json:"data"
ResponseData data = 3;
}
message OtherAttrs {
string gross_wegiht = 1;
}
message LadderPrice {
int64 purchases = 1;
float price_cn = 2;
float price_us = 3;
float price_ac = 4;
}
message GoodsModel {
// @inject_tag: json:"other_attrs"
OtherAttrs other_attrs = 1;
// @inject_tag: json:"pick_type"
int64 pick_type = 2;
// @inject_tag: json:"barcode"
string barcode = 3;
// @inject_tag: json:"goods_id"
string goods_id = 4;
// @inject_tag: json:"goods_type
int64 goods_type = 5;
// @inject_tag: json:"supplier_id"
int64 supplier_id = 6;
// @inject_tag: json:"brand_id"
int64 brand_id = 7;
// @inject_tag: json:"class_id1"
int64 class_id1 = 8;
// @inject_tag: json:"class_id2"
int64 class_id2 = 9;
// @inject_tag: json:"goods_name"
string goods_name = 10;
// @inject_tag: json:"status"
int64 status = 11;
// @inject_tag: json:"encoded"
string encoded = 12;
// @inject_tag: json:"encap"
string encap = 13;
// @inject_tag: json:"packing"
int64 packing = 14;
// @inject_tag: json:"goods_unit"
int64 goods_unit = 15;
// @inject_tag: json:"goods_images"
bool goods_images = 16;
// @inject_tag: json:"pdf"
string pdf = 17;
// @inject_tag: json:"goods_brief"
string goods_brief = 18;
// @inject_tag: json:"moq"
int64 moq = 19;
// @inject_tag: json:"mpq"
int64 mpq = 20;
// @inject_tag: json:"ladder_price"
repeated LadderPrice ladder_price = 21;
// @inject_tag: json:"update_time"
int64 update_time = 22;
// @inject_tag: json:"sku_name"
string sku_name = 23;
// @inject_tag: json:"mpl"
int64 mpl = 24;
// @inject_tag: json:"stock"
int64 stock = 25;
// @inject_tag: json:"attrs"
string attrs = 26;
// @inject_tag: json:"cost"
string cost = 27;
// @inject_tag: json:"new_cost"
string new_cost = 28;
// @inject_tag: json:"supplier_stock"
int64 supplier_stock = 29;
// @inject_tag: json:"self_supplier_type"
int64 self_supplier_type = 30;
// @inject_tag: json:"cn_delivery_time"
string cn_delivery_time = 31;
// @inject_tag: json:"brand_name"
string brand_name = 32;
// @inject_tag: json:"supplier_name"
string supplier_name = 33;
string goods_unit_name = 34;
string packing_name = 35;
string mpq_unit_name = 36;
// @inject_tag: json:"ac_type"
int64 ac_type = 37;
int64 allow_coupon = 38;
string class_id1_name = 39;
string class_id2_name = 40;
// @inject_tag: json:"otheis_buyr_attrs"
int64 is_buy = 41;
// @inject_tag: json:"hk_delivery_type"
string hk_delivery_type = 42;
}
\ No newline at end of file
syntax = "proto3";
package users;
service UserService {
rpc Test(UserRequest) returns (UserResponse) {}
}
message UserRequest {
string id = 1;
}
message UserResponse {
string ret = 2;
}
## golang 商品微服务
### 项目启动
直接到cmd下面直接找到想启动的服务进行```go run xxx```即可,需要传入配置文件地址的话,则可以
```go run xxx.go -config xxx/xxx.ini```
一:启动http 对外服务:
cd cmd/http
go build -o ./http ./http_server.go
运行-线上: ./http -config=../../conf/prod
运行-开发: ./http -config=../../conf/dev
二:启动定时任务
cd cmd/cron
go build -o ./cron ./cron_server.go
增加定时crontab 任务:
运行-线上: 0 0 */3 * * cd /go_sku_server/cmd/cron/ && ./cron -config=../../conf/prod
运行-开发: 0 0 */3 * * cd /go_sku_server/cmd/cron/ && ./cron -config=../../conf/dev
### 目录结构
├── bat //运行脚本或者protoc生成脚本
......
package requests
//使用根据供应商获取商品信息方法的通用请求
type GetGoodsBySupplierRequest struct {
Keyword string `form:"keyword"`
SupplierName string `form:"supplier_name"`
Stock int `form:"stock"`
SupplierId string `form:"supplier_id"`
Offset int `form:"offset"`
FollowHit int `form:"follow_hit"`
CheckButton int `form:"check_button"`
GoodsNameEq string `form:"goods_name/eq"`
IsExact int `form:"is_exact"`
BrandId string `form:"brand_id"`
Flag string `form:"flag"` //调试标志
AvailRank int `form:"avail_rank"`
SingleRank int `form:"single_rank"`
StockRank int `form:"stock_rank"`
ComRank int `form:"com_rank"`
FirstSearchPage int `form:"first_search_page"`
P int `form:"p"`
Topic int `form:"topic"`
K1 int `form:"k1"`
K2 int `form:"k2"`
}
package requests
type GetDataIndexRequest struct {
//Keyword string `form:"keyword"`
KNums int `form:"kNums"`
IsSort int `form:"is_sort"`
//SupplierId string `form:"supplier_id"`
//SupplierName string `form:"supplier_name"`
//GoodsNameEq string `form:"goods_name/eq"`
//BrandId string `form:"brand_id"`
//Offset int `form:"offset"`
//FollowHit int `form:"follow_hit"`
//Stock int `form:"stock"`
//IsExact int `form:"is_exact"`
//AvailRank int `form:"avail_rank"`
//SingleRank int `form:"single_rank"`
//StockRank int `form:"stock_rank"`
//ComRank int `form:"com_rank"`
//FirstSearchPage int `form:"first_search_page"`
//P int `form:"p"`
//Topic int `form:"topic"`
//K1 int `form:"k1"`
//K2 int `form:"k2"`
//Keyword string `form:"keyword"`
//SupplierId string `form:"supplier_id"`
//SupplierName string `form:"supplier_name"`
//Stock int `form:"stock"`
GetGoodsBySupplierRequest
}
package requests
type ExactGoodsRequest struct {
SupplierId string `json:"supplier_id"`
GoodsName string `json:"goods_name"`
}
package requests
import (
"github.com/syyongx/php2go"
"go_sku_server/pkg/config"
)
type QuoteIndexRequest struct {
GetGoodsBySupplierRequest
}
type QuoteGetDataRequest struct {
Keyword string `form:"keyword"`
SupplierName string `form:"supplier_name"`
}
func CheckQuoteRequest(r QuoteIndexRequest) (errCode int, errMsg string) {
//解码参数
var err error
if r.Keyword != "" {
r.Keyword, err = php2go.URLDecode(r.Keyword)
if err != nil {
return 1, "参数解码失败"
}
}
//判断参数
if r.Keyword == "" || r.SupplierId == "" {
return 1, "缺少参数"
}
//判断供应商
if config.Get("SUPPLIER_ALL."+r.SupplierId).String() == "" {
return 1, "供应商id有误"
}
return
}
package requests
type SumIpRequest struct {
StartTime int64 `form:"start_time"`
EndTime int64 `form:"end_time"`
Size int `form:"size"`
}
type ScrollRequest struct {
Scroll int `form:"scroll"`
ScrollId int `form:"scroll_id"`
}
package requests
type SetButtonRequest struct {
Val int `form:"val"`
}
type GetWbListRequest struct {
ListType int `form:"type"`
}
type SetWbListRequest struct {
Type string `form:"type"`
IpList string `form:"ip_list"`
AddOrRm string `form:"add_or_rm"`
}
type SetIpalgRequest struct {
Ip string `form:"ip"`
ListType int `form:"type"`
Num int `json:"num"`
}
\ No newline at end of file
#!/bin/bash
cd /data/gocode/go_sku_server
git pull origin dev
cp /data/gocode/go_sku_server/conf/prod/config.ini.prod /data/gocode/go_sku_server/conf/config.ini
cp /data/gocode/go_sku_server/conf/prod/database.ini.prod /data/gocode/go_sku_server/conf/database.ini
cp /data/gocode/go_sku_server/conf/prod/message.ini.prod /data/gocode/go_sku_server/conf/message.ini
cp /data/gocode/go_sku_server/conf/prod/rabmq_key.ini.prod /data/gocode/go_sku_server/conf/rabmq_key.ini
cp /data/gocode/go_sku_server/conf/prod/redis_config.ini.prod /data/gocode/go_sku_server/conf/redis_config.ini
cp /data/gocode/go_sku_server/conf/prod/redis_key.ini.prod /data/gocode/go_sku_server/conf/redis_key.ini
cp /data/gocode/go_sku_server/conf/prod/search.ini.prod /data/gocode/go_sku_server/conf/search.ini
go build -o ./cmd/search_http_server ./cmd/search_http_server.go
supervisorctl restart go_sku_server
go build -o ./cmd/http/http_server ./cmd/http/http_server.go
go build -o ./cmd/http/cron ./cmd/http/cron_server.go
supervisorctl restart go_sku_server_http
\ No newline at end of file
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