Mybatis 复用

基础 sql 定义


  

    SELECT cd.amount
          FROM config_dpf cd
                   left join device_parts_fitting dpf on cd.dpf_id = dpf.id
          where cd.cdp_id = ${cdpId}
            and dpf.type = ${type}
            and cd.is_deleted = '0'
            and dpf.is_deleted = '0'
  

注意:这里传值使用了${cdpId},使用 # 会报错
sql 复用

SELECT c.config_name,
--              c.project_name,

               dp.type,
               dp.name,
               dp.description as dpDescription,
               dp.volume,
               dp.size,
               dp.price,
               dp.discount,
               dp.sale_price,
               dp.unit,
               dp.width,
               dp.deep,
               dp.height,
               dp.brand_id,
      ifnull(total_price, 0) + ifnull(copper_price, 0) as summary,

             (
                
                  
                  
                
                ) as padlock,

             (
                
                  
                  
                
                ) as interlock,

             (
                
                  
                  
                
                ) as shuntTrip,
             t.*
      FROM config_device_parts t
               left join config c on t.config_id = c.id
               left join device_parts dp on t.device_parts_id = dp.id

      where t.config_id = #{configId} and t.is_deleted = '0'
      order by t.update_time desc

你可能感兴趣的:(Mybatis 复用)