CodeModelMapper.xml 2.2 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10
<?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.skyeye.codemodel.dao.CodeModelDao">
	
	<select id="queryCodeModelList" parameterType="java.util.Map" resultType="java.util.Map">
		SELECT
			a.id,
			a.model_name modelName,
			a.model_content modelContent,
			a.model_text modelText,
doc_wei's avatar
doc_wei 已提交
11
			a.model_type modelType,
doc_wei's avatar
doc_wei 已提交
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
			CONVERT(a.create_time, char) createTime
		FROM
			code_model a
		WHERE a.group_id = #{groupId}
			ORDER BY a.create_time DESC
	</select>
	
	<select id="queryCodeModelMationByName" parameterType="java.util.Map" resultType="java.util.Map">
		SELECT
			a.id,
			a.model_name modelName
		FROM
			code_model a
		WHERE a.group_id = #{groupId}
			AND a.model_name = #{modelName}
	</select>
	
	<insert id="insertCodeModelMation" parameterType="java.util.Map">
	     INSERT into code_model 
doc_wei's avatar
doc_wei 已提交
31
	     (id, group_id, model_name, model_content, model_text, model_type, create_id, create_time)
doc_wei's avatar
doc_wei 已提交
32
	     VALUES
doc_wei's avatar
doc_wei 已提交
33
	     (#{id}, #{groupId}, #{modelName}, #{modelContent}, #{modelText}, #{modelType}, #{createId}, #{createTime})
doc_wei's avatar
doc_wei 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
	</insert>
	
	<delete id="deleteCodeModelById" parameterType="java.util.Map">
		DELETE
		FROM
			code_model
		WHERE
			id = #{id}
	</delete>
	
	<select id="queryCodeModelMationToEditById" parameterType="java.util.Map" resultType="java.util.Map">
		SELECT
			a.id,
			a.model_name modelName,
			a.model_content modelContent,
doc_wei's avatar
doc_wei 已提交
49 50
			a.model_text modelText,
			a.model_type modelType
doc_wei's avatar
doc_wei 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
		FROM
			code_model a
		WHERE a.id = #{id}
	</select>
	
	<select id="queryCodeModelMationByIdAndName" parameterType="java.util.Map" resultType="java.util.Map">
		SELECT
			a.id,
			a.model_name modelName
		FROM
			code_model a
		WHERE a.id != #{id}
			AND a.group_id = #{groupId}
			AND a.model_name = #{modelName}
	</select>
	
	<update id="editCodeModelMationById" parameterType="java.util.Map">
		UPDATE code_model
		<set>
			<if test="modelName != '' and modelName != null">
				model_name = #{modelName},
			</if>
			<if test="modelContent != '' and modelContent != null">
				model_content = #{modelContent},
			</if>
			<if test="modelText != '' and modelText != null">
				model_text = #{modelText},
			</if>
		</set>
		WHERE id = #{id}
	</update>
	
</mapper>