Commit 5ff88ecc by Li Feifei

格式化代码

parent 8c41e3b3
Pipeline #15602 failed with stages
in 13 seconds
...@@ -3,7 +3,7 @@ package service ...@@ -3,7 +3,7 @@ package service
import ( import (
"ppt_server/app/dao" "ppt_server/app/dao"
"ppt_server/app/model" "ppt_server/app/model"
"ppt_server/packed" "ppt_server/packed/file"
"github.com/gogf/gf/frame/g" "github.com/gogf/gf/frame/g"
) )
...@@ -21,7 +21,8 @@ type fileService struct { ...@@ -21,7 +21,8 @@ type fileService struct {
// 上传课件 // 上传课件
func (f *fileService) Upload(r *model.FileUploadRequest) { func (f *fileService) Upload(r *model.FileUploadRequest) {
// 解析上传课件URL // 解析上传课件URL
parserURLObject, err := packed.Upload(r, f.done, f.ok)
parserURLObject, err := file.Upload(r, f.done, f.ok)
if err != nil { if err != nil {
g.Log().Async().Errorf("Parser Url err: %s\n", err) g.Log().Async().Errorf("Parser Url err: %s\n", err)
return return
...@@ -36,7 +37,7 @@ func (f *fileService) Upload(r *model.FileUploadRequest) { ...@@ -36,7 +37,7 @@ func (f *fileService) Upload(r *model.FileUploadRequest) {
go parserURLObject.Worker(err) go parserURLObject.Worker(err)
// 回调通知 // 回调通知
n := packed.NewNotify() n := file.NewNotify()
select { select {
case <-f.done: case <-f.done:
// 上传失败 // 上传失败
......
...@@ -2,39 +2,37 @@ ...@@ -2,39 +2,37 @@
* @Authore: lifeifei * @Authore: lifeifei
* @Date: 2021/7/21 4:26 下午 * @Date: 2021/7/21 4:26 下午
*/ */
package packed package http
import ( import (
"net/http" "net/http"
"net/http/cookiejar" "net/http/cookiejar"
"time" "time"
clientHttp "ppt_server/library/http"
"github.com/gogf/gf/frame/g" "github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp" "github.com/gogf/gf/net/ghttp"
) )
// 保持会话请求 // 保持会话请求
type sessionHttpClient struct { type SessionHttpClient struct {
c *ghttp.Client c *ghttp.Client
} }
func NewSessionHttpClient() *sessionHttpClient { func NewSessionHttpClient() *SessionHttpClient {
jar, _ := cookiejar.New(nil) jar, _ := cookiejar.New(nil)
c := g.Client() c := g.Client()
c.Jar = jar c.Jar = jar
c.CheckRedirect = func(req *http.Request, via []*http.Request) error { c.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse return http.ErrUseLastResponse
} }
return &sessionHttpClient{c} return &SessionHttpClient{c}
} }
func (client *sessionHttpClient) Post(link string, data ...interface{}) ([]byte, error) { func (client *SessionHttpClient) Post(link string, data ...interface{}) ([]byte, error) {
return clientHttp.Handle(client.c.Timeout(10*time.Second).Post(link, data)) return Handle(client.c.Timeout(10*time.Second).Post(link, data))
} }
func (client *sessionHttpClient) Get(url string) ([]byte, error) { func (client *SessionHttpClient) Get(url string) ([]byte, error) {
return clientHttp.Handle(client.c.Timeout(10 * time.Second).Get(url)) return Handle(client.c.Timeout(10 * time.Second).Get(url))
} }
package packed package file
import ( import (
"encoding/json" "encoding/json"
"os" "os"
"ppt_server/library/http"
"ppt_server/app/model" "ppt_server/app/model"
"github.com/gogf/gf/errors/gerror" "github.com/gogf/gf/errors/gerror"
...@@ -15,7 +16,7 @@ type Notify struct { ...@@ -15,7 +16,7 @@ type Notify struct {
name string name string
password string password string
url string url string
client *sessionHttpClient client *http.SessionHttpClient
} }
func NewNotify() *Notify { func NewNotify() *Notify {
...@@ -23,7 +24,7 @@ func NewNotify() *Notify { ...@@ -23,7 +24,7 @@ func NewNotify() *Notify {
url: g.Cfg().GetString("notify.url"), url: g.Cfg().GetString("notify.url"),
name: os.Getenv("live_name"), name: os.Getenv("live_name"),
password: os.Getenv("live_pwd"), password: os.Getenv("live_pwd"),
client: NewSessionHttpClient(), client: http.NewSessionHttpClient(),
} }
} }
......
package packed package file
import ( import (
"fmt" "fmt"
......
package packed package file
import ( import (
"archive/zip" "archive/zip"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment