mall学习笔记(3)

Posted on 2023-05-10 21:04  Capterlliar  阅读(13)  评论(0编辑  收藏  举报

今天想调取一个product的attribute。

已知一个product有数据库表里的属性,还有一些手动添加的attribute。

attribute_category将attribute根据不同的商品类别分为几组,然后attribute_value建立attribute和其值的一个映射。

1. mybatis的example.createCriteria()方法学习记录_VVAIVG的博客-CSDN博客

大概是把查询的条件用函数拼起来的过程。

2. dao和dto

观察了一下成品代码,和learning中的还是挺不一样的。

dao是连接数据库获取数据的层。涉及到一些多表查询时生成的mapper解决不了,需要手写sql。

dto是连接接口获取参数的层。

3. 写一点mybatis

<collection property="productAttributeList" columnPrefix="attr_" resultMap="...">

columnPrefix就是集合中每个元素名字加一个前缀

下载mybatis插件的时候select的id会爆红,不影响编译,卸了就好了(

4. 报错

Description:

Field pmsProductAttributeCategoryService in com.example.demo.controller.PmsProductAttributeCategoryController required a bean of type 'com.example.demo.dao.PmsProductAttributeCategoryDao' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.example.demo.dao.PmsProductAttributeCategoryDao' in your configuration.

mybatis mapper-locations作用_米兰的小铁匠z的博客-CSDN博客

添加了mapper-locations,但是没啥用。于是把dao和dto合并到mapper和model里,能跑了,很神奇。