ym923 | 977239c | 2025-06-06 17:36:14 +0800 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 3 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 4 | |
| 5 | <mapper namespace="com.pt5.pthouduan.mapper.ActivityMapper"> |
| 6 | |
| 7 | <!-- 插入活动 --> |
| 8 | <insert id="insert" parameterType="com.pt5.pthouduan.entity.Activity" |
| 9 | useGeneratedKeys="true" keyProperty="activityid" keyColumn="activityid"> |
| 10 | INSERT INTO activity ( |
| 11 | title, |
| 12 | content, |
| 13 | photo, |
| 14 | time, |
| 15 | is_show, |
| 16 | award |
| 17 | ) VALUES ( |
| 18 | #{title}, |
| 19 | #{content}, |
| 20 | #{photo}, |
| 21 | #{time}, |
| 22 | #{is_show}, |
| 23 | #{award} |
| 24 | ) |
| 25 | </insert> |
| 26 | |
| 27 | <!-- 删除活动 --> |
| 28 | <delete id="deleteById" parameterType="int"> |
| 29 | DELETE FROM activity WHERE activityid = #{activityid} |
| 30 | </delete> |
| 31 | |
| 32 | <!-- 更新活动 --> |
| 33 | <update id="updateById" parameterType="com.pt5.pthouduan.entity.Activity"> |
| 34 | UPDATE activity |
| 35 | SET |
| 36 | title = #{title}, |
| 37 | content = #{content}, |
| 38 | photo = #{photo}, |
| 39 | time = #{time}, |
| 40 | is_show = #{is_show}, |
| 41 | award = #{award} |
| 42 | WHERE activityid = #{activityid} |
| 43 | </update> |
| 44 | |
| 45 | <!-- 查询所有 is_show 为指定值的活动 --> |
| 46 | <select id="selectByIsShow" resultType="com.pt5.pthouduan.entity.Activity"> |
| 47 | SELECT * |
| 48 | FROM activity |
| 49 | WHERE is_show = #{is_show} |
| 50 | ORDER BY time DESC |
| 51 | </select> |
| 52 | |
| 53 | <!-- ✅ 新增:根据活动ID查询活动详情 --> |
| 54 | <select id="selectById" parameterType="int" resultType="com.pt5.pthouduan.entity.Activity"> |
| 55 | SELECT * |
| 56 | FROM activity |
| 57 | WHERE activityid = #{activityid} |
| 58 | </select> |
| 59 | |
| 60 | </mapper> |