diff --git a/rest/matter_controller.go b/rest/matter_controller.go index 291c193..9c11cd8 100644 --- a/rest/matter_controller.go +++ b/rest/matter_controller.go @@ -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") diff --git a/rest/matter_service.go b/rest/matter_service.go index 626208b..f082014 100644 --- a/rest/matter_service.go +++ b/rest/matter_service.go @@ -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) + "的文件") } } diff --git a/rest/user_controller.go b/rest/user_controller.go index 14e0376..0311582 100644 --- a/rest/user_controller.go +++ b/rest/user_controller.go @@ -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, } diff --git a/rest/util_string.go b/rest/util_string.go index ab29901..ac49eed 100644 --- a/rest/util_string.go +++ b/rest/util_string.go @@ -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)