写在前面
本篇文章将实现应用列表,同样和其他列表的不同之处,在于查询条件的不同。
系列文章
[实战]MVC5+EF6+MySql企业网盘实战(27)——应用列表
实现
查询添加还是以文件对应的图标来进行筛选。
using System;using System.Collections.Generic;using System.Linq;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.Site.Models;namespace Wolfy.NetDisk.Site.Controllers{ public class ExesController : Controller { private IMyFileServiceRepository _myFileServiceRepository = new MyFileServiceRepository(); private ILogServiceRepository _logServiceRepository = new LogServiceRepository(); private IFileTypeServiceRepository fileTypeServiceRepository = new FileTypeServiceRepository(); // // GET: /Images/ public ActionResult Lists() { UserInfo user = Session["user"] as UserInfo; if (user == null) { return RedirectToAction("Login", "UserInfo"); } return View(); } [HttpGet] public JsonResult GetApks() { UserInfo userInfo = Session["user"] as UserInfo; int page = Convert.ToInt32(Request.Params["page"]); if (page <= 0) { page = 1; } if (userInfo == null) { RedirectToAction("Login", "UserInfo"); } int pageSize = 10; int recordCount = 0; var documentPaged = _myFileServiceRepository.FindPaged(page, pageSize, out recordCount, x => x.User.Id == userInfo.Id && x.IsDelete == false && (x.FileIcon.Contains("ApkType.png")), false, x => x.CreateDt); int totalPage = Convert.ToInt32(Math.Ceiling(recordCount * 1.0 / pageSize)); List lstMyFileViewModel = new List (); foreach (var item in documentPaged) { lstMyFileViewModel.Add(new MyFileViewModel() { Id = item.Id, FileIcon = item.FileIcon, FileServerUrl = "/NetDisk/" + item.FileMd5 + item.FileExt, Name = item.Name, FileThumnailUrl = string.Empty, Size = item.FileSize, Dt = item.CreateDt }); } return new JsonResult() { Data = new JavaScriptSerializer().Serialize(new { _data = lstMyFileViewModel, _code = 200, total = totalPage }), JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } }}
前端
测试
总结
废话不多少,都在代码里。