SourceMapper.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.tofly.base.mapper.SourceMapper">
  4. <resultMap id="sourceMap" type="com.tofly.base.entity.Source">
  5. <id property="id" column="ID"/>
  6. <result property="pid" column="PID"/>
  7. <result property="name" column="NAME"/>
  8. <result property="cval" column="CVAL"/>
  9. <result property="createTime" column="CREATE_TIME"/>
  10. <result property="createUser" column="CREATE_USER"/>
  11. <result property="ckey" column="CKEY"/>
  12. </resultMap>
  13. <select id="getSourceByUser" parameterType="java.lang.Long" resultType="map">
  14. select s.*,(select code from TF_SMPN_SOURCEDIC_X where id=s.pid) as code
  15. from TF_SMPN_SOURCE_X s
  16. where exists (select 1
  17. from TF_SMPN_DEPARTMENTSOURCE_X ds,
  18. TF_SMPN_DEPARTMENT_X d,
  19. TF_SMPN_USER_X u
  20. where ds.department_id = d.id
  21. and ds.source_id = s.id
  22. and d.id = u.department_id
  23. and d.status_flag = '1'
  24. and u.status_flag = '1'
  25. and u.id=#{id})
  26. </select>
  27. <select id="listSources" parameterType="java.lang.Long" resultType="map" databaseId="oracle">
  28. select sd.*,
  29. (select notes
  30. from tf_smpn_code_x c
  31. where key = '0007'
  32. and ulevel = '2'
  33. and value = sd.code) name,
  34. sd.name groupname
  35. from tf_smpn_sourcedic_x sd
  36. where exists
  37. (select 1
  38. from tf_smpn_source_x s, tf_smpn_departmentsource_x ds
  39. where s.id = ds.source_id
  40. and s.pid = sd.id
  41. and ds.department_id = #{departmentId})
  42. </select>
  43. <select id="listSources" parameterType="java.lang.Long" resultType="map" databaseId="mysql">
  44. select sd.*,
  45. (select notes
  46. from TF_SMPN_CODE_X c
  47. where `key` = '0007'
  48. and ulevel = '2'
  49. and `value` = sd.code) name,
  50. sd.`name` groupname
  51. from TF_SMPN_SOURCEDIC_X sd
  52. where exists
  53. (select 1
  54. from TF_SMPN_SOURCE_X s, TF_SMPN_DEPARTMENTSOURCE_X ds
  55. where s.id = ds.source_id
  56. and s.pid = sd.id
  57. and ds.department_id = #{departmentId})
  58. </select>
  59. </mapper>