BuildHistoryMapper.xml 3.2 KB
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.monitor.mysql.mapper.BuildHistoryMapper" >
  <resultMap id="BaseResultMap" type="com.model.BuildProcessHistory" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="status" property="status" jdbcType="INTEGER" />
    <result column="currentStatus" property="currentStatus" jdbcType="INTEGER" />
    <result column="localid" property="localid" jdbcType="VARCHAR" />
    <result column="environment" property="environment" jdbcType="VARCHAR" />
    <result column="operate" property="operate" jdbcType="VARCHAR" />
    <result column="user" property="user" jdbcType="VARCHAR" />
    <result column="project_order" property="projectOrder" jdbcType="VARCHAR" />
    <result column="branch" property="branch" jdbcType="VARCHAR" />
    <result column="currentProject" property="currentProject" jdbcType="VARCHAR" />
    <result column="rollbackfile" property="rollbackfile" jdbcType="VARCHAR" />
    <result column="tag" property="tag" jdbcType="VARCHAR" />
    <result column="workid" property="workid" jdbcType="VARCHAR" />
    <result column="createTime" property="createTime" jdbcType="VARCHAR" />

  </resultMap>

  <sql id="Base_Column_List" >
    id,status,localid,currentStatus,environment,operate,user,project_order,branch,currentProject,rollbackfile,tag, workid,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime
  </sql>

  <select id="selectCountByCodition"  resultType="java.lang.Integer">
    select
      count(1)
    from build_process_history
    where
    1=1
    <if test="params.environment != null &amp;&amp; params.environment != ''" >
      and environment = #{params.environment}
    </if>
    <if test="params.currentProject != null &amp;&amp; params.currentProject != ''" >
      and currentProject = #{params.currentProject}
    </if>
    <if test="params.currentStatus != 0" >
      and currentStatus = #{params.currentStatus}
    </if>
  </select>

  <select id="selectByCodition"   resultMap="BaseResultMap">
    select
    id,status,localid,currentStatus,environment,operate,user,project_order,branch,currentProject,rollbackfile,tag, workid,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') AS createTime
    from build_process_history
    where
    1=1
    <if test="params.environment != null &amp;&amp; params.environment != ''" >
      and environment = #{params.environment}
    </if>
    <if test="params.currentProject != null &amp;&amp; params.currentProject != ''" >
      and currentProject = #{params.currentProject}
    </if>
    <if test="params.currentStatus != 0" >
      and currentStatus = #{params.currentStatus}
    </if>
    order by create_time desc
    limit #{startIndex},#{pageSize}
  </select>

  <select id="selectLatestSuccessProjectRecord"   resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from build_process_history
    where currentStatus=2 and currentProject= #{currentProject}
    <if test="environment != null &amp;&amp; environment != ''" >
      and environment like  concat('%',#{environment},'%')
    </if>
    order by create_time desc,id desc
    limit 1
  </select>

</mapper>