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