| <?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="bounty.mapper.BountySubmissionMapper"> |
| <!-- 继承 BaseMapper 的默认方法(如 insert、selectById 等),无需重复定义 --> |
| |
| <!-- 示例:自定义分页查询(若默认方法不满足需求) --> |
| <select id="getBountySubmissionsByPage" resultType="bounty.domain.BountySubmission"> |
| SELECT * FROM bounty_submissions |
| WHERE bounty_id = #{bountyId} |
| LIMIT #{offset}, #{pageSize} |
| </select> |
| |
| <insert id="insert" parameterType="bounty.domain.BountySubmission"> |
| INSERT INTO bounty_submissions ( |
| bounty_id, |
| user_id, |
| content, |
| attachment, <!-- 新增字段 --> |
| create_time, |
| status |
| ) VALUES ( |
| #{bountyId}, |
| #{userId}, |
| #{content}, |
| #{attachment}, <!-- 绑定字段 --> |
| NOW(), |
| '0' |
| ) |
| </insert> |
| |
| <select id="getSubmissionsByBountyId" resultType="bounty.domain.BountySubmission"> |
| SELECT id, user_id AS userId, content, attachment, status |
| FROM bounty_submissions |
| WHERE bounty_id = #{bountyId} |
| </select> |
| |
| <!-- BountySubmissionMapper.xml --> |
| <update id="updateById" parameterType="bounty.domain.BountySubmission"> |
| UPDATE bounty_submissions |
| SET |
| status = #{et.status} |
| WHERE id = #{et.id} |
| </update> |
| |
| <select id="selectById" resultType="bounty.domain.BountySubmission"> |
| SELECT id, bounty_id AS bountyId, user_id AS userId, content, attachment, status |
| FROM bounty_submissions |
| WHERE id = #{id} |
| </select> |
| |
| </mapper> |