/// <summary> /// 添加文件记录 /// </summary> /// <param name="model"></param> /// <returns></returns> public string AddFile(UpFileModel model) { var err = CheckModel(model); if (ValidateHelper.IsPlumpString(err)) { return(err); } //如果数据库中有就直接返回成功 var dal = new UpFileDal(); if (dal.Exist(x => x.FileMD5 == model.FileMD5 && x.UserID == model.UserID)) { return(SUCCESS); } model.CreateTime = DateTime.Now; return(dal.Add(model) > 0 ? SUCCESS : "添加文件失败"); }
/// <summary> /// 删除文件 /// </summary> /// <param name="fid"></param> /// <param name="uid"></param> /// <returns></returns> public string DeleteFile(string fid, string uid) { var dal = new UpFileDal(); var model = dal.GetFirst(x => x.UID == fid && x.UserID == uid); if (model == null) { return("数据不存在"); } var md5 = model.FileMD5; if (dal.Delete(model) > 0) { if (!dal.Exist(x => x.FileMD5 == md5)) { QiniuHelper.Delete(md5); } } return("删除失败"); }