<?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.fuxi.ws.data.dao.WMapMapper">
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    <id column="MapID" jdbcType="SMALLINT" property="mapid" />
    <result column="MenuID" jdbcType="INTEGER" property="menuid" />
    <result column="KeyWord" jdbcType="NVARCHAR" property="keyword" />
    <result column="Title" jdbcType="NVARCHAR" property="title" />
    <result column="Face" jdbcType="NVARCHAR" property="face" />
    <result column="dec" jdbcType="NVARCHAR" property="dec" />
    <result column="ContextType" jdbcType="TINYINT" property="contexttype" />
    <result column="MapUrl" jdbcType="NVARCHAR" property="mapurl" />
    <result column="Kind" jdbcType="TINYINT" property="kind" />
    <result column="Province" jdbcType="VARCHAR" property="province" />
    <result column="City" jdbcType="VARCHAR" property="city" />
    <result column="County" jdbcType="VARCHAR" property="county" />
    <result column="DepartmentID" jdbcType="VARCHAR" property="departmentid" />
    <result column="Created" jdbcType="TIMESTAMP" property="created" />
    <result column="WXImageID" jdbcType="VARCHAR" property="wximageid" />
    <result column="WXMapID" jdbcType="VARCHAR" property="wxmapid" />
    <result column="ShareCount" jdbcType="INTEGER" property="sharecount" />
    <result column="ReadCount" jdbcType="INTEGER" property="readcount" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    <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="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    MapID, MenuID, KeyWord, Title, Face, dec, ContextType, MapUrl, Kind, Province, City, 
    County, DepartmentID, Created, WXImageID, WXMapID, ShareCount, ReadCount
  </sql>
  <select id="selectByExample" parameterType="com.fuxi.ws.data.entity.WMapExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from W_Map
    <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.Short" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    select 
    <include refid="Base_Column_List" />
    from W_Map
    where MapID = #{mapid,jdbcType=SMALLINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Short">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    delete from W_Map
    where MapID = #{mapid,jdbcType=SMALLINT}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    insert into W_Map (MapID, MenuID, KeyWord, 
      Title, Face, dec, 
      ContextType, MapUrl, Kind, 
      Province, City, County, 
      DepartmentID, Created, WXImageID, 
      WXMapID, ShareCount, ReadCount
      )
    values (#{mapid,jdbcType=SMALLINT}, #{menuid,jdbcType=INTEGER}, #{keyword,jdbcType=NVARCHAR}, 
      #{title,jdbcType=NVARCHAR}, #{face,jdbcType=NVARCHAR}, #{dec,jdbcType=NVARCHAR}, 
      #{contexttype,jdbcType=TINYINT}, #{mapurl,jdbcType=NVARCHAR}, #{kind,jdbcType=TINYINT}, 
      #{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{county,jdbcType=VARCHAR}, 
      #{departmentid,jdbcType=VARCHAR}, #{created,jdbcType=TIMESTAMP}, #{wximageid,jdbcType=VARCHAR}, 
      #{wxmapid,jdbcType=VARCHAR}, #{sharecount,jdbcType=INTEGER}, #{readcount,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    insert into W_Map
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="mapid != null">
        MapID,
      </if>
      <if test="menuid != null">
        MenuID,
      </if>
      <if test="keyword != null">
        KeyWord,
      </if>
      <if test="title != null">
        Title,
      </if>
      <if test="face != null">
        Face,
      </if>
      <if test="dec != null">
        dec,
      </if>
      <if test="contexttype != null">
        ContextType,
      </if>
      <if test="mapurl != null">
        MapUrl,
      </if>
      <if test="kind != null">
        Kind,
      </if>
      <if test="province != null">
        Province,
      </if>
      <if test="city != null">
        City,
      </if>
      <if test="county != null">
        County,
      </if>
      <if test="departmentid != null">
        DepartmentID,
      </if>
      <if test="created != null">
        Created,
      </if>
      <if test="wximageid != null">
        WXImageID,
      </if>
      <if test="wxmapid != null">
        WXMapID,
      </if>
      <if test="sharecount != null">
        ShareCount,
      </if>
      <if test="readcount != null">
        ReadCount,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="mapid != null">
        #{mapid,jdbcType=SMALLINT},
      </if>
      <if test="menuid != null">
        #{menuid,jdbcType=INTEGER},
      </if>
      <if test="keyword != null">
        #{keyword,jdbcType=NVARCHAR},
      </if>
      <if test="title != null">
        #{title,jdbcType=NVARCHAR},
      </if>
      <if test="face != null">
        #{face,jdbcType=NVARCHAR},
      </if>
      <if test="dec != null">
        #{dec,jdbcType=NVARCHAR},
      </if>
      <if test="contexttype != null">
        #{contexttype,jdbcType=TINYINT},
      </if>
      <if test="mapurl != null">
        #{mapurl,jdbcType=NVARCHAR},
      </if>
      <if test="kind != null">
        #{kind,jdbcType=TINYINT},
      </if>
      <if test="province != null">
        #{province,jdbcType=VARCHAR},
      </if>
      <if test="city != null">
        #{city,jdbcType=VARCHAR},
      </if>
      <if test="county != null">
        #{county,jdbcType=VARCHAR},
      </if>
      <if test="departmentid != null">
        #{departmentid,jdbcType=VARCHAR},
      </if>
      <if test="created != null">
        #{created,jdbcType=TIMESTAMP},
      </if>
      <if test="wximageid != null">
        #{wximageid,jdbcType=VARCHAR},
      </if>
      <if test="wxmapid != null">
        #{wxmapid,jdbcType=VARCHAR},
      </if>
      <if test="sharecount != null">
        #{sharecount,jdbcType=INTEGER},
      </if>
      <if test="readcount != null">
        #{readcount,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WMapExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    select count(*) from W_Map
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    update W_Map
    <set>
      <if test="menuid != null">
        MenuID = #{menuid,jdbcType=INTEGER},
      </if>
      <if test="keyword != null">
        KeyWord = #{keyword,jdbcType=NVARCHAR},
      </if>
      <if test="title != null">
        Title = #{title,jdbcType=NVARCHAR},
      </if>
      <if test="face != null">
        Face = #{face,jdbcType=NVARCHAR},
      </if>
      <if test="dec != null">
        dec = #{dec,jdbcType=NVARCHAR},
      </if>
      <if test="contexttype != null">
        ContextType = #{contexttype,jdbcType=TINYINT},
      </if>
      <if test="mapurl != null">
        MapUrl = #{mapurl,jdbcType=NVARCHAR},
      </if>
      <if test="kind != null">
        Kind = #{kind,jdbcType=TINYINT},
      </if>
      <if test="province != null">
        Province = #{province,jdbcType=VARCHAR},
      </if>
      <if test="city != null">
        City = #{city,jdbcType=VARCHAR},
      </if>
      <if test="county != null">
        County = #{county,jdbcType=VARCHAR},
      </if>
      <if test="departmentid != null">
        DepartmentID = #{departmentid,jdbcType=VARCHAR},
      </if>
      <if test="created != null">
        Created = #{created,jdbcType=TIMESTAMP},
      </if>
      <if test="wximageid != null">
        WXImageID = #{wximageid,jdbcType=VARCHAR},
      </if>
      <if test="wxmapid != null">
        WXMapID = #{wxmapid,jdbcType=VARCHAR},
      </if>
      <if test="sharecount != null">
        ShareCount = #{sharecount,jdbcType=INTEGER},
      </if>
      <if test="readcount != null">
        ReadCount = #{readcount,jdbcType=INTEGER},
      </if>
    </set>
    where MapID = #{mapid,jdbcType=SMALLINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Aug 09 11:09:52 CST 2016.
    -->
    update W_Map
    set MenuID = #{menuid,jdbcType=INTEGER},
      KeyWord = #{keyword,jdbcType=NVARCHAR},
      Title = #{title,jdbcType=NVARCHAR},
      Face = #{face,jdbcType=NVARCHAR},
      dec = #{dec,jdbcType=NVARCHAR},
      ContextType = #{contexttype,jdbcType=TINYINT},
      MapUrl = #{mapurl,jdbcType=NVARCHAR},
      Kind = #{kind,jdbcType=TINYINT},
      Province = #{province,jdbcType=VARCHAR},
      City = #{city,jdbcType=VARCHAR},
      County = #{county,jdbcType=VARCHAR},
      DepartmentID = #{departmentid,jdbcType=VARCHAR},
      Created = #{created,jdbcType=TIMESTAMP},
      WXImageID = #{wximageid,jdbcType=VARCHAR},
      WXMapID = #{wxmapid,jdbcType=VARCHAR},
      ShareCount = #{sharecount,jdbcType=INTEGER},
      ReadCount = #{readcount,jdbcType=INTEGER}
    where MapID = #{mapid,jdbcType=SMALLINT}
  </update>
  
  <select id="wMapList" resultType="java.util.LinkedHashMap">
		SELECT a.MapID, a.MenuID, a.KeyWord, a.Title, a.Face, a.dec, a.MapUrl,b.Department,
			CONVERT(varchar(10),a.Created, 121) as Date,CONVERT(varchar(10), a.Created, 108) AS Time,isnull(a.ShareCount,0) as ShareCount,isnull(a.ReadCount,0) as ReadCount,a.ContextType 
		FROM  W_Map a left join
		Department b on b.departmentid=a.departmentid
		<if test="conditions != null and conditions != ''">
			where
			${conditions}
		</if>		
		order by MapID desc
	</select>	
</mapper>