美文网首页
2019-05-29

2019-05-29

作者: TW_BBK_陈思瑶 | 来源:发表于2019-05-29 17:57 被阅读0次

实验课听课列表

  1. 结合course表、user表、courseanduser表查询所有课程
    HTML页面代码
     <li th:style="'display:' + @{(${session.user.state==0} ? 'block' : 'none')} + ''">
                <a href="javascript:;">
                    <i class="iconfont">&#xe726;</i>
                    <cite>听课管理</cite>
                    <i class="iconfont nav_right">&#xe697;</i>
                </a>
                <ul class="sub-menu">
                    <li>
                        <a th:_href="@{/course/SelectKecheng}">
                            <i class="iconfont">&#xe6a7;</i>
                            <cite>实验课听课列表</cite>
                        </a>
                    </li >
                    <li>
                        <a th:_href="@{/course/SelectKecheng_two}">
                            <i class="iconfont">&#xe6a7;</i>
                            <cite>理论课听课列表</cite>
                        </a>
                    </li >
                </ul>
            </li> 
    

对应的courseController代码

@RequestMapping("SelectKecheng")
    public String SelectKecheng(Model model,Course course, Integer pageNum, Integer pageSize) {
        if (pageNum==null || pageNum==0) {
            //当前页
            pageNum=1;
        }
        if (pageSize==null) {
            //每页的数量
            pageSize=4;
        }
        PageInfo<Course> page= courseService.queryByPage(course, pageNum, pageSize);
        model.addAttribute("page",page);
        
        return "admin-rule";    
    }

对应的courseServiceImpl.java代码

@Override
    public PageInfo<Course> queryByPage(Course course, Integer pageNum, Integer pageSize) {
        //获取当前页pageNum,pageSize条内容,开始分页
        // 第一行是设置页数和每页显示几条,插件会自动对接下来的sql语句加上分页方式。
        Page<Course> page=PageHelper.startPage(pageNum, pageSize,true);
        System.out.println("course.getName"+course.getName());
        //查询所有数据
        courseMapper.SelectKecheng(course.getName());
        //PageInfo中是分页的一些信息,包括总页数,当前页,总数据等。
        return page.toPageInfo();
    }

对应的courseMapper.java代码

List<Course> SelectKecheng(@Param("name") String name);

对应的courseMapper.xml代码

