|
|
@@ -7,18 +7,20 @@ using System.IO; |
|
|
|
|
|
|
|
namespace Learun.Application.WebApi.Modules |
|
|
|
{ |
|
|
|
public class AnnexesApiWx : BaseApi |
|
|
|
{ |
|
|
|
public AnnexesApiWx() |
|
|
|
: base("/learun/adms/annexes") |
|
|
|
public class AnnexesApiWx : BaseApi |
|
|
|
{ |
|
|
|
Get["/wxlist"] = WxGetList; |
|
|
|
Get["/wxdown"] = WxDownload; |
|
|
|
Get["/wxfileinfo"] = WxFileInfo; |
|
|
|
Post["/wxupload"] = WxUpload; |
|
|
|
Post["/wxdelete"] = WxDeleteFile; |
|
|
|
} |
|
|
|
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); |
|
|
|
public AnnexesApiWx() |
|
|
|
: base("/learun/adms/annexes") |
|
|
|
{ |
|
|
|
Get["/wxlist"] = WxGetList; |
|
|
|
Get["/wxdown"] = WxDownload; |
|
|
|
Get["/wxfileinfo"] = WxFileInfo; |
|
|
|
Post["/wxupload"] = WxUpload; |
|
|
|
Post["/wxbase64"] = WxUploadbase64; |
|
|
|
Post["/wxdelete"] = WxDeleteFile; |
|
|
|
Post["/wxuploadinsingle"] = WxUploadInSingle; |
|
|
|
} |
|
|
|
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 获取附件列表 |
|
|
@@ -33,20 +35,52 @@ namespace Learun.Application.WebApi.Modules |
|
|
|
return Success(list); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 上传附件图片文件 |
|
|
|
/// <summary> |
|
|
|
/// <returns></returns> |
|
|
|
public Response WxUpload(dynamic _) |
|
|
|
{ |
|
|
|
var files = (List<HttpFile>)this.Context.Request.Files; |
|
|
|
var folderId = this.GetReqData(); |
|
|
|
|
|
|
|
string filePath = Config.GetValue("AnnexesFile"); |
|
|
|
string uploadDate = DateTime.Now.ToString("yyyyMMdd"); |
|
|
|
string fileEextension = Path.GetExtension(files[0].Name); |
|
|
|
string fileType = fileEextension.Replace(".", ""); |
|
|
|
string fileGuid = Guid.NewGuid().ToString(); |
|
|
|
public Response WxUploadbase64(dynamic _) |
|
|
|
{ |
|
|
|
var files = (List<HttpFile>)this.Context.Request.Files; |
|
|
|
//string folderId = Request.Form["folderId"]; |
|
|
|
//string filePath = Config.GetValue("AnnexesFile"); |
|
|
|
//string uploadDate = DateTime.Now.ToString("yyyyMMdd"); |
|
|
|
//string fileEextension = Path.GetExtension(files[0].Name); |
|
|
|
//string fileType = fileEextension.Replace(".", ""); |
|
|
|
//string fileGuid = Guid.NewGuid().ToString(); |
|
|
|
byte[] bytes = new byte[files[0].Value.Length]; |
|
|
|
files[0].Value.Read(bytes, 0, bytes.Length); |
|
|
|
string src = Convert.ToBase64String(bytes); |
|
|
|
//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(); |
|
|
|
// string src = "data:image/png;base64," + Convert.ToBase64String(bytes); |
|
|
|
// //virtualPath |
|
|
|
//} |
|
|
|
|
|
|
|
return SuccessString(src); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 上传附件图片文件 |
|
|
|
/// <summary> |
|
|
|
/// <returns></returns> |
|
|
|
public Response WxUpload(dynamic _) |
|
|
|
{ |
|
|
|
var files = (List<HttpFile>)this.Context.Request.Files; |
|
|
|
string folderId = Request.Form["folderId"]; |
|
|
|
string filePath = Config.GetValue("AnnexesFile"); |
|
|
|
string uploadDate = DateTime.Now.ToString("yyyyMMdd"); |
|
|
|
string fileEextension = Path.GetExtension(files[0].Name); |
|
|
|
string fileType = fileEextension.Replace(".", ""); |
|
|
|
string fileGuid = Guid.NewGuid().ToString(); |
|
|
|
|
|
|
|
string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.userId, uploadDate, fileGuid, fileEextension); |
|
|
|
|
|
|
|