PhotoMapper.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.ygj.yuemum.dao.admin.PhotoDao" >
  4. <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.admin.Photo" >
  5. <id column="id" property="id" jdbcType="INTEGER" />
  6. <result column="photo_code" property="photo_code" jdbcType="INTEGER" />
  7. <result column="photo_title" property="photo_title" jdbcType="VARCHAR" />
  8. </resultMap>
  9. <sql id="Base_Column_List" >
  10. id, photo_code, photo_title
  11. </sql>
  12. <!-- 得到所有的照片信息 -->
  13. <select id="getAll" resultMap="BaseResultMap" >
  14. select
  15. <include refid="Base_Column_List" />
  16. from photo
  17. </select>
  18. <!-- 根据id查找某个照片信息 -->
  19. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  20. select
  21. <include refid="Base_Column_List" />
  22. from photo
  23. where photo_code = #{photo_code,jdbcType=INTEGER}
  24. </select>
  25. <!-- 根据id删除某个照片信息 -->
  26. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  27. delete from photo
  28. where id = #{id,jdbcType=INTEGER}
  29. </delete>
  30. <!-- 插入一条照片信息 -->
  31. <insert id="insertSelective" parameterType="com.ygj.yuemum.domain.admin.Photo" >
  32. insert into photo
  33. <trim prefix="(" suffix=")" suffixOverrides="," >
  34. <if test="photo_code != null" >
  35. photo_code,
  36. </if>
  37. <if test="photo_title != null" >
  38. photo_title,
  39. </if>
  40. </trim>
  41. <trim prefix="values (" suffix=")" suffixOverrides="," >
  42. <if test="photo_code != null" >
  43. #{photo_code,jdbcType=INTEGER},
  44. </if>
  45. <if test="photo_title != null" >
  46. #{photo_title,jdbcType=VARCHAR}
  47. </if>
  48. </trim>
  49. </insert>
  50. <!-- 根据id更新一条照片信息 -->
  51. <update id="updateByPrimaryKeySelective" parameterType="com.ygj.yuemum.domain.admin.Photo" >
  52. update photo
  53. <set >
  54. <if test="photo_code != null" >
  55. photo_code = #{photo_code,jdbcType=INTEGER},
  56. </if>
  57. <if test="photo_title != null" >
  58. photo_title = #{photo_title,jdbcType=VARCHAR}
  59. </if>
  60. </set>
  61. where id = #{id,jdbcType=INTEGER}
  62. </update>
  63. </mapper>