Commit 97bec1849e40423c50033aa553bca868d0fe6f0e
1 parent
4a502dd5
fix: 账号系统只有一个数据库。
Showing
4 changed files
with
55 additions
and
14 deletions
Show diff stats
cmd/gameserver/action/GmAction.go renamed to cmd/gameserver/gmaction/GmAction.go
cmd/httpserver/action/AccountAction.go
@@ -19,12 +19,13 @@ type AccountAction struct { | @@ -19,12 +19,13 @@ type AccountAction struct { | ||
19 | HttpServer *service.AccountServer | 19 | HttpServer *service.AccountServer |
20 | } | 20 | } |
21 | 21 | ||
22 | -/*Register 账号注册 | ||
23 | -2 验证码转化为string错误 | ||
24 | -3 验证码错误 | ||
25 | -4 手机号已存在,不用重复注册 | ||
26 | -5 uid get error | ||
27 | -6 mongo create error | 22 | +/* |
23 | +Register 账号注册 | ||
24 | + 2 验证码转化为string错误 | ||
25 | + 3 验证码错误 | ||
26 | + 4 手机号已存在,不用重复注册 | ||
27 | + 5 uid get error | ||
28 | + 6 mongo create error | ||
28 | */ | 29 | */ |
29 | func (h *AccountAction) Register(c *gin.Context) (int, interface{}) { | 30 | func (h *AccountAction) Register(c *gin.Context) (int, interface{}) { |
30 | var register pb.Register | 31 | var register pb.Register |
@@ -64,9 +65,10 @@ func (h *AccountAction) Register(c *gin.Context) (int, interface{}) { | @@ -64,9 +65,10 @@ func (h *AccountAction) Register(c *gin.Context) (int, interface{}) { | ||
64 | return 0, "success" | 65 | return 0, "success" |
65 | } | 66 | } |
66 | 67 | ||
67 | -/*Login 登录 | ||
68 | -2 账号不存在 | ||
69 | -3 密码错误 | 68 | +/* |
69 | +Login 登录 | ||
70 | + 2 账号不存在 | ||
71 | + 3 密码错误 | ||
70 | */ | 72 | */ |
71 | func (h *AccountAction) Login(c *gin.Context) (int, interface{}) { | 73 | func (h *AccountAction) Login(c *gin.Context) (int, interface{}) { |
72 | var login pb.Account | 74 | var login pb.Account |
@@ -97,9 +99,10 @@ func (h *AccountAction) Login(c *gin.Context) (int, interface{}) { | @@ -97,9 +99,10 @@ func (h *AccountAction) Login(c *gin.Context) (int, interface{}) { | ||
97 | return 0, rsp | 99 | return 0, rsp |
98 | } | 100 | } |
99 | 101 | ||
100 | -/*Sms 发短信 | ||
101 | -2 发送太频繁 | ||
102 | -3 发送失败 | 102 | +/* |
103 | +Sms 发短信 | ||
104 | + 2 发送太频繁 | ||
105 | + 3 发送失败 | ||
103 | */ | 106 | */ |
104 | func (h *AccountAction) Sms(c *gin.Context) (int, interface{}) { | 107 | func (h *AccountAction) Sms(c *gin.Context) (int, interface{}) { |
105 | phone, ok := c.GetQuery("phone") | 108 | phone, ok := c.GetQuery("phone") |
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +package main | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "os" | ||
6 | + "os/signal" | ||
7 | + "pro2d/cmd/httpserver/action" | ||
8 | + "pro2d/cmd/httpserver/service" | ||
9 | + "pro2d/common" | ||
10 | + "pro2d/common/logger" | ||
11 | + "syscall" | ||
12 | +) | ||
13 | + | ||
14 | +func main() { | ||
15 | + err := make(chan error) | ||
16 | + stopChan := make(chan os.Signal) | ||
17 | + signal.Notify(stopChan, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL) | ||
18 | + | ||
19 | + common.GlobalSconf = common.GlobalConf.AccountConf | ||
20 | + | ||
21 | + web := service.NewAccountServer("v1", fmt.Sprintf(":%d", common.GlobalSconf.Port)) | ||
22 | + web.BindHandler(&action.AccountAction{HttpServer: web}) | ||
23 | + go func() { | ||
24 | + err <- web.Start() | ||
25 | + }() | ||
26 | + | ||
27 | + select { | ||
28 | + case e := <-err: | ||
29 | + logger.Error("http server error: %v", e) | ||
30 | + case <-stopChan: | ||
31 | + logger.Debug("http stop") | ||
32 | + web.Stop() | ||
33 | + } | ||
34 | +} |
common/db/mongoproxy/mongoplugin.go
@@ -47,7 +47,11 @@ func ConnectMongo(conf *common.MongoConf, ID int64) error { | @@ -47,7 +47,11 @@ func ConnectMongo(conf *common.MongoConf, ID int64) error { | ||
47 | return err | 47 | return err |
48 | } | 48 | } |
49 | 49 | ||
50 | - mongoDatabase = mongoClient.Database(fmt.Sprintf("%s_%d", conf.DBName, ID)) | 50 | + if conf.DBName != "account" { |
51 | + mongoDatabase = mongoClient.Database(fmt.Sprintf("%s_%d", conf.DBName, ID)) | ||
52 | + } else { | ||
53 | + mongoDatabase = mongoClient.Database(conf.DBName) | ||
54 | + } | ||
51 | return nil | 55 | return nil |
52 | } | 56 | } |
53 | 57 |