08. 开发用户端物品展示功能

262 字约 1 分钟读完328 次阅读更新于 2026/5/3

给物品加上分类 ID

新增物品加上分类 ID

<el-form-item label="分类" prop="name">
  <el-select v-model="data.form.categoryId">
    <el-option v-for="item in data.categoryList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  </el-select>
</el-form-item>

物品查询加上 status 条件 以及分类的连表查询

<select id="selectAll" resultType="com.example.entity.Items">
    select items.*, user.name as userName, category.name as categoryName from `items`
    left join user on items.user_id = user.id
    left join category on items.category_id = category.id
    <where>
        <if test="name != null"> and items.name like concat('%', #{name}, '%')</if>
        <if test="userId != null"> and items.user_id = #{userId}</if>
        <if test="status != null"> and items.status = #{status}</if>
        <if test="categoryId != null"> and items.category_id = #{categoryId}</if>
        <if test="checkStatus != null"> and items.check_status = #{checkStatus}</if>
    </where>
    order by items.id desc
</select>

物品修改的接口

本节课的前端代码 ItemsView.vue