泰山磨剑
十年磨一剑
十年磨一剑
我的首页
文章
相册
圈子
留言
管理
 
    当前所在页面:首页>>文章>>基于.Net平台的extjs单用户Blog系统
基于.Net平台的extjs单用户Blog系统
    作者: 来源: 发表时间:2008-04-14

 
 

  这是通过Java版本的Wlr单用户Blog系统改写的系统,是一个基于ExtSJ技术实现的简单blog系统,演示了ExtJS的综合应用。

  系统后台使用.Net平台,语言为C#,技术构架为NHibernate+Spring.Net+Vifir实现,支持多种数据库,采用三层结构,数据访问层DAO、业务逻辑层及表示层完全分离。DAO层使用的泛型DAO,只需要一个DAO接口即可,不需要写具体的实现。

  系统演示:http://www.vifir.com/resources/records/codes/wlrblog-net/wlrblog-net.html

  系统下载地址:http://www.vifir.com/download/extblog-net.zip

  下面是系统后台的截图

  

  (登录)

  系统中的一些源码摘要:

  域模型:  

namespace Vifir.Model.Domain
{
   public class Topic
    {
        private long id;
        
        private string title;      

        private string content;
        
        private string intro;       

        private TopicCategory category;       

        private IList<TopicComment> comments = new List<TopicComment>();

       private DateTime inputTime = DateTime.Now;
       
        private int readTimes = 0;
       public virtual long Id
        {
            get { return id; }
            set { id = value; }
        }
       public virtual string Title
        {
            get { return title; }
            set { title = value; }
        }
       public virtual string Content
        {
            get { return content; }
            set { content = value; }
        }
       public virtual string Intro
        {
            get { return intro; }
            set { intro = value; }
        }
       public virtual TopicCategory Category
        {
            get { return category; }
            set { category = value; }
        }
       public virtual IList<TopicComment> Comments
        {
            get { return comments; }
            set { comments = value; }
        }
       public virtual DateTime InputTime
        {
            get { return inputTime; }
            set { inputTime = value; }
        }
       public virtual int ReadTimes
        {
            get { return readTimes; }
            set { readTimes = value; }
        }
    }
}

  DAO接口

namespace Vifir.Model.DAO
{
    public interface ITopicDAO : GenericDAO
    {
    }
}

  泛型DAO配置

<object id="TopicDao" parent="abstractDao">
    <property name="proxyInterfaces" value="Vifir.Model.DAO.ITopicDAO"/>
    <property name="target">
      <object parent="baseDAO" type="Vifir.Core.GenericDAOImpl&lt;Vifir.Model.Domain.Topic>,Vifir.Core" />
    </property>
  </object>

  TopicService业务层实现代码

namespace Vifir.Model.Service.Impl
{
    public class TopicServiceImpl:ITopicService
    {
        	private ITopicDAO topicDao;

    public ITopicDAO TopicDao
    {
      set { topicDao = value; }
    }
	

	public long addTopic(Topic topic) {	
		this.topicDao.Save(topic);
		return topic.Id;
	}
	
	public Topic getTopic(long id) {
		Topic topic = this.topicDao.Get(id);
		return topic;
		}
	
	public bool delTopic(long id) {	
			Topic topic = this.getTopic(id);
			if(topic.Comments.Count>0)throw new LogicException("该文章下还有评论,不能删除!");
			if (topic != null) {
				this.topicDao.Remove(id);
				return true;
			}			
			return false;	
	}
	
	
	public IPageList getTopicBy(IQueryObject queryObject) {	
		return QueryUtil.query(queryObject, typeof(Topic),this.topicDao);		
	}
	
	public bool updateTopic(long id, Topic topic) {
        if (id != default(long))
        {
			topic.Id=id;
		} else {
			return false;
		}
		this.topicDao.Update(topic);
		return true;
	}	
    }
}

 Web层的添删改查代码:  

public partial class manage_Topic : BaseAction
{
    private ITopicService service;   
    private ITopicCategoryService categoryService;
    public ITopicService Service
    {
        set { service = value; }
    }
    public ITopicCategoryService CategoryService
    {  
        set { categoryService = value; }
    }

    public void List()
    {
        QueryObject qo = new QueryObject();
        ToPo(qo);
        string categoryId = Request.Params["categoryId"];
        if (categoryId != null && !"".Equals(categoryId))
        {
            qo.addQuery("obj.Category.id", long.Parse(categoryId), "=");
        }
        IPageList pageList = service.getTopicBy(qo);
        jsonResult = pageList;
    }

    public void Remove()
    {
        long id = long.Parse(Request.Params["id"]);
        service.delTopic(id);
        jsonResult = true;
    }

    public void Save()
    {
       Topic obj = new Topic();
       ToPo(obj);
       string CategoryId = Request.Params["CategoryId"];
       if (CategoryId != null && !"".Equals(CategoryId))
       {
         TopicCategory c = this.categoryService.getTopicCategory(long.Parse(CategoryId));
         obj.Category = c;
       }
       if (!HasError())
       service.addTopic(obj);
       extFormResult = true;
    }

    public void Update()
    {
        long id = long.Parse(Request.Params["id"]);
        Topic obj = service.getTopic(id);
        ToPo(obj);
        string CategoryId = Request.Params["CategoryId"];
        if (CategoryId != null && !"".Equals(CategoryId))
        {
            TopicCategory c = this.categoryService.getTopicCategory(long.Parse(CategoryId));
            obj.Category = c;
        }
        if (!HasError())
            service.updateTopic(id, obj);
        extFormResult = true;
    }
}
 
 

(阅读 )   评论数(:5)
评论】 【收藏】
评论:共5条
This site is like a classroom, eecpxt I don't hate it. lol
评论人: BKWjQurCwtzvJ     评论时间: 2012-02-10 20:45:46
1Ax5S9  <a href="http://asqnkgdewnfl.com/">asqnkgdewnfl</a>
评论人: SdAnulNpAnWUXY     评论时间: 2012-02-11 17:26:20
CAfURe , [url=http://tpzxoyiwpens.com/]tpzxoyiwpens[/url], [link=http://afwipkobmwbh.com/]afwipkobmwbh[/link], http://jsizeymuwxoq.com/
评论人: tcOpJOSjgXoNPLBN     评论时间: 2012-02-11 23:51:31
sRPItQ  <a href="http://xaudaqertayc.com/">xaudaqertayc</a>
评论人: DNovdmdv     评论时间: 2012-02-13 20:24:41
NIc23P , [url=http://qdnshyxiodiw.com/]qdnshyxiodiw[/url], [link=http://ijlkvbzjseyu.com/]ijlkvbzjseyu[/link], http://czybvhximmdq.com/
评论人: yZvPhyrFJx     评论时间: 2012-02-14 22:43:12

发表评论:
发表人:
评论: 
验证码:
请输入前面图中的四位验证码,字母不区分大小写
  
 
关于我们 | 诚聘英才 | 联系我们 | 广告业务 | 网站地图 | 法律声明

EasyJF开源团队版权所有  建议使用1024*768分辨率