|
|
@@ -26,6 +26,8 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
Get["/pageList"] = GetPageList; |
|
|
|
Get["/form"] = GetForm; |
|
|
|
Post["/save"] = SaveForm; |
|
|
|
Post["/upload"] = Upload; |
|
|
|
Post["/deleteFiles"] = DeleteFiles; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@@ -99,8 +101,20 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
if (annexesFileEntity != null) |
|
|
|
{ |
|
|
|
url = annexesFileEntity.F_FilePath.Substring(annexesFileEntity.F_FilePath.IndexOf("Resource")); |
|
|
|
StuInfoFreshEntity.Url = url; |
|
|
|
} |
|
|
|
} |
|
|
|
//获取附件列表 |
|
|
|
var annexesFileList = annexesFileIBLL.GetList(StuInfoFreshEntity.ID); |
|
|
|
if (annexesFileList.Any()) |
|
|
|
{ |
|
|
|
foreach (var item in annexesFileList) |
|
|
|
{ |
|
|
|
item.F_FilePath = item.F_FilePath.Substring(item.F_FilePath.IndexOf("Resource")); |
|
|
|
} |
|
|
|
StuInfoFreshEntity.FilesList = annexesFileList.ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
StuInfoFreshEntity.DormitoryName = accdormitoryIBLL.GetDormitoryInfoByPlanStuNo(StuInfoFreshEntity.ID); |
|
|
|
if (StuInfoFreshEntity.IsPoor != "1") |
|
|
|
{ |
|
|
@@ -335,6 +349,87 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
return Success("保存成功!"); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 上传附件图片文件 |
|
|
|
/// <summary> |
|
|
|
/// <returns></returns> |
|
|
|
public Response Upload(dynamic _) |
|
|
|
{ |
|
|
|
var files = (List<HttpFile>)this.Context.Request.Files; |
|
|
|
var folderId = this.GetReq<FileModel>().folderId;//文件夹id=新生id |
|
|
|
|
|
|
|
string filePath = Config.GetValue("AnnexesFile"); |
|
|
|
string uploadDate = DateTime.Now.ToString("yyyyMMdd"); |
|
|
|
string FileEextension = Path.GetExtension(files[0].Name); |
|
|
|
string fileGuid = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.userId, uploadDate, fileGuid, FileEextension); |
|
|
|
|
|
|
|
//创建文件夹 |
|
|
|
string path = Path.GetDirectoryName(virtualPath); |
|
|
|
Directory.CreateDirectory(path); |
|
|
|
AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); |
|
|
|
if (!System.IO.File.Exists(virtualPath)) |
|
|
|
{ |
|
|
|
byte[] bytes = new byte[files[0].Value.Length]; |
|
|
|
files[0].Value.Read(bytes, 0, bytes.Length); |
|
|
|
FileInfo file = new FileInfo(virtualPath); |
|
|
|
FileStream fs = file.Create(); |
|
|
|
fs.Write(bytes, 0, bytes.Length); |
|
|
|
fs.Close(); |
|
|
|
|
|
|
|
//文件信息写入数据库 |
|
|
|
fileAnnexesEntity.F_Id = fileGuid; |
|
|
|
fileAnnexesEntity.F_FolderId = folderId; |
|
|
|
fileAnnexesEntity.F_FileName = files[0].Name; |
|
|
|
fileAnnexesEntity.F_FilePath = virtualPath; |
|
|
|
fileAnnexesEntity.F_FileSize = files[0].Value.Length.ToString(); |
|
|
|
fileAnnexesEntity.F_FileExtensions = FileEextension; |
|
|
|
fileAnnexesEntity.F_FileType = FileEextension.Replace(".", ""); |
|
|
|
fileAnnexesEntity.F_CreateUserId = userInfo.userId; |
|
|
|
fileAnnexesEntity.F_CreateUserName = userInfo.realName; |
|
|
|
|
|
|
|
annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); |
|
|
|
} |
|
|
|
|
|
|
|
//文件地址截取到resource后 |
|
|
|
fileAnnexesEntity.F_FilePath = fileAnnexesEntity.F_FilePath.Substring(fileAnnexesEntity.F_FilePath.IndexOf("Resource")); |
|
|
|
|
|
|
|
return Success(fileAnnexesEntity); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 删除附件 |
|
|
|
/// </summary> |
|
|
|
/// <param name="_"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public Response DeleteFiles(dynamic _) |
|
|
|
{ |
|
|
|
var fileId = this.GetReqData<FileModel>().id; |
|
|
|
|
|
|
|
AnnexesFileEntity fileInfoEntity = annexesFileIBLL.GetEntity(fileId); |
|
|
|
if (fileInfoEntity != null) |
|
|
|
{ |
|
|
|
//删除附件表 |
|
|
|
annexesFileIBLL.DeleteEntity(fileId); |
|
|
|
//删除文件 |
|
|
|
if (System.IO.File.Exists(fileInfoEntity.F_FilePath)) |
|
|
|
{ |
|
|
|
System.IO.File.Delete(fileInfoEntity.F_FilePath); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//下载 |
|
|
|
//if (FileDownHelper.FileExists(fileInfoEntity.F_FilePath)) |
|
|
|
//{ |
|
|
|
// FileDownHelper.DownLoadnew(fileInfoEntity.F_FilePath); |
|
|
|
//} |
|
|
|
} |
|
|
|
|
|
|
|
return Success("删除成功"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 私有类 |
|
|
|
|
|
|
|
/// <summary> |
|
|
@@ -389,6 +484,7 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
/// </summary> |
|
|
|
public List<StuInfoFreshEmergePeopleEntity> StuInfoFreshEmergePeopleEntities { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public class PhotoModel |
|
|
@@ -397,5 +493,10 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
public string account { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
public class FileModel |
|
|
|
{ |
|
|
|
public string folderId { get; set; } |
|
|
|
public string id { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
} |