項目【學會】:會議新增檢索功能

描述:根據會議申請開始日期,會議申請結束日期,會議開始日期和回憶狀態進行檢索。多條件檢索,或者單條件檢索,如果都爲空,則檢索全部。然後回顯到頁面上,可清空條件在此搜索。

 

頁面展示:

 

JSP頁面:進到展示一覽畫面搜素框前的內容爲空不顯示,搜索框輸入內容,提交點擊搜索後回顯剛輸入的內容。清空:清空全部輸入框的內容。

<form action="/search" method="get" style="width:98.5%;margin:0 auto;">
                    <div class="panel-body" style="padding-top:0px;margin-top:0px;">
                        <div class="pad-btm form-inline" style="padding-bottom:0px;">
                            <div class="row" >
                                <div class="col-sm-6 table-toolbar-left" style="width:100%;padding-top:25px;">

                                    <div style="width:100%;">

                                        <div style="width:20%;float:left;">
                                            <label style="float:left;height:25px;line-height:25px;">會議開始日:</label>
                                            <div class="col-sm-6" style="float:left;width:65%;">
                                                <input type="text" class="form-control input-lg" id="datetimepicker4a" name="meetingstarttime"  style="height:25px;width:100%;"  value="${backshow[0]}">
                                            </div>
                                        </div>



                                        <div style="width:20%;float:left;">
                                            <label style="float:left;height:25px;line-height:25px;">申込開始日:</label>
                                            <div class="col-sm-6" style="float:left;width:65%;">
                                                <input type="text"  class="form-control input-lg" id="datetimepicker3" name="meetingstartdate" style="height:25px;width:100%;"  value="${backshow[1]}">
                                            </div>
                                        </div>



                                        <div style="width:20%;float:left;">
                                            <label style="float:left;height:25px;line-height:25px;">申込終了日:</label>
                                            <div class="col-sm-6" style="float:left;width:65%;">
                                                <input type="text"  class="form-control input-lg" id="datetimepicker4" name="mettingenddate" style="height:25px;width:100%;"  value="${backshow[2]}">
                                            </div>
                                        </div>


                                        <div style="width:20%;float:left;">
                                            <label style="float:left;height:25px;line-height:25px;">會議の狀態</label>
                                            <div class="col-sm-6" style="float:left;width:65%;">
                                                <span id="spp" style="display:none;">${backshow[3]}</span>
                                                <select id="sta" name="sta" style="height:25px;width:100%;">
                                                    <option value =""></option>
                                                    <option value ="CLOSE">CLOSE</option>
                                                    <option value="OPEN">OPEN</option>
                                                </select>

                                            </div>
                                        </div>



                                        <div style="width:20%;float:left;text-align: right;">
                                           <button class="btn btn-info" type="submit" style="width:80px;height:25px;line-height:10px;margin-right:15px;">検索</button>
                                            <button type="button" class="btn btn-warning" onclick="res()" style="width:80px;height:25px;line-height:10px;">クリア</button>
                                        </div>


                                    </div>

                                </div>
                            </div>
                        </div>


                    </div>
                    </form>



<script type="text/javascript">

    window.onload=function xuan()
    {
        var sta = $("#spp").text();
        if(sta=="1")
        {
            $("#sta").find("option:eq(1)").attr("selected",true);
        }
        else if(sta=="0")
        {
            $("#sta").find("option:eq(2)").attr("selected",true);
        }
        else
        {
            $("#sta").find("option:eq(0)").attr("selected",true);
        }

    }

    function res()
    {
        document.getElementById("datetimepicker4a").value=null;
        document.getElementById("datetimepicker3").value=null;
        document.getElementById("datetimepicker4").value=null;
        document.getElementById("sta").options[0].selected = true;
    }
</script>

 

Controller層:

@Controller
public class MeetingShowController {

    @Autowired
    MeetingShowService meetingShowService;

