Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
open-source
/
dev-ops
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a93e50e3
authored
Jun 24, 2024
by
larosa
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add some lines
parent
bb6dd43e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletions
internal/consts/consts.go
internal/service/apiList.go
internal/consts/consts.go
View file @
a93e50e3
package
consts
const
(
// 接口统计中的用户redisKey
API_INTERFACE_USERNAME_KEY
=
"api_apiKey_interface_user_name_key"
// 接口每天统计上限redisKey
API_INTERFACE_DAYCALLMAX_STATISTICS_KEY
=
"api_apiKey_interface_dayCallMax_key"
// 接口每分钟统计上限redisKey
API_INTERFACE_MINCALLMAX_STATISTICS_KEY
=
"api_apiKey_interface_minCallMax_key"
// 接口每天统计情况redisKey
API_INTERFACE_DAYCALL_STATISTICS_KEY
=
"api_apiKey_interface_dayCall_statistics"
)
internal/service/apiList.go
View file @
a93e50e3
...
...
@@ -3,9 +3,13 @@ package service
import
(
"context"
v1
"dev-ops/api/v1"
"dev-ops/internal/consts"
"dev-ops/utility/response"
"fmt"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/frame/g"
"strings"
"time"
)
type
sApiList
struct
{}
...
...
@@ -20,8 +24,26 @@ func (s *sApiList) GetApiList(ctx context.Context, req *v1.ApiListReq) (interfac
"limit"
:
req
.
Limit
,
"offset_time"
:
req
.
OffsetTime
,
}
apiNumsMap
:=
map
[
string
]
int
{}
fmt
.
Println
(
param
)
//业务逻辑 先从mongodb中获取全量的openplatform的接口名称,再依次去mysql数据库中查
interfaceName
:=
"brandgetStandardBrandList"
interfaceNameList
:=
[]
string
{
"/brand/getStandardBrandList"
}
//mongodb中获取的接口信息
now
:=
time
.
Now
()
dayStr
:=
now
.
Format
(
"2006-01-02"
)
redisDayApiKeyKey
:=
consts
.
API_INTERFACE_DAYCALL_STATISTICS_KEY
+
"_"
+
dayStr
apiKeysData
,
_
:=
g
.
Redis
(
"235"
)
.
Do
(
ctx
,
"SMEMBERS"
,
redisDayApiKeyKey
)
//先获取所有的apiKey
if
nil
!=
apiKeysData
&&
!
apiKeysData
.
IsEmpty
()
{
for
_
,
apiKey
:=
range
apiKeysData
.
Array
()
{
redisKey
:=
redisDayApiKeyKey
+
"_"
+
apiKey
.
(
string
)
interfaceNames
,
_
:=
g
.
Redis
(
"235"
)
.
Do
(
ctx
,
"HKEYS"
,
redisKey
)
if
interfaceNames
!=
nil
{
for
_
,
interfaceItem
:=
range
interfaceNameList
{
if
strings
.
ReplaceAll
(
interfaceItem
,
"/"
,
""
)
==
}
}
}
}
else
{
//redis中暂无数据
}
return
"ok"
,
response
.
CodeSuccess
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment