Commit ec776a94 authored by 张振华's avatar 张振华

refactor

parent af0e35c9
...@@ -242,7 +242,7 @@ func GuessQueryRawTxCmd() *cobra.Command { ...@@ -242,7 +242,7 @@ func GuessQueryRawTxCmd() *cobra.Command {
} }
func addGuessQueryFlags(cmd *cobra.Command) { func addGuessQueryFlags(cmd *cobra.Command) {
cmd.Flags().Int32P("type", "t", 1, "query type, 1:Ids,2:Id,3:Addr,4:Status,5:AdminAddr,6:AddrStatus,7:AdminStatus,8:CategoryStatus") cmd.Flags().StringP("type", "t", "", "query type:ids,id,addr,status,adminAddr,addrStatus,adminStatus,categoryStatus")
cmd.Flags().StringP("gameId", "g", "", "game Id") cmd.Flags().StringP("gameId", "g", "", "game Id")
cmd.Flags().StringP("addr", "a", "", "address") cmd.Flags().StringP("addr", "a", "", "address")
cmd.Flags().StringP("adminAddr", "m", "", "admin address") cmd.Flags().StringP("adminAddr", "m", "", "admin address")
...@@ -254,7 +254,7 @@ func addGuessQueryFlags(cmd *cobra.Command) { ...@@ -254,7 +254,7 @@ func addGuessQueryFlags(cmd *cobra.Command) {
func guessQuery(cmd *cobra.Command, args []string) { func guessQuery(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
ty, _ := cmd.Flags().GetInt32("type") ty, _ := cmd.Flags().GetString("type")
gameID, _ := cmd.Flags().GetString("gameId") gameID, _ := cmd.Flags().GetString("gameId")
addr, _ := cmd.Flags().GetString("addr") addr, _ := cmd.Flags().GetString("addr")
adminAddr, _ := cmd.Flags().GetString("adminAddr") adminAddr, _ := cmd.Flags().GetString("adminAddr")
...@@ -276,7 +276,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -276,7 +276,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
//7:QueryGameByAdminStatus, //7:QueryGameByAdminStatus,
//8:QueryGameByCategoryStatus, //8:QueryGameByCategoryStatus,
switch ty { switch ty {
case 1: case "ids":
gameIds := strings.Split(gameIDs, ";") gameIds := strings.Split(gameIDs, ";")
req := &gty.QueryGuessGameInfos{ req := &gty.QueryGuessGameInfos{
GameIDs: gameIds, GameIDs: gameIds,
...@@ -287,7 +287,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -287,7 +287,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
case 2: case "id":
req := &gty.QueryGuessGameInfo{ req := &gty.QueryGuessGameInfo{
GameID: gameID, GameID: gameID,
} }
...@@ -297,7 +297,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -297,7 +297,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
case 3: case "addr":
req := &gty.QueryGuessGameInfo{ req := &gty.QueryGuessGameInfo{
Addr: addr, Addr: addr,
Index: index, Index: index,
...@@ -308,7 +308,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -308,7 +308,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
case 4: case "status":
req := &gty.QueryGuessGameInfo{ req := &gty.QueryGuessGameInfo{
Status: status, Status: status,
Index: index, Index: index,
...@@ -319,7 +319,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -319,7 +319,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
case 5: case "adminAddr":
req := &gty.QueryGuessGameInfo{ req := &gty.QueryGuessGameInfo{
AdminAddr: adminAddr, AdminAddr: adminAddr,
Index: index, Index: index,
...@@ -330,7 +330,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -330,7 +330,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
case 6: case "addrStatus":
req := &gty.QueryGuessGameInfo{ req := &gty.QueryGuessGameInfo{
Addr: addr, Addr: addr,
Status: status, Status: status,
...@@ -342,7 +342,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -342,7 +342,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
case 7: case "adminStatus":
req := &gty.QueryGuessGameInfo{ req := &gty.QueryGuessGameInfo{
AdminAddr: adminAddr, AdminAddr: adminAddr,
Status: status, Status: status,
...@@ -354,7 +354,7 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -354,7 +354,7 @@ func guessQuery(cmd *cobra.Command, args []string) {
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
case 8: case "categoryStatus":
req := &gty.QueryGuessGameInfo{ req := &gty.QueryGuessGameInfo{
Category: category, Category: category,
Status: status, Status: status,
...@@ -365,5 +365,8 @@ func guessQuery(cmd *cobra.Command, args []string) { ...@@ -365,5 +365,8 @@ func guessQuery(cmd *cobra.Command, args []string) {
var res gty.GuessGameRecords var res gty.GuessGameRecords
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res) ctx := jsonrpc.NewRPCCtx(rpcLaddr, "Chain33.Query", params, &res)
ctx.Run() ctx.Run()
default:
fmt.Println("Wrong type:", ty, " ,only support: ids,id,addr,status,adminAddr,addrStatus,adminStatus,categoryStatus")
} }
} }
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 to comment