Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Dui123
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
王天宇
Dui123
Commits
8c4186d6
Commit
8c4186d6
authored
Feb 15, 2022
by
wty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改埋点记录方式
parent
cf125989
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
13 deletions
+7
-13
getConfig.js
config/getConfig.js
+1
-1
md.js
server/routes/md.js
+6
-12
No files found.
config/getConfig.js
View file @
8c4186d6
const
env
=
'
dev
'
const
env
=
'
test
'
const
getConfig
=
()
=>
{
switch
(
env
){
...
...
server/routes/md.js
View file @
8c4186d6
...
...
@@ -5,18 +5,12 @@ const router = express.Router()
router
.
get
(
'/addMd'
,
async
(
req
,
res
)
=>
{
const
{
uid
,
uname
,
type
,
info
,
timestamp
}
=
req
.
query
const
SQL_query
=
'SELECT * FROM md WHERE md_user_id = ? AND md_type = ? AND md_info = ?'
const
SQL_add
=
'UPDATE md SET md.last_time = ? , md.md_num = md.md_num + 1 WHERE md.md_id = ?'
//
const SQL_query = 'SELECT * FROM md WHERE md_user_id = ? AND md_type = ? AND md_info = ?'
//
const SQL_add = 'UPDATE md SET md.last_time = ? , md.md_num = md.md_num + 1 WHERE md.md_id = ?'
const
SQL_addNew
=
`INSERT INTO md (md.md_user_id, md.md_user_name, md.md_type, md.md_num, md_info, last_time) VALUES (?,?,?,1,?,?)`
try
{
const
mdInfo
=
await
query
(
SQL_query
,
[
uid
,
type
,
info
])
if
(
mdInfo
.
length
<=
0
)
{
const
addNewRes
=
await
query
(
SQL_addNew
,
[
uid
,
uname
,
type
,
info
,
String
(
timestamp
)])
if
(
addNewRes
[
'affectedRows'
]
>
0
)
res
.
send
({
success
:
true
,
message
:
'新增埋点'
})
return
}
const
addRes
=
await
query
(
SQL_add
,
[
String
(
timestamp
),
mdInfo
[
0
][
'md_id'
]])
if
(
addRes
[
'affectedRows'
]
<=
0
)
throw
'未找到埋点:md_id='
+
mdInfo
[
0
][
'md_id'
]
const
addNewRes
=
await
query
(
SQL_addNew
,
[
uid
,
uname
,
type
,
info
,
String
(
timestamp
)])
if
(
addNewRes
[
'affectedRows'
]
>
0
)
res
.
send
({
success
:
true
,
message
:
'新增埋点'
})
res
.
send
({
success
:
true
})
}
catch
(
e
)
{
console
.
error
(
e
)
...
...
@@ -28,12 +22,12 @@ router.get('/addMd', async (req, res) => {
router
.
get
(
'/queryAllMd'
,
async
(
req
,
res
)
=>
{
const
SQL
=
'SELECT * FROM md'
try
{
const
mdInfo
=
await
query
(
SQL
,
[])
const
mdInfo
=
await
query
(
SQL
,
[])
res
.
send
({
success
:
true
,
data
:
mdInfo
})
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
e
)
res
.
send
({
success
:
false
,
err
:
e
})
}
...
...
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