WH01243 4 years ago
parent
commit
e391ed0fc6
2 changed files with 29 additions and 2 deletions
  1. 9 2
      rpc/internal/logic/integralconsumelogic.go
  2. 20 0
      rpc/test/consume_test.go

+ 9 - 2
rpc/internal/logic/integralconsumelogic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	"context"
+	"points_service/service"
 
 	"points_service/rpc/integral"
 	"points_service/rpc/internal/svc"
@@ -15,6 +16,10 @@ type IntegralConsumeLogic struct {
 	logx.Logger
 }
 
+var (
+	integralService = &service.IntegralService{}
+)
+
 func NewIntegralConsumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *IntegralConsumeLogic {
 	return &IntegralConsumeLogic{
 		ctx:    ctx,
@@ -26,6 +31,8 @@ func NewIntegralConsumeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *I
 // 消耗积分
 func (l *IntegralConsumeLogic) IntegralConsume(in *integral.AddReq) (*integral.AddResp, error) {
 	// todo: add your logic here and delete this line
-
-	return &integral.AddResp{}, nil
+	integralService.IntegralConsumeService("ABC", "1", "2021-03-10 08:00:00", "2021-03-20",1, 1, 1, 10000)
+	return &integral.AddResp{
+		Status: true,
+	},nil
 }

+ 20 - 0
rpc/test/consume_test.go

@@ -0,0 +1,20 @@
+package test
+
+import (
+	"context"
+	"github.com/tal-tech/go-zero/zrpc"
+	"log"
+	"points_service/rpc/integral"
+	"points_service/rpc/integralclient"
+	"testing"
+	"time"
+)
+
+func  Test_Consume(t *testing.T)  {
+	ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+	FileSystem :=integralclient.NewIntegral(zrpc.MustNewClient(c.FileSystemConf))
+	req := &integral.AddReq{UserId: "xzh", CountPoints: 123}
+	res, err := FileSystem.IntegralConsume(ctx, req)
+	log.Println("err ", err)
+	log.Println("req ", res)
+}