千峰商城-springboot项目搭建-56-首页轮播图

数据库操作实现:
1.分析数据表结构
查询status=1且按照seq进行排序

 

2.添加测试数据

 

 

 

 

 

3.编写sql语句
    SELECT img_id,img_url,img_bg_color,prod_id,category_id,index_type,seq,STATUS,create_time,update_time 
    FROM index_img WHERE STATUS=1 ORDER BY seq

 

4.在mapper接口(dao)中定义操作方法

public interface IndexImgMapper extends GeneralDAO<IndexImg> {
    //1.查询轮播图信息:查询status=1且按照seq进行排序
    public List<IndexImg> listIndexImgs();
}

 

 

5.配置映射文件

<?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.qfedu.fmmall.dao.IndexImgMapper">
  <resultMap id="BaseResultMap" type="com.qfedu.fmmall.entity.IndexImg">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="img_id" jdbcType="VARCHAR" property="imgId" />
    <result column="img_url" jdbcType="VARCHAR" property="imgUrl" />
    <result column="img_bg_color" jdbcType="VARCHAR" property="imgBgColor" />
    <result column="prod_id" jdbcType="VARCHAR" property="prodId" />
    <result column="category_id" jdbcType="VARCHAR" property="categoryId" />
    <result column="index_type" jdbcType="INTEGER" property="indexType" />
    <result column="seq" jdbcType="INTEGER" property="seq" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>

  <select id="listIndexImgs" resultMap="BaseResultMap">
    SELECT img_id,img_url,img_bg_color,prod_id,category_id,index_type,seq,STATUS,create_time,update_time
    FROM index_img WHERE STATUS=1 ORDER BY seq
  </select>
</mapper>

 

 
 
posted @ 2022-07-14 20:10  临易  阅读(82)  评论(0编辑  收藏  举报