Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenhan wang
pastebin
Commits
518215c7
Commit
518215c7
authored
Dec 17, 2022
by
chenhan wang
Browse files
Merge remote-tracking branch 'origin/master1'
parents
6309d619
c479c99e
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/model/init.go
View file @
518215c7
...
...
@@ -10,10 +10,9 @@ import (
)
var
DB
*
gorm
.
DB
var
id1
uint
=
0
func
Init
()
{}
func
Init_
()
{
func
Init
()
{
connectDatabase
()
var
err
error
// insert auto-table
...
...
@@ -47,52 +46,43 @@ func connectDatabase() {
}
// Backcheck content through link
func
findlink
(
name
string
)
string
{
var
p
Users
err
:=
DB
.
First
(
&
p
,
"Route = ?"
,
name
)
//通过链接反查内容
func
findlink
(
_Route
string
)
content
{
var
p
content
err
:=
DB
.
First
(
&
p
,
"Route = ?"
,
_Route
)
if
err
!=
nil
{
logrus
.
Error
(
err
)
}
return
p
.
Name
return
p
}
// save text information
func
savetext
(
_username
string
,
s
string
,
t1
time
.
Time
)
{
p
:=
Users
{
Username
:
_username
,
Name
:
s
,
Date
:
time
.
Now
(),
Time1
:
t1
,
//保存文本和文件信息
func
savetext
(
_Route
string
,
_Time
uint
,
_Passwd
string
,
_Time1
time
.
Time
)
{
id1
++
p
:=
content
{
ID
:
id1
,
Route
:
_Route
,
Passwd
:
_Passwd
,
Date
:
time
.
Now
(),
Time1
:
_Time1
,
Time2
:
0
,
}
DB
.
Create
(
&
p
)
p1
:=
content
{
Name
:
s
,
Time
:
0
,
}
DB
.
Create
(
&
p1
)
}
// Check whether the number of visits exceeds the threshold
func
checkt
(
s
string
)
{
// Check whether the number of visits exceeds the threshold and the time limit
//检查是否超过总访问次数和截止时间
func
checkt
(
_Route
string
)
{
var
p
content
err
:=
DB
.
First
(
&
p
,
"Route = ?"
,
s
)
err
:=
DB
.
First
(
&
p
,
"Route = ?"
,
_Route
)
if
err
!=
nil
{
logrus
.
Error
(
err
)
}
p
.
Time
++
if
p
.
Time
>
200
{
t
:=
time
.
Now
()
p
.
Time2
++
if
p
.
Time2
>
p
.
Time
||
t
.
After
(
p
.
Time1
)
{
DB
.
Delete
(
&
p
)
}
}
// Check whether the number of visits exceeds the time limit
func
checkt1
(
s
string
)
{
var
p
[]
Users
DB
.
Find
(
&
p
)
for
i
:=
0
;
i
<
len
(
p
);
i
++
{
t
:=
time
.
Now
()
if
p
[
i
]
.
Time1
.
After
(
t
)
{
DB
.
Delete
(
&
p
)
}
}
}
}
\ No newline at end of file
backend/model/model.go
View file @
518215c7
...
...
@@ -2,22 +2,23 @@ package model
import
(
"time"
"gorm.io/gorm"
)
type
Users
struct
{
gorm
.
Model
Username
string
type
content
struct
{
ID
uint
`gorm:"primarykey"`
Route
string
Time
uint
Passwd
string
Name
string
Date
time
.
Time
Size
uint
Route
string
Time1
time
.
Time
Time2
uint
}
type
content
struct
{
gorm
.
Model
type
Users
struct
{
Username
string
Passwd
string
Name
string
Time
uint
Size
uint
Route
string
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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