    @RequestMapping("/search")
    public ModelAndView  search(HttpServletRequest request, HttpServletResponse response)
    {
        ModelAndView modelandview = new ModelAndView("meetinglist_show");
        String meetingstarttime =request.getParameter("meetingstarttime");
        String meetingstartdate =request.getParameter("meetingstartdate");
        String mettingenddate =request.getParameter("mettingenddate");
        String sta =request.getParameter("sta");

        String sta1;
        if(sta.equals("CLOSE"))
        {
            sta1="1";
        }
        else if(sta.equals("OPEN"))
        {
            sta1="0";
        }
        else
        {
            sta1="";
        }

        Map<String,Object> map = new HashMap<>();
        map.put("meetingstarttime",meetingstarttime);
        map.put("meetingstartdate",meetingstartdate);
        map.put("mettingenddate",mettingenddate);
        map.put("sta",sta1);

        List<MeetingShowDto> seach = meetingShowService.search(map);
        List<String> backshow = new ArrayList<>();
        backshow.add(meetingstarttime);
        backshow.add(meetingstartdate);
        backshow.add(mettingenddate);
        backshow.add(sta1);

        modelandview.addObject("select", seach);
        modelandview.addObject("backshow", backshow);

        return modelandview;
    }

}

 

Service層:

@Service
public class MeetingShowService {

    @Autowired
    MeetingShowDao meetingShowDao;

    public List<MeetingShowDto> search(Map<String,Object> map) {
        return meetingShowDao.search(map);
    }
}

 

Dao層:

@Component
public interface MeetingShowDao {

    List<MeetingShowDto> search(Map<String, Object> map);
}

 

Mapper.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.smt.societymeeting.dao.MeetingShowDao">


    <resultMap id="SelectAll" type="com.smt.societymeeting.dto.MeetingShowDto">

        <id property="meetingid" column="MEETINGID"></id>
        <result property="meetingname" column="MEETINGNAME"></result>
        <result property="meetingintroduce" column="MEETINGINTRODUCE"></result>
        <result property="meetingstartdate" column="MEETINGSTARTDATE"></result>
        <result property="mettingenddate" column="METTINGENDDATE"></result>
        <result property="meetingstarttime" column="MEETINGSTARTTIME"></result>
        <result property="typeselect" column="TYPESELECT"></result>
        <result property="status" column="sta"></result>

   <!--     <association property="typeselect" resultMap="Selectapplication"></association>-->

    </resultMap>

    <resultMap id="Selectapplication" type="com.smt.societymeeting.dto.ApplicationDto">

        <id property="applicationid" column="APPLICATIONID"></id>
        <result property="applicationtype" column="APPLICATIONTYPE"></result>
        <result property="applicationname" column="APPLICATIONNAME"></result>
        <result property="ative" column="sta"></result>

    </resultMap>


    <select id="search" resultMap="SelectAll">

            SELECT * FROM (SELECT * ,
        IF
        (DATE_FORMAT(MEETINGSTARTTIME,'%Y-%m-%d')<![CDATA[ <= ]]>DATE_FORMAT(NOW(),'%Y-%m-%d'),"1","0") AS sta
        FROM meeting) as tt
            <where>
                <if test="meetingstarttime!=null and meetingstarttime!=''">
                    and tt.MEETINGSTARTTIME <![CDATA[ <= ]]> #{meetingstarttime}
                </if>
                <if test="meetingstartdate!=null and meetingstartdate!=''">
                and tt.meetingstartdate <![CDATA[ <= ]]> #{meetingstartdate}
                </if>
                <if test="mettingenddate!=null and mettingenddate!=''">
                    and tt.mettingenddate <![CDATA[ <= ]]> #{mettingenddate}
                </if>
                <if test="sta!=null and sta!=''">
                    and tt.sta <![CDATA[ = ]]> #{sta}
                </if>
            </where>

    </select>
</mapper>

 

mapper-config文件:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

    <typeAliases>
        <typeAlias alias="ApplicationDto" type="com.smt.societymeeting.dto.ApplicationDto"/>
        <typeAlias alias="MeetingShowDto" type="com.smt.societymeeting.dto.MeetingShowDto"/>
       
    </typeAliases>

    <typeHandlers>
        <typeHandler handler="com.smt.societymeeting.framework.typeHandler.LocalDateTimeTypeHandler"/>
    </typeHandlers>

    <mappers>
 
        <mapper resource="com/smt/societymeeting/dao/MeetingShow-mapper.xml"/>

    </mappers>

</configuration>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章