区分环境
This commit is contained in:
19
apps/user/etc/user.dev.yaml
Normal file
19
apps/user/etc/user.dev.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
Name: user.rpc
|
||||
ListenOn: 0.0.0.0:11001
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: user.rpc
|
||||
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
AuthJWT:
|
||||
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
|
||||
AccessExpire: 86400 # JWT过期时间
|
||||
CacheRedis:
|
||||
- Host: "127.0.0.1:6379"
|
||||
Pass: "" # Redis 密码,如果未设置则留空
|
||||
Type: "node" # 单节点模式
|
||||
SentinelRpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: sentinel.rpc
|
||||
@@ -2,18 +2,18 @@ Name: user.rpc
|
||||
ListenOn: 0.0.0.0:11001
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
- tyapi_etcd:2379
|
||||
Key: user.rpc
|
||||
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
DataSource: "tianyuanapi:g3h98u0291j@tcp(tyapi_mysql:3306)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
AuthJWT:
|
||||
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
|
||||
AccessExpire: 86400 # JWT过期时间
|
||||
CacheRedis:
|
||||
- Host: "127.0.0.1:6379"
|
||||
- Host: "tyapi_redis:6379"
|
||||
Pass: "" # Redis 密码,如果未设置则留空
|
||||
Type: "node" # 单节点模式
|
||||
SentinelRpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
- tyapi_etcd:2379
|
||||
Key: sentinel.rpc
|
||||
@@ -24,7 +24,7 @@ func NewGetPendingEnterpriseLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||
}
|
||||
|
||||
// 获取待审核企业列表
|
||||
func (l *GetPendingEnterpriseLogic) GetPendingEnterprise() (*user.GetPendingEnterpriseResp, error) {
|
||||
func (l *GetPendingEnterpriseLogic) GetPendingEnterprise(in *user.GetPendingEnterpriseReq) (*user.GetPendingEnterpriseResp, error) {
|
||||
// 调用 Model 层获取待审核企业列表
|
||||
enterprises, total, err := l.svcCtx.EnterpriseAuthModel.FindPendingList(l.ctx, in.Page, in.PageSize)
|
||||
if err != nil {
|
||||
|
||||
@@ -26,7 +26,7 @@ func NewEnterpriseServer(svcCtx *svc.ServiceContext) *EnterpriseServer {
|
||||
// 获取待审核企业列表
|
||||
func (s *EnterpriseServer) GetPendingEnterprise(ctx context.Context, in *user.GetPendingEnterpriseReq) (*user.GetPendingEnterpriseResp, error) {
|
||||
l := enterpriselogic.NewGetPendingEnterpriseLogic(ctx, s.svcCtx)
|
||||
return l.GetPendingEnterprise()
|
||||
return l.GetPendingEnterprise(in)
|
||||
}
|
||||
|
||||
// 审核企业
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"tianyuan-api/apps/user/internal/config"
|
||||
authServer "tianyuan-api/apps/user/internal/server/auth"
|
||||
@@ -18,9 +19,23 @@ import (
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/user.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
// 读取环境变量 ENV,默认为 "prod"
|
||||
env := os.Getenv("ENV")
|
||||
if env == "" {
|
||||
env = "production"
|
||||
}
|
||||
|
||||
// 根据 ENV 加载不同的配置文件
|
||||
var defaultConfigFile string
|
||||
if env == "development" {
|
||||
defaultConfigFile = "etc/user.dev.yaml" // 开发环境配置
|
||||
} else {
|
||||
defaultConfigFile = "etc/user.yaml" // 生产环境配置
|
||||
}
|
||||
|
||||
// 允许通过命令行参数覆盖配置文件路径
|
||||
configFile := flag.String("f", defaultConfigFile, "the config file")
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
|
||||
Reference in New Issue
Block a user