星核进销存-1.0 海王星商品管理功能
星核进销存-1.0 海王星商品管理功能
系统截图

星核进销存-1.0 海王星商品管理功能

技术依赖:如无特殊说明;所有配置和技术选型均采用Ruoyi-vue快速开发框架
SpringBoot
Mybatis
Mysql
vue-element ui说明:一个订单中有多种商品;所以有一个订单表有一个订单详情表

表结构设计:
订单表:order
order_id 订单表ID
订单详情表:order_items
id :详情表ID
order_id:订单表ID
goods_id:商品ID增加订单:
Controller层代码:
mybatis xml的写法
collection主要是应对表关系是一对多的情况
property:属性
javaType:
<resultMap>
<result property="orderId" column="order_id" />
<result property="goodsAmount" column="goods_amount" />
<collection property="orderItems" column="dept_id" javaType="java.util.List" resultMap="orderItemsResult" />
</resultMap>
<resultMap id="YshopOrderItemsResult" type="orderItems">
<id property="id" column="id" />
<result property="goodsId" column="goods_id"/>
<result property="price" column="price"/>
</resultMap>
<resultMap type="YshopGoodsType" id="YshopGoodsTypeResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="params" column="params" />
<collection property="students" ofType="Student">
<result property="id" column="sid"/>
<result property="name" column="sname"/>
<result property="tid" column="tid"/>
</collection>
<collection property=""></collection>
</resultMap>
/*java代码*/
public Order selectById()
select * from order left join order_items on order.id=order_items.order_id where order.id=100;
方式二:mybatis 一对多查询方式二
相关文章:
《事务的处理》
https://blog.csdn.net/weixin_46645338/article/details/123987406
https://blog.csdn.net/weixin_45877245/article/details/119821218
[1]:
项目开发中,性能是我们比较关注的问题,特别是数据库的性能;作为一个开发,经常和SQL语句打交道,想要写出合格的SQL语句,我们需要了解SQL语句在数据库中是如何扫描表、如何使用索引的。
0:Index Scan 索引扫描
数据库索引是用于提高数据库表的数据访问速度的。
想要理解索引原理必须清楚一种数据结构「平衡树」(非二叉),也就是b tree或者 b+ tree,重要的事情说三遍:“平衡树,平衡树,平衡树”。当然, 有的数据库也使用哈希桶作用索引的数据结构 。然而,主流的RDBMS都是把平衡树当做数据表默认的索引数据结构的。
数据查询又慢了?