主頁(yè) > 知識(shí)庫(kù) > ASP.NET MVC5網(wǎng)站開(kāi)發(fā)文章管理架構(gòu)(七)

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

熱門(mén)標(biāo)簽:地方門(mén)戶網(wǎng)站 百度競(jìng)價(jià)排名 硅谷的囚徒呼叫中心 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 阿里云 服務(wù)器配置 網(wǎng)站排名優(yōu)化 集中運(yùn)營(yíng)管理辦法

一、總體說(shuō)明
先看一下文章管理設(shè)想要實(shí)現(xiàn)的功能:

再看一下類圖

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

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

 二、搭建架構(gòu)
這個(gè)順序根以前一樣

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

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

 }
}

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

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

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

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

3.IBLL

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

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

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

4.BLL

同樣先從CategoryService開(kāi)始,然后依次添加ArticleService,AttachmentService。CommonModelService。

using 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:BaseServiceCategory>,InterfaceCategoryService
 {
 public CategoryService() : base(RepositoryFactory.CategoryRepository) { }
 }
}

5、Web

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

欄目控制器CategoryController

using 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

using 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

using 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
 {
 }
}

架構(gòu)結(jié)束啦,下面就開(kāi)始實(shí)現(xiàn)文章相關(guān)功能!

您可能感興趣的文章:
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)管理列表、回復(fù)及刪除(十三)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)我的咨詢列表及添加咨詢(十二)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)修改及刪除文章(十)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)添加文章(八)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶修改資料和密碼(六)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶登錄、注銷(五)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶注冊(cè)(四)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)項(xiàng)目框架(二)
  • ASP.NET MVC5網(wǎng)站開(kāi)發(fā)概述(一)
  • MVC4制作網(wǎng)站教程第三章 刪除用戶組操作3.4

標(biāo)簽:廣西 隨州 開(kāi)封 梧州 烏蘭察布 威海 甘孜 西雙版納

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP.NET MVC5網(wǎng)站開(kāi)發(fā)文章管理架構(gòu)(七)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266