一、需求:
操作流程:
1、进入商品查询列表页面
2、点击修改,进入商品修改页面,页面中显示了要修改的商品(从数据库查询)
3、在商品修改页面,修改商品信息,修改后,点击提交
代码:
ItemsMapper.xml:--使用的是逆向工程生成的:
1 <mapper namespace="com.cy.mapper.ItemsMapper" > 2 <sql id="Base_Column_List" > 3 id, name, price, pic, createtime 4 </sql> 5 <sql id="Blob_Column_List" > 6 detail 7 </sql> 8 <resultMap id="BaseResultMap" type="com.cy.po.Items" > 9 <id column="id" property="id" jdbcType="INTEGER" /> 10 <result column="name" property="name" jdbcType="VARCHAR" /> 11 <result column="price" property="price" jdbcType="REAL" /> 12 <result column="pic" property="pic" jdbcType="VARCHAR" /> 13 <result column="createtime" property="createtime" jdbcType="TIMESTAMP" /> 14 </resultMap> 15 <resultMap id="ResultMapWithBLOBs" type="com.cy.po.Items" extends="BaseResultMap" > 16 <result column="detail" property="detail" jdbcType="LONGVARCHAR" /> 17 </resultMap> 18 <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" > 19 select 20 <include refid="Base_Column_List" /> 21 , 22 <include refid="Blob_Column_List" /> 23 from items 24 where id = #{id,jdbcType=INTEGER} 25 </select> 26 27 <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.cy.po.ItemsCustom" > 28 update items 29 set name = #{name,jdbcType=VARCHAR}, 30 price = #{price,jdbcType=REAL}, 31 pic = #{pic,jdbcType=VARCHAR}, 32 createtime = #{createtime,jdbcType=TIMESTAMP}, 33 detail = #{detail,jdbcType=LONGVARCHAR} 34 where id = #{id,jdbcType=INTEGER} 35 </update> 36 </mapper>
ItemsService.java:
1 public interface ItemsService { 2 3 public List<ItemsCustom> findItemsList(ItemsQueryVo itemsQueryVo) throws Exception; 4 5 //根据id查询商品信息 6 public ItemsCustom findItemsById(Integer id) throws Exception; 7 8 //修改商品信息 9 public void updateItems(Integer id, ItemsCustom itemsCustom) throws Exception; 10 }