先看一下文章管理設(shè)想要實(shí)現(xiàn)的功能:







再看一下類圖







這里Category是欄目;CommonModel是公共模型;Article是文章;Attachment是附件;

CommonModel是內(nèi)容管" />

国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

15158846557 在線咨詢 在線咨詢
15158846557 在線咨詢
所在位置: 首頁 > 營銷資訊 > 網(wǎng)站運(yùn)營 > ASP.NET MVC5網(wǎng)站開發(fā)文章管理架構(gòu)(七)

ASP.NET MVC5網(wǎng)站開發(fā)文章管理架構(gòu)(七)

時(shí)間:2023-05-28 06:33:01 | 來源:網(wǎng)站運(yùn)營

時(shí)間:2023-05-28 06:33:01 來源:網(wǎng)站運(yùn)營

ASP.NET MVC5網(wǎng)站開發(fā)文章管理架構(gòu)(七):一、總體說明

先看一下文章管理設(shè)想要實(shí)現(xiàn)的功能:







再看一下類圖







這里Category是欄目;CommonModel是公共模型;Article是文章;Attachment是附件;

CommonModel是內(nèi)容管理這塊抽取出來的公共部分,像文章,咨詢甚至產(chǎn)品都有一些共同的內(nèi)容這里把它單獨(dú)提取出來作為一個(gè)類。CommonModel可能包含一片文章,包含一組附件,包含一系列評(píng)論,他們之間的關(guān)系類圖中已經(jīng)表示出來。

二、搭建架構(gòu)

這個(gè)順序根以前一樣







1、IDAL

在IDAL添加接口InterfaceCommonModelRepository,其實(shí)只是繼承自InterfaceBaseRepository,沒有添加任何其他內(nèi)容。




12345678910111213namespace Ninesky.IDAL{ /// <summary> /// 公共模型接口 /// <remarks> /// 創(chuàng)建:2014.02.23 /// 修改:2014.02.28 /// </remarks> /// </summary> public interface InterfaceCommonModelRepository:InterfaceBaseRepository<Models.CommonModel> { }}



再依次添加InterfaceCategory,InterfaceArticle,InterfaceAttachment,方式和公共模型接口相同。

2、DAL

DAL中是對(duì)IDAL接口的實(shí)現(xiàn),還是從CommonModel開始,先添加CommonModelRepository,也是跟原來一樣直接繼承沒有什么代碼。




123456789101112namespace Ninesky.DAL{ /// <summary> /// 公共模型倉儲(chǔ) /// <remarks> /// 創(chuàng)建:2014.02.23 /// </remarks> /// </summary> public class CommonModelRepository:BaseRepository<Models.CommonModel>, IDAL.InterfaceCommonModel { }}



然后依次添加CategoryRepository,ArticleRepository,AttachmentRepository。

3.IBLL

這次先從InterfaceCategoryService開始,InterfaceArticleService,InterfaceCommentService,InterfaceAttachmentService。InterfaceCommonModelService內(nèi)容較多放在最后。
InterfaceCategoryService

具體功能會(huì)在做欄目的時(shí)候再寫,這里暫時(shí)空著。




123456789101112namespace Ninesky.IBLL{ /// <summary> /// 欄目服務(wù)接口 /// <remarks> /// 創(chuàng)建:2014.02.23 /// </remarks> /// </summary> public class InterfaceCategoryService:InterfaceBaseService<Models.Category> { }}



4.BLL

同樣先從CategoryService開始,然后依次添加ArticleService,AttachmentService。CommonModelService。




1234567891011121314151617181920using Ninesky.DAL;using Ninesky.IBLL;using Ninesky.Models;using System;using System.Collections.Generic;using System.Linq; namespace Ninesky.BLL{ /// <summary> /// 欄目服務(wù) /// <remarks> /// 創(chuàng)建:2014.02.27 /// </remarks> /// </summary> public class CategoryService:BaseService<Category>,InterfaceCategoryService { public CategoryService() : base(RepositoryFactory.CategoryRepository) { } }}



5、Web

在web項(xiàng)目的Member區(qū)域下添加三個(gè)空控制器。

欄目控制器CategoryController




1234567891011121314151617181920using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using Ninesky.IBLL;using Ninesky.BLL; using Ninesky.Models; namespace Ninesky.Web.Areas.Member.Controllers{ [Authorize] public class CategoryController : Controller { private InterfaceCategoryService categoryRepository; public CategoryController() { categoryRepository = new CategoryService(); } }}



文章控制器ArticleController




123456789101112131415161718using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using Ninesky.Models;using Ninesky.IBLL;using Ninesky.BLL; namespace Ninesky.Web.Areas.Member.Controllers{ public class ArticleController : Controller { private InterfaceArticleService articleService; private InterfaceCommonModelService commonModelService; public ArticleController() { articleService = new ArticleService(); commonModelService = new CommonModelService(); } }}



附件控制器AttachmentController




123456789101112131415161718192021222324using System;using System.Collections.Generic;using System.Linq;using System.Collections;using System.Web;using System.Web.Mvc;using System.IO;using Ninesky.IBLL;using Ninesky.BLL;using Ninesky.Models; namespace Ninesky.Web.Areas.Member.Controllers{ /// <summary> /// 附件控制器 /// <remarks> /// 創(chuàng)建:2014.03.05 /// </remarks> /// </summary> [Authorize] public class AttachmentController : Controller { }}


關(guān)鍵詞:管理,發(fā)文

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