千峰商城-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>
分类:
千峰商城项目
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性