Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
ppt_server
Overview
Overview
Details
Activity
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Li Feifei
ppt_server
Commits
5ff88ecc
Commit
5ff88ecc
authored
Jul 26, 2021
by
Li Feifei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式化代码
parent
8c41e3b3
Pipeline
#15602
failed with stages
in 13 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
18 deletions
+18
-18
file.go
app/service/file.go
+4
-3
session_http_client.go
library/http/session_http_client.go
+8
-10
.DS_Store
packed/file/.DS_Store
+0
-0
file_notify.go
packed/file/file_notify.go
+4
-3
file_parser.go
packed/file/file_parser.go
+1
-1
file_upload.go
packed/file/file_upload.go
+1
-1
No files found.
app/service/file.go
View file @
5ff88ecc
...
...
@@ -3,7 +3,7 @@ package service
import
(
"ppt_server/app/dao"
"ppt_server/app/model"
"ppt_server/packed"
"ppt_server/packed
/file
"
"github.com/gogf/gf/frame/g"
)
...
...
@@ -21,7 +21,8 @@ type fileService struct {
// 上传课件
func
(
f
*
fileService
)
Upload
(
r
*
model
.
FileUploadRequest
)
{
// 解析上传课件URL
parserURLObject
,
err
:=
packed
.
Upload
(
r
,
f
.
done
,
f
.
ok
)
parserURLObject
,
err
:=
file
.
Upload
(
r
,
f
.
done
,
f
.
ok
)
if
err
!=
nil
{
g
.
Log
()
.
Async
()
.
Errorf
(
"Parser Url err: %s
\n
"
,
err
)
return
...
...
@@ -36,7 +37,7 @@ func (f *fileService) Upload(r *model.FileUploadRequest) {
go
parserURLObject
.
Worker
(
err
)
// 回调通知
n
:=
packed
.
NewNotify
()
n
:=
file
.
NewNotify
()
select
{
case
<-
f
.
done
:
// 上传失败
...
...
packed
/session_http_client.go
→
library/http
/session_http_client.go
View file @
5ff88ecc
...
...
@@ -2,39 +2,37 @@
* @Authore: lifeifei
* @Date: 2021/7/21 4:26 下午
*/
package
packed
package
http
import
(
"net/http"
"net/http/cookiejar"
"time"
clientHttp
"ppt_server/library/http"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
)
// 保持会话请求
type
s
essionHttpClient
struct
{
type
S
essionHttpClient
struct
{
c
*
ghttp
.
Client
}
func
NewSessionHttpClient
()
*
s
essionHttpClient
{
func
NewSessionHttpClient
()
*
S
essionHttpClient
{
jar
,
_
:=
cookiejar
.
New
(
nil
)
c
:=
g
.
Client
()
c
.
Jar
=
jar
c
.
CheckRedirect
=
func
(
req
*
http
.
Request
,
via
[]
*
http
.
Request
)
error
{
return
http
.
ErrUseLastResponse
}
return
&
s
essionHttpClient
{
c
}
return
&
S
essionHttpClient
{
c
}
}
func
(
client
*
s
essionHttpClient
)
Post
(
link
string
,
data
...
interface
{})
([]
byte
,
error
)
{
return
clientHttp
.
Handle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Post
(
link
,
data
))
func
(
client
*
S
essionHttpClient
)
Post
(
link
string
,
data
...
interface
{})
([]
byte
,
error
)
{
return
Handle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Post
(
link
,
data
))
}
func
(
client
*
s
essionHttpClient
)
Get
(
url
string
)
([]
byte
,
error
)
{
return
clientHttp
.
Handle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Get
(
url
))
func
(
client
*
S
essionHttpClient
)
Get
(
url
string
)
([]
byte
,
error
)
{
return
Handle
(
client
.
c
.
Timeout
(
10
*
time
.
Second
)
.
Get
(
url
))
}
packed/file/.DS_Store
0 → 100644
View file @
5ff88ecc
File added
packed/notify.go
→
packed/
file/file_
notify.go
View file @
5ff88ecc
package
packed
package
file
import
(
"encoding/json"
"os"
"ppt_server/library/http"
"ppt_server/app/model"
"github.com/gogf/gf/errors/gerror"
...
...
@@ -15,7 +16,7 @@ type Notify struct {
name
string
password
string
url
string
client
*
s
essionHttpClient
client
*
http
.
S
essionHttpClient
}
func
NewNotify
()
*
Notify
{
...
...
@@ -23,7 +24,7 @@ func NewNotify() *Notify {
url
:
g
.
Cfg
()
.
GetString
(
"notify.url"
),
name
:
os
.
Getenv
(
"live_name"
),
password
:
os
.
Getenv
(
"live_pwd"
),
client
:
NewSessionHttpClient
(),
client
:
http
.
NewSessionHttpClient
(),
}
}
...
...
packed/file_parser.go
→
packed/file
/file
_parser.go
View file @
5ff88ecc
package
packed
package
file
import
(
"fmt"
...
...
packed/file_upload.go
→
packed/file
/file
_upload.go
View file @
5ff88ecc
package
packed
package
file
import
(
"archive/zip"
...
...
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