studentmapper.xml 3.87 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="getStudentByStudentId" resultMap="BaseResultMap">
	        select top 1 vs.name,vs.student_id,vs.class_id,vs.class_name from SZ_V_School_Student vs
      where role_state=1 and school_id=#{schoolId} and student_id=#{studentId}
    </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="getStuCountBySchoolId" resultType="java.lang.Integer">
        select count(0) from SZ_V_School_Student where school_id=#{schoolId}
    </select>

    <select id="getGradeBySchoolId" resultType="com.sincere.morningcheck.model.Grade">
        select id,grade,ShortName from SZ_Grade where Status=1 and SchoolId = #{schoolId}
    </select>

    <select id="getStuUserId" resultType="java.lang.String">
         select vs.user_id 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=#{num}
      where vs.role_state=1 and school_id = #{schoolId}
    </select>

    <select id="getOpenId" resultType="java.lang.String">
        select u.XSTOpenId from SZ_UserRole ur join
                     SZ_SPRole sp on ur.customerId = sp.student_id join
                    SZ_userrole ur2 on sp.parent_id = ur2.customerId
                     join sz_user u on ur2.user_id = u.user_id
                     where ur.user_id = #{stuUserId}
                     and ur2.usertype = 3 and ur2.school_id = #{schoolId}
                     and (u.XSTOpenId !='' or u.XSTOpenId is not null)
    </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>