赞
踩
’我的图片表中有一个字段是描述我写成desc了,正好是mysql中的关键字 就不能使用了
2.1可以把请求分开
在商品浏览页中 只显示商品的大致信息 当用户再点击其他按钮时在发出请求
把数据整合到一起 利用association 和 collection 表示
多对一
- <association property="categories" javaType="com.hrmy.entity.Categories">
- <id property="id" column="id"/>
- <result property="parentId" column="parent_id"/>
- <result property="name" column="name"/>
- <result property="createdAt" column="created_at"/>
- <result property="updatedAt" column="update_at"/>
- </association>
一对多
collection中需要ofType
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
- public class ProductSearchVo {
- //商品名称
- private String productSearchVo;
- }
- @ApiOperation(value = "根据商品名字模糊查询商品")
- @GetMapping("{nameAndId}")
- public Result queryByNameAndId(@ApiParam(value = "商品或者id模糊查询商品") ProductSearchVo productSearchVo) {
- return productsService.queryByNameAndId(productSearchVo);
- }
- <select id="queryByNameAndId" resultType="com.hrmy.entity.Products">
- select
- id, name, category_id, created_at, updated_at, desc_img, status, sales,main_photo
- from products
- where ishot = 0
- <if test="productSearchVo != null and productSearchVo !=''">
- and (name like concat ('%',#{productSearchVo},'%')) or (id like concat('%',#{productSearchVo},'%'))
- </if>
- </select>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。