Commit 5ff88ecc by Li Feifei

格式化代码

parent 8c41e3b3
Pipeline #15602 failed with stages
in 13 seconds
......@@ -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:
// 上传失败
......
......@@ -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 sessionHttpClient struct {
type SessionHttpClient struct {
c *ghttp.Client
}
func NewSessionHttpClient() *sessionHttpClient {
func NewSessionHttpClient() *SessionHttpClient {
jar, _ := cookiejar.New(nil)
c := g.Client()
c.Jar = jar
c.CheckRedirect = func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}
return &sessionHttpClient{c}
return &SessionHttpClient{c}
}
func (client *sessionHttpClient) Post(link string, data ...interface{}) ([]byte, error) {
return clientHttp.Handle(client.c.Timeout(10*time.Second).Post(link, data))
func (client *SessionHttpClient) Post(link string, data ...interface{}) ([]byte, error) {
return Handle(client.c.Timeout(10*time.Second).Post(link, data))
}
func (client *sessionHttpClient) Get(url string) ([]byte, error) {
return clientHttp.Handle(client.c.Timeout(10 * time.Second).Get(url))
func (client *SessionHttpClient) Get(url string) ([]byte, error) {
return Handle(client.c.Timeout(10 * time.Second).Get(url))
}
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 *sessionHttpClient
client *http.SessionHttpClient
}
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(),
}
}
......
package packed
package file
import (
"fmt"
......
package packed
package file
import (
"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