|
|
@ -6,7 +6,6 @@ import ( |
|
|
"regexp" |
|
|
"regexp" |
|
|
"strconv" |
|
|
"strconv" |
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
type MatterController struct { |
|
|
type MatterController struct { |
|
|
@ -249,52 +248,36 @@ func (this *MatterController) Page(writer http.ResponseWriter, request *http.Req |
|
|
func (this *MatterController) Upload(writer http.ResponseWriter, request *http.Request) *WebResult { |
|
|
func (this *MatterController) Upload(writer http.ResponseWriter, request *http.Request) *WebResult { |
|
|
|
|
|
|
|
|
userUuid := request.FormValue("userUuid") |
|
|
userUuid := request.FormValue("userUuid") |
|
|
|
|
|
puuid := request.FormValue("puuid") |
|
|
|
|
|
privacyStr := request.FormValue("privacy") |
|
|
|
|
|
file, handler, err := request.FormFile("file") |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
defer func() { |
|
|
|
|
|
err := file.Close() |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
user := this.checkUser(writer, request) |
|
|
user := this.checkUser(writer, request) |
|
|
|
|
|
//管理员可以传到指定用户的目录下。
|
|
|
if user.Role != USER_ROLE_ADMINISTRATOR { |
|
|
if user.Role != USER_ROLE_ADMINISTRATOR { |
|
|
userUuid = user.Uuid |
|
|
userUuid = user.Uuid |
|
|
} |
|
|
} |
|
|
user = this.userDao.CheckByUuid(userUuid) |
|
|
user = this.userDao.CheckByUuid(userUuid) |
|
|
|
|
|
|
|
|
alienStr := request.FormValue("alien") |
|
|
if puuid == "" { |
|
|
alien := false |
|
|
this.PanicBadRequest("puuid必填") |
|
|
puuid := "" |
|
|
|
|
|
|
|
|
|
|
|
if alienStr == "true" { |
|
|
|
|
|
alien = true |
|
|
|
|
|
|
|
|
|
|
|
//如果是应用文件的话,统一放在同一个地方。
|
|
|
|
|
|
puuid = this.matterService.GetDirUuid(userUuid, fmt.Sprintf("/应用数据/%s", time.Now().Local().Format("20060102150405"))) |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
puuid = request.FormValue("puuid") |
|
|
if puuid != MATTER_ROOT { |
|
|
if puuid == "" { |
|
|
//验证puuid是否存在
|
|
|
this.PanicBadRequest("puuid必填") |
|
|
this.matterDao.CheckByUuidAndUserUuid(puuid, userUuid) |
|
|
} else { |
|
|
|
|
|
if puuid != MATTER_ROOT { |
|
|
|
|
|
//找出上一级的文件夹。
|
|
|
|
|
|
this.matterDao.CheckByUuidAndUserUuid(puuid, userUuid) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
privacy := false |
|
|
privacy := privacyStr == TRUE |
|
|
privacyStr := request.FormValue("privacy") |
|
|
|
|
|
if privacyStr == "true" { |
|
|
|
|
|
privacy = true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
err := request.ParseMultipartForm(32 << 20) |
|
|
err = request.ParseMultipartForm(32 << 20) |
|
|
this.PanicError(err) |
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
file, handler, err := request.FormFile("file") |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
|
|
|
|
|
|
defer func() { |
|
|
|
|
|
err := file.Close() |
|
|
|
|
|
this.PanicError(err) |
|
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
//对于IE浏览器,filename可能包含了路径。
|
|
|
//对于IE浏览器,filename可能包含了路径。
|
|
|
fileName := handler.Filename |
|
|
fileName := handler.Filename |
|
|
pos := strings.LastIndex(fileName, "\\") |
|
|
pos := strings.LastIndex(fileName, "\\") |
|
|
@ -306,7 +289,7 @@ func (this *MatterController) Upload(writer http.ResponseWriter, request *http.R |
|
|
fileName = fileName[pos+1:] |
|
|
fileName = fileName[pos+1:] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
matter := this.matterService.Upload(file, user, puuid, fileName, privacy, alien) |
|
|
matter := this.matterService.Upload(file, user, puuid, fileName, privacy, false) |
|
|
|
|
|
|
|
|
return this.Success(matter) |
|
|
return this.Success(matter) |
|
|
} |
|
|
} |
|
|
@ -338,7 +321,7 @@ func (this *MatterController) Crawl(writer http.ResponseWriter, request *http.Re |
|
|
|
|
|
|
|
|
privacy := false |
|
|
privacy := false |
|
|
privacyStr := request.FormValue("privacy") |
|
|
privacyStr := request.FormValue("privacy") |
|
|
if privacyStr == "true" { |
|
|
if privacyStr == TRUE { |
|
|
privacy = true |
|
|
privacy = true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -464,7 +447,7 @@ func (this *MatterController) ChangePrivacy(writer http.ResponseWriter, request |
|
|
uuid := request.FormValue("uuid") |
|
|
uuid := request.FormValue("uuid") |
|
|
privacyStr := request.FormValue("privacy") |
|
|
privacyStr := request.FormValue("privacy") |
|
|
privacy := false |
|
|
privacy := false |
|
|
if privacyStr == "true" { |
|
|
if privacyStr == TRUE { |
|
|
privacy = true |
|
|
privacy = true |
|
|
} |
|
|
} |
|
|
//找出该文件或者文件夹
|
|
|
//找出该文件或者文件夹
|
|
|
|