项目【学会】:SSM框架实现查询会议,新增会议,修改会议

整体描述:3个功能,会议的全部展示,插入新的会议记录,id要求不可修改自动增长,id展示形式:年份+申込書種類+顺番(后期申込書種類不放入id里了),修改会议记录。

 

查询全部会议功能:

展示效果:

 

JSP界面(表格部分):

<div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>名前</th>
                                    <th>開始日</th>
                                    <th>終了日</th>
                                    <th>会議日</th>
                                    <th>操作</th>
                                </tr>
                                </thead>

                                <tbody>

                                <c:forEach items="${select}" var="item" >
                                <tr>
                                    <td>${item.meetingid}</td>
                                    <td>${item.meetingname}</td>
                                    <td><fmt:formatDate value="${item.meetingstartdate}" pattern="yyyy/MM/dd"/></td>
                                    <td><fmt:formatDate value="${item.mettingenddate}" pattern="yyyy/MM/dd"/></td>
                                    <td><fmt:formatDate value="${item.meetingstarttime}" type="time" timeStyle="medium"/></td>
                                    <td><button class="label label-table label-success" style="border:1px solid #91c957;border-radius:4px;width:80px;" ><a href="/meetingupdate?id=${item.meetingid}" style="color:#fff;">变更</a></button></td>
                                </tr>

                                </c:forEach>

                                </tbody>
                            </table>
                        </div>

Controller层:

@Controller
public class MeetingShowController {

    @Autowired
    MeetingShowService meetingShowService;


    @RequestMapping("/meetingshow")
    public ModelAndView meetingShow()
    {
        ModelAndView modelandview = new ModelAndView("meetinglist_show");
        List<MeetingShowDto> meetingShowSelect = meetingShowService.meetingShowSelect();
        modelandview.addObject("select",meetingShowSelect);
        return modelandview;
    }
}

Service层:

@Service
public class MeetingShowService {

    @Autowired
    MeetingShowDao meetingShowDao;

    public List<MeetingShowDto> meetingShowSelect (){return meetingShowDao.meetingShowSelect();}
}

Dao层:

@Component

public interface MeetingShowDao {
    List<MeetingShowDto> meetingShowSelect();
}

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>

   <!--     <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="ACTIVE"></result>

    </resultMap>

    <select id="meetingShowSelect" resultMap="SelectAll" >
    select * from meeting
    </select>

</mapper>

 

新增会议功能:点击新增,id实现自动增长,id由日期和4位顺番组成。申请书种类查询其他表中显示激活的种类。

展示效果:

 

JSP页面:

<form class="form-horizontal" id="form" method="post" action="/meetingInsert">
                                    <div class="panel-body">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">ID</label>
                                            <div class="col-sm-6">
                                                <input type="text" placeholder="${zz}" class="form-control input-sm" id="meetingid" name="meetingid" value="${zz}" readonly="readonly">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">会議名称</label>
                                            <div class="col-sm-6">
                                                <input type="text" placeholder="会議名称" class="form-control" id="meetingname" name="meetingname" >
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">会議紹介</label>
                                            <div class="col-sm-6">
                                                <input type="text" placeholder="会議紹介" class="form-control input-lg" id="meetingintroduce" name="meetingintroduce">
                                            </div>
                                        </div>


                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">申込開始日</label>
                                            <div class="col-sm-6">
                                                <input type="text" placeholder="申込開始日" class="form-control input-lg" id="datetimepicker3" name="meetingstartdate">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">申込終了日</label>
                                            <div class="col-sm-6">
                                                <input type="text" placeholder="申込終了日" class="form-control input-lg" id="datetimepicker4" name="mettingenddate" >
                                            </div>
                                        </div>


                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">会議開催日</label>
                                            <div class="col-sm-6">
                                                <input type="text" placeholder="会議開催日" class="form-control input-lg" id="datetimepicker4a" name="meetingstarttime">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">申込書種類選択</label>
                                            <div class="col-sm-6">

                                                <div class="checkbox">

                                                    <c:forEach items="${applicationselect}" var="item" >
                                                    <label class="form-checkbox form-normal form-primary active"><input type="checkbox" value="${item.applicationid}" id="typeselect" name="typeselect">${item.applicationname}</label>
                                                    </c:forEach>

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


                                    <div class="panel-footer" style="border:0px;background:#fff;">
                                        <div class="row">
                                            <div class="col-sm-9 col-sm-offset-3" style="margin-left:0px;width:100%;text-align: center;">
                                                <button class="btn btn-info btn-labeled fa fa-user fa-lg" type="submit" style="margin-right:1%;" >確認</button>
                                                <button class="btn btn-warning btn-labeled fa fa-repeat fa-lg" type="button" onclick="ret()">戻る</button>
                                            </div>
                                        </div>
                                    </div>

                                </form>



