|  |  |  | @ -1,6 +1,12 @@ | 
			
		
	
		
			
				
					|  |  |  |  | <?xml version="1.0" encoding="UTF-8" ?> | 
			
		
	
		
			
				
					|  |  |  |  | <?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标签定义了MyBatis的映射文件,namespace属性指定了对应的Mapper接口的全限定名, | 
			
		
	
		
			
				
					|  |  |  |  |      用于将XML中的SQL语句与Java代码中的Mapper接口方法关联起来 --> | 
			
		
	
		
			
				
					|  |  |  |  | <mapper namespace="com.njupt.swg.dao.CategoryMapper" > | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为BaseResultMap的结果映射,用于将从数据库查询结果映射到Java中的com.njupt.swg.entity.Category实体类对象。 | 
			
		
	
		
			
				
					|  |  |  |  |        通过<constructor>标签内的<idArg>和<arg>元素来指定构造函数参数与数据库表字段的对应关系, | 
			
		
	
		
			
				
					|  |  |  |  |        包括字段名、JDBC类型以及对应的Java类型等信息 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <resultMap id="BaseResultMap" type="com.njupt.swg.entity.Category" > | 
			
		
	
		
			
				
					|  |  |  |  |     <constructor > | 
			
		
	
		
			
				
					|  |  |  |  |       <idArg column="id" jdbcType="INTEGER" javaType="java.lang.Integer" /> | 
			
		
	
	
		
			
				
					|  |  |  | @ -12,111 +18,136 @@ | 
			
		
	
		
			
				
					|  |  |  |  |       <arg column="update_time" jdbcType="TIMESTAMP" javaType="java.util.Date" /> | 
			
		
	
		
			
				
					|  |  |  |  |     </constructor> | 
			
		
	
		
			
				
					|  |  |  |  |   </resultMap> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为Base_Column_List的SQL片段,包含了要从数据库表中查询的列名列表, | 
			
		
	
		
			
				
					|  |  |  |  |        后续其他SQL语句可以通过<include>标签引用这个片段,方便复用代码 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <sql id="Base_Column_List" > | 
			
		
	
		
			
				
					|  |  |  |  |     id, parent_id, name, status, sort_order, create_time, update_time | 
			
		
	
		
			
				
					|  |  |  |  |   </sql> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为selectByPrimaryKey的查询语句,用于根据主键(id)查询记录。 | 
			
		
	
		
			
				
					|  |  |  |  |        resultMap属性指定了使用前面定义的BaseResultMap来映射查询结果,parameterType指定了传入参数的类型为Integer(对应主键的类型)。 | 
			
		
	
		
			
				
					|  |  |  |  |        SQL语句通过<include>标签引用了Base_Column_List片段来获取指定列的数据,并根据传入的主键值进行筛选查询 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > | 
			
		
	
		
			
				
					|  |  |  |  |     select  | 
			
		
	
		
			
				
					|  |  |  |  |     select | 
			
		
	
		
			
				
					|  |  |  |  |     <include refid="Base_Column_List" /> | 
			
		
	
		
			
				
					|  |  |  |  |     from mmall_category | 
			
		
	
		
			
				
					|  |  |  |  |     where id = #{id,jdbcType=INTEGER} | 
			
		
	
		
			
				
					|  |  |  |  |   </select> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为deleteByPrimaryKey的删除语句,用于根据主键(id)删除记录,parameterType指定了传入参数的类型为Integer(对应主键的类型), | 
			
		
	
		
			
				
					|  |  |  |  |        SQL语句指定了从mmall_category表中删除满足id条件的记录 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | 
			
		
	
		
			
				
					|  |  |  |  |     delete from mmall_category | 
			
		
	
		
			
				
					|  |  |  |  |     where id = #{id,jdbcType=INTEGER} | 
			
		
	
		
			
				
					|  |  |  |  |   </delete> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为insert的插入语句,用于向mmall_category表中插入一条完整的记录,parameterType指定了传入参数的类型为com.njupt.swg.entity.Category实体类, | 
			
		
	
		
			
				
					|  |  |  |  |        SQL语句明确列出了要插入的列名以及对应的通过#{属性名,jdbcType=类型}方式获取实体类属性值来插入数据,对于create_time和update_time使用了数据库函数now()来获取当前时间插入 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <insert id="insert" parameterType="com.njupt.swg.entity.Category" > | 
			
		
	
		
			
				
					|  |  |  |  |     insert into mmall_category (id, parent_id, name,  | 
			
		
	
		
			
				
					|  |  |  |  |       status, sort_order, create_time,  | 
			
		
	
		
			
				
					|  |  |  |  |       update_time) | 
			
		
	
		
			
				
					|  |  |  |  |     values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},  | 
			
		
	
		
			
				
					|  |  |  |  |       #{status,jdbcType=BIT}, #{sortOrder,jdbcType=INTEGER}, now(), | 
			
		
	
		
			
				
					|  |  |  |  |       now()) | 
			
		
	
		
			
				
					|  |  |  |  |     insert into mmall_category (id, parent_id, name, | 
			
		
	
		
			
				
					|  |  |  |  |                                 status, sort_order, create_time, | 
			
		
	
		
			
				
					|  |  |  |  |                                 update_time) | 
			
		
	
		
			
				
					|  |  |  |  |     values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, | 
			
		
	
		
			
				
					|  |  |  |  |             #{status,jdbcType=BIT}, #{sortOrder,jdbcType=INTEGER}, now(), | 
			
		
	
		
			
				
					|  |  |  |  |             now()) | 
			
		
	
		
			
				
					|  |  |  |  |   </insert> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为insertSelective的插入语句,相比于insert语句更加灵活,它会根据传入的com.njupt.swg.entity.Category实体类对象中属性是否为null来决定是否插入对应的列数据。 | 
			
		
	
		
			
				
					|  |  |  |  |        通过<trim>标签结合<if>条件判断来动态构建插入语句的列名和对应的值部分,避免插入不必要的null值到数据库表中 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <insert id="insertSelective" parameterType="com.njupt.swg.entity.Category" > | 
			
		
	
		
			
				
					|  |  |  |  |     insert into mmall_category | 
			
		
	
		
			
				
					|  |  |  |  |     <trim prefix="(" suffix=")" suffixOverrides="," > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="id != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="id!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         id, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="parentId != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="parentId!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         parent_id, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="name != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="name!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         name, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="status != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="status!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         status, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="sortOrder != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="sortOrder!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         sort_order, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="createTime != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="createTime!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         create_time, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="updateTime != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="updateTime!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         update_time, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |     </trim> | 
			
		
	
		
			
				
					|  |  |  |  |     <trim prefix="values (" suffix=")" suffixOverrides="," > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="id != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="id!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         #{id,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="parentId != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="parentId!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         #{parentId,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="name != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="name!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         #{name,jdbcType=VARCHAR}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="status != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="status!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         #{status,jdbcType=BIT}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="sortOrder != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="sortOrder!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         #{sortOrder,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="createTime != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="createTime!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         now(), | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="updateTime != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="updateTime!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         now(), | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |     </trim> | 
			
		
	
		
			
				
					|  |  |  |  |   </insert> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为updateByPrimaryKeySelective的更新语句,根据传入的com.njupt.swg.entity.Category实体类对象中属性是否为null来决定是否更新对应的列数据。 | 
			
		
	
		
			
				
					|  |  |  |  |        通过<set>标签结合<if>条件判断来动态构建更新语句的列赋值部分,只更新有值变化的列,避免不必要的全列更新,最后根据主键(id)来定位要更新的记录 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <update id="updateByPrimaryKeySelective" parameterType="com.njupt.swg.entity.Category" > | 
			
		
	
		
			
				
					|  |  |  |  |     update mmall_category | 
			
		
	
		
			
				
					|  |  |  |  |     <set > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="parentId != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="parentId!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         parent_id = #{parentId,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="name != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="name!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         name = #{name,jdbcType=VARCHAR}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="status != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="status!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         status = #{status,jdbcType=BIT}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="sortOrder != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="sortOrder!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         sort_order = #{sortOrder,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="createTime != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="createTime!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         create_time = #{createTime,jdbcType=TIMESTAMP}, | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="updateTime != null" > | 
			
		
	
		
			
				
					|  |  |  |  |       <if test="updateTime!= null" > | 
			
		
	
		
			
				
					|  |  |  |  |         update_time = now(), | 
			
		
	
		
			
				
					|  |  |  |  |       </if> | 
			
		
	
		
			
				
					|  |  |  |  |     </set> | 
			
		
	
		
			
				
					|  |  |  |  |     where id = #{id,jdbcType=INTEGER} | 
			
		
	
		
			
				
					|  |  |  |  |   </update> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为updateByPrimaryKey的更新语句,用于根据传入的com.njupt.swg.entity.Category实体类对象来更新mmall_category表中对应主键(id)的记录的所有列数据, | 
			
		
	
		
			
				
					|  |  |  |  |        直接列出了要更新的列名和对应从实体类获取的属性值,最后根据主键(id)来定位要更新的记录 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <update id="updateByPrimaryKey" parameterType="com.njupt.swg.entity.Category" > | 
			
		
	
		
			
				
					|  |  |  |  |     update mmall_category | 
			
		
	
		
			
				
					|  |  |  |  |     set parent_id = #{parentId,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |       name = #{name,jdbcType=VARCHAR}, | 
			
		
	
		
			
				
					|  |  |  |  |       status = #{status,jdbcType=BIT}, | 
			
		
	
		
			
				
					|  |  |  |  |       sort_order = #{sortOrder,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |       create_time = #{createTime,jdbcType=TIMESTAMP}, | 
			
		
	
		
			
				
					|  |  |  |  |       update_time = now() | 
			
		
	
		
			
				
					|  |  |  |  |         name = #{name,jdbcType=VARCHAR}, | 
			
		
	
		
			
				
					|  |  |  |  |         status = #{status,jdbcType=BIT}, | 
			
		
	
		
			
				
					|  |  |  |  |         sort_order = #{sortOrder,jdbcType=INTEGER}, | 
			
		
	
		
			
				
					|  |  |  |  |         create_time = #{createTime,jdbcType=TIMESTAMP}, | 
			
		
	
		
			
				
					|  |  |  |  |         update_time = now() | 
			
		
	
		
			
				
					|  |  |  |  |     where id = #{id,jdbcType=INTEGER} | 
			
		
	
		
			
				
					|  |  |  |  |   </update> | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   <!-- 定义了一个名为selectCategoryChildrenByParentId的查询语句,用于根据父节点的categoryId查询其对应的子节点记录。 | 
			
		
	
		
			
				
					|  |  |  |  |        parameterType指定了传入参数的类型为int(对应categoryId的类型),resultMap指定了使用前面定义的BaseResultMap来映射查询结果, | 
			
		
	
		
			
				
					|  |  |  |  |        SQL语句通过<include>标签引用了Base_Column_List片段来获取指定列的数据,并根据传入的父节点categoryId值进行筛选查询 --> | 
			
		
	
		
			
				
					|  |  |  |  |   <select id="selectCategoryChildrenByParentId" parameterType="int" resultMap="BaseResultMap"> | 
			
		
	
		
			
				
					|  |  |  |  |     SELECT <include refid="Base_Column_List"/> from mmall_category where parent_id = #{categoryId} | 
			
		
	
		
			
				
					|  |  |  |  |   </select> | 
			
		
	
	
		
			
				
					|  |  |  | 
 |