- JWT claims extended with tenantId; login enforces strict tenant verification - AuthorityMiddleware: tenant scope check + Casbin path permission + anti-spoofing - CRM relation API (upstream/downstream one-hop, create/update/history, full graph) - CrmRepo backed by PostgreSQL with $N placeholders - gRPC tenant propagation via UnaryClientInterceptor (x-tenant-id metadata) - All legacy tables (12) gain tenant_id column with indexes - All model queries inject WHERE tenant_id filter - Casbin gorm-adapter downgraded to v3.28.0 for v2 compatibility - GraphSyncWorker (Kafka -> Neo4j) with idempotent MERGE - Full graph API restricted to admin role only - Database migrations for MySQL (CRM tables + tenant columns) and PostgreSQL (CRM init) - Docker Compose: added postgres service to main stack, graph stack with Kafka/Debezium/Neo4j Made-with: Cursor
68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/model"
|
|
"muyu-apiserver/pkg/tenantctx"
|
|
"muyu-apiserver/rpc/system/internal/svc"
|
|
"muyu-apiserver/rpc/system/pb"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
type ListConfigLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewListConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListConfigLogic {
|
|
return &ListConfigLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *ListConfigLogic) ListConfig(in *pb.ListConfigReq) (*pb.ListConfigResp, error) {
|
|
tenantId := tenantctx.ExtractTenantId(l.ctx)
|
|
|
|
var err error
|
|
var configs []*model.SysConfig
|
|
|
|
if in.ConfigGroup != "" {
|
|
configs, err = l.svcCtx.ConfigModel.FindByGroup(l.ctx, tenantId, in.ConfigGroup)
|
|
} else {
|
|
configs, err = l.svcCtx.ConfigModel.FindAll(l.ctx, tenantId)
|
|
}
|
|
if err != nil {
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
}
|
|
|
|
list := make([]*pb.ConfigInfo, 0, len(configs))
|
|
for _, cfg := range configs {
|
|
var configValue, remark string
|
|
if cfg.ConfigValue.Valid {
|
|
configValue = cfg.ConfigValue.String
|
|
}
|
|
if cfg.Remark.Valid {
|
|
remark = cfg.Remark.String
|
|
}
|
|
|
|
list = append(list, &pb.ConfigInfo{
|
|
ConfigId: cfg.ConfigId,
|
|
ConfigKey: cfg.ConfigKey,
|
|
ConfigValue: configValue,
|
|
ConfigName: cfg.ConfigName,
|
|
ConfigGroup: cfg.ConfigGroup,
|
|
Remark: remark,
|
|
UpdatedAt: cfg.UpdatedAt.Format("2006-01-02 15:04:05"),
|
|
})
|
|
}
|
|
|
|
return &pb.ListConfigResp{List: list}, nil
|
|
}
|