<script type="text/javascript">
    $(function () {
        $('#datetimepicker3').datetimepicker({
            locale: 'zh-cn',
            viewMode: 'days',
            format: 'YYYY/MM/DD'
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $('#datetimepicker4').datetimepicker({ locale: 'zh-cn',viewMode: 'days',format: 'YYYY/MM/DD'});
    });
</script>

<script type="text/javascript">
    $(function () {
        $('#datetimepicker4a').datetimepicker({locale: 'zh-cn',format: 'HH:mm:ss'});
    });
</script>


<script>
    function ret(){
        window.location.href="/meetingshow";
    }

</script>

Controller层:

@Controller
public class MeetingShowController {

    @Autowired
    MeetingShowService meetingShowService;


    @RequestMapping("/meetinginsert")
    public ModelAndView meetingInsert()
    {
        ModelAndView modelandview = new ModelAndView("meetinglist_insert");//跳转到新页面
        List<ApplicationDto> applicationSelect = meetingShowService.applicationSelect();//查询状态是激活情况得种类名称

        List<String> mettingName = meetingShowService.meetingName();//查询会议的名称

        String str="";
        Integer[] arr = new Integer[mettingName.size()];
        String strsub=" ";
        Integer max = 0;
        for(int i=0;i<mettingName.size();i++) //遍历集合
        {
            str = mettingName.get(i);//取集合里面的数据

          if(str.length()>=4) {
              strsub = str.substring(str.length() - 4); //集合里数据只要后四位
              arr[i] =Integer.parseInt(strsub); //转化成int类型
          }

        }

        for (int i = 0; i < arr.length; i++) {  //遍历数组

            if (arr[i] > max) {
                max = arr[i]; // 找最大值输出
            }
        }
        max+=1; //最大值+1 实现自动增长的功能
        DecimalFormat df=new DecimalFormat("0000");//转化格式 4位格式前面补0
        String str1=df.format(max);//自动增长的数字给一个字符串

        Date date = new Date();
        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy");//取当前日期的年份
        String str2 =dateFormat.format(date).toString();//转化字符串
        String name=str2+str1;//拼接字符串

        modelandview.addObject("applicationselect",applicationSelect);//查询的种类返回给前端
        modelandview.addObject("zz",name);//拼接的字符串返回给前端 
        return modelandview;
    }

    @RequestMapping("/meetingInsert")
    public String meetingInsert(MeetingShowDto meetingShowDto)
    {
        Integer meetinginsert = meetingShowService.meetinginsert(meetingShowDto);
        return "redirect:/meetingshow";
    }
}

Service层:

@Service
public class MeetingShowService {

    @Autowired
    MeetingShowDao meetingShowDao;

    public List<ApplicationDto> applicationSelect(){return meetingShowDao.applicationSelect();}
    public List<String> meetingName(){return meetingShowDao.meetingName();}
    public Integer meetinginsert (MeetingShowDto meetingShowDto){return meetingShowDao.meetingInsert(meetingShowDto);}
}

Dao层:

@Component

public interface MeetingShowDao {

    List<ApplicationDto> applicationSelect();
    List<String> meetingName();
    Integer meetingInsert(MeetingShowDto meetingShowDto);
}

Mapper.xml:

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

   <!--     <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="ACTIVE"></result>

    </resultMap>


    <select id="applicationSelect" resultMap="Selectapplication" >
    select applicationid ,applicationname from application where active="1"
    </select>

    <select id="meetingName" resultType="String" >
    select MEETINGID from meeting
    </select>


    <insert id="meetingInsert" parameterType="com.smt.societymeeting.dto.MeetingShowDto">

INSERT INTO meeting(MEETINGID,MEETINGNAME,MEETINGINTRODUCE,MEETINGSTARTDATE,METTINGENDDATE,MEETINGSTARTTIME,TYPESELECT)VALUES
(#{meetingid},#{meetingname},#{meetingintroduce},#{meetingstartdate},#{mettingenddate},#{meetingstarttime},#{typeselect})
    </insert>

</mapper>

 

修改会议功能:点击修改带着条数据的其他内容显示,提交的时候修改

 

展示效果:

 

JSP页面:

         <form class="form-horizontal" id="form" method="post" action="/meetingupdateById">
                                    <div class="panel-body">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">ID</label>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control input-sm" id="meetingid" name="meetingid" value="${scc[0].meetingid}" readonly="readonly">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">会議名称</label>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control" id="meetingname" name="meetingname" value="${scc[0].meetingname}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">会議紹介</label>
                                            <div class="col-sm-6">
                                                <input type="text"  class="form-control input-lg" id="meetingintroduce" name="meetingintroduce" value="${scc[0].meetingintroduce}">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">申込開始日</label>
                                            <div class="col-sm-6">
                                                <input type="text"  class="form-control input-lg" id="datetimepicker3" name="meetingstartdate" value="<fmt:formatDate value="${scc[0].meetingstartdate}" pattern="yyyy/MM/dd"/>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">申込終了日</label>
                                            <div class="col-sm-6">
                                                <input type="text"  class="form-control input-lg" id="datetimepicker4" name="mettingenddate" value="<fmt:formatDate value="${scc[0].mettingenddate}" pattern="yyyy/MM/dd"/>">
                                            </div>
                                        </div>


                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">会議開催日</label>
                                            <div class="col-sm-6">
                                                <input type="text" class="form-control input-lg" id="datetimepicker4a" name="meetingstarttime" value="<fmt:formatDate value="${scc[0].meetingstarttime}" type="time" timeStyle="medium"/>">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label  class="col-sm-3 control-label">申込書種類選択</label>
                                            <div class="col-sm-6">


                                                <div class="checkbox">

                                                    <c:forEach items="${applicationselect}" var="item" >
                                                    <label class="form-checkbox form-normal form-primary active"><input type="checkbox" value="${item.applicationid}" id="typeselect" name="typeselect">${item.applicationname}</label>
                                                    </c:forEach>

                                                </div>



                                            </div>
                                        </div>



                                    </div>


                                    <div class="panel-footer" style="border:0px;background:#fff;">
                                        <div class="row">
                                            <div class="col-sm-9 col-sm-offset-3" style="margin-left:0px;margin-left:0px;width:100%;text-align: center;">
                                                <button class="btn btn-info btn-labeled fa fa-user fa-lg" type="submit" style="margin-right:1%;">確認</button>
                                                <button class="btn btn-warning btn-labeled fa fa-repeat fa-lg" type="button" onclick="ret()">戻る</button>
                                            </div>
                                        </div>
                                    </div>



                                </form>





<script type="text/javascript">
    $(function () {
        $('#datetimepicker3').datetimepicker({
            locale: 'zh-cn',
            viewMode: 'days',
            format: 'YYYY/MM/DD'
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $('#datetimepicker4').datetimepicker({ locale: 'zh-cn',viewMode: 'days',format: 'YYYY/MM/DD'});
    });
</script>

<script type="text/javascript">
    $(function () {
        $('#datetimepicker4a').datetimepicker({locale: 'zh-cn',format: 'HH:mm:ss'});
    });
</script>


<script>
    function ret(){
        window.location.href="/meetingshow";
    }

</script>


<script src="/resources/admin/time/js/base.js">    </script>

Controller层:

@Controller
public class MeetingShowController {

    @Autowired
    MeetingShowService meetingShowService;


    @RequestMapping("/meetingupdate")
    public ModelAndView meetingUpdate(String id)
    {
        ModelAndView modelandview  = new ModelAndView("meetinglist_update");
        List<MeetingShowDto> meetingselectbyid =meetingShowService.meetingSelectById(id);
        List<ApplicationDto> applicationSelect = meetingShowService.applicationSelect();
        modelandview.addObject("scc",meetingselectbyid);
        modelandview.addObject("applicationselect",applicationSelect);
       /* Integer meetingupdate = meetingShowService.meetingupdate(id);*/
        return modelandview;
    }

    @RequestMapping("/meetingupdateById")
    public String meetingUpdateById(MeetingShowDto meetingShowDto)
    {
      Integer meetingupdate = meetingShowService.meetingupdate(meetingShowDto);
      return "redirect:/meetingshow";
    }


}

Service层:


@Service
public class MeetingShowService {

    @Autowired
    MeetingShowDao meetingShowDao;

    public Integer meetingupdate (MeetingShowDto meetingShowDto){return meetingShowDao.meetingupdate(meetingShowDto);}
    public List<MeetingShowDto> meetingSelectById(String id){return meetingShowDao.meetingSelectById(id);}

}

Dao层:

@Component

public interface MeetingShowDao {

    Integer meetingupdate(MeetingShowDto meetingShowDto);
    List<MeetingShowDto> meetingSelectById(String id);

}

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>

   <!--     <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="ACTIVE"></result>

    </resultMap>


    <select id="meetingSelectById" resultMap="SelectAll" >
    SELECT * FROM meeting WHERE MEETINGID=#{id}
    </select>


    <update id="meetingupdate" parameterType="com.smt.societymeeting.dto.MeetingShowDto">

UPDATE meeting SET meeting.MEETINGNAME = #{meetingname},meeting.MEETINGINTRODUCE = #{meetingintroduce},meeting.MEETINGSTARTDATE = #{meetingstartdate},meeting.METTINGENDDATE = #{mettingenddate},meeting.MEETINGSTARTTIME = #{meetingstarttime},meeting.TYPESELECT = #{typeselect}
WHERE meeting.MEETINGID = #{meetingid}
    </update>


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


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

    </mappers>

</configuration>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值