studentmapper.xml 2.47 KB
<?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.sincere.morningcheck.dao.StudentDao">

    <!--声明返回结果参数-->
    <resultMap id="BaseResultMap" type="com.sincere.morningcheck.model.Student">
        <result column="student_id" property="stuId" jdbcType="INTEGER" javaType="java.lang.Integer"/>
        <result column="name" property="stuName" jdbcType="VARCHAR" javaType="java.lang.String"/>
        <result column="class_id" property="classId" jdbcType="INTEGER" javaType="java.lang.Integer"/>
        <result column="class_name" property="className" jdbcType="VARCHAR" javaType="java.lang.String"/>
        <result column="Cards" property="cardNos" jdbcType="VARCHAR" javaType="java.lang.String"/>
    </resultMap>


    <select id="getStudents" resultMap="BaseResultMap">
        select class_id,student_id,name,class_name,(student_num+
        case when
        (select dbo.StringJoin(distinct a.CardNum) from HS_StudentCards a where a.State=1 and a.CardNum is not null and len(a.CardNum)=8 and a.StudentId=vs.student_id)!=''
        then
        ','+(select dbo.StringJoin( a.CardNum) from HS_StudentCards a where a.State=1 and a.CardNum is not null and len(a.CardNum)=8 and a.StudentId=vs.student_id)
        else
        ''
        end
        ) as Cards
         from SZ_V_School_Student vs where vs.role_state=1 and vs.school_id=#{schoolId} and vs.student_num is not null and LEN(vs.student_num)=8
    </select>

    <select id="getStudentByCardNo" resultMap="BaseResultMap">
      select top 1 vs.name,vs.student_id,vs.class_id,vs.class_name from SZ_V_School_Student vs
      inner join SZ_V_Card b on b.type=2 and vs.student_id=b.user_id and b.num=#{cardNo}
      where vs.role_state=1
    </select>

    <select id="getStudentByStuUserId" resultMap="BaseResultMap">
        select top 1 vs.name,vs.student_id,vs.class_id,vs.class_name,Cards=vs.student_num from SZ_V_School_Student vs
        where user_id=#{sUserId}
    </select>

    <select id="swipeCard" statementType="CALLABLE" resultType="java.util.Map">
    {call xiaoan.dbo.AttendanceService(
        #{att_id, mode=IN},
        #{card_num, mode=IN},
        #{func_no, mode=IN},
        #{flag, mode=IN},
        #{intime, mode=IN},
        #{arr, mode=OUT, jdbcType=VARCHAR},
        #{iscuccess,mode=OUT,jdbcType=INTEGER}
    )}
   </select>
</mapper>