<?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="vip.xiaonuo.disk.mapper.MajorMapper">
    <select id="selectMajorList" resultType="vip.xiaonuo.disk.vo.major.MajorVo">
        SELECT
            a.id,
            a.major_name majorName,
            a.major_code majorCode,
            a.college_id collegeId,
            b.name collegeName,
            a.create_time createTime,
            a.create_user createUser
        FROM
            major a
        LEFT JOIN college b ON a.college_id = b.id
       <where>
        <if test="majorPageParam.searchKey!=null">
            a.major_name like concat('%',#{majorPageParam.searchKey},'%')
        </if>
       </where>
       order by a.create_time desc
    </select>


    <select id="detail" resultType="vip.xiaonuo.disk.vo.major.MajorVo">
        SELECT
            a.id,
            a.major_name majorName,
            a.major_code majorCode,
            a.college_id collegeId,
            b.name collegeName,
            a.create_time createTime,
            a.create_user createUser
        FROM
            major a
                LEFT JOIN college b ON a.college_id = b.id
        where  a.id=#{id}
    </select>

    <select id="select" resultType="vip.xiaonuo.disk.vo.major.MajorVo">
        SELECT
            a.id,
            a.major_name majorName,
            a.major_code majorCode,
            a.college_id collegeId,
            b.name collegeName,
            a.create_time createTime,
            a.create_user createUser
        FROM
            major a
                LEFT JOIN college b ON a.college_id = b.id
        where  a.college_id=#{collegeId}
    </select>
</mapper>
