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
230b533b
Commit
230b533b
authored
Dec 17, 2022
by
chenhan wang
Browse files
version
parent
9d8521e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/app/controller/interface.go
View file @
230b533b
...
@@ -29,16 +29,15 @@ type File struct {
...
@@ -29,16 +29,15 @@ type File struct {
User
string
`json:"user"`
User
string
`json:"user"`
Passwd
string
`json:"passwd"`
Passwd
string
`json:"passwd"`
SessionId
string
`json:"sessionId"`
SessionId
string
`json:"sessionId"`
FileLink
string
`json:"fileLink"`
FileLink
string
`json:"fileLink"`
//Expiry time.Time `json:"expiry"` // 有效期
//Expiry time.Time `json:"expiry"` // 有效期
//Content string `json:"content"`
//Content string `json:"content"`
}
}
type
pass
struct
{
type
pass
struct
{
SessionId
string
`json:"sessionId"`
SessionId
string
`json:"sessionId"`
Passwd
string
`json:"passwd"`
Passwd
string
`json:"passwd"`
FileLink
string
`json:"fileLink"`
FileLink
string
`json:"fileLink"`
}
}
type
Text
struct
{
type
Text
struct
{
...
@@ -63,7 +62,7 @@ func AskPasswd(c echo.Context) error {
...
@@ -63,7 +62,7 @@ func AskPasswd(c echo.Context) error {
return
echo
.
ErrBadRequest
return
echo
.
ErrBadRequest
}
}
if
model
.
Createlink
(
info
.
SessionId
,
info
.
Passwd
,
info
.
FileLink
)
==
true
{
if
model
.
Createlink
(
info
.
SessionId
,
info
.
Passwd
,
info
.
FileLink
)
==
true
{
// 成功建立连接
// 成功建立连接
SetCookie
(
c
,
info
)
SetCookie
(
c
,
info
)
return
c
.
String
(
http
.
StatusOK
,
"登录成功"
)
return
c
.
String
(
http
.
StatusOK
,
"登录成功"
)
...
@@ -142,12 +141,12 @@ func RecvFile(c echo.Context) error {
...
@@ -142,12 +141,12 @@ func RecvFile(c echo.Context) error {
}
}
// 更新数据库
// 更新数据库
dinfo
:=
model
.
Users
{
dinfo
:=
model
.
Users
{
Username
:
info
.
User
,
Username
:
info
.
User
,
Passwd
:
info
.
Passwd
,
Passwd
:
info
.
Passwd
,
Name
:
info
.
FileName
,
// 无后缀
Name
:
info
.
FileName
,
// 无后缀
Size
:
uint
(
fi
.
Size
()),
Size
:
uint
(
fi
.
Size
()),
Route
:
filePath
,
Route
:
filePath
,
//Time1: info.Expiry,
//Time1: info.Expiry,
}
}
model
.
Createuser
(
dinfo
)
// 数据库一条新纪录
model
.
Createuser
(
dinfo
)
// 数据库一条新纪录
...
@@ -166,16 +165,16 @@ func SendFile(c echo.Context) error {
...
@@ -166,16 +165,16 @@ func SendFile(c echo.Context) error {
info
.
FileType
=
"txt"
info
.
FileType
=
"txt"
}
}
if
model
.
find
(
info
.
FileLink
,
info
.
SessionId
,
)
==
false
{
if
model
.
find
(
info
.
FileLink
,
info
.
SessionId
)
==
false
{
cookie
,
err
:=
c
.
Cookie
(
info
.
SessionId
)
cookie
,
err
:=
c
.
Cookie
(
info
.
SessionId
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
cookie
.
Value
!=
info
.
FileLink
{
if
cookie
.
Value
!=
info
.
FileLink
{
return
err
// you wenti
return
err
// you wenti
}
}
}
}
filePath
:=
"./files/"
+
info
.
FileType
+
"/"
+
info
.
FileName
+
"."
+
info
.
FileType
filePath
:=
"./files/"
+
info
.
FileType
+
"/"
+
info
.
FileName
+
"."
+
info
.
FileType
src
,
err
:=
os
.
Open
(
filePath
)
src
,
err
:=
os
.
Open
(
filePath
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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