教务管理系统之mapper层

AnswerMapper.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.example.academicadministration.dao.AnswerDao">
<insert id="addAnswer" parameterType="com.example.academicadministration.pojo.Answer">
    insert into answer (stuid, homeworkid, score, answerfile, submittime)
    VALUES(#{stuid},#{homeworkid},#{score},#{answerfile},#{submittime})
</insert>
    <update id="updateAnswer" parameterType="com.example.academicadministration.pojo.Answer">
        update answer set answerfile=#{answerfile},submittime=#{submittime} where stuid=#{stuid} and homeworkid=#{homeworkid}
    </update>
    <select id="myAnswer" resultType="com.example.academicadministration.pojo.Answer">
        select * from answer where stuid=#{stuid} and homeworkid=#{homeworkid}
    </select>
    <update id="updateScore" parameterType="com.example.academicadministration.pojo.Answer">
        update answer set score=#{score} where stuid=#{stuid} and homeworkid=#{homeworkid}
    </update>
    <delete id="deleteAnswer">
        delete from answer where stuid=#{stuid} and homeworkid=#{homeworkid}
    </delete>
</mapper>

CourseMapper.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.example.academicadministration.dao.CourseDao">
    <insert id="addCourse" parameterType="com.example.academicadministration.pojo.Course">
        insert into course
(coursename, courselimit, courseday, coursetime, courseroom, coursekind)
values (#{coursename},#{courselimit},#{courseday},#{coursetime},#{courseroom},#{coursekind})
    </insert>
    <delete id="deleteCourse">
        delete from course where courseid=#{courseid}
    </delete>

    <select id="browseCourse" resultType="com.example.academicadministration.pojo.Course">
        select * from course where courseid like #{condition} or courseroom like #{condition} or coursetime like #{condition} or courseday like #{condition} or coursekind like #{condition} or coursename like #{condition} or courselimit like #{condition} or coursenumber like #{condition}
    </select>
    <select id="checkTeacher" resultType="java.lang.String">
        select teaid from teacourse where courseid=#{courseid} and teaid=#{teaid}
    </select>
    <insert id="addTeacherCourse">
        insert ignore  into teacourse (teaid, courseid) values (#{teaid},#{courseid})
    </insert>
    <delete id="deleteTeacherCourse">
        delete from teacourse where teaid=#{stuid} and courseid=#{courseid}
    </delete>
    <insert id="addStudentCourse">
        insert ignore into stucourse (stuid, courseid) values (#{stuid},#{courseid})
    </insert>
    <update id="addNum">
        update course set coursenumber=coursenumber+1 where courseid=#{courseid}
    </update>
    <delete id="deleteStudentCourse">
        delete from stucourse where stuid=#{stuid} and courseid=#{courseid}
    </delete>
    <update id="deleteNum">
        update course set coursenumber=coursenumber-1 where courseid=#{courseid}
    </update>
    <select id="myCourse" resultType="com.example.academicadministration.pojo.Course">
        select * from course where courseid in (select courseid from stucourse where stuid=#{stuid})
    </select>
    <select id="TmyCourse" resultType="com.example.academicadministration.pojo.Course">
        select * from course where courseid in (select courseid from teacourse where teaid=#{teaid})
    </select>
    <select id="browseScore" resultType="java.lang.String">
        select coursescore from stucourse where stuid=#{stuid} and courseid=#{courseid}
    </select>
    <update id="updateScore">
        update stucourse set coursescore=#{coursescore} where stuid=#{stuid} and courseid=#{courseid}
    </update>
</mapper>

HomeworkMapper.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.example.academicadministration.dao.HomeworkDao">
<insert id="addHomework" parameterType="com.example.academicadministration.pojo.Homework">
    insert into homework (courseid, startline, endline, homeworkrequest, homeworkfile)
    VALUES(#{courseid},#{startline},#{endline},#{homeworkrequest},#{homeworkfile})
</insert>
    <delete id="deleteHomework">
        delete from homework where homeworkid=#{homeworkid}
    </delete>
    <select id="browseHomeworkAll" resultType="com.example.academicadministration.pojo.Homework">
        select * from homework where courseid = #{courseid}
    </select>
    <select id="browseHomework1" resultType="com.example.academicadministration.pojo.Homework">
        select * from homework where endline &lt;= (select curdate()) and  courseid =#{courseid}
    </select>
    <select id="browseHomework2" resultType="com.example.academicadministration.pojo.Homework">
        select * from homework where endline &gt; (select curdate()) and  courseid =#{courseid}
    </select>
</mapper>

MangerMapper.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.example.academicadministration.dao.MangerDao">
<select id="login" resultType="java.lang.String">
    select mangerpwd from manger where mangerid=#{id}
</select>
    <update id="reset">
        update manger set mangerpwd=MD5(#{newpwd}) where mangerid=#{mangerid} and MD5(mangerpwd=#{oldpwd})
    </update>
</mapper>

StudentMapper.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.example.academicadministration.dao.StudentDao">
    <insert id="addStudent" parameterType="com.example.academicadministration.pojo.Student">
        insert ignore into student
            (stuid, stupwd, stuname, stusex, sturace, stuorigin, stuenrollment, stucollege, stumajor, stuclass, stuphone, stuphoto)
        VALUES(#{stuid},MD5(#{stupwd}),#{stuname},#{stusex},#{sturace},#{stuorigin},#{stuenrollment},#{stucollege},#{stumajor},#{stuclass},#{stuphone},#{stuphoto})
    </insert>
    <delete id="deleteStudent">
        delete from student where stuid=#{stuid}
    </delete>
    <update id="inauditStudent">
        update student set stustate=false where stuid=#{stuid}
    </update>
    <update id="auditStudent">
        update student set stustate=true where stuid=#{stuid}
    </update>
    <update id="reset">
        update student set stupwd=MD5(#{newpwd}) where stuid=#{stuid} and stupwd=#{stupwd}
    </update>
    <select id="browseStudent" resultType="com.example.academicadministration.pojo.Student">
        select * from student where stuid like #{condition} or stusex like #{condition} or stuclass like #{condition} or stuorigin like #{condition}
or sturace like #{condition} or stucollege like #{condition} or stuenrollment like #{condition} or stumajor like #{condition} or stuname like #{condition}
or stuphone like #{condition}
    </select>
    <select id="myStudent" resultType="com.example.academicadministration.pojo.Student">
        select * from student where stuid in (select stuid from stucourse where courseid=#{courseid})
    </select>
</mapper>

TeacherMapper.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.example.academicadministration.dao.TeacherDao">
    <insert id="addTeacher" parameterType="com.example.academicadministration.pojo.Teacher">
        insert ignore into teacher
            (teaid, teapwd, teaname, teasex, tearace, teaorigin, teacollege, teapost, teagraduation, teadegree, teaphone, teaphoto)
        VALUES (#{teaid},MD5(#{teapwd}),#{teaname},#{teasex},#{tearace},#{teaorigin},#{teacollege},#{teapost},#{teagraduation},#{teadegree},#{teaphone},#{teaphoto})
    </insert>
    <delete id="deleteTeacher">
        delete from teacher where teaid=#{teaid}
    </delete>
    <update id="inauditTeacher">
        update teacher set teastate=false where teaid=#{teaid}
    </update>
    <update id="auditTeacher">
        update teacher set teastate=true where teaid=#{teaid}
    </update>
    <update id="reset">
        update teacher set teapwd=MD5(#{newpwd}) where teaid=#{teaid} and teapwd=#{teapwd}
    </update>
    <select id="browseTeacher" resultType="com.example.academicadministration.pojo.Teacher">
        select * from teacher where teaid like #{condition} or teaname like #{condition} or teadegree like #{condition} or teagraduation like #{condition}
or teaorigin like #{condition} or tearace like #{condition} or teacollege like #{condition} or teaphone like #{condition} or teapost like #{condition} or teasex like #{condition}
    </select>
</mapper>

VideoMapper.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.example.academicadministration.dao.VideoDao">
    <insert id="addVideo" parameterType="com.example.academicadministration.pojo.Video">
        insert into video (courseid, videoname, videointroducation,videocover, videofile,videotime)
        VALUES (#{courseid},#{videoname},#{videointroducation},#{videocover},#{videofile},#{videotime})
    </insert>
    <select id="browseVideo" resultType="com.example.academicadministration.pojo.Video">
        select * from video where videoid like #{condition} or videoname like #{condition} or videointroducation like #{condition} order by videotime
    </select>
    <delete id="deleteVideo">
        delete from video where videoid=#{videoid}
    </delete>
</mapper>

 

posted @ 2023-06-10 11:33  突破铁皮  阅读(15)  评论(0编辑  收藏  举报