【汇智学堂】-SpringMVC+Mybatis+Spring框架使用入门(垃圾分类商品管理查询功能DaoMapper层)

<?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.dao.GoodsDao">
	<resultMap type="com.bean.Goods" id="findallgoods">
		<id property="g_id" column="g_id" />
		<result property="g_name" column="g_name" />
		<result property="g_manufacturerName" column="g_manufacturerName" />
		<result property="g_manufacturerId" column="g_manufacturerId" />
		<result property="g_weight" column="g_weight" />
		<result property="g_examine" column="g_examine" />
		<result property="g_material" column="g_material" />
		<result property="g_unitPrice" column="g_unitPrice" />
		<result property="g_producer" column="g_producer" />
		<result property="g_produceDate" column="g_produceDate" />
		<result property="g_psid" column="g_psid" />
		<result property="g_license" column="g_license" />
		<result property="g_howToUse" column="g_howToUse" />
	</resultMap>

	<select id="findallgoods" resultMap="findallgoods">
		select * from goods
		<if test="name!=null and name!=''">
			and g_name like '%${name}%'
		</if>
		order by g_id DESC
	</select>

	<select id="onleGoods" resultType="com.bean.Goods">
		select * from goods where g_name=#{g_name} and g_isdel=1
	</select>

	<delete id="delGoods">
        delete from goods where g_id=#{id}
   </delete>

	<insert id="addGoods">
		insert into goods
		(g_manufacturerName,g_manufacturerId,g_name,g_weight,g_examine,g_isdel,g_material,g_unitPrice,g_producer,g_produceDate,g_periodOffQuelity,g_psid,g_license,g_howToUse)
		VALUE
		(#{goods.g_manufacturerName},#{goods.g_manufacturerId},#{goods.g_name},#{goods.g_weight},0,0,#{goods.g_material},#{goods.g_unitPrice},#{goods.g_producer},#{goods.gs_produceDate},#{goods.g_periodOffQuelity},#{goods.g_psid},#{goods.g_license},#{goods.g_howToUse})
	</insert>

</mapper>

猜你喜欢

转载自blog.csdn.net/weixin_39593940/article/details/91125474