Browse Source

feat:修改成功返回码

xuzhiheng 3 years ago
parent
commit
579c96af6c
2 changed files with 32 additions and 3 deletions
  1. 29 0
      rpc/test/user_test.go
  2. 3 3
      service/user.go

+ 29 - 0
rpc/test/user_test.go

@@ -25,3 +25,32 @@ func Test_UserAdd(t *testing.T) {
 	log.Println("err ", err)
 	log.Println("res:", res)
 }
+
+// go test -v -run Test_UserUpdate
+func Test_UserUpdate(t *testing.T) {
+	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
+	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	req := &pb.UserIdReq{
+		Id:       int64(4),
+		Appid:    "10000",
+		Phone:    "18530014520",
+		Nickname: "小徐的公司",
+		Company:  "郑州森曼木材有限公司",
+	}
+	res, err := FileSystem.UserUpdate(ctx, req)
+	log.Println("err ", err)
+	log.Println("res:", res)
+}
+
+// go test -v -run Test_UserDel
+func Test_UserDel(t *testing.T) {
+	ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
+	FileSystem := usercenterclient.NewUserCenter(zrpc.MustNewClient(c.FileSystemConf))
+	req := &pb.UserIdReq{
+		Id:    int64(4),
+		Appid: "10000",
+	}
+	res, err := FileSystem.UserDel(ctx, req)
+	log.Println("err ", err)
+	log.Println("res:", res)
+}

+ 3 - 3
service/user.go

@@ -28,7 +28,7 @@ func UserAdd(this *UserAddReq) *UserAddResp {
 		msg = "新增用户失败"
 	}
 	return &UserAddResp{
-		ErrorCode: 1,
+		ErrorCode: entity.SuccessCode,
 		ErrorMsg:  msg,
 		Data:      &UserAdds{Status: int64(status), Id: userId},
 	}
@@ -43,7 +43,7 @@ func UserUpdate(this *UserIdReq) *ExamineResp {
 		msg = "更新用户失败"
 	}
 	return &ExamineResp{
-		ErrorCode: 1,
+		ErrorCode: entity.SuccessCode,
 		ErrorMsg:  msg,
 		Data:      &ExamineData{Status: int64(status)},
 	}
@@ -58,7 +58,7 @@ func UserDel(this *UserIdReq) *ExamineResp {
 		msg = "删除用户失败"
 	}
 	return &ExamineResp{
-		ErrorCode: 1,
+		ErrorCode: entity.SuccessCode,
 		ErrorMsg:  msg,
 		Data:      &ExamineData{Status: int64(status)},
 	}