ProjectFileMapper.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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,namespace的值习惯上设置成包名+sql映射文件名,这样就能够保证namespace的值是唯一的,例如namespace="me.gacl.mapping.userMapper"就是me.gacl.mapping(包名)+userMapper(userMapper.xml文件去除后缀)
  4. -->
  5. <mapper namespace="com.fuzamei.mapperInterface.ProjectFileMapper">
  6. <!-- 根据操作记录给的条件查询分页数据 -->
  7. <select id="queryProjectFileInformation" resultMap="ProjectFileRM">
  8. select
  9. pf.id,
  10. pf.project_id,
  11. pf.project_name,
  12. pf.update_time,
  13. att.id as id2,
  14. att.attachment_id,
  15. att.attachment_name,
  16. att.url,
  17. att.upload_person_id,
  18. att.create_time
  19. from
  20. (select
  21. *
  22. from
  23. project_file
  24. <where>
  25. <if test="projectName!='' and projectName!=null">
  26. project_name=#{projectName}
  27. </if>
  28. <if test="startTime!=null and endTime!=null">
  29. and update_time between #{startTime} and #{endTime}
  30. </if>
  31. </where>) pf
  32. left join
  33. project_file_id pfi
  34. on
  35. pf.project_id=pfi.project_id
  36. left join
  37. attachment att
  38. on
  39. att.attachment_id=pfi.project_file_id
  40. order by
  41. pf.id asc
  42. limit
  43. #{startPage},#{rowNum}
  44. </select>
  45. <resultMap type="com.fuzamei.entity.ProjectFile" id="ProjectFileRM" autoMapping="true">
  46. <id column="id" property="id"/>
  47. <collection property="attachments" autoMapping="true" javaType="com.fuzamei.entity.Attachment">
  48. <id column="id2" property="id"/>
  49. </collection>
  50. </resultMap>
  51. <!-- 分页用查询总记录条数 -->
  52. <select id="findAllInformation" resultType="int">
  53. select
  54. count(*)
  55. from
  56. project_file
  57. <where>
  58. <if test="projectName!='' and projectName!=null">
  59. project_name=#{projectName}
  60. </if>
  61. <if test="startTime!=null and endTime!=null">
  62. and update_time between #{startTime} and #{endTime}
  63. </if>
  64. </where>
  65. </select>
  66. <select id="checkoutProjectFiles" resultType="com.fuzamei.entity.ProjectFile">
  67. select
  68. pf.project_id,
  69. pf.project_name,
  70. att.attachment_name,
  71. pf.hash,
  72. att.url
  73. from
  74. project_file pf
  75. left join
  76. attachment att
  77. on
  78. pf.project_file_id = att.attachment_id
  79. where
  80. pf.project_id=#{projectId}
  81. and
  82. pf.project_name=#{projectName}
  83. order by
  84. pf.update_time asc
  85. </select>
  86. <insert id="insertInformationIntoTable">
  87. insert into
  88. project_file(project_id,
  89. project_name,
  90. project_file_id,
  91. update_time,hash)
  92. values(
  93. #{projectId},
  94. #{projectName},
  95. #{attachmentId},
  96. #{updateTime},
  97. #{hash})
  98. </insert>
  99. <!-- 将上传的文件信息插入到附件表中 -->
  100. <insert id="insertInformationToAttachment">
  101. insert into
  102. attachment(attachment_id,
  103. attachment_name,url,
  104. upload_person_id,
  105. create_time)
  106. values(#{attachmentId},
  107. #{attachmentName},
  108. #{url},
  109. #{userId},
  110. #{addTime})
  111. </insert>
  112. <!-- 将上传项目文档的这个操作信息插入到操作记录表 -->
  113. <insert id="insertOperationHistoryInformationToDao">
  114. insert into
  115. operation_history(operator_type_id,
  116. operator_account,
  117. operator_role,
  118. operator_person,
  119. operator_time,
  120. hash)
  121. values(#{operatorTypeId},
  122. #{operatorAccount},
  123. #{operatorRole},
  124. #{operatorPerson},
  125. #{operatorTime},
  126. #{hash})
  127. </insert>
  128. </mapper>