[实战]MVC5+EF6+MySql企业网盘实战(12)——新建文件夹和上传文件
写在前面
之前的上传文件的功能,只能上传到根目录,前两篇文章实现了新建文件夹的功能,则这里对上传文件的功能进行适配。
系列文章
[EF]vs15+ef6+mysql code first方式
[实战]MVC5+EF6+MySql企业网盘实战(2)——用户注册
[实战]MVC5+EF6+MySql企业网盘实战(3)——验证码
[实战]MVC5+EF6+MySql企业网盘实战(4)——上传头像
[实战]MVC5+EF6+MySql企业网盘实战(5)——登录界面,头像等比例压缩
[实战]MVC5+EF6+MySql企业网盘实战(5)——页面模板
[实战]MVC5+EF6+MySql企业网盘实战(5)——ajax方式注册
[实战]MVC5+EF6+MySql企业网盘实战(6)——ajax方式登录
[实战]MVC5+EF6+MySql企业网盘实战(7)——文件上传
[实战]MVC5+EF6+MySql企业网盘实战(8)——文件下载、删除
[实战]MVC5+EF6+MySql企业网盘实战(9)——编辑文件名
[实战]MVC5+EF6+MySql企业网盘实战(10)——新建文件夹
[实战]MVC5+EF6+MySql企业网盘实战(11)——新建文件夹2
[实战]MVC5+EF6+MySql企业网盘实战(12)——新建文件夹和上传文件
代码片段
发现如果从数据表中的filePath中获取目录,比较繁琐,干脆在myfile表中添加一个表示目录的字段folderPath,这样获取某个目录下的文件相对更方便一点。同时考虑有文件名称这个字段了,就将filePath这个字段删除了。
所以调整后的代码如下:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using Wolfy.NetDisk.BLL;
using Wolfy.NetDisk.IBLL;
using Wolfy.NetDisk.Model;
using Wolfy.NetDisk.Utilities; namespace Wolfy.NetDisk.Site.Controllers
{
public class HomeController : Controller
{
private IUserInfoServiceRepository _userInfoServiceRepository = new UserInfoServiceRepository();
private IMyFileServiceRepository _myFileServiceRepository = new MyFileServiceRepository();
[HttpGet]
public ActionResult FileList()
{
UserInfo userInfo = Session["user"] as UserInfo;
if (userInfo == null)
{
return RedirectToAction("Login", "UserInfo");
}
string folderPath = Request.Params["path"];
Expression<Func<MyFile, bool>> where = null;
if (string.IsNullOrEmpty(folderPath))
{ where = x => x.User.Id == userInfo.Id && x.FolderPath == "/NetDisk/" + userInfo.UserName + "/";
}
else
{
//保证路径格式一直以/结束
folderPath = folderPath.TrimEnd('/') + "/";
where = x => x.User.Id == userInfo.Id && !x.IsDelete && x.FolderPath == folderPath;
}
var fileList = _myFileServiceRepository.FindAll(where).OrderBy(x => x.IsFolder).OrderByDescending(x => x.CreateDt);
ViewBag.UserInfo = userInfo;
ViewBag.ChildTitle = "我的网盘";
return View(fileList);
} [HttpPost]
public void UploadFile(string filePath)
{
UserInfo userInfo = Session["user"] as UserInfo;
if (userInfo == null)
{
RedirectToAction("Login", "UserInfo");
}
var files = Request.Files;
if (files.Count > )
{
var file = files[];
string fileName = file.FileName;
Stream inputStream = file.InputStream;
string fileSaveFolder = string.Empty;
if (!string.IsNullOrEmpty(filePath))
{
filePath = Server.UrlDecode(filePath);
fileSaveFolder = Server.MapPath("~/" + filePath); }
else
{
fileSaveFolder = Request.MapPath("~/NetDisk/" + userInfo.UserName);
} //如果目标不存在,则创建
if (!Directory.Exists(fileSaveFolder))
{
Directory.CreateDirectory(fileSaveFolder); }
byte[] buffer = new byte[inputStream.Length];
//判断是否已经超出个人网盘大小
var myFiles = _myFileServiceRepository.FindAll(x => x.User.Id == userInfo.Id);
int myDiskSize = ;
if (myFiles.Count() > )
{
myDiskSize = myFiles.Sum(x => x.FileSize);
}
//如果已经超出网盘大小,则给出提示
if (myDiskSize + buffer.Length > userInfo.NetDiskSize)
{
AlertMsg("对不起,您的网盘空间不足,请清理后再次上传,或联系管理员进行扩容。", "");
return;
}
inputStream.Read(buffer, , buffer.Length);
string strFileMd5 = MD5Helper.GetMD5FromFile(buffer);
string fileSavePath = Path.Combine(fileSaveFolder, filePath);
fileSavePath = Path.Combine(fileSaveFolder, fileName);
//如果文件已经存在
if (System.IO.File.Exists(fileSavePath))
{
//对文件进行重命名
fileName = ReNameHelper.FileReName(fileSavePath);
fileSavePath = Path.Combine(fileSaveFolder, fileName);
}
file.SaveAs(fileSavePath);
var currentUser = _userInfoServiceRepository.Find(x => x.Id == userInfo.Id);
MyFile myFile = new MyFile()
{
FileMd5 = strFileMd5,
ModifyDt = DateTime.Now,
IsDelete = false,
FileSize = buffer.Length,
FolderPath = filePath,
FileExt = Path.GetExtension(fileSavePath),
CreateDt = DateTime.Now,
FileName = fileName,
FileIcon = GetFileIcon(Path.GetExtension(fileSavePath)),
User = currentUser,
IsFolder =
};
//保存数据库
_myFileServiceRepository.Add(myFile);
_myFileServiceRepository.SaveChanges();
string json = new JavaScriptSerializer().Serialize(myFile);
AlertMsg("上传成功", json);
}
}
private void AlertMsg(string msg, string fileJson)
{
Response.ContentType = "text/html";
Response.Write("<script>parent.showMsg('" + msg + "','" + fileJson + "');</script>");
Response.End();
}
private string GetFileIcon(string fileExt)
{
string fileIconPath = "/Content/Images/";
switch (fileExt.ToLower())
{
case ".doc":
case ".docx":
fileIconPath += "DocType.png";
break;
case ".xlx":
case ".xlxs":
fileIconPath += "XlsType.png";
break;
case ".ppt":
case ".pptx":
fileIconPath += "PptType.png";
break;
case ".pdf":
fileIconPath += "PdfType.png";
break;
case ".apk":
fileIconPath += "ApkType.png";
break;
case ".dwt":
case ".dwg":
case ".dws":
case ".dxf":
fileIconPath += "CADType.png";
break;
case ".exe":
fileIconPath += "ExeType.png";
break;
case ".png":
case ".gif":
case ".jpg":
fileIconPath += "ImgType.png";
break;
case ".txt":
fileIconPath += "TxtType.png";
break;
case ".bt":
fileIconPath += "TorrentType.png";
break;
case ".rmvb":
case ".avi":
case ".flv":
fileIconPath += "VideoType.png";
break;
case ".zip":
case ".7z":
case ".rar":
fileIconPath += "MusicType.png";
break;
case ".mp3":
fileIconPath += "MusicType.png";
break;
default:
fileIconPath += "OtherType.png";
break;
}
return fileIconPath;
}
/// <summary>
/// 文件下载
/// </summary>
/// <param name="fileId"></param>
public void DownLoadFile(string fileId)
{
UserInfo userInfo = Session["user"] as UserInfo;
if (userInfo == null)
{
RedirectToAction("Login", "UserInfo");
return;
}
if (string.IsNullOrEmpty(fileId))
{
throw new ArgumentNullException("fileId is errror");
}
int id = Convert.ToInt32(fileId);
var findFile = _myFileServiceRepository.Find(x => x.Id == id);
if (findFile == null)
{
AlertMsg("文件不存在", "");
return;
}
string filePath = Request.MapPath("~/" + findFile.FolderPath + "/" + findFile.FileName);
//以字符流的形式下载文件
FileStream fs = new FileStream(filePath, FileMode.Open);
byte[] bytes = new byte[(int)fs.Length];
fs.Read(bytes, , bytes.Length);
fs.Close();
Response.ContentType = "application/octet-stream";
//通知浏览器下载文件而不是打开
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(findFile.FileName, System.Text.Encoding.UTF8));
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
public void DeleteFile(string fileId)
{
UserInfo userInfo = Session["user"] as UserInfo;
if (userInfo == null)
{
RedirectToAction("Login", "UserInfo");
return;
}
if (string.IsNullOrEmpty(fileId))
{
throw new ArgumentNullException("fileId is errror");
}
int id = Convert.ToInt32(fileId);
var findFile = _myFileServiceRepository.Find(x => x.Id == id);
if (findFile == null)
{
AlertMsg("文件不存在", "");
return;
}
findFile.IsDelete = true;
_myFileServiceRepository.Update(findFile);
int count = _myFileServiceRepository.SaveChanges();
if (count > )
{
var response = new { code = , fileId = findFile.Id };
Response.Write(new JavaScriptSerializer().Serialize(response));
}
} public JsonResult EditFileName()
{
string fileId = Request.Form["fileId"];
string fileNewName = Request.Form["fileNewName"];
UserInfo userInfo = Session["user"] as UserInfo;
if (userInfo == null)
{
RedirectToAction("Login", "UserInfo");
}
int id = Convert.ToInt32(fileId);
var findFile = _myFileServiceRepository.Find(x => x.Id == id);
findFile.FileName = fileNewName;
_myFileServiceRepository.Update(findFile);
int count = _myFileServiceRepository.SaveChanges();
if (count > )
{
var response = new
{
code = ,
msg = "更新成功"
};
return new JsonResult() { Data = new JavaScriptSerializer().Serialize(response) };
}
return new JsonResult() { Data = new JavaScriptSerializer().Serialize(new { code = , msg = "保存失败" }) };
} public JsonResult CreateFolder()
{
UserInfo userInfo = Session["user"] as UserInfo; if (userInfo == null)
{
RedirectToAction("Login", "UserInfo");
}
string folderPath = Server.UrlDecode(Request.Params["folderPath"]);
string folderName = Request.Params["folderName"];
if (string.IsNullOrEmpty(folderName))
{
throw new ArgumentNullException("文件夹名称不能为空");
}
//检查文件夹是否已经存在
Expression<Func<MyFile, bool>> where = null;
if (string.IsNullOrEmpty(folderPath))
{
where = x => x.User.Id == userInfo.Id && x.IsFolder == && x.IsDelete == false && x.FolderPath == "/NetDisk/Wolfy/";
}
else
{
where = x => x.User.Id == userInfo.Id && x.IsFolder == && x.IsDelete == false && x.FolderPath == folderPath;
}
var count = _myFileServiceRepository.FindAll(where).Count();
userInfo = _userInfoServiceRepository.Find(x => x.Id == userInfo.Id);
if (count > )
{
//如果不存在,则新建,否则进行自动重命名
folderName = folderName + "(" + (count + ).ToString() + ")";
}
if (string.IsNullOrEmpty(folderPath))
{
folderPath = "/NetDisk/" + userInfo.UserName;
}
MyFile folder = new MyFile()
{
FolderPath = folderPath.TrimEnd('/') + "/",
FileName = folderName,
CreateDt = DateTime.Now,
User = userInfo,
FileExt = string.Empty,
FileIcon = "/Content/Images/FolderType.png",
FileMd5 = string.Empty,
FileSize = ,
IsDelete = false,
ModifyDt = DateTime.Now
};
try
{
_myFileServiceRepository.Add(folder);
_myFileServiceRepository.SaveChanges();
}
catch (Exception)
{
return new JsonResult() { Data = new JavaScriptSerializer().Serialize(new { code = , msg = "创建失败" }) };
}
return new JsonResult() { Data = new JavaScriptSerializer().Serialize(new { code = , folder = folder }) };
}
}
}
HomeController
前端代码如下
@model IEnumerable<Wolfy.NetDisk.Model.MyFile> @{
ViewBag.Title = "FileList";
Layout = "~/Views/Shared/_Layout.cshtml"; }
<button id="btnUpload" class="btn-primary">上传文件</button>
<button class="btn-primary" id="btnNewFolder">新建文件夹</button> <div class="box-content" id="fileList">
<div class="dataTables_wrapper" role="grid">
<table id="fileList" class="table table-striped table-bordered responsive" aria-describedby="DataTables_Table_0_info">
<thead>
<tr role="row">
<th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Username: activate to sort column descending" style="width: 312px;">文件名</th> <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Role: activate to sort column ascending" style="width: 144px;">大小</th>
<th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Date registered: activate to sort column ascending" style="width: 263px;">修改日期</th> <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Actions: activate to sort column ascending" style="width: 549px;">操作</th>
</tr>
</thead> <tbody role="alert" aria-live="polite" aria-relevant="all">
@{int i = 0;}
@foreach (var item in Model)
{
i++;
<tr class="i%2==0?'even':'odd'" id="tr-@item.Id"> @{
if (@item.FileMd5 != "")
{
<td class=" even sorting_1"><img src="@item.FileIcon" alt="" /> <span id="sp-@item.Id">@item.FileName</span></td>
<td class="center ">@item.FileSize 字节</td>
}
else
{
<td class=" even sorting_1">
<a href="FileList?path=@item.FolderPath@item.FileName" id="lnkFolder-@item.Id" onclick="clickFolder('sp-@item.Id')">
<img src="@item.FileIcon" alt="@item.FileName" />
<span id="sp-@item.Id">@item.FileName</span>
</a>
</td>
<td class="center "></td>
}
} <td class="center ">@item.ModifyDt</td> <td class="center "> <a class="btn btn-info" href="javascript:void(0)" onclick="editFile(@item.Id,'@item.FileName')">
<i class="glyphicon glyphicon-edit icon-white"></i>
编辑
</a>
<a class="btn btn-danger" href="javascript:void(0)" onclick="deleteFile(@item.Id)">
<i class="glyphicon glyphicon-trash icon-white"></i>
删除
</a>
@{ if (@item.FileMd5 != "")
{ <a class="btn btn-success" href="/Home/DownLoadFile?fileId=@item.Id">
<i class="glyphicon glyphicon-zoom-in icon-white"></i>
下载
</a> } }
</td>
</tr> }
</tbody>
</table>
</div>
</div>
<div class="modal fade" id="modal-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true"> <div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3 id="alertTitlte">编辑</h3>
</div>
<div class="modal-body"> </div>
<div class="modal-footer">
<a href="#" class="btn btn-default" data-dismiss="modal" id="lnkCancel">取消</a>
<a href="#" class="btn btn-primary" data-dismiss="modal" id="lnkSave">保存</a>
</div>
</div>
</div>
</div> <form action="UploadFile" id="fileForm" method="post" enctype="multipart/form-data" target="fileFrame">
<input type="file" accept="*/*" style="display:none" id="btnFile" name="fileData" />
<input type="hidden" id="hdFilePath" name="filePath" value="" />
<input type="hidden" id="hdcallbackInfo" name="name" value="" />
</form> <iframe style="display:none" name="fileFrame" id="fileFrame"></iframe>
<script>
function CurentTime() {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
if (hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm;
return (clock);
};
//上传成功后,单击确定,更新刚刚拼接文件信息
function showMsg(msg, callbackInfo) {
if (msg) {
$(".modal-body").html(msg);
//回调信息
$("#hdcallbackInfo").val(callbackInfo);
console.log(callbackInfo);
//为确定按钮注册单击事件,确定后更新拼接在列表上的文件信息
$('#fileListSure').bind('click', function () {
var fileInfo = $("#hdcallbackInfo").val();
console.log(fileInfo);
fileInfo = JSON.parse(fileInfo);
$("#fileDownLoad").attr("href", "/Home/DownLoadFile?fileId=" + fileInfo.Id);
$("#fileName").html('<img src="' + fileInfo.FileIcon + '" id="fileicon" alt="" />' + fileInfo.FileName + '');
});
$("#myModal").modal("show");
};
};
//创建文件夹
$('#btnNewFolder').click(function () {
//设置弹出框标题
var title = $('#alertTitlte').html();
//从url中获取当前目录
var url = window.location.href;
console.log(url);
if (url.indexOf('path') > 1) {
$('#hdFilePath').val(url.split('=')[1]);
};
$('#alertTitlte').html('新建文件夹');
//清空弹出框内容
$(".modal-body").html('');
$(".modal-body").html('<input type="text" placeholder="请输入名称" class="form-control" name="name" value="新建文件夹" id="txtFileName" />');
$('#txtFileName').val('');
$('#modal-edit').modal('show');
$('#txtFileName').val('新建文件夹');
$('#lnkSave').unbind('click');
$('#lnkSave').bind('click', function () {
$.post('CreateFolder', { folderName: $('#txtFileName').val(), folderPath: $('#hdFilePath').val() }, function (data) {
data = JSON.parse(data);
var folder = data.folder;
if (data.code == 200) {
$('<tr class="odd"> <td class=" even sorting_1" id="fileName"> <a href="#" id="lnkFolder-' + folder.Id + '" onclick="clickFolder(sp-' + folder.Id + ')"><img src="/Content/Images/FolderType.png" id="fileicon" alt="" />' + folder.FileName + '</a></td><td class="center"></td><td class="center ">' + CurentTime() + '</td><td class="center "><a class="btn btn-info" href="#" id="fileEdit"> <i class="glyphicon glyphicon-edit icon-white"></i> 编辑 </a><a class="btn btn-danger" href="#"><i class="glyphicon glyphicon-trash icon-white" id="fileDelete"></i> 删除 </a> </td></tr>').insertBefore($('#fileList tbody')); };
//还原弹出框标题
$('#alertTitlte').html(title);
});
}); });
//编辑文件名
function editFile(fileId, fileName) {
$(".modal-body").html('');
$(".modal-body").html('<input type="text" placeholder="请输入名称" class="form-control" name="name" value="' + fileName + '" id="txtFileName" />');
$("#modal-edit").modal('show');
//弹出框注册取消,保存事件
$('#lnkCancel').click(function () {
//单机取消,清空内容
$("#txtFileName").val('');
});
//首先移除已经绑定的单机事件
$('#lnkSave').unbind('click');
$('#lnkSave').bind('click', function () {
var file = {
fileId: fileId,
fileNewName: $('#txtFileName').val()
};
$.post("/Home/EditFileName", file, function (data) {
data = JSON.parse(data);
if (data.code == 200) {
$('#sp-' + fileId).html(file.fileNewName);
}
});
}); };
function deleteFile(fileId) {
console.log(fileId);
$.getJSON("/Home/DeleteFile?fileId=" + fileId, function (data) {
console.log(data.code);
if (data.code == 4) { $("#tr-" + fileId).remove();
}; });
}; $('#btnUpload').click(function () {
//从url中获取当前目录
var url = window.location.href;
console.log(url);
if (url.indexOf('path') > 1) {
$('#hdFilePath').val(url.split('=')[1]);
};
$("#btnFile").click();
});
$("#btnFile").change(function () {
var files = this.files;
for (var i = 0; i < files.length; i++) {
var file = files[i];
console.log(file);
$('<tr class="odd"> <td class=" even sorting_1" id="fileName"><img src="/Content/Images/othertype.png" id="fileicon" alt="" />' + file.name + '</td><td class="center">' + file.size + ' 字节</td><td class="center ">' + CurentTime() + '</td><td class="center "><a class="btn btn-info" href="#" id="fileEdit" > <i class="glyphicon glyphicon-edit icon-white"></i> 编辑 </a><a class="btn btn-danger" href="#"><i class="glyphicon glyphicon-trash icon-white" id="fileDelete"></i> 删除 </a> <a class="btn btn-success" href="#" id="fileDownLoad"><i class="glyphicon glyphicon-zoom-in icon-white"></i> 下载 </a></td></tr>').appendTo($('#fileList tbody'));
};
$('#fileForm').submit();
}); </script>
FileList.cshtml
测试
总结
将新建文件夹与上传文件功能组合。
[实战]MVC5+EF6+MySql企业网盘实战(12)——新建文件夹和上传文件的更多相关文章
- [实战]MVC5+EF6+MySql企业网盘实战(28)——其他列表
写在前面 本篇文章将实现,其他文件类型的列表. 系列文章 [EF]vs15+ef6+mysql code first方式 [实战]MVC5+EF6+MySql企业网盘实战(1) [实战]MVC5+EF ...
- [实战]MVC5+EF6+MySql企业网盘实战(27)——应用列表
写在前面 本篇文章将实现应用列表,同样和其他列表的不同之处,在于查询条件的不同. 系列文章 [EF]vs15+ef6+mysql code first方式 [实战]MVC5+EF6+MySql企业网盘 ...
- [实战]MVC5+EF6+MySql企业网盘实战(26)——音乐列表
写在前面 本篇文章将实现,音乐列表,同样和其他列表的不同之处,在于查询条件的不同. 系列文章 [EF]vs15+ef6+mysql code first方式 [实战]MVC5+EF6+MySql企业网 ...
- [实战]MVC5+EF6+MySql企业网盘实战(25)——种子列表
写在前面 上篇文章实现了视频列表,本篇文章继续实现其他的文件列表.功能相似.这里就不再赘述. 系列文章 [EF]vs15+ef6+mysql code first方式 [实战]MVC5+EF6+MyS ...
- [实战]MVC5+EF6+MySql企业网盘实战(24)——视频列表
写在前面 上篇文章实现了文档列表,所以实现视频列表就依葫芦画瓢就行了. 系列文章 [EF]vs15+ef6+mysql code first方式 [实战]MVC5+EF6+MySql企业网盘实战(1) ...
- [实战]MVC5+EF6+MySql企业网盘实战(23)——文档列表
写在前面 上篇文章实现了图片列表,这篇文章实现文档列表将轻车熟路,因为逻辑基本相似,只是查询条件的不同.这里将txt,doc,docx,ppt,pptx,xls,xlsx的文件都归为文档列表中. 系列 ...
- [实战]MVC5+EF6+MySql企业网盘实战(22)——图片列表
写在前面 实现逻辑是:单击图片节点,加载所有的当前用户之前上传的图片,分页,按时间倒序加载. 系列文章 [EF]vs15+ef6+mysql code first方式 [实战]MVC5+EF6+MyS ...
- [实战]MVC5+EF6+MySql企业网盘实战(21)——网盘操作日志
写在前面 上篇文章介绍了一个bootstrap的分页插件,这篇将弄一个完整的例子,就以日志分页为例说明如何请求服务端然后进行分页. 系列文章 [EF]vs15+ef6+mysql code first ...
- [实战]MVC5+EF6+MySql企业网盘实战(20)——Bootstrap Paginator
写在前面 考虑到数据量的问题,特引入bootstrap的分页插件.插件下载地址:https://github.com/lyonlai/bootstrap-paginator 系列文章 [EF]vs15 ...
随机推荐
- Codeforces Round #209 (Div. 2)A贪心 B思路 C思路+快速幂
A. Table time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- [CQOI2009] 中位数 (前缀和)
[CQOI2009] 中位数 题目描述 给出1~n的一个排列,统计该排列有多少个长度为奇数的连续子序列的中位数是b.中位数是指把所有元素从小到大排列后,位于中间的数. 输入输出格式 输入格式: 第一行 ...
- ASP.NET MVC4+EasyUI+EntityFrameWork5权限管理系统——数据库的设计(一)
快一年没写博客了,这段时间感觉好迷茫,写点博客,记录一下自己的成长过程,希望对大家也有帮助 先上图 一个用户可以有多个角色,一个用户可以属于多个部门,这些都可以控制到权限,有时特殊要求,同样的部门和角 ...
- Log-structured File Systems
换到博客园排版有问题,原版在这里:http://xubenbenhit.github.io/LogStructureFileSystem.html Log-structured File System ...
- Js冒泡事件详解及阻止
Js冒泡机制是指如果某元素定义了事件A,如click事件,如果触发了事件之后,没有阻止冒泡事件,那么事件将向父级元素传播,触发父类的click函数. 如下例所示: <html> & ...
- 用C++写一个没人用的ECS
github地址:https://github.com/yangrc1234/Resecs 在做大作业的时候自己实现了一个简单的ECS,起了个名字叫Resecs. 这里提一下一些实现的细节,作为回顾. ...
- 在Unity中实现屏幕空间反射Screen Space Reflection(4)
第四部分讲一下如何在2D屏幕空间步进光线. http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html 中的代码感 ...
- 【leetcode 简单】第三十三题 验证回文串
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写. 说明:本题中,我们将空字符串定义为有效的回文串. 示例 1: 输入: "A man, a plan, a c ...
- 背包DP FOJ 2214
题目:http://acm.fzu.edu.cn/problem.php?pid=2214 (http://www.fjutacm.com/Problem.jsp?pid=2053) 这题看起来是一题 ...
- RF, GBDT, XGB区别
GBDT与XGB区别 1. 传统GBDT以CART作为基分类器,xgboost还支持线性分类器(gblinear),这个时候xgboost相当于带L1和L2正则化项的逻辑斯蒂回归(分类问题)或者线性回 ...