<select id="SelectKecheng" resultMap="ResultMap">
        SELECT c.*,u.id AS uid,u.name AS uname,u.classes AS uclasses,u.sorce AS usorce,u.lsorce AS ulsorce FROM `course` AS c
        JOIN `courseanduser` AS cu
        ON c.id=cu.cid
        JOIN `user` AS u
        ON cu.uid=u.id
        <where>
            <if test="name!=null and name!=''">
                c.name like concat ('%',#{name},'%')
            </if>
            and u.state=2
            ORDER BY u.sorce DESC
        </where>
</select>

将查询数据渲染到页面上

    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form layui-col-md12 x-so"
                th:action="@{/course/SelectKecheng}" method="post">
                <input type="text" name="name" placeholder="请输入课程名称"
                    autocomplete="off" class="layui-input">
                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                    <i class="layui-icon">&#xe615;</i>
                </button>
            </form>
        </div>
        <table class="layui-table">
            <thead>
                <tr>
                    <th>课程ID</th>
                    <th>课程名字</th>
                    <th>课程内容</th>
                    <th>该课程老师</th>
                    <th>班级</th>
                    <th>总分</th>
                    <th>操作</th>
            </thead>
            <tbody>
                <tr class="r" th:each="item : ${page.list}">
                    <td th:text="${item.id}">1</td>
                    <td th:text="${item.name}">admin/user/userlist</td>
                    <td th:text="${item.context}">admin/user/userlist</td>
                    <td th:text="${item.user.name}">admin/user/userlist</td>
                    <td th:text="${item.user.classes}">会员列表</td>
                    <td class="z" th:text="${item.user.sorce}" th:id="${item.user.id}" ></td>
                    <td class="td-manage">
                        <a style="color: yellowgreen;" title="查看听课老师" th:onclick="openModak(this,[[${item.id}]])"
                        href="javascript:;"> <i class="layui-icon">&#xe62e;</i>
                        </a>
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="page">
            <div>
                <a class="prev" th:href="@{/course/SelectKecheng?(pageNum=${page.prePage})}">上一页</a> 
                <a class="next" th:href="@{/course/SelectKecheng?(pageNum=${page.nextPage})}">下一页</a>
            </div>
        </div>

    </div>
  1. 查看听课老师
    HTML页面代码
 <td class="td-manage">
  <a style="color: yellowgreen;" title="查看听课老师" th:onclick="openModak(this,[[${item.id}]])"
 href="javascript:;"> <i class="layui-icon">&#xe62e;</i>  </a>
 </td>

var socre = 0;
function openModak(obj,id) {
        var url=[[@{/user/SelectTingKeLaoShi}]];
            $.ajax({
                url:url,
                type:"post",
                dataType:"json",
                data:{
                    id:id
                },
                success:function(result){
                    $(".tbody").html("");
                 $.each(result,function(i,obj){
                    var b=("<tr>"+
                            "<td>"+obj.name+"</td>"+
                            "<td>"+obj.classes+"</td>"+
                            "<td>"+obj.ex.time+"</td>"+
                            "<td>"+obj.ex.topic+"</td>"+
                            "<td>"+obj.ex.address+"</td>"+
                            "<td>"+obj.ex.evaluate+"</td>"+
                            "<td>"+obj.ex.comment+"</td>"+
                            "<td class='f'>"+obj.ex.score+"</td>"+
                        "</tr>");
                    socre += obj.ex.score;
                     $(".tbody").append(b);
                });
                 var uid=$(".z").attr("id");
                
                var url=[[@{/user/XiuGaiZongFen}]];
                    $.ajax({
                        url:url,
                        type:"post",
                        data:{
                            sorce:socre,
                            id:uid
                        },
                        success:function(result){
                            
                        }
                        
                    });
                 form.render();
                }       
            });
            layui.use([ 'layer' ], function() {
                var layer = layui.layer, $ = layui.$;
                layer.open({
                    type : 1,//类型
                    area : [ '900px', '500px' ],//定义宽和高
                    title : '查看听课老师',//题目
                    shadeClose : false,//点击遮罩层关闭
                    content : $('#motaikunag')
                //打开的内容
                });
            })
        }

userController.java

@RequestMapping("SelectTingKeLaoShi")
    @ResponseBody
    public List<User> SelectTingKeLaoShi(String id) {

        List<User> list = userService.SelectTingKeLaoShi(id);

        System.out.println(JSON.toJSONString(list));

        return list;
    }

userServiceImpl.java

@Override
    public List<User> SelectTingKeLaoShi(String id) {
        return userMapper.SelectTingKeLaoShi(id);
    }

userMapper.java

 List<User> SelectTingKeLaoShi(@Param("id") String id);

userMapper.xml

<select id="SelectTingKeLaoShi" resultMap="ResultMap_two">
        SELECT u.*,e.topic AS
        etopic,e.time AS etime, e.address AS eaddress,e.evaluate AS
        eevaluate,e.comment AS ecomment,e.score AS escore FROM `user` AS u
        JOIN `experiment` AS e
        ON u.id=e.uid
        JOIN course AS c
        ON e.courseid=c.id
        WHERE c.id=#{id}
    </select>

将数据渲染到页面上

<div id="motaikunag" style="display: none;">
        <table style="margin-top: 0%" class="layui-table main"   width="100%" border="0" cellspacing="0" cellpadding="0" >
            <colgroup>
                <col width="150">
                <col width="200">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th>听课老师</th>
                    <th>该老师班级</th>
                    <th>听课时间</th>
                    <th>课题</th>
                    <th>地址</th>
                    <th>评价</th>
                    <th>评论</th>
                    <th>分数</th>
                </tr>
            </thead>
            <tbody class="tbody">
                
            </tbody>
        </table>
    </div>

相关文章

  • ajax应用

    2019-05-29 Ajax简介 ​ Ajax(Asynchronous Javascript And XM...

  • cockroachDB学习笔记(二)

    title: cockroachDB学习笔记二date: 2019-05-29 21:57:57tags: 基础架...

  • 2019-05-30

    陈蒋 2019-05-29 姓名:陈蒋,公司名称:扬州滋奇餐饮有限公司 ...

  • 2019-5-29晨间日记

    2019-05-29 【践行人员】袁顺娟 【践行天数】210/1000 【今日天气】雨 【昨日早睡】22:30 【...

  • new Date().getDay()在不同时区的

    new Date("2019-05-29").getDay() 在不同时区得到的值不一样 new Date("20...

  • Pandas-log

    Day 1 2019-05-29 Pandas 的数据结构介绍 Series Series 是一种类似于一维数组的...

  • 2019-06-25

    2019-05-29 心惠语录: 人成了,事就成了。 别人怎样对你,是你自己吸引来到。 别人在你身边,是...

  • 极致践行号竹子林分队13次读书会

    时间:2019-05-29 地点:深圳福田竹子林 人员: 主持:晓莹 分享:美芳、秀音 旁听:绮舒、琼羽 一、题记...

  • 2019-05-29晨跑5

    时间:2019-05-29 06:00 线路:天马河绿道 成绩:10公里用时59分06秒 感受:因为雨,昨天多歇了...

  • 2019-05-29

    2019-05-29 姓名:郭祥华 组别:315期六项精进努力一组 【日精进打卡第529】 【知~学习】 背诵《...

网友评论

      本文标题:2019-05-29

      本文链接:https://www.haomeiwen.com/subject/flqutctx.html