码迷,mamicode.com
首页 > 其他好文 > 详细

【SSM部落客(博客)项目实战13】首页功能完善

时间:2016-08-08 12:58:02      阅读:358      评论:0      收藏:0      [点我收藏+]

标签:

这个模块总体有四个功能要实现,但是不难,所以我打算一起写出来了。
1按照日志类别查询日志
这块做法很简单 就是拼数据到后台进行查询 难点sql代码 大家可以看下

    <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>

    <select id="findById" parameterType="Integer" resultMap="BlogTypeResult">
        select * from t_blogType where id=#{id}
    </select>

2按照日志日期查询日志
这块做法很简单 就是拼数据到后台进行查询 难点sql代码 大家可以看下

<select id="list" parameterType="Map" resultMap="BlogResult">
        select * from t_blog
        <where>
            <if test="typeId!=null and typeId!=‘‘ ">
                and typeId=#{typeId}
            </if>
            <if test="releaseDateStr!=null and releaseDateStr!=‘‘ ">
                and DATE_FORMAT(releaseDate,‘%Y年%m月‘)=#{releaseDateStr}
            </if>
        </where>
        order by releaseDate desc
        <if test="start!=null and size!=null">
            limit #{start},#{size}
        </if>
    </select>

    <select id="getTotal" parameterType="Map" resultType="Long">
        select count(*) from t_blog
        <where>
            <if test="typeId!=null and typeId!=‘‘ ">
                and typeId=#{typeId}
            </if>
            <if test="releaseDateStr!=null and releaseDateStr!=‘‘ ">
                and DATE_FORMAT(releaseDate,‘%Y年%m月‘)=#{releaseDateStr}
            </if>
        </where>
    </select>

3博主个人介绍页面实现
因为我初始化的时候吧这块的信息读取出来了 存储到application中 所以后面用到这个会直接取 但是有个问题就是会有缓存问题 后台一旦是修改了 前台不会变 但是不用担心 后面我会加个缓存清空的功能的

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<div class="data_list">
        <div class="data_list_title">
            <img src="${pageContext.request.contextPath}/static/images/about_icon.png"/>
            关于博主
        </div>
    <div style="padding: 30px">
        ${blogger.profile }
    </div>
</div>

技术分享

4联系博主下载源码
这个页面是凑份子的 页面数据完全是写死的 只是想告诉大家 不一定所有的数据都要是从数据库读取的 如何选择 应该看应用看需求 O(∩_∩)O哈哈~

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<div class="data_list">
        <div class="data_list_title">
    <img src="${pageContext.request.contextPath}/static/images/download_icon.png"/>
    联系博主下载源码</div>
    <div style="padding: 30px">
        源码拒绝分享  哈哈哈
    </div>
</div>

技术分享


【正在看本人博客的这位童鞋,我看你气度不凡,谈吐间隐隐有王者之气,日后必有一番作为!下面有个“顶”字,你就顺手把它点了吧(要先登录CSDN账号哦 )】


—–乐于分享,共同进步!
—–更多文章请看:http://blog.csdn.net/duruiqi_fx


【SSM部落客(博客)项目实战13】首页功能完善

标签:

原文地址:http://blog.csdn.net/duruiqi_fx/article/details/52150645

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!