首页 > 代码库 > msyql springMVC 操作

msyql springMVC 操作

<?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.elevator.dao.ProjectMapper" >

<resultMap id="BaseResultMap" type="com.elevator.model.Project" >
<id column="projectid" property="projectId" jdbcType="VARCHAR" />
<result column="projectname" property="projectName" jdbcType="VARCHAR" />
<result column="updatetime" property="updateTime" jdbcType="VARCHAR" />
</resultMap>


<select id="getProjectList" resultMap="BaseResultMap" parameterType="com.elevator.model.Project">
select projectid, projectname,updatetime from ec_project

where 1 = 1

<if test="projectId !=null and projectId !=‘‘ ">
and projectid like CONCAT(‘%‘,#{projectId},‘%‘)
</if>
<if test="projectName !=null and projectName !=‘‘ ">
and projectname like CONCAT(‘%‘,#{projectName},‘%‘)
</if>
</select>

<insert id="addProject" parameterType="com.elevator.model.Project">
insert into ec_project
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="projectId != null" >
projectid,
</if>
<if test="projectName != null" >
projectname,
</if>
<if test="updateTime != null" >
updatetime,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="projectId != null" >
#{projectId, jdbcType=VARCHAR},
</if>
<if test="projectName != null" >
#{projectName, jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
#{updateTime, jdbcType=DATE},
</if>
</trim>
</insert>
</mapper>

msyql springMVC 操作