Mybits Demo

<?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.zpark.sun.dao.impl.ModelDaoImpl">
	<resultMap type="Model" id="ModelMap">
		<id column="model_id"  property="modelId"/>
		<result column="model_name" property="modelName" />
		<result column="model_path" property="modelPath" />
		<result column="tpl_channel_prefix" property="tplChannelPrefix" />
		<result column="tpl_content_prefix" property="tplContentPrefix" />
		
		<result column="title_img_width" property="titleImgWidth" />
		<result column="title_img_height" property="titleImgHeight" />
		<result column="content_img_width" property="contentImgWidth" />
		<result column="content_img_height" property="contentImgHeight" />
		
		<result column="priority" property="priority" />
		<result column="has_content" property="hasContent" />
		<result column="is_disabled" property="isDisabled" />
		<result column="is_def" property="isDef" />
	</resultMap>
	
	<resultMap type="ModelItem" id="ModelItemMap">
		<id column="modelitem_id" property="modelItemId"/>
		<result column="model_id" property="modelId" />
		<result column="field" property="field" />
		<result column="item_label" property="itemLabel" />
		<result column="priority" property="priority" />
		<result column="def_value" property="defValue" />
		<result column="opt_value" property="optValue" />
		<result column="text_size" property="textSize" />
		<result column="area_rows" property="areaRows" />
		<result column="area_cols" property="areaCols" />
		<result column="help" property="help" />
		<result column="help_position" property="helpPosition" />
		<result column="data_type" property="dataType" />
		<result column="is_single" property="isSingle" />
		<result column="is_channel" property="isChannel" />
		<result column="is_custom" property="isCustom" />
		<result column="is_display" property="isDisplay" />
		<result column="is_system" property="isSystem" />
		<result column="is_quote" property="isQuote" />
	</resultMap>
	<insert id="insertModel" parameterType="Model">
		insert into t_model(
		model_name,
		model_path,
		tpl_channel_prefix,
		tpl_content_prefix,
		title_img_width,
		title_img_height,
		content_img_width,
		content_img_height,
		priority,
		has_content,
		is_disabled,
		is_def) 
		values(#{modelName},#{modelPath},#{tplChannelPrefix},
		#{tplContentPrefix},#{titleImgWidth},#{titleImgHeight},
		#{contentImgWidth},#{contentImgHeight},#{priority},
		#{hasContent},#{isDisabled},#{isDef})
	</insert>
	
	<delete id="deleteModel" parameterType="int">
		delete from t_model where model_id = #{id}
	</delete>
	
	<update id="updateModel" parameterType="Model">
		update t_model set
		model_name=#{modelName},
		model_path=#{modelPath},
		tpl_channel_prefix=#{tplChannelPrefix},
		tpl_content_prefix=#{tplContentPrefix},
		title_img_width=#{titleImgWidth},
		title_img_height=#{titleImgHeight},
		content_img_width=#{contentImgWidth},
		content_img_height=#{contentImgHeight},
		priority=#{priority},
		has_content=#{hasContent},
		is_disabled=#{isDisabled},
		is_def=#{isDef} 
		where model_id=#{modelId}
	</update>
	
	<update id="InitializationModelDefaultAttribute" >
		update t_model set is_def=0
	</update>
	<update id="SetNewDefault" parameterType="int">
		update t_model set is_def=1 where model_id=#{id}
	</update>
	
	<select id="returnInsertModelId" resultType="int">
		select max(model_id) from t_model
	</select>
	<select id="selectModel" resultMap="ModelMap" parameterType="int">
		select model_id,model_name,model_path,tpl_channel_prefix,
		tpl_content_prefix,title_img_width,title_img_height,
		content_img_width,content_img_height,
		priority,has_content,is_disabled,is_def
		from t_model
		where model_id=#{id}
	</select>
	
	<select id="selectAllModel" resultMap="ModelMap">
		select model_id,model_name,model_path,tpl_channel_prefix,
		tpl_content_prefix,title_img_width,title_img_height,
		content_img_width,content_img_height,
		priority,has_content,is_disabled,is_def
		from t_model 
		order by model_id
	</select>
	<insert id="insertModelItem" parameterType="ModelItem">
		insert into t_model_item
		(model_id,field,item_label,priority,def_value,
		opt_value,text_size,area_rows,area_cols,help,
		help_position,data_type,is_single,
		is_channel,is_custom,is_display,is_system,is_quote)
		values(#{modelId},#{field},#{itemLabel},#{priority},
		#{defValue},#{optValue},#{textSize},#{areaRows},#{areaCols},
		#{help},#{helpPosition},#{dataType},#{isSingle},
		#{isChannel},#{isCustom},#{isDisplay},#{isSystem},#{isQuote})
	</insert>
	
	<update id="updateModelItem" parameterType="ModelItem">
		update t_model_item set
		model_id=#{modelId},
		field=#{field},
		item_label=#{itemLabel},
		priority=#{priority},
		def_value=#{defValue},
		opt_value=#{optValue},
		text_size=#{textSize},
		area_rows=#{areaRows},
		area_cols=#{areaCols},
		help=#{help},
		help_position=#{helpPosition},
		data_type=#{dataType},
		is_single=#{isSingle},
		is_channel=#{isChannel},
		is_custom=#{isCustom},
		is_display=#{isDisplay},
		is_system=#{isSystem},
		is_quote=#{isQuote}
		where modelitem_id=#{modelItemId}
	</update>
	<update id="loadSystemModelItem" parameterType="int">
		update t_model_item 
		set is_quote=1 
		where modelitem_id=#{id}
	</update>
	<update id="unloadSystemModelItem" parameterType="int">
		update t_model_item 
		set is_quote=0 
		where modelitem_id=#{id}
	</update>
	<delete id="deleteModelItem" parameterType="int">
		delete from t_model_item where modelitem_id=#{id}
	</delete>
	
	<select id="selectModelItem" resultMap="ModelItemMap" parameterType="int">
		select 
		modelitem_id,model_id,field,item_label,priority,def_value,
		opt_value,text_size,area_rows,area_cols,help,
		help_position,data_type,is_single,
		is_channel,is_custom,is_display,is_system,is_quote 
		from t_model_item
		where modelitem_id=#{id}
	</select>
	
	<select id="selectAllSystemModelItems" resultMap="ModelItemMap">
		select 
		field,item_label,priority,data_type,is_single,
		is_channel,is_custom,is_display,is_system,is_quote 
		from t_model_item_system
	</select>
	
	<select id="selectModelItemsByModelId" resultMap="ModelItemMap" parameterType="int">
		select 
		modelitem_id,model_id,field,item_label,priority,def_value,
		opt_value,text_size,area_rows,area_cols,help,
		help_position,data_type,is_single,
		is_channel,is_custom,is_display,is_system,is_quote 
		from t_model_item
		where model_id=#{id}
	</select>
	
	
</mapper>

猜你喜欢

转载自blog.csdn.net/u014793936/article/details/51722868
今日推荐