<?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.xhkjedu.suser.mapper.system.UsecretMapper">
    <!--获取密保问题列表-->
    <select id="findAll" resultType="java.util.Map">
        select u.usid,u.sname,u.sorder,u.belong,u.createtime,u2.username createname
        ,(select count(uu.uusid) from t_user_usecret uu where uu.usid=u.usid)usenum
        from t_usecret u left join t_user u2 on u2.userid=u.createid
        where u.belong=1
        <if test="usecret.schoolid!=null and usecret.schoolid!=0">
            or (u.schoolid=#{usecret.schoolid} and belong=3)
        </if>
        order by u.sorder
    </select>
    <!--获取密保问题选择列表-->
    <select id="listForSel" resultType="java.util.Map">
        select u.usid,u.sname from t_usecret u
        where u.belong=1
        <if test="schoolid!=null and schoolid!=0">
            or (u.schoolid=#{schoolid} and belong=3)
        </if>
        order by u.sorder
    </select>
    <!--获取密保问题数量-->
    <select id="getNumBySchoolId" resultType="java.lang.Integer">
        select count(u.usid) from t_usecret u
        where u.belong=1
        <if test="schoolid!=null and schoolid!=0">
            or (u.schoolid=#{schoolid} and belong=3)
        </if>
        order by u.sorder
    </select>
</mapper>
