IssueManagerMapper.xml 8.81 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.diligrp.etrade.admin.dao.IssueManagerMapper">
  <resultMap id="BaseResultMap" type="com.diligrp.etrade.admin.model.IssueManager">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="modified_time" jdbcType="TIMESTAMP" property="modifiedTime" />
    <result column="creater_id" jdbcType="BIGINT" property="createrId" />
    <result column="creater" jdbcType="VARCHAR" property="creater" />
    <result column="modifier_id" jdbcType="BIGINT" property="modifierId" />
    <result column="modifier" jdbcType="VARCHAR" property="modifier" />
    <result column="sort" jdbcType="INTEGER" property="sort" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="content" jdbcType="VARCHAR" property="content" />
    <result column="head_pic_url" jdbcType="VARCHAR" property="headPicUrl" />
    <result column="weixin_pic_url" jdbcType="VARCHAR" property="weixinPicUrl" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="state" jdbcType="TINYINT" property="state" />
    <result column="market_id" jdbcType="BIGINT" property="marketId" />
    <result column="version" jdbcType="INTEGER" property="version" />
  </resultMap>
  <sql id="Base_Column_List">
    id, created_time, modified_time, creater_id, creater, modifier_id, modifier, sort, 
    `name`, content, head_pic_url, weixin_pic_url, remark, `state`, market_id, version
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from issue_manager
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from issue_manager
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.diligrp.etrade.admin.model.IssueManager" useGeneratedKeys="true">
    insert into issue_manager (creater_id,
      creater, modifier_id, modifier, 
      sort, `name`, content, 
      head_pic_url, weixin_pic_url, remark, 
      `state`, market_id
      )
    values (#{createrId,jdbcType=BIGINT},
      #{creater,jdbcType=VARCHAR}, #{modifierId,jdbcType=BIGINT}, #{modifier,jdbcType=VARCHAR}, 
      #{sort,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, 
      #{headPicUrl,jdbcType=VARCHAR}, #{weixinPicUrl,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, 
      #{state,jdbcType=TINYINT}, #{marketId,jdbcType=BIGINT}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.diligrp.etrade.admin.model.IssueManager" useGeneratedKeys="true">
    insert into issue_manager
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="modifiedTime != null">
        modified_time,
      </if>
      <if test="createrId != null">
        creater_id,
      </if>
      <if test="creater != null">
        creater,
      </if>
      <if test="modifierId != null">
        modifier_id,
      </if>
      <if test="modifier != null">
        modifier,
      </if>
      <if test="sort != null">
        sort,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="content != null">
        content,
      </if>
      <if test="headPicUrl != null">
        head_pic_url,
      </if>
      <if test="weixinPicUrl != null">
        weixin_pic_url,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="marketId != null">
        market_id,
      </if>
      <if test="version != null">
        version,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="createdTime != null">
        #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="modifiedTime != null">
        #{modifiedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createrId != null">
        #{createrId,jdbcType=BIGINT},
      </if>
      <if test="creater != null">
        #{creater,jdbcType=VARCHAR},
      </if>
      <if test="modifierId != null">
        #{modifierId,jdbcType=BIGINT},
      </if>
      <if test="modifier != null">
        #{modifier,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        #{sort,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        #{content,jdbcType=VARCHAR},
      </if>
      <if test="headPicUrl != null">
        #{headPicUrl,jdbcType=VARCHAR},
      </if>
      <if test="weixinPicUrl != null">
        #{weixinPicUrl,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        #{state,jdbcType=TINYINT},
      </if>
      <if test="marketId != null">
        #{marketId,jdbcType=BIGINT},
      </if>
      <if test="version != null">
        #{version,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.diligrp.etrade.admin.model.IssueManager">
    update issue_manager
    <set>
      <if test="createdTime != null">
        created_time = #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="modifiedTime != null">
        modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createrId != null">
        creater_id = #{createrId,jdbcType=BIGINT},
      </if>
      <if test="creater != null">
        creater = #{creater,jdbcType=VARCHAR},
      </if>
      <if test="modifierId != null">
        modifier_id = #{modifierId,jdbcType=BIGINT},
      </if>
      <if test="modifier != null">
        modifier = #{modifier,jdbcType=VARCHAR},
      </if>
      <if test="sort != null">
        sort = #{sort,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        content = #{content,jdbcType=VARCHAR},
      </if>
      <if test="headPicUrl != null">
        head_pic_url = #{headPicUrl,jdbcType=VARCHAR},
      </if>
      <if test="weixinPicUrl != null">
        weixin_pic_url = #{weixinPicUrl,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="state != null">
        `state` = #{state,jdbcType=TINYINT},
      </if>
      <if test="marketId != null">
        market_id = #{marketId,jdbcType=BIGINT},
      </if>
      <if test="version != null">
        version = #{version,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.diligrp.etrade.admin.model.IssueManager">
    update issue_manager
    set
      modifier_id = #{modifierId,jdbcType=BIGINT},
      modifier = #{modifier,jdbcType=VARCHAR},
      sort = #{sort,jdbcType=INTEGER},
      `name` = #{name,jdbcType=VARCHAR},
      content = #{content,jdbcType=VARCHAR},
      head_pic_url = #{headPicUrl,jdbcType=VARCHAR},
      weixin_pic_url = #{weixinPicUrl,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      `state` = #{state,jdbcType=TINYINT},
      market_id = #{marketId,jdbcType=BIGINT},
      version = version + 1
    where id = #{id,jdbcType=BIGINT}
      and version = #{version}
  </update>

  <!-- 分页查询 -->
  <select id="listPage" resultType="com.diligrp.etrade.admin.model.IssueManager">
    select <include refid="Base_Column_List"/>
    from
    issue_manager
    <where> 1=1
      <if test="marketId != null">
        and market_id = #{marketId}
      </if>

      <if test="name != null and name != ''">
        and name like concat('%', #{name}, '%')
      </if>

      <if test="beginTime != null">
        and created_time &gt;= #{beginTime}
      </if>

      <if test="endTime != null">
        and created_time &lt;= #{endTime}
      </if>

      <if test="state != null">
        and state = #{state}
      </if>
    </where>
    ORDER BY created_time DESC
  </select>

  <!-- 根据市场查询 -->
  <select id="listByMarketId" resultType="com.diligrp.etrade.admin.model.IssueManager">
    select <include refid="Base_Column_List"/>
    from issue_manager
    where 1=1
    <if test="state != null">
      and state = #{state}
    </if>
    and market_id=#{marketId,jdbcType=BIGINT}
    ORDER BY sort ASC
  </select>
  <!-- 查询市场可用的记录条数 -->
  <select id="countEnableByMarketId" resultType="java.lang.Integer">
    select count(*) as number
    from issue_manager
    where state = 1
    and market_id=#{marketId,jdbcType=BIGINT}
  </select>
</mapper>