作者 yangfu

上传 切图

... ... @@ -37,7 +37,7 @@ user_center_app_key ="39aefef9e22744a3b2d2d3791824ae7b"
user_center_app_secret ="cykbjnfqgctn"
#Html5
h5_host = "https://web-open.fjmaimaimai.com"
h5_host = "https://web-open-test.fjmaimaimai.com"
#审核中心
suplus_host ="http://suplus-approve-dev.fjmaimaimai.com"
\ No newline at end of file
... ...
... ... @@ -38,7 +38,7 @@ user_center_app_secret ="cykbjnfqgctn"
#Html5
h5_host = "https://web-open.fjmaimaimai.com"
h5_host = "https://web-open-test.fjmaimaimai.com"
#审核中心
suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com"
... ...
... ... @@ -37,7 +37,7 @@ user_center_app_key ="39aefef9e22744a3b2d2d3791824ae7b"
user_center_app_secret ="cykbjnfqgctn"
#Html5
h5_host = "https://web-open.fjmaimaimai.com"
h5_host = "https://web-open-test.fjmaimaimai.com"
#审核中心
suplus_host ="http://suplus-approve-test.fjmaimaimai.com"
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@ go 1.12
require (
github.com/astaxie/beego v1.10.0
github.com/disintegration/imaging v1.6.2
github.com/go-sql-driver/mysql v1.4.1
github.com/gomodule/redigo v1.7.0
github.com/gorilla/websocket v1.4.1
... ... @@ -13,7 +14,6 @@ require (
github.com/satori/go.uuid v1.2.0
github.com/sony/sonyflake v1.0.0
gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
google.golang.org/appengine v1.6.2 // indirect
)
... ...
... ... @@ -26,7 +26,7 @@ func GetUserBaseInfoAggregation(id int64, companyId int64) (v *protocol.UserBase
return
}
if len(v.UserCompany.NickName) > 0 {
v.User.NickName = v.UserCompany.NickName //公司里面的用户名称
v.User.NickName = v.User.NickName
}
wg.Add(3)
go func() {
... ...
... ... @@ -3,6 +3,7 @@ package chance
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/common"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/idgen"
... ... @@ -190,7 +191,7 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques
Icon: item.Icon,
Doc: item.Doc,
FormList: make([]*protocol.Form, len(forms)),
Link: fmt.Sprintf("%v?templateId=%v", item.Id),
Link: fmt.Sprintf("%v/#/ability/opportunity?id=%v", beego.AppConfig.String("h5_host"), item.Id),
}
for j := range forms {
form := forms[j]
... ...
... ... @@ -105,7 +105,7 @@ func Announcements(header *protocol.RequestHeader, request *protocol.Announcemen
Title: bulletin.Title,
Control: int(bulletin.AllowClose),
//link:'https://web-open.fjmaimaimai.com/#/ability/announcement?id='+announcementCfgData[i].id+'&uid='+param.uid
Link: fmt.Sprintf("%v#/ability/announcement?id=%v&uid=%v", beego.AppConfig.String("h5_host"), bulletin.Id, msg.ReceiveUserId),
Link: fmt.Sprintf("%v#/ability/announcement?id=%v&uid=%v&oppo", beego.AppConfig.String("h5_host"), bulletin.Id, msg.ReceiveUserId),
}
item.Cover = protocol.Cover{
Path: bulletin.Cover,
... ...
... ... @@ -2,6 +2,7 @@ package upload
import (
"fmt"
"github.com/disintegration/imaging"
"io"
"mime/multipart"
"os"
... ... @@ -69,8 +70,9 @@ func UploadFile(request *protocol.FileRequest) (rsp *protocol.FileResponse, err
virtualPath = beego.AppConfig.String("source_host") + filepath.Join(virtualPath, request.FileType, date)
for i := range request.Files {
f := request.Files[i]
prefix := fmt.Sprintf("%v_%v", time.Now().Unix(), common.RandomString(32))
subfix := path.Ext(f.Filename)
filename = fmt.Sprintf("%v_%v%v", time.Now().Unix(), common.RandomString(32), subfix)
filename = fmt.Sprintf("%v%v", prefix, subfix)
src, err = f.Open()
if err != nil {
log.Error(err)
... ... @@ -88,10 +90,35 @@ func UploadFile(request *protocol.FileRequest) (rsp *protocol.FileResponse, err
return
}
rsp.Paths = append(rsp.Paths, filepath.Join(virtualPath, filename))
ResizeImage(request.FileType, sourcePath, prefix, subfix, f)
}
return
}
func ResizeImage(fileType int, fileName string, file *multipart.FileHeader) (err error) {
func ResizeImage(fileType, sourcePath, prefix, subfix string, file *multipart.FileHeader) (err error) {
var (
src multipart.File
thumbName = "_thumb"
)
if fileType != protocol.FileImage {
return
}
filename := fmt.Sprintf("%v%v%v", prefix, thumbName, subfix)
filename = filepath.Join(sourcePath, filename)
if src, err = file.Open(); err != nil {
log.Error(err)
return
}
image, err := imaging.Decode(src)
if err != nil {
fmt.Println(err)
return
}
image = imaging.Resize(image, 0, 200, imaging.Lanczos)
err = imaging.Save(image, filename)
if err != nil {
log.Error(err)
}
log.Debug(fmt.Sprintf("resize iamge:%v", filename))
return
}
... ...