src/config/mybatis/mapper/common/ProductMapper.xml

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?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.ischoolbar.programmer.dao.common.ProductDao">
	<!-- 商品插入操作 -->
	<insert id="add" parameterType="com.ischoolbar.programmer.entity.common.Product">
		insert into product(id,productCategoryId,name,tags,imageUrl,price,stock,sellNum,viewNum,commentNum,content,createTime) values(null,#{productCategoryId},#{name},#{tags},#{imageUrl},#{price},#{stock},#{sellNum},#{viewNum},#{commentNum},#{content},#{createTime})
	</insert>
	<!-- 商品更新操作 -->
	<update id="edit" parameterType="com.ischoolbar.programmer.entity.common.Product">
		update product set productCategoryId = #{productCategoryId},name = #{name},tags = #{tags},imageUrl = #{imageUrl},price = #{price},stock = #{stock},content = #{content} where id = #{id}
	</update>
	<!-- 商品统计数量更新 -->
	<update id="updateNum" parameterType="com.ischoolbar.programmer.entity.common.Product">
		update product set stock = #{stock},sellNum = #{sellNum},viewNum = #{viewNum},commentNum = #{commentNum} where id = #{id}
	</update>
	<!-- 商品信息搜索查询 -->
	<select id="findList" parameterType="Map" resultType="com.ischoolbar.programmer.entity.common.Product">
		select * from product where 1 = 1 
		<if test="name != null">
			and name like '%${name}%' 
		</if>
		<if test="tags != null">
			and tags like '%${tags}%'  
		</if>
		<if test="priceMin != null">
			and price &gt; #{priceMin}  
		</if>
		<if test="priceMax != null">
			and price &lt; #{priceMax}  
		</if>
		<if test="orderBy != null and sort != null">
			order by ${orderBy} ${sort}   
		</if>
		<if test="offset != null and pageSize != null">
			limit #{offset},#{pageSize}
		</if>
	</select>
	<!-- 模糊搜索总条数 -->
	<select id="getTotal" parameterType="Map" resultType="Integer">
		select count(*) from product where 1 = 1 
		<if test="name != null">
			and name like '%${name}%' 
		</if>
		<if test="tags != null">
			and tags in(${tags})  
		</if>
		<if test="priceMin != null">
			and price &gt; #{priceMin}  
		</if>
		<if test="priceMax != null">
			and price &lt; #{priceMax}  
		</if>
	</select>
	<!-- 根据id查询 -->
	<select id="findById" parameterType="Long" resultType="com.ischoolbar.programmer.entity.common.Product">
		select * from product where id = #{value}
	</select>
	<!-- 删除商品信息 -->
后面还有 4 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。