|
@@ -0,0 +1,103 @@
|
|
|
+<?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.ym.mec.biz.dal.dao.PhotoDao">
|
|
|
+
|
|
|
+ <resultMap type="com.ym.mec.biz.dal.entity.Photo" id="Photo">
|
|
|
+ <result column="id_" property="id" />
|
|
|
+ <result column="photo_album_id_" property="photoAlbumId" />
|
|
|
+ <result column="name_" property="name" />
|
|
|
+ <result column="client_show_" property="clientShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
|
|
|
+ <result column="url_" property="url" />
|
|
|
+ <result column="thumbnail_url_" property="thumbnailUrl" />
|
|
|
+ <result column="order_" property="order" />
|
|
|
+ <result column="create_time_" property="createTime" />
|
|
|
+ <result column="update_time_" property="updateTime" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 根据主键查询一条记录 -->
|
|
|
+ <select id="get" resultMap="Photo" >
|
|
|
+ SELECT * FROM photo_ WHERE id_ = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 全查询 -->
|
|
|
+ <select id="findAll" resultMap="Photo">
|
|
|
+ SELECT * FROM photo_ ORDER BY id_
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 向数据库增加一条记录 -->
|
|
|
+ <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Photo" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
|
|
+ INSERT INTO photo_ (photo_album_id_,name_,client_show_,url_,thumbnail_url_,create_time_,update_time_,order_)
|
|
|
+ VALUES(#{photoAlbumId},#{name},#{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{url},#{thumbnailUrl},NOW(),NOW(),#{order})
|
|
|
+ </insert>
|
|
|
+ <insert id="batchInsert">
|
|
|
+ INSERT INTO photo_ (photo_album_id_,name_,client_show_,url_,thumbnail_url_,create_time_,update_time_,order_)
|
|
|
+ VALUES
|
|
|
+ <foreach collection="photoList" item="photo" separator=",">
|
|
|
+ (#{photo.photoAlbumId},#{photo.name},#{photo.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
+ #{photo.url},#{photo.thumbnailUrl},NOW(),NOW(),#{photo.order})
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 根据主键查询一条记录 -->
|
|
|
+ <update id="update" parameterType="com.ym.mec.biz.dal.entity.Photo">
|
|
|
+ UPDATE photo_ <set>
|
|
|
+ <if test="order != null">
|
|
|
+ order_ = #{order},
|
|
|
+ </if>
|
|
|
+ <if test="photoAlbumId != null">
|
|
|
+ photo_album_id_ = #{photoAlbumId},
|
|
|
+ </if>
|
|
|
+ <if test="url != null">
|
|
|
+ url_ = #{url},
|
|
|
+ </if>
|
|
|
+ <if test="clientShow != null">
|
|
|
+ client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
+ </if>
|
|
|
+ <if test="thumbnailUrl != null">
|
|
|
+ thumbnail_url_ = #{thumbnailUrl},
|
|
|
+ </if>
|
|
|
+ <if test="name != null">
|
|
|
+ name_ = #{name},
|
|
|
+ </if>
|
|
|
+ update_time_ = NOW()
|
|
|
+ </set> WHERE id_ = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 根据主键删除一条记录 -->
|
|
|
+ <delete id="delete" >
|
|
|
+ DELETE FROM photo_ WHERE id_ = #{id}
|
|
|
+ </delete>
|
|
|
+ <delete id="deleteByAlbumId">
|
|
|
+ DELETE FROM photo_ WHERE photo_album_id_ = #{albumId}
|
|
|
+ </delete>
|
|
|
+ <delete id="deleteByIds">
|
|
|
+ DELETE FROM photo_ WHERE FIND_IN_SET(id_,#{id})
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 分页查询 -->
|
|
|
+ <select id="queryPage" resultMap="Photo" parameterType="map">
|
|
|
+ SELECT * FROM photo_
|
|
|
+ <include refid="queryPageSql"/>
|
|
|
+ ORDER BY order_ ASC,id_ DESC
|
|
|
+ <include refid="global.limit"/>
|
|
|
+ </select>
|
|
|
+ <sql id="queryPageSql">
|
|
|
+ <where>
|
|
|
+ <if test="photoAlbumId != null">
|
|
|
+ AND photo_album_id_ = #{photoAlbumId}
|
|
|
+ </if>
|
|
|
+ <if test="clientShow != null">
|
|
|
+ AND client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
+ <!-- 查询当前表的总记录数 -->
|
|
|
+ <select id="queryCount" resultType="int">
|
|
|
+ SELECT COUNT(id_) FROM photo_
|
|
|
+ <include refid="queryPageSql"/>
|
|
|
+ </select>
|
|
|
+</mapper>
|