SysMsgMinidao_getMyMsgDtoPage.sql 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. select
  2. sm.id,
  3. sm.msg_title as msgTitle,
  4. sm.msg_content as msgContent,
  5. sm.send_id as sendId,
  6. sm.send_status as sendStatus,
  7. sm.create_date as createDate,
  8. sm.send_time as sendTime,
  9. sm.is_pushapp as isPushapp,
  10. sm.received_range as receivedRange,
  11. sm.busid as busid,
  12. smd.read_status as readStatus
  13. FROM
  14. t_bus_sys_msg sm
  15. LEFT JOIN t_bus_sys_msg_detail smd ON sm.id = smd.msg_id
  16. WHERE
  17. sm.send_status='1'
  18. <#if (sysMsgDto.receivedId )?? && sysMsgDto.receivedId ?length gt 0>
  19. AND (smd.received_id like CONCAT('%', :sysMsgDto.receivedId ,'%') or (smd.received_id LIKE CONCAT('%', (select org_id from t_s_user_org where user_id = :sysMsgDto.receivedId limit 1),'%') and smd.received_id LIKE CONCAT('%', (select in_postid from t_bus_user_personnel where userid = :sysMsgDto.receivedId limit 1),'%')))
  20. <#else>
  21. AND smd.received_id = null
  22. </#if>
  23. <#if (sysMsgDto.readStatus )?? && sysMsgDto.readStatus ?length gt 0>
  24. and smd.read_status = :sysMsgDto.readStatus
  25. </#if>
  26. <#if (sysMsgDto.msgTitle )?? && sysMsgDto.msgTitle ?length gt 0>
  27. and sm.msg_title like CONCAT('%', :sysMsgDto.msgTitle ,'%')
  28. </#if>
  29. <#if (sysMsgDto.sendTime_begin1 )?? >
  30. and sm.send_time >= :sysMsgDto.sendTime_begin1
  31. </#if>
  32. <#if (sysMsgDto.sendTime_end2 )?? >
  33. and sm.send_time <= :sysMsgDto.sendTime_end2
  34. </#if>
  35. ORDER BY
  36. smd.read_status,
  37. sm.send_time desc, sm.id