wangchuanjin 3 жил өмнө
parent
commit
cb2cb42d55

+ 13 - 0
public/entity/base_ent_empower.go

@@ -2,6 +2,7 @@ package entity
 
 import (
 	"database/sql"
+	"strings"
 
 	. "app.yhyue.com/moapp/jybase/common"
 	. "app.yhyue.com/moapp/jybase/date"
@@ -66,3 +67,15 @@ func (b *base_ent_empower) ReEmpower(appid, function_code string, ent_id int64,
 		return r1 >= 0 && r2 == int64(len(ent_user_id)) && r3 > 0
 	})
 }
+
+//取消授权
+func (b *base_ent_empower) CancelEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) bool {
+	args := []interface{}{appid, function_code, ent_id}
+	wh := []string{}
+	for _, v := range ent_user_id {
+		wh = append(wh, "?")
+		args = append(args, v)
+	}
+	r1 := Mysql_BaseService.UpdateOrDeleteBySql(`delete from base_ent_empower where appid=? and function_code=? and ent_id=? and ent_user_id in (`+strings.Join(wh, ",")+`)`, args...)
+	return r1 == int64(len(ent_user_id))
+}

+ 15 - 0
public/service/power.go

@@ -55,3 +55,18 @@ func ReEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) i
 	}
 	return 0
 }
+
+/*
+ * 取消授权
+ * @param appid
+ * @param function_code 功能代码
+ * @param ent_id 企业id
+ * @param ent_user_id 企业用户id
+ * @return 0:失败 1:成功
+ */
+func CancelEmpower(appid, function_code string, ent_id int64, ent_user_id []int64) int64 {
+	if Base_ent_empower.CancelEmpower(appid, function_code, ent_id, ent_user_id) {
+		return 1
+	}
+	return 0
+}

+ 6 - 2
public/service/power_test.go

@@ -24,6 +24,10 @@ func TestHasPowers(t *testing.T) {
 }
 
 func TestReEmpower(t *testing.T) {
-	assert.Equal(t, 1, ReEmpower("10000", "znsj_kf_use", 14184, []int64{4271}))
-	assert.Equal(t, 1, ReEmpower("10000", "znsj_jqr_use", 14184, []int64{4271}))
+	assert.Equal(t, int64(1), ReEmpower("10000", "znsj_kf_use", 14184, []int64{4271, 123}))
+	assert.Equal(t, int64(1), ReEmpower("10000", "znsj_jqr_use", 14184, []int64{4271}))
+}
+
+func TestCancelEmpower(t *testing.T) {
+	assert.Equal(t, int64(1), CancelEmpower("10000", "znsj_kf_use", 14184, []int64{4271, 123}))
 }

+ 46 - 0
rpc/internal/logic/cancelempowerlogic.go

@@ -0,0 +1,46 @@
+package logic
+
+import (
+	"context"
+	"fmt"
+
+	. "bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/service"
+	"bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/resourceCenter/rpc/pb"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CancelEmpowerLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewCancelEmpowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelEmpowerLogic {
+	return &CancelEmpowerLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 取消授权
+func (l *CancelEmpowerLogic) CancelEmpower(in *pb.EmpowerReq) (*pb.Resp, error) {
+	resp := &pb.Resp{}
+	if in.Appid == "" {
+		l.Error(fmt.Sprintf("%+v", in), "无效的参数appid")
+		return resp, nil
+	} else if in.FunctionCode == "" {
+		l.Error(fmt.Sprintf("%+v", in), "无效的参数function_code")
+		return resp, nil
+	} else if in.EntId == 0 {
+		l.Error(fmt.Sprintf("%+v", in), "无效的参数ent_id")
+		return resp, nil
+	} else if len(in.EntUserId) == 0 {
+		l.Error(fmt.Sprintf("%+v", in), "无效的参数ent_user_id")
+		return resp, nil
+	}
+	resp.Status = CancelEmpower(in.Appid, in.FunctionCode, in.EntId, in.EntUserId)
+	return resp, nil
+}

+ 2 - 2
rpc/internal/logic/reempowerlogic.go

@@ -25,8 +25,8 @@ func NewReEmpowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReEmpow
 	}
 }
 
-// 重新分配
-func (l *ReEmpowerLogic) ReEmpower(in *pb.ReEmpowerReq) (*pb.Resp, error) {
+// 重新授权
+func (l *ReEmpowerLogic) ReEmpower(in *pb.EmpowerReq) (*pb.Resp, error) {
 	resp := &pb.Resp{}
 	if in.Appid == "" {
 		l.Error(fmt.Sprintf("%+v", in), "无效的参数appid")

+ 8 - 2
rpc/internal/server/resourceserver.go

@@ -40,8 +40,14 @@ func (s *ResourceServer) Deduction(ctx context.Context, in *pb.DeductionReq) (*p
 	return l.Deduction(in)
 }
 
-// 重新分配
-func (s *ResourceServer) ReEmpower(ctx context.Context, in *pb.ReEmpowerReq) (*pb.Resp, error) {
+// 重新授权
+func (s *ResourceServer) ReEmpower(ctx context.Context, in *pb.EmpowerReq) (*pb.Resp, error) {
 	l := logic.NewReEmpowerLogic(ctx, s.svcCtx)
 	return l.ReEmpower(in)
 }
+
+// 取消授权
+func (s *ResourceServer) CancelEmpower(ctx context.Context, in *pb.EmpowerReq) (*pb.Resp, error) {
+	l := logic.NewCancelEmpowerLogic(ctx, s.svcCtx)
+	return l.CancelEmpower(in)
+}

+ 44 - 40
rpc/pb/resource.pb.go

@@ -281,7 +281,7 @@ func (x *DeductionReq) GetIds() []string {
 	return nil
 }
 
-type ReEmpowerReq struct {
+type EmpowerReq struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
@@ -292,8 +292,8 @@ type ReEmpowerReq struct {
 	EntUserId    []int64 `protobuf:"varint,4,rep,packed,name=ent_user_id,json=entUserId,proto3" json:"ent_user_id,omitempty"` //企业用户id
 }
 
-func (x *ReEmpowerReq) Reset() {
-	*x = ReEmpowerReq{}
+func (x *EmpowerReq) Reset() {
+	*x = EmpowerReq{}
 	if protoimpl.UnsafeEnabled {
 		mi := &file_resource_proto_msgTypes[3]
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -301,13 +301,13 @@ func (x *ReEmpowerReq) Reset() {
 	}
 }
 
-func (x *ReEmpowerReq) String() string {
+func (x *EmpowerReq) String() string {
 	return protoimpl.X.MessageStringOf(x)
 }
 
-func (*ReEmpowerReq) ProtoMessage() {}
+func (*EmpowerReq) ProtoMessage() {}
 
-func (x *ReEmpowerReq) ProtoReflect() protoreflect.Message {
+func (x *EmpowerReq) ProtoReflect() protoreflect.Message {
 	mi := &file_resource_proto_msgTypes[3]
 	if protoimpl.UnsafeEnabled && x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -319,33 +319,33 @@ func (x *ReEmpowerReq) ProtoReflect() protoreflect.Message {
 	return mi.MessageOf(x)
 }
 
-// Deprecated: Use ReEmpowerReq.ProtoReflect.Descriptor instead.
-func (*ReEmpowerReq) Descriptor() ([]byte, []int) {
+// Deprecated: Use EmpowerReq.ProtoReflect.Descriptor instead.
+func (*EmpowerReq) Descriptor() ([]byte, []int) {
 	return file_resource_proto_rawDescGZIP(), []int{3}
 }
 
-func (x *ReEmpowerReq) GetAppid() string {
+func (x *EmpowerReq) GetAppid() string {
 	if x != nil {
 		return x.Appid
 	}
 	return ""
 }
 
-func (x *ReEmpowerReq) GetFunctionCode() string {
+func (x *EmpowerReq) GetFunctionCode() string {
 	if x != nil {
 		return x.FunctionCode
 	}
 	return ""
 }
 
-func (x *ReEmpowerReq) GetEntId() int64 {
+func (x *EmpowerReq) GetEntId() int64 {
 	if x != nil {
 		return x.EntId
 	}
 	return 0
 }
 
-func (x *ReEmpowerReq) GetEntUserId() []int64 {
+func (x *EmpowerReq) GetEntUserId() []int64 {
 	if x != nil {
 		return x.EntUserId
 	}
@@ -435,25 +435,27 @@ var file_resource_proto_rawDesc = []byte{
 	0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05,
 	0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75,
 	0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52,
-	0x03, 0x69, 0x64, 0x73, 0x22, 0x80, 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x45, 0x6d, 0x70, 0x6f, 0x77,
-	0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x01,
-	0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x66,
-	0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x0c, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65,
-	0x12, 0x15, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03,
-	0x52, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0b, 0x65, 0x6e, 0x74, 0x5f, 0x75,
-	0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e,
-	0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x1e, 0x0a, 0x04, 0x52, 0x65, 0x73, 0x70, 0x12,
-	0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
-	0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x32, 0x96, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f,
-	0x75, 0x72, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x48, 0x61, 0x6e,
-	0x64, 0x6c, 0x65, 0x12, 0x09, 0x2e, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x05,
-	0x2e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x0a, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f,
-	0x77, 0x65, 0x72, 0x12, 0x0e, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x77, 0x65, 0x72,
-	0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x09, 0x44, 0x65,
-	0x64, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x2e, 0x44, 0x65, 0x64, 0x75, 0x63, 0x74,
-	0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a,
-	0x09, 0x52, 0x65, 0x45, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x0d, 0x2e, 0x52, 0x65, 0x45,
+	0x03, 0x69, 0x64, 0x73, 0x22, 0x7e, 0x0a, 0x0a, 0x45, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x52,
+	0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x75, 0x6e, 0x63,
+	0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x0c, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x15, 0x0a,
+	0x06, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65,
+	0x6e, 0x74, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0b, 0x65, 0x6e, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72,
+	0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73,
+	0x65, 0x72, 0x49, 0x64, 0x22, 0x1e, 0x0a, 0x04, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06,
+	0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74,
+	0x61, 0x74, 0x75, 0x73, 0x32, 0xb9, 0x01, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
+	0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65,
+	0x12, 0x09, 0x2e, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65,
+	0x73, 0x70, 0x12, 0x23, 0x0a, 0x0a, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x77, 0x65, 0x72,
+	0x12, 0x0e, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x52, 0x65, 0x71,
+	0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x09, 0x44, 0x65, 0x64, 0x75, 0x63,
+	0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x2e, 0x44, 0x65, 0x64, 0x75, 0x63, 0x74, 0x69, 0x6f, 0x6e,
+	0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x09, 0x52, 0x65,
+	0x45, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x0b, 0x2e, 0x45, 0x6d, 0x70, 0x6f, 0x77, 0x65,
+	0x72, 0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x0d, 0x43,
+	0x61, 0x6e, 0x63, 0x65, 0x6c, 0x45, 0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x0b, 0x2e, 0x45,
 	0x6d, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x05, 0x2e, 0x52, 0x65, 0x73, 0x70,
 	0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
@@ -475,20 +477,22 @@ var file_resource_proto_goTypes = []interface{}{
 	(*PowerReq)(nil),      // 0: PowerReq
 	(*CheckPowerReq)(nil), // 1: CheckPowerReq
 	(*DeductionReq)(nil),  // 2: DeductionReq
-	(*ReEmpowerReq)(nil),  // 3: ReEmpowerReq
+	(*EmpowerReq)(nil),    // 3: EmpowerReq
 	(*Resp)(nil),          // 4: Resp
 }
 var file_resource_proto_depIdxs = []int32{
 	0, // 0: Resource.PowerHandle:input_type -> PowerReq
 	1, // 1: Resource.CheckPower:input_type -> CheckPowerReq
 	2, // 2: Resource.Deduction:input_type -> DeductionReq
-	3, // 3: Resource.ReEmpower:input_type -> ReEmpowerReq
-	4, // 4: Resource.PowerHandle:output_type -> Resp
-	4, // 5: Resource.CheckPower:output_type -> Resp
-	4, // 6: Resource.Deduction:output_type -> Resp
-	4, // 7: Resource.ReEmpower:output_type -> Resp
-	4, // [4:8] is the sub-list for method output_type
-	0, // [0:4] is the sub-list for method input_type
+	3, // 3: Resource.ReEmpower:input_type -> EmpowerReq
+	3, // 4: Resource.CancelEmpower:input_type -> EmpowerReq
+	4, // 5: Resource.PowerHandle:output_type -> Resp
+	4, // 6: Resource.CheckPower:output_type -> Resp
+	4, // 7: Resource.Deduction:output_type -> Resp
+	4, // 8: Resource.ReEmpower:output_type -> Resp
+	4, // 9: Resource.CancelEmpower:output_type -> Resp
+	5, // [5:10] is the sub-list for method output_type
+	0, // [0:5] is the sub-list for method input_type
 	0, // [0:0] is the sub-list for extension type_name
 	0, // [0:0] is the sub-list for extension extendee
 	0, // [0:0] is the sub-list for field type_name
@@ -537,7 +541,7 @@ func file_resource_proto_init() {
 			}
 		}
 		file_resource_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*ReEmpowerReq); i {
+			switch v := v.(*EmpowerReq); i {
 			case 0:
 				return &v.state
 			case 1:

+ 46 - 8
rpc/pb/resource_grpc.pb.go

@@ -28,8 +28,10 @@ type ResourceClient interface {
 	CheckPower(ctx context.Context, in *CheckPowerReq, opts ...grpc.CallOption) (*Resp, error)
 	//资源扣减
 	Deduction(ctx context.Context, in *DeductionReq, opts ...grpc.CallOption) (*Resp, error)
-	//重新分配
-	ReEmpower(ctx context.Context, in *ReEmpowerReq, opts ...grpc.CallOption) (*Resp, error)
+	//重新授权
+	ReEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error)
+	//取消授权
+	CancelEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error)
 }
 
 type resourceClient struct {
@@ -67,7 +69,7 @@ func (c *resourceClient) Deduction(ctx context.Context, in *DeductionReq, opts .
 	return out, nil
 }
 
-func (c *resourceClient) ReEmpower(ctx context.Context, in *ReEmpowerReq, opts ...grpc.CallOption) (*Resp, error) {
+func (c *resourceClient) ReEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error) {
 	out := new(Resp)
 	err := c.cc.Invoke(ctx, "/Resource/ReEmpower", in, out, opts...)
 	if err != nil {
@@ -76,6 +78,15 @@ func (c *resourceClient) ReEmpower(ctx context.Context, in *ReEmpowerReq, opts .
 	return out, nil
 }
 
+func (c *resourceClient) CancelEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error) {
+	out := new(Resp)
+	err := c.cc.Invoke(ctx, "/Resource/CancelEmpower", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ResourceServer is the server API for Resource service.
 // All implementations must embed UnimplementedResourceServer
 // for forward compatibility
@@ -86,8 +97,10 @@ type ResourceServer interface {
 	CheckPower(context.Context, *CheckPowerReq) (*Resp, error)
 	//资源扣减
 	Deduction(context.Context, *DeductionReq) (*Resp, error)
-	//重新分配
-	ReEmpower(context.Context, *ReEmpowerReq) (*Resp, error)
+	//重新授权
+	ReEmpower(context.Context, *EmpowerReq) (*Resp, error)
+	//取消授权
+	CancelEmpower(context.Context, *EmpowerReq) (*Resp, error)
 	mustEmbedUnimplementedResourceServer()
 }
 
@@ -104,9 +117,12 @@ func (UnimplementedResourceServer) CheckPower(context.Context, *CheckPowerReq) (
 func (UnimplementedResourceServer) Deduction(context.Context, *DeductionReq) (*Resp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method Deduction not implemented")
 }
-func (UnimplementedResourceServer) ReEmpower(context.Context, *ReEmpowerReq) (*Resp, error) {
+func (UnimplementedResourceServer) ReEmpower(context.Context, *EmpowerReq) (*Resp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ReEmpower not implemented")
 }
+func (UnimplementedResourceServer) CancelEmpower(context.Context, *EmpowerReq) (*Resp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method CancelEmpower not implemented")
+}
 func (UnimplementedResourceServer) mustEmbedUnimplementedResourceServer() {}
 
 // UnsafeResourceServer may be embedded to opt out of forward compatibility for this service.
@@ -175,7 +191,7 @@ func _Resource_Deduction_Handler(srv interface{}, ctx context.Context, dec func(
 }
 
 func _Resource_ReEmpower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(ReEmpowerReq)
+	in := new(EmpowerReq)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
@@ -187,7 +203,25 @@ func _Resource_ReEmpower_Handler(srv interface{}, ctx context.Context, dec func(
 		FullMethod: "/Resource/ReEmpower",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(ResourceServer).ReEmpower(ctx, req.(*ReEmpowerReq))
+		return srv.(ResourceServer).ReEmpower(ctx, req.(*EmpowerReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Resource_CancelEmpower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(EmpowerReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ResourceServer).CancelEmpower(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/Resource/CancelEmpower",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ResourceServer).CancelEmpower(ctx, req.(*EmpowerReq))
 	}
 	return interceptor(ctx, in, info, handler)
 }
@@ -215,6 +249,10 @@ var Resource_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "ReEmpower",
 			Handler:    _Resource_ReEmpower_Handler,
 		},
+		{
+			MethodName: "CancelEmpower",
+			Handler:    _Resource_CancelEmpower_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "resource.proto",

+ 5 - 3
rpc/resource.proto

@@ -29,7 +29,7 @@ message DeductionReq {
   repeated string ids = 6;  //id列表
 }
 
-message ReEmpowerReq {
+message EmpowerReq {
   string appid = 1;
   string function_code = 2; //功能代码
   int64 ent_id = 3;         //企业id
@@ -47,6 +47,8 @@ service Resource {
   rpc CheckPower(CheckPowerReq) returns(Resp);
   //资源扣减
   rpc Deduction(DeductionReq) returns(Resp);
-  //重新分配
-  rpc ReEmpower(ReEmpowerReq) returns(Resp);
+  //重新授权
+  rpc ReEmpower(EmpowerReq) returns(Resp);
+  //取消授权
+  rpc CancelEmpower(EmpowerReq) returns(Resp);
 }

+ 13 - 5
rpc/resource/resource.go

@@ -15,8 +15,8 @@ import (
 type (
 	CheckPowerReq = pb.CheckPowerReq
 	DeductionReq  = pb.DeductionReq
+	EmpowerReq    = pb.EmpowerReq
 	PowerReq      = pb.PowerReq
-	ReEmpowerReq  = pb.ReEmpowerReq
 	Resp          = pb.Resp
 
 	Resource interface {
@@ -26,8 +26,10 @@ type (
 		CheckPower(ctx context.Context, in *CheckPowerReq, opts ...grpc.CallOption) (*Resp, error)
 		// 资源扣减
 		Deduction(ctx context.Context, in *DeductionReq, opts ...grpc.CallOption) (*Resp, error)
-		// 重新分配
-		ReEmpower(ctx context.Context, in *ReEmpowerReq, opts ...grpc.CallOption) (*Resp, error)
+		// 重新授权
+		ReEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error)
+		// 取消授权
+		CancelEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error)
 	}
 
 	defaultResource struct {
@@ -59,8 +61,14 @@ func (m *defaultResource) Deduction(ctx context.Context, in *DeductionReq, opts
 	return client.Deduction(ctx, in, opts...)
 }
 
-// 重新分配
-func (m *defaultResource) ReEmpower(ctx context.Context, in *ReEmpowerReq, opts ...grpc.CallOption) (*Resp, error) {
+// 重新授权
+func (m *defaultResource) ReEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error) {
 	client := pb.NewResourceClient(m.cli.Conn())
 	return client.ReEmpower(ctx, in, opts...)
 }
+
+// 取消授权
+func (m *defaultResource) CancelEmpower(ctx context.Context, in *EmpowerReq, opts ...grpc.CallOption) (*Resp, error) {
+	client := pb.NewResourceClient(m.cli.Conn())
+	return client.CancelEmpower(ctx, in, opts...)
+}