<?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.qmth.sop.business.mapper.TBViolationDetailMapper">
    <select id="listByViolationId" resultType="com.qmth.sop.business.entity.TBViolationDetail">
        SELECT
        a.*,
        cu.real_name create_name
        FROM
        t_b_violation_detail a
        LEFT JOIN sys_user cu ON cu.id = a.create_id
        <where>
            <if test="id != null and id != ''">
                and a.violation_id = #{id}
            </if>
        </where>

        ORDER BY a.create_time DESC
    </select>
</mapper>
