<?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.ruoyi.system.mapper.grid.GridWgLogMapper">
  <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.grid.GridWgLog">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="object_id" jdbcType="VARCHAR" property="objectId" />
    <result column="object_name" jdbcType="VARCHAR" property="objectName" />
    <result column="create_time" jdbcType="VARCHAR" property="createTime" />
    <result column="create_name" jdbcType="VARCHAR" property="createName" />
    <result column="create_id" jdbcType="VARCHAR" property="createId" />
    <result column="create_wg_code" jdbcType="VARCHAR" property="createWgCode" />
    <result column="type" jdbcType="VARCHAR" property="type" />
    <result column="operate" jdbcType="VARCHAR" property="operate" />
    <result column="bind_name" jdbcType="VARCHAR" property="bindName" />
    <result column="content" jdbcType="VARCHAR" property="content" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, object_id, object_name, create_time, create_name, create_id, create_wg_code, type, operate,
    bind_name, content
  </sql>
  <select id="selectByExample" parameterType="com.ruoyi.system.domain.grid.GridWgLogExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from grid_wg_log
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from grid_wg_log
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from grid_wg_log
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.ruoyi.system.domain.grid.GridWgLogExample">
    delete from grid_wg_log
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.ruoyi.system.domain.grid.GridWgLog">
    insert into grid_wg_log (id, object_id, object_name, create_time,
      create_name, create_id, create_wg_code,
      type, operate, bind_name,
      content)
    values (#{id,jdbcType=VARCHAR}, #{objectId,jdbcType=VARCHAR},#{objectName,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR},
      #{createName,jdbcType=VARCHAR}, #{createId,jdbcType=VARCHAR}, #{createWgCode,jdbcType=VARCHAR},
      #{type,jdbcType=VARCHAR}, #{operate,jdbcType=VARCHAR}, #{bindName,jdbcType=VARCHAR},
      #{content,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.ruoyi.system.domain.grid.GridWgLog">
    insert into grid_wg_log
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="objectName != null">
        object_name,
      </if>
      <if test="objectId != null">
        object_id,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="createName != null">
        create_name,
      </if>
      <if test="createId != null">
        create_id,
      </if>
      <if test="createWgCode != null">
        create_wg_code,
      </if>
      <if test="type != null">
        type,
      </if>
      <if test="operate != null">
        operate,
      </if>
      <if test="bindName != null">
        bind_name,
      </if>
      <if test="content != null">
        content,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="objectName != null">
        #{objectName,jdbcType=VARCHAR},
      </if>
      <if test="objectId != null">
        #{objectId,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=VARCHAR},
      </if>
      <if test="createName != null">
        #{createName,jdbcType=VARCHAR},
      </if>
      <if test="createId != null">
        #{createId,jdbcType=VARCHAR},
      </if>
      <if test="createWgCode != null">
        #{createWgCode,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        #{type,jdbcType=VARCHAR},
      </if>
      <if test="operate != null">
        #{operate,jdbcType=VARCHAR},
      </if>
      <if test="bindName != null">
        #{bindName,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        #{content,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.ruoyi.system.domain.grid.GridWgLogExample" resultType="java.lang.Long">
    select count(*) from grid_wg_log
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update grid_wg_log
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.objectName != null">
        object_name = #{record.objectName,jdbcType=VARCHAR},
      </if>
      <if test="record.objectId != null">
        object_id = #{record.objectId,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=VARCHAR},
      </if>
      <if test="record.createName != null">
        create_name = #{record.createName,jdbcType=VARCHAR},
      </if>
      <if test="record.createId != null">
        create_id = #{record.createId,jdbcType=VARCHAR},
      </if>
      <if test="record.createWgCode != null">
        create_wg_code = #{record.createWgCode,jdbcType=VARCHAR},
      </if>
      <if test="record.type != null">
        type = #{record.type,jdbcType=VARCHAR},
      </if>
      <if test="record.operate != null">
        operate = #{record.operate,jdbcType=VARCHAR},
      </if>
      <if test="record.bindName != null">
        bind_name = #{record.bindName,jdbcType=VARCHAR},
      </if>
      <if test="record.content != null">
        content = #{record.content,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update grid_wg_log
    set id = #{record.id,jdbcType=VARCHAR},
    object_id = #{record.objectId,jdbcType=VARCHAR},
      object_name = #{record.objectName,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=VARCHAR},
      create_name = #{record.createName,jdbcType=VARCHAR},
      create_id = #{record.createId,jdbcType=VARCHAR},
      create_wg_code = #{record.createWgCode,jdbcType=VARCHAR},
      type = #{record.type,jdbcType=VARCHAR},
      operate = #{record.operate,jdbcType=VARCHAR},
      bind_name = #{record.bindName,jdbcType=VARCHAR},
    content = #{record.content,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.system.domain.grid.GridWgLog">
    update grid_wg_log
    <set>
      <if test="objectName != null">
        object_name = #{objectName,jdbcType=VARCHAR},
      </if>
      <if test="objectId != null">
        object_id = #{objectId,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=VARCHAR},
      </if>
      <if test="createName != null">
        create_name = #{createName,jdbcType=VARCHAR},
      </if>
      <if test="createId != null">
        create_id = #{createId,jdbcType=VARCHAR},
      </if>
      <if test="createWgCode != null">
        create_wg_code = #{createWgCode,jdbcType=VARCHAR},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=VARCHAR},
      </if>
      <if test="operate != null">
        operate = #{operate,jdbcType=VARCHAR},
      </if>
      <if test="bindName != null">
        bind_name = #{bindName,jdbcType=VARCHAR},
      </if>
      <if test="content != null">
        content = #{content,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.ruoyi.system.domain.grid.GridWgLog">
    update grid_wg_log
    set object_name = #{objectName,jdbcType=VARCHAR},
    object_id = #{objectId,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=VARCHAR},
      create_name = #{createName,jdbcType=VARCHAR},
      create_id = #{createId,jdbcType=VARCHAR},
      create_wg_code = #{createWgCode,jdbcType=VARCHAR},
      type = #{type,jdbcType=VARCHAR},
      operate = #{operate,jdbcType=VARCHAR},
      bind_name = #{bindName,jdbcType=VARCHAR},
    content = #{content,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>

  <select id="selectInfo" parameterType="java.lang.String" resultType="map">
    select
      count(case when type = '1' and operate = 'insert' then 1 else null end) as peopelInsertNum,
      count(case when type = '1' and operate = 'update' then 1 else null end) as peopelUpdateNum,
      count(case when type = '1' and operate = 'bind' then 1 else null end) as peopelBindNum,
      count(case when type = '1' and operate = 'interview' then 1 else null end) as peopelInterviewNum,
      count(case when type = '2' and operate = 'insert' then 1 else null end) as houseInsertNum,
      count(case when type = '2' and operate = 'update' then 1 else null end) as houseUpdateNum,
      count(case when type = '2' and operate = 'bind' then 1 else null end) as houseBindNum,
      count(case when type = '2' and operate = 'interview' then 1 else null end) as houseInterviewNum,
      count(case when type = '3' and operate = 'insert' then 1 else null end) as companyInsertNum,
      count(case when type = '3' and operate = 'update' then 1 else null end) as companyUpdateNum,
      count(case when type = '3' and operate = 'bind' then 1 else null end) as companyBindNum,
      count(case when type = '3' and operate = 'interview' then 1 else null end) as companyInterviewNum,
      count(case when type = '4' and operate = 'insert' then 1 else null end) as shopInsertNum,
      count(case when type = '4' and operate = 'update' then 1 else null end) as shoplUpdateNum,
      count(case when type = '4' and operate = 'bind' then 1 else null end) as shopBindNum,
      count(case when type = '4' and operate = 'interview' then 1 else null end) as shopInterviewNum
    from grid_wg_log
      where 1=1
      <if test="wgCode != null and wgCode != ''">
          and create_wg_code like concat(#{wgCode}, '%')
      </if>
      <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
          and (create_time between #{startTime} and #{endTime})
      </if>
  </select>

</mapper>
