WorkflowMapper.xml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.siwei.apply.mapper.WorkflowMapper">
  4. <resultMap id="WorkflowResultMap" type="com.siwei.apply.domain.Workflow">
  5. <id property="id" column="id"/>
  6. <result property="projectType" column="project_type"/>
  7. <result property="name" column="name"/>
  8. <result property="index" column="index"/>
  9. <result property="tableName" column="table_name"/>
  10. </resultMap>
  11. <select id="selectByProjectTypeAndTableName" resultMap="WorkflowResultMap">
  12. SELECT id, project_type, name, "index" AS index, table_name
  13. FROM t_workflow
  14. WHERE project_type = #{projectType}
  15. AND table_name = #{tableName}
  16. LIMIT 1
  17. </select>
  18. <select id="selectPrevByProjectTypeAndTableName" resultMap="WorkflowResultMap">
  19. SELECT id, project_type, name, "index" AS index, table_name
  20. FROM t_workflow
  21. WHERE project_type = #{projectType}
  22. AND "index" &lt; (
  23. SELECT "index"
  24. FROM t_workflow
  25. WHERE project_type = #{projectType}
  26. AND table_name = #{tableName}
  27. )
  28. ORDER BY "index" DESC
  29. LIMIT 1
  30. </select>
  31. <!-- 新增:根据 project_type 获取列表,按 index 升序返回 -->
  32. <select id="selectByProjectTypeOrderByIndex" parameterType="int" resultType="com.siwei.apply.domain.res.ProjectCycleRes">
  33. SELECT
  34. id,
  35. project_type AS projectType,
  36. name,
  37. table_name AS tableName,
  38. "index" AS index
  39. FROM t_workflow
  40. WHERE project_type = #{projectType}
  41. ORDER BY "index" ASC
  42. </select>
  43. </mapper>