ProjectCompanyMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.caimei.modules.project.dao.ProjectCompanyDao">
  4. <sql id="projectCompanyColumns">
  5. a.id AS "id",
  6. a.name AS "name",
  7. a.area AS "area",
  8. a.scale AS "scale",
  9. a.cooperationWay AS "cooperationWay",
  10. a.maxPerformance AS "maxPerformance",
  11. a.divideScale AS "divideScale",
  12. a.starClub AS "starClub",
  13. a.hotProject AS "hotProject",
  14. a.shareNum AS "shareNum",
  15. a.enabledStatus AS "enabledStatus",
  16. a.createBy AS "createBy.id",
  17. a.createDate AS "createDate",
  18. a.updateBy AS "updateBy.id",
  19. a.updateDate AS "updateDate",
  20. (select count(1) from project_company_pro b WHERE b.companyId=a.id) AS "projectNum",
  21. (select count(1) from project_company_pro_marketingconference pm WHERE pm.companyId=a.id) AS "marketingconferenceNum",
  22. (select count(1) from project_company_apparatus pca WHERE pca.companyId=a.id) AS "apparatusNum"
  23. </sql>
  24. <sql id="projectCompanyJoins">
  25. </sql>
  26. <select id="get" resultType="ProjectCompany">
  27. SELECT
  28. <include refid="projectCompanyColumns"/>
  29. FROM project_company a
  30. <include refid="projectCompanyJoins"/>
  31. WHERE a.id = #{id}
  32. </select>
  33. <select id="findByProjectId" resultType="ProjectCompany">
  34. SELECT
  35. <include refid="projectCompanyColumns"/>
  36. FROM project_company a
  37. LEFT JOIN project_company_pro b ON a.id=b.companyId
  38. WHERE b.projectId = #{param1}
  39. </select>
  40. <select id="findList" resultType="ProjectCompany">
  41. SELECT
  42. <include refid="projectCompanyColumns"/>
  43. FROM project_company a
  44. <include refid="projectCompanyJoins"/>
  45. <where>
  46. <if test="id != null and id != ''">
  47. AND a.id = #{id}
  48. </if>
  49. <if test="name != null and name != ''">
  50. AND a.name LIKE concat('%',#{name},'%')
  51. </if>
  52. <if test="enabledStatus != null and enabledStatus != ''">
  53. AND a.enabledStatus = #{enabledStatus}
  54. </if>
  55. </where>
  56. <choose>
  57. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  58. ORDER BY ${page.orderBy}
  59. </when>
  60. <otherwise>
  61. ORDER BY a.enabledStatus DESC,a.createDate DESC
  62. </otherwise>
  63. </choose>
  64. </select>
  65. <select id="findAllList" resultType="ProjectCompany">
  66. SELECT
  67. <include refid="projectCompanyColumns"/>
  68. FROM project_company a
  69. <include refid="projectCompanyJoins"/>
  70. <where>
  71. </where>
  72. <choose>
  73. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  74. ORDER BY ${page.orderBy}
  75. </when>
  76. <otherwise>
  77. ORDER BY a.enabledStatus DESC,a.createDate DESC
  78. </otherwise>
  79. </choose>
  80. </select>
  81. <insert id="insert" parameterType="ProjectCompany" keyProperty="id" useGeneratedKeys="true">
  82. INSERT INTO project_company(
  83. name,
  84. area,
  85. scale,
  86. cooperationWay,
  87. maxPerformance,
  88. divideScale,
  89. starClub,
  90. hotProject,
  91. enabledStatus,
  92. createBy,
  93. createDate,
  94. updateBy,
  95. updateDate
  96. ) VALUES (
  97. #{name},
  98. #{area},
  99. #{scale},
  100. #{cooperationWay},
  101. #{maxPerformance},
  102. #{divideScale},
  103. #{starClub},
  104. #{hotProject},
  105. #{enabledStatus},
  106. #{createBy.id},
  107. #{createDate},
  108. #{updateBy.id},
  109. #{updateDate}
  110. )
  111. </insert>
  112. <update id="update">
  113. UPDATE project_company SET
  114. name = #{name},
  115. area = #{area},
  116. scale = #{scale},
  117. cooperationWay = #{cooperationWay},
  118. maxPerformance = #{maxPerformance},
  119. divideScale = #{divideScale},
  120. starClub = #{starClub},
  121. hotProject = #{hotProject},
  122. enabledStatus = #{enabledStatus},
  123. updateBy = #{updateBy.id},
  124. updateDate = #{updateDate}
  125. WHERE id = #{id}
  126. </update>
  127. <delete id="delete">
  128. DELETE FROM project_company WHERE id = #{id}
  129. </delete>
  130. <update id="updateEnabledStatusByIds">
  131. UPDATE project_company a SET a.enabledStatus = #{param1}
  132. WHERE a.id IN
  133. <foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
  134. #{id}
  135. </foreach>
  136. </update>
  137. </mapper>