欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > 学java的第3天 后端商城小程序工作

学java的第3天 后端商城小程序工作

2024/10/24 6:28:02 来源:https://blog.csdn.net/weixin_67865831/article/details/140215183  浏览:    关键词:学java的第3天 后端商城小程序工作

1.数据库的大坑 特殊字段名

’我的图片表中有一个字段是描述我写成desc了,正好是mysql中的关键字 就不能使用了

2.后端编写 

2.1可以把请求分开

在商品浏览页中 只显示商品的大致信息 当用户再点击其他按钮时在发出请求

2.2把请求合并

把数据整合到一起 利用association 和 collection 表示 

2.2.1association

多对一 

<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>

2.2.2collection

一对多

2.3遇到的问题

collection中需要ofType 

3.一个框框实现条件模糊查找

@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">selectid, name, category_id, created_at, updated_at, desc_img, status, sales,main_photofrom productswhere ishot = 0<if test="productSearchVo != null and productSearchVo !=''">and (name like concat ('%',#{productSearchVo},'%')) or (id like concat('%',#{productSearchVo},'%'))</if></select>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com