jiaojiao7 4 år sedan
förälder
incheckning
8af59eba6f

+ 1 - 1
api/etc/integral-api.yaml

@@ -1,7 +1,7 @@
 Name: integral-api
 Host: 0.0.0.0
 Port: 8888
-resources:
+ResourcesCenter:
   Etcd:
     Hosts:
       - 127.0.0.1:2379

+ 23 - 18
api/integral.api

@@ -1,20 +1,25 @@
 syntax = "v1"
 
 type resourcesReq {
-	AccountId      string `json:"accountId"`               //账户标识
-	CompanyId      int64  `json:"companyId,optional"`      //企业标识
-	DepartmentId   int64  `json:"departmentId,optional"`   //组织标识
-	Name           string `json:"name"`                    //资源名称
-	ResourceType   string `json:"resourceType"`            //资源类型
-	Number         int64  `json:"number"`                  //数量
-	Spec           string `json:"spec,optional"`           //规格
-	AppId          string `json:"appId"`                   //标识
-	Model          int64  `json:"model"`                   //操作类型0使用1新增
-	RuleId         string `json:"ruleId,optional"`         //使用规则标识
-	UserId         string `json:"userId"`                  //用户标识
-	Url            string `json:"url,optional"`            //下载地址
-	SearchCriteria string `json:"searchCriteria,optional"` //搜索条件
-	Source         string `json:"source,optional"`         //数据来源
+	AccountId        string `form:"accountId"`                 //账户标识
+	CompanyId        int64  `form:"companyId,optional"`        //企业标识
+	DepartmentId     int64  `form:"departmentId,optional"`     //组织标识
+	Name             string `form:"name"`                      //资源名称
+	ResourceType     string `form:"resourceType"`              //资源类型
+	Number           int64  `form:"number"`                    //数量
+	Spec             string `form:"spec,optional"`             //规格
+	AppId            string `form:"appId"`                     //标识
+	Model            int64  `form:"model"`                     //操作类型0使用1新增
+	RuleId           string `form:"ruleId,optional"`           //使用规则标识
+	UserId           string `form:"userId"`                    //用户标识
+	Url              string `form:"url,optional"`              //下载地址
+	SearchCriteria   string `form:"searchCriteria,optional"`   //搜索条件
+	Source           string `form:"source,optional"`           //数据来源
+	StartTime        string `form:"startTime,optional"`        //新增时数据包开始时间
+	EndTime          string `form:"endTime,optional"`          //新增时数据包截止时间
+	InfoId           string `form:"infoId,optional"`           //信息标识
+	DuplicateRemoval int64  `form:"duplicateRemoval,optional"` //是否去重0不去1去重
+
 }
 
 type resourcesRes {
@@ -23,9 +28,9 @@ type resourcesRes {
 	Message string `form:"message"`
 }
 type previewReq {
-	InfoId        string `json:"infoId,optional"`        //信息标识
-	AccountId     string `json:"accountId,optional"`     //企业标识
-	DeductionType string `json:"deductionType,optional"` //资源代码
+	InfoId        string `form:"infoId,optional"`        //信息标识
+	AccountId     string `form:"accountId,optional"`     //企业标识
+	DeductionType string `form:"deductionType,optional"` //资源代码
 }
 
 type previewRes {
@@ -63,7 +68,7 @@ type authRes {
 service integral-api {
 	//资源操作
 	@handler UpdateUserBalanceHandler // TODO: set handler name and delete this comment
-	post /updateUserBalance (resourcesReq) returns(previewRes)
+	post /resources/updateUserBalance (resourcesReq) returns(resourcesRes)
 	//预览信息
 	@handler FindPreviewHandler // TODO: set handler name and delete this comment
 	post /findPreview (previewReq) returns(previewRes)

+ 5 - 1
api/internal/config/config.go

@@ -1,7 +1,11 @@
 package config
 
-import "github.com/tal-tech/go-zero/rest"
+import (
+	"github.com/tal-tech/go-zero/rest"
+	"github.com/tal-tech/go-zero/zrpc"
+)
 
 type Config struct {
 	rest.RestConf
+	ResourcesCenter zrpc.RpcClientConf
 }

+ 2 - 2
api/internal/handler/routes.go

@@ -14,12 +14,12 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 		[]rest.Route{
 			{
 				Method:  http.MethodPost,
-				Path:    "/updateUserBalance",
+				Path:    "/resources/updateUserBalance",
 				Handler: UpdateUserBalanceHandler(serverCtx),
 			},
 			{
 				Method:  http.MethodPost,
-				Path:    "/findPreview",
+				Path:    "/resources/findPreview",
 				Handler: FindPreviewHandler(serverCtx),
 			},
 			{

+ 24 - 2
api/internal/logic/findpreviewlogic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	"context"
+	"fmt"
 
 	"app.yhyue.com/moapp/jyResourcesCenter/api/internal/svc"
 	"app.yhyue.com/moapp/jyResourcesCenter/api/internal/types"
@@ -25,6 +26,27 @@ func NewFindPreviewLogic(ctx context.Context, svcCtx *svc.ServiceContext) FindPr
 
 func (l *FindPreviewLogic) FindPreview(req types.PreviewReq) (*types.PreviewRes, error) {
 	// todo: add your logic here and delete this line
-
-	return &types.PreviewRes{}, nil
+	result := &types.PreviewRes{}
+	fmt.Println(req)
+	//lsi := l.svcCtx.ResourcesCenter
+	/*resp, err := lsi(l.ctx, &activityclient.UpdateStateReq{
+		UserId:         req.UserId,
+		AppId:          req.AppId,
+		UserLottertId:  req.UserLotteryId,
+		Model:          req.Model,
+		OrderCode:      req.OrderCode,
+		UserName:       req.UserName,
+		DiscountId:     req.DiscountId,
+		UserPhone:      req.UserPhone,
+		UseProduct:     req.UseProduct,
+		UseProductType: req.UseProductType,
+	})
+	if err != nil {
+		return nil, err
+	}*/
+	result.Code = 0
+	result.Message = "资源重复查询"
+	result.DeductionNumb=0
+	result.RepeatNumb=0
+	return result, nil
 }

+ 23 - 3
api/internal/logic/updateuserbalancelogic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	"context"
+	"fmt"
 
 	"app.yhyue.com/moapp/jyResourcesCenter/api/internal/svc"
 	"app.yhyue.com/moapp/jyResourcesCenter/api/internal/types"
@@ -23,8 +24,27 @@ func NewUpdateUserBalanceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 	}
 }
 
-func (l *UpdateUserBalanceLogic) UpdateUserBalance(req types.ResourcesReq) (*types.PreviewRes, error) {
+func (l *UpdateUserBalanceLogic) UpdateUserBalance(req types.ResourcesReq) (*types.ResourcesRes, error) {
 	// todo: add your logic here and delete this line
-
-	return &types.PreviewRes{}, nil
+	result := &types.ResourcesRes{}
+	fmt.Println(req)
+	//lsi := l.svcCtx.ResourcesCenter
+	/*resp, err := lsi(l.ctx, &activityclient.UpdateStateReq{
+		UserId:         req.UserId,
+		AppId:          req.AppId,
+		UserLottertId:  req.UserLotteryId,
+		Model:          req.Model,
+		OrderCode:      req.OrderCode,
+		UserName:       req.UserName,
+		DiscountId:     req.DiscountId,
+		UserPhone:      req.UserPhone,
+		UseProduct:     req.UseProduct,
+		UseProductType: req.UseProductType,
+	})
+	if err != nil {
+		return nil, err
+	}*/
+	result.Code = 0
+	result.Message = "资源操作成功"
+	return result, nil
 }

+ 4 - 0
api/internal/svc/servicecontext.go

@@ -2,14 +2,18 @@ package svc
 
 import (
 	"app.yhyue.com/moapp/jyResourcesCenter/api/internal/config"
+	"app.yhyue.com/moapp/jyResourcesCenter/rpc/resourcesCenterclient"
+	"github.com/tal-tech/go-zero/zrpc"
 )
 
 type ServiceContext struct {
 	Config config.Config
+	ResourcesCenter resourcesCenterclient.ResourcesCenter
 }
 
 func NewServiceContext(c config.Config) *ServiceContext {
 	return &ServiceContext{
 		Config: c,
+		ResourcesCenter:resourcesCenterclient.NewResourcesCenter(zrpc.MustNewClient(c.ResourcesCenter)),
 	}
 }

+ 21 - 17
api/internal/types/types.go

@@ -2,20 +2,24 @@
 package types
 
 type ResourcesReq struct {
-	AccountId      string `json:"accountId"`               //账户标识
-	CompanyId      int64  `json:"companyId,optional"`      //企业标识
-	DepartmentId   int64  `json:"departmentId,optional"`   //组织标识
-	Name           string `json:"name"`                    //资源名称
-	ResourceType   string `json:"resourceType"`            //资源类型
-	Number         int64  `json:"number"`                  //数量
-	Spec           string `json:"spec,optional"`           //规格
-	AppId          string `json:"appId"`                   //标识
-	Model          int64  `json:"model"`                   //操作类型0使用1新增
-	RuleId         string `json:"ruleId,optional"`         //使用规则标识
-	UserId         string `json:"userId"`                  //用户标识
-	Url            string `json:"url,optional"`            //下载地址
-	SearchCriteria string `json:"searchCriteria,optional"` //搜索条件
-	Source         string `json:"source,optional"`         //数据来源
+	AccountId        string `form:"accountId"`                 //账户标识
+	CompanyId        int64  `form:"companyId,optional"`        //企业标识
+	DepartmentId     int64  `form:"departmentId,optional"`     //组织标识
+	Name             string `form:"name"`                      //资源名称
+	ResourceType     string `form:"resourceType"`              //资源类型
+	Number           int64  `form:"number"`                    //数量
+	Spec             string `form:"spec,optional"`             //规格
+	AppId            string `form:"appId"`                     //标识
+	Model            int64  `form:"model"`                     //操作类型0使用1新增
+	RuleId           string `form:"ruleId,optional"`           //使用规则标识
+	UserId           string `form:"userId"`                    //用户标识
+	Url              string `form:"url,optional"`              //下载地址
+	SearchCriteria   string `form:"searchCriteria,optional"`   //搜索条件
+	Source           string `form:"source,optional"`           //数据来源
+	StartTime        string `form:"startTime,optional"`        //新增时数据包开始时间
+	EndTime          string `form:"endTime,optional"`          //新增时数据包截止时间
+	InfoId           string `form:"infoId,optional"`           //信息标识
+	DuplicateRemoval int64  `form:"duplicateRemoval,optional"` //是否去重0不去1去重
 }
 
 type ResourcesRes struct {
@@ -24,9 +28,9 @@ type ResourcesRes struct {
 }
 
 type PreviewReq struct {
-	InfoId        string `json:"infoId,optional"`        //信息标识
-	AccountId     string `json:"accountId,optional"`     //企业标识
-	DeductionType string `json:"deductionType,optional"` //资源代码
+	InfoId        string `form:"infoId,optional"`        //信息标识
+	AccountId     string `form:"accountId,optional"`     //企业标识
+	DeductionType string `form:"deductionType,optional"` //资源代码
 }
 
 type PreviewRes struct {

+ 1 - 0
go.sum

@@ -165,6 +165,7 @@ github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGn
 github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
 github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=
 github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA=
 github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=