Fix a lot of details.
This commit is contained in:
@ -5,6 +5,8 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MatterController struct {
|
type MatterController struct {
|
||||||
@ -213,7 +215,7 @@ func (this *MatterController) Upload(writer http.ResponseWriter, request *http.R
|
|||||||
alien = true
|
alien = true
|
||||||
|
|
||||||
//如果是应用文件的话,统一放在同一个地方。
|
//如果是应用文件的话,统一放在同一个地方。
|
||||||
puuid = this.matterService.GetDirUuid(userUuid, "/应用数据")
|
puuid = this.matterService.GetDirUuid(userUuid, fmt.Sprintf("/应用数据/%s", time.Now().Local().Format("20060102150405")))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
puuid = request.FormValue("puuid")
|
puuid = request.FormValue("puuid")
|
||||||
|
@ -95,7 +95,7 @@ func (this *MatterService) Upload(file multipart.File, user *User, puuid string,
|
|||||||
//判断用户自身上传大小的限制。
|
//判断用户自身上传大小的限制。
|
||||||
if user.SizeLimit >= 0 {
|
if user.SizeLimit >= 0 {
|
||||||
if written > user.SizeLimit {
|
if written > user.SizeLimit {
|
||||||
panic("您最大只能上传" + HumanFileSize(user.SizeLimit, false) + "的文件")
|
panic("您最大只能上传" + HumanFileSize(user.SizeLimit) + "的文件")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,11 @@ func (this *UserController) Login(writer http.ResponseWriter, request *http.Requ
|
|||||||
Expires: expiration}
|
Expires: expiration}
|
||||||
http.SetCookie(writer, &cookie)
|
http.SetCookie(writer, &cookie)
|
||||||
|
|
||||||
|
//更新用户上次登录时间和ip
|
||||||
|
user.LastTime = time.Now()
|
||||||
|
user.LastIp = GetIpAddress(request)
|
||||||
|
this.userDao.Save(user)
|
||||||
|
|
||||||
return this.Success(user)
|
return this.Success(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +110,7 @@ func (this *UserController) Create(writer http.ResponseWriter, request *http.Req
|
|||||||
panic("邮箱必填!")
|
panic("邮箱必填!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
avatarUrl := request.FormValue("avatarUrl")
|
||||||
phone := request.FormValue("phone")
|
phone := request.FormValue("phone")
|
||||||
gender := request.FormValue("gender")
|
gender := request.FormValue("gender")
|
||||||
role := request.FormValue("role")
|
role := request.FormValue("role")
|
||||||
@ -140,6 +146,7 @@ func (this *UserController) Create(writer http.ResponseWriter, request *http.Req
|
|||||||
Phone: phone,
|
Phone: phone,
|
||||||
Gender: gender,
|
Gender: gender,
|
||||||
City: city,
|
City: city,
|
||||||
|
AvatarUrl: avatarUrl,
|
||||||
SizeLimit: sizeLimit,
|
SizeLimit: sizeLimit,
|
||||||
Status: USER_STATUS_OK,
|
Status: USER_STATUS_OK,
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,9 @@ import (
|
|||||||
|
|
||||||
//把一个大小转变成方便读的格式
|
//把一个大小转变成方便读的格式
|
||||||
//human readable file size
|
//human readable file size
|
||||||
func HumanFileSize(bytes int64, si bool) string {
|
func HumanFileSize(bytes int64) string {
|
||||||
var thresh int64 = 1000
|
var thresh int64 = 1024
|
||||||
if si {
|
|
||||||
thresh = 1024
|
|
||||||
}
|
|
||||||
if bytes < 0 {
|
if bytes < 0 {
|
||||||
bytes = 0
|
bytes = 0
|
||||||
}
|
}
|
||||||
@ -19,9 +17,7 @@ func HumanFileSize(bytes int64, si bool) string {
|
|||||||
return fmt.Sprintf("%dB", bytes)
|
return fmt.Sprintf("%dB", bytes)
|
||||||
}
|
}
|
||||||
var units = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
|
var units = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
|
||||||
if si {
|
|
||||||
units = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
|
|
||||||
}
|
|
||||||
var u = 0
|
var u = 0
|
||||||
var tmp = float64(bytes)
|
var tmp = float64(bytes)
|
||||||
var standard = float64(thresh)
|
var standard = float64(thresh)
|
||||||
|
Reference in New Issue
Block a user