In order to reduce the load on the server, so I intend to initialize some basic information into the cache, so that some initialization of the operation can not always query, greatly reduce the burden of the server, while the user experience will be greatly improved.
Don't say much nonsense I began to put the core code out, together to see.
Similar to the previous module functionality, the only trouble is that the data query statement is a little more difficult to write.
Query statement:
<?xml version= "1.0" encoding= "UTF-8"?><! DOCTYPE mapperpublic "-//mybatis.org//dtd Mapper 3.0//en" "Http://mybatis.org/dtd/mybatis-3-mapper.dtd" ><mapper namespace="Com.duruiqi.dao.BlogDao"> <resultmap type="Blog" id="Blogresult"> <result property ="id" column="id"/> <result property ="title " Column="title"/> <result property ="Summary" column="Summary"/> <result property ="ReleaseDate" column="ReleaseDate"/> <result property ="Clickhit" column="Clickhit"/> <result property ="Replyhit" column="Replyhit"/ > <result property ="Content" column="Content"/> <result property ="KeyWord" column="KeyWord"/> </resultmap> <select id="Countlist" resultmap="Blogresult"> SELECT date_format (ReleaseDate, '%y years%m months ') as Releasedatestr,count (*) as Blogcount from T_blog GROUP by Date_format (releas EDate, '%y year%m Month ') ORDER by Date_format (ReleaseDate, '%y year%m month ') DESC;</Select></mapper>
<?xml version= "1.0" encoding= "UTF-8"?><! DOCTYPE mapperpublic "-//mybatis.org//dtd Mapper 3.0//en" "Http://mybatis.org/dtd/mybatis-3-mapper.dtd" ><mapper namespace="Com.duruiqi.dao.BlogTypeDao"> <resultmap type="Blogtype" id="Blogtyperesult"> <result property ="id" column="id"/> <result property ="TypeName" column="TypeName"/ > <result property ="OrderNo" column="OrderNo"/> </resultmap> <select id="Countlist" resultmap="Blogtyperesult" >SELECT T2.id,t2.typename,count (t1.id) as Blogcount from T_blog T1 right JOIN t_blogtype T2 on t1.typeid=t2.id GROUP by T2 . TypeName ORDER by T2.orderno;</Select></mapper>
Monitoring controls
Blogtypeservice blogtypeservice= (Blogtypeservice) ApplicationContext. Getbean("Blogtypeservice");List<blogtype> Blogtypecountlist=blogtypeservice. Countlist();//Query the category of blogs and the number of blogsApplication. SetAttribute("Blogtypecountlist", blogtypecountlist);Blogservice blogservice= (Blogservice) ApplicationContext. Getbean("Blogservice");List<blog> Blogcountlist=blogservice. Countlist();//Search Blogs by date groupApplication. SetAttribute("Blogcountlist", blogcountlist);
Page get
<c:foreach var = items = "${blogtypecountlist}" ; <li ; <span ; <a href =; ${blogtypecount.typename} (${blogtypecount.blogcount} ) </a ; </span ; </li > </c:foreach ;
<c:foreach var = items = "${blogcountlist}" ; & Lt li ; <span <a href =; ${blogcount.releasedatestr} (${blogcount.blogcount}) </a ; </ span ; </li </c:foreach ;
Page effect:
Basic information initialized to this end, very simple, O (∩_∩) o haha ~
"is looking at my blog of the children's shoes, I see you imposing, the conversation between the faint king of the gas, there will be a future!" There is a "top" word, you can conveniently point it (to login csdn account first) "
-willing to share and progress together!
- More articles please see: Http://blog.csdn.net/duruiqi_fx
"SSM Blogger (blog) Project combat 09" Initialize log category and log date information data