This is a system rewritten through the Java WLR single-user Blog system. It is a simple blog System Based on extsj technology and demonstrates the comprehensive application of extjs.
System background usage.. NET platform. The language is C # And the technical architecture is nhib.pdf + spring. net + vifir implementation, supports a variety of databases, uses a three-tier structure, data access layer Dao, business logic layer and presentation layer completely separated. The generic Dao used by the DaO layer only requires a DaO interface and does not require specific implementation.
System Demo: http://www.vifir.com/resources/records/codes/wlrblog-net/wlrblog-net.html
System: http://www.vifir.com/download/extblog-net.zip
(Note: This code is only for learning and use. It is not an open-source project. It is just a demo of extjs in. NET platform, the download source code is only part of the web layer, the business layer has been encapsulated into the DLL, you can use vs2005 (SP1) or a later version to open, create an empty database before running. The system automatically creates a table based on the domain model !)
Below is the system Background
(LOGIN)
System source code summary:
Domain Model:
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 Interface
namespace Vifir.Model.DAO
{
public interface ITopicDAO : GenericDAO
{
}
}
Generic Dao Configuration
<object id="TopicDao" parent="abstractDao">
<property name="proxyInterfaces" value="Vifir.Model.DAO.ITopicDAO"/>
<property name="target">
<object parent="baseDAO" type="Vifir.Core.GenericDAOImpl<Vifir.Model.Domain.Topic>,Vifir.Core" />
</property>
</object>
Topicservice business layer implementation code
Namespace vifir. model. Service. impl
{
Public class topicserviceimpl: itopicservice
{
Private itopicdao topicdao;
Public itopicdao topicdao
{
Set {topicdao = value ;}
}
Public long addtopic (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 ("this article has comments and cannot be deleted! ");
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 ){
If (ID! = Default (long ))
{
Topic. ID = ID;
} Else {
Return false;
}
This. topicdao. Update (topic );
Return true;
}
}
}
Add, delete, modify, and query code for the web layer:
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;
}
}