factroy store
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 30s
CI / admin (push) Successful in 22s
CI / bff (push) Successful in 19s
CI / chore (push) Successful in 20s
CI / equipment (push) Successful in 20s
CI / express (push) Successful in 21s
CI / factory (push) Failing after 3s
CI / payment (push) Failing after 5s
CI / product (push) Successful in 18s
CI / record (push) Successful in 18s
CI / sale (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 19s
CI / wecom (push) Successful in 19s
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 30s
CI / admin (push) Successful in 22s
CI / bff (push) Successful in 19s
CI / chore (push) Successful in 20s
CI / equipment (push) Successful in 20s
CI / express (push) Successful in 21s
CI / factory (push) Failing after 3s
CI / payment (push) Failing after 5s
CI / product (push) Successful in 18s
CI / record (push) Successful in 18s
CI / sale (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 19s
CI / wecom (push) Successful in 19s
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
login_out_time=43200 #api接口超时时间分
|
||||
login_refresh_out_time=83200
|
||||
name = "sale-service"
|
||||
listenOn = "0.0.0.0:10700"
|
||||
listenOn = "0.0.0.0:10300"
|
||||
mode = "dev"
|
||||
[log]
|
||||
path = "logs"
|
||||
@@ -53,5 +53,7 @@
|
||||
|
||||
[encrypt]
|
||||
data_key = "u2t9T3luZtoRfhBstkFN6TiIMW38BA8a"
|
||||
|
||||
[services]
|
||||
chore = "chore-service"
|
||||
chore = "chore-service"
|
||||
user = "user-service"
|
||||
@@ -0,0 +1,13 @@
|
||||
package dao
|
||||
|
||||
import "lone-services/pkg/utils"
|
||||
|
||||
type Tags struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
TagID int64 `gorm:"column:tag_id" json:"tag_id"`
|
||||
Remarks string `gorm:"column:remarks" json:"remarks"`
|
||||
Status uint8 `gorm:"column:status" json:"status"`
|
||||
CreatedAt utils.CustomTime `gorm:"column:created_at" json:"created_at"`
|
||||
UpdatedAt utils.CustomTime `gorm:"column:updated_at" json:"updated_at"`
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/wecom/tags"
|
||||
wecom "lone-services/rpc/wecom/pb"
|
||||
"lone-services/services/wecom/internal/dao"
|
||||
"lone-services/services/wecom/internal/model"
|
||||
"lone-services/services/wecom/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateTagsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreateTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTagsLogic {
|
||||
return &CreateTagsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateTagsLogic) CreateTags(in *wecom.CreateTagsReq) (*wecom.Response, error) {
|
||||
|
||||
client := NewTagClient()
|
||||
data := tags.CreateRequest{
|
||||
TagName: in.Name,
|
||||
}
|
||||
tag, err := client.Create(l.ctx, data)
|
||||
if err != nil {
|
||||
l.Logger.Error("create tag error", "error", err)
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
create := dao.Tags{
|
||||
Name: in.Name,
|
||||
Remarks: in.Remarks,
|
||||
Status: 1,
|
||||
TagID: tag.TagID,
|
||||
CreatedAt: utils.Now(),
|
||||
}
|
||||
err = model.TagsModel{}.Init().Create(&create)
|
||||
if err != nil {
|
||||
l.Logger.Error("create tag error", "error", err)
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
return okResponse(nil), nil
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/wecom/auth"
|
||||
"lone-services/pkg/wecom/tags"
|
||||
"lone-services/services/wecom/internal/dao"
|
||||
"lone-services/services/wecom/internal/model"
|
||||
|
||||
@@ -128,3 +130,7 @@ func cleanAgentIds(ids []int64) []int64 {
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func NewTagClient() *tags.Client {
|
||||
return tags.NewClient(auth.NewClient(utils.GetConfigString("wecom.corp_id"), utils.GetConfigString("wecom.corp_secret")))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
wecom "lone-services/rpc/wecom/pb"
|
||||
"lone-services/services/wecom/internal/dao"
|
||||
"lone-services/services/wecom/internal/model"
|
||||
"lone-services/services/wecom/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ItemsTagsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewItemsTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemsTagsLogic {
|
||||
return &ItemsTagsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ItemsTagsLogic) ItemsTags(in *wecom.ItemsTagsReq) (*wecom.Response, error) {
|
||||
|
||||
w := modelbase.Params{
|
||||
Page: int(in.Page),
|
||||
Size: int(in.PageSize),
|
||||
Order: "id desc",
|
||||
}
|
||||
|
||||
if in.Name != utils.StringEmpty {
|
||||
w.Like["name"] = "%" + in.Name + "%"
|
||||
}
|
||||
var data []dao.Tags
|
||||
page, err := model.TagsModel{}.Init().Page(w, &data)
|
||||
if err != nil {
|
||||
return failResponse(utils.Fail), nil
|
||||
}
|
||||
return okResponse(page), nil
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"lone-services/pkg/modelbase"
|
||||
)
|
||||
|
||||
type TagsModel struct {
|
||||
modelbase.Base
|
||||
}
|
||||
|
||||
func (m TagsModel) TableName() string {
|
||||
return modelbase.Prefix() + "tags"
|
||||
}
|
||||
|
||||
func (m TagsModel) Init() TagsModel {
|
||||
m.Table = m.TableName()
|
||||
return m
|
||||
}
|
||||
@@ -57,3 +57,13 @@ func (s *WecomServer) Types(ctx context.Context, in *wecom.EmptyReq) (*wecom.Res
|
||||
l := logic.NewTypesLogic(ctx, s.svcCtx)
|
||||
return l.Types(in)
|
||||
}
|
||||
|
||||
func (s *WecomServer) CreateTags(ctx context.Context, in *wecom.CreateTagsReq) (*wecom.Response, error) {
|
||||
l := logic.NewCreateTagsLogic(ctx, s.svcCtx)
|
||||
return l.CreateTags(in)
|
||||
}
|
||||
|
||||
func (s *WecomServer) ItemsTags(ctx context.Context, in *wecom.ItemsTagsReq) (*wecom.Response, error) {
|
||||
l := logic.NewItemsTagsLogic(ctx, s.svcCtx)
|
||||
return l.ItemsTags(in)
|
||||
}
|
||||
|
||||
@@ -14,9 +14,11 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
CreateTagsReq = wecom.CreateTagsReq
|
||||
CreateUserReq = wecom.CreateUserReq
|
||||
DeleteUserReq = wecom.DeleteUserReq
|
||||
EmptyReq = wecom.EmptyReq
|
||||
ItemsTagsReq = wecom.ItemsTagsReq
|
||||
ItemsUserReq = wecom.ItemsUserReq
|
||||
Response = wecom.Response
|
||||
StatusUserReq = wecom.StatusUserReq
|
||||
@@ -30,6 +32,8 @@ type (
|
||||
DeleteUser(ctx context.Context, in *DeleteUserReq, opts ...grpc.CallOption) (*Response, error)
|
||||
ItemsAgents(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error)
|
||||
Types(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error)
|
||||
CreateTags(ctx context.Context, in *CreateTagsReq, opts ...grpc.CallOption) (*Response, error)
|
||||
ItemsTags(ctx context.Context, in *ItemsTagsReq, opts ...grpc.CallOption) (*Response, error)
|
||||
}
|
||||
|
||||
defaultWecom struct {
|
||||
@@ -77,3 +81,13 @@ func (m *defaultWecom) Types(ctx context.Context, in *EmptyReq, opts ...grpc.Cal
|
||||
client := wecom.NewWecomClient(m.cli.Conn())
|
||||
return client.Types(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultWecom) CreateTags(ctx context.Context, in *CreateTagsReq, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := wecom.NewWecomClient(m.cli.Conn())
|
||||
return client.CreateTags(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultWecom) ItemsTags(ctx context.Context, in *ItemsTagsReq, opts ...grpc.CallOption) (*Response, error) {
|
||||
client := wecom.NewWecomClient(m.cli.Conn())
|
||||
return client.ItemsTags(ctx, in, opts...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user