From 883db65ea4090b18674a9a7f63c22faf19875b27 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 9 Jul 2024 21:54:04 +0800 Subject: [PATCH] 1 --- app/mix/dao/mongo.go | 4 ++-- app/mix/service/apiservice.go | 32 ++++++++++++++++++++++++-- app/mix/service/service.go | 6 ++--- library/taginterceptor/crypt_test.go | 34 +++++++++++++++------------- 4 files changed, 52 insertions(+), 24 deletions(-) diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 65875f38..452f2fb1 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -2683,7 +2683,7 @@ func (m *Mongo) GetStreamerAuthApprovalDetailsHisList(ctx *gin.Context, req *str list := make([]*dbstruct.StreamerAuthApprovalDetails, 0) col := m.getColStreamerAuthApprovalDetailsHis() query := qmgo.M{ - "del_flag": 0, + "del_flag": consts.Deleted, } if req.Status != nil { query["status"] = util.DerefInt64(req.Status) @@ -2703,7 +2703,7 @@ func (m *Mongo) GetStreamerAuthApprovalDetailsHisListByMid(ctx *gin.Context, req list := make([]*dbstruct.StreamerAuthApprovalDetails, 0) col := m.getColStreamerAuthApprovalDetailsHis() query := qmgo.M{ - "del_flag": 0, + "del_flag": consts.Deleted, } if req.Status != nil { query["status"] = util.DerefInt64(req.Status) diff --git a/app/mix/service/apiservice.go b/app/mix/service/apiservice.go index 99f5eb4f..24b53158 100644 --- a/app/mix/service/apiservice.go +++ b/app/mix/service/apiservice.go @@ -1288,7 +1288,21 @@ func (s *Service) GetStreamerAuthApprovalStatuses(ctx *gin.Context, req *streame return } if streamerauthapprovalbasic == nil { - basicStatus = consts.StreamerAuthApprovalBasicApprove_NotFound + list, err := _DefaultStreamerAuthApprovalBasicHis.OpListByMid(ctx, &streamerauthapprovalbasichisproto.OpListByMidReq{ + Uid: goproto.Int64(req.BaseRequest.Mid), + Offset: 0, + Limit: 1, + }) + if err != nil { + logger.Error("_DefaultStreamerAuthApprovalBasicHis OpListByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeStreamerAuthApprovalBasicSrvFail + return + } + if len(list) == 0 { + basicStatus = consts.StreamerAuthApprovalBasicApprove_NotFound + } else { + basicStatus = list[0].GetApproveStatus() + } } else { basicStatus = streamerauthapprovalbasic.GetApproveStatus() } @@ -1302,7 +1316,21 @@ func (s *Service) GetStreamerAuthApprovalStatuses(ctx *gin.Context, req *streame return } if streamerauthapprovaldetails == nil { - detailsStatus = consts.StreamerAuthApprovalDetailsApprove_NotFound + list, err := _DefaultStreamerAuthApprovalDetailsHis.OpListByMid(ctx, &streamerauthapprovaldetailshisproto.OpListByMidReq{ + Uid: goproto.Int64(req.BaseRequest.Mid), + Offset: 0, + Limit: 1, + }) + if err != nil { + logger.Error("_DefaultStreamerAuthApprovalDetailsHis OpListByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeStreamerAuthApprovalDetailsSrvFail + return + } + if len(list) == 0 { + detailsStatus = consts.StreamerAuthApprovalDetailsApprove_NotFound + } else { + detailsStatus = list[0].GetApproveStatus() + } } else { detailsStatus = streamerauthapprovaldetails.GetApproveStatus() } diff --git a/app/mix/service/service.go b/app/mix/service/service.go index a3704c8b..f5ae2e1a 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -1964,8 +1964,7 @@ func (s *Service) OpApproveStreamerAuthApprovalBasic(ctx *gin.Context, req *stre ApproveStatus: req.ApproveStatus, Remarks: req.Remarks, }, - Ids: req.Ids, - ApproveStatus: consts.StreamerAuthApprovalBasicApprove_Waiting, + Ids: req.Ids, }) if err == qmgo.ErrNoSuchDocuments { ec = errcode.ErrCodeStreamerAuthApprovalBasicNotExist @@ -2165,8 +2164,7 @@ func (s *Service) OpApproveStreamerAuthApprovalDetails(ctx *gin.Context, req *st ApproveStatus: req.ApproveStatus, Remarks: req.Remarks, }, - Ids: req.Ids, - ApproveStatus: consts.StreamerAuthApprovalDetailsApprove_Waiting, + Ids: req.Ids, }) if err == qmgo.ErrNoSuchDocuments { ec = errcode.ErrCodeStreamerAuthApprovalDetailsNotExist diff --git a/library/taginterceptor/crypt_test.go b/library/taginterceptor/crypt_test.go index 1a6f8461..4f10daf0 100644 --- a/library/taginterceptor/crypt_test.go +++ b/library/taginterceptor/crypt_test.go @@ -1,6 +1,7 @@ package interceptor import ( + "encoding/base64" "fmt" "service/api/consts" "service/app/mix/conf" @@ -8,6 +9,7 @@ import ( "service/library/logger" "service/library/mycrypto" "testing" + "time" ) func Test(t *testing.T) { @@ -30,23 +32,23 @@ func Test(t *testing.T) { // fmt.Println(string(phone)) // hash := mycrypto.CryptoServiceInstance().SHA256.Encrypt(phone) // fmt.Println(string(hash)) - // mobilePhone := "18282063182" - // rsaBytes, _ := mycrypto.CryptoServiceInstance().RSA.Encrypt([]byte(mobilePhone)) - // base64EncryptedBytes := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes))) - // base64.StdEncoding.Encode(base64EncryptedBytes, rsaBytes) - // phoneHash := mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(mobilePhone)) + mobilePhone := "13728423678" + rsaBytes, _ := mycrypto.CryptoServiceInstance().AES.Encrypt([]byte(mobilePhone)) + base64EncryptedBytes := make([]byte, base64.StdEncoding.EncodedLen(len(rsaBytes))) + base64.StdEncoding.Encode(base64EncryptedBytes, rsaBytes) + phoneHash := mycrypto.CryptoServiceInstance().SHA256.Encrypt([]byte(mobilePhone)) - // fmt.Printf("Time:%v\n", time.Now().Unix()) - // fmt.Printf("RSA:%v\n", string(base64EncryptedBytes)) - // fmt.Printf("PhoneHash:%v\n", phoneHash) + fmt.Printf("Time:%v\n", time.Now().Unix()) + fmt.Printf("RSA:%v\n", string(base64EncryptedBytes)) + fmt.Printf("PhoneHash:%v\n", phoneHash) - data := "FortuneFavorsTheBold2@" - sign := "G7I7Z+RGNqbGOecP3aBmki3Y9omqs0AICwFRLkZ1CRhRh/3BFN1kBcZrmFeoUibzeM3t2D8AsdF8cSankmfLjOR6rN2xx49mQRawy7Zat7DLRj6j+eDJZ2jhIFXcLl72Ap7KSxzk0UyiFS7FVnK3esmqQtQpDfE8UPgPW9IOzYo=" - err = mycrypto.CryptoServiceInstance().HygSHA1WithRSA.Verify([]byte(data), sign) - if err != nil { - logger.Error("err : %v", err) - } else { - logger.Info("Verify success") - } + // data := "FortuneFavorsTheBold2@" + // sign := "G7I7Z+RGNqbGOecP3aBmki3Y9omqs0AICwFRLkZ1CRhRh/3BFN1kBcZrmFeoUibzeM3t2D8AsdF8cSankmfLjOR6rN2xx49mQRawy7Zat7DLRj6j+eDJZ2jhIFXcLl72Ap7KSxzk0UyiFS7FVnK3esmqQtQpDfE8UPgPW9IOzYo=" + // err = mycrypto.CryptoServiceInstance().HygSHA1WithRSA.Verify([]byte(data), sign) + // if err != nil { + // logger.Error("err : %v", err) + // } else { + // logger.Info("Verify success") + // } }