<?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.ruoyi.web.work.mapper.ColumnMapper">

    <select id="selectList" resultType="com.ruoyi.web.work.domain.Column">
        select * from tb_column where type = #{type}
        <if test="state != null ">and state = #{state}</if>
        order by order_num asc
    </select>

    <select id="selectByTitle" resultType="java.util.Map">
        SELECT t.id,t.title
        <if test="type=='position'">
            ,(SELECT GROUP_CONCAT(c.title ORDER BY c.create_time ASC SEPARATOR '-')
            FROM tb_column c
            WHERE FIND_IN_SET(c.id, t.ancestors)) AS tag
        </if>
        FROM tb_column t
        WHERE t.type =#{type}
        AND concat(title,pinyin) like concat('%', #{title}, '%')
        AND t.level =#{level}
    </select>

</mapper>