You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.7 KiB
47 lines
1.7 KiB
<?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.example.springbootstudy.dao.ClientDao">
|
|
<resultMap type="com.example.springbootstudy.pojo.Client" id="client_mapping">
|
|
<id property="id" column="id"/>
|
|
<result property="name" column="name"/>
|
|
<result property="ID_Number" column="ID_Number"/>
|
|
<result property="vip_id" column="vip_id"/>
|
|
<association property="vip" column="vip_id" javaType="com.example.springbootstudy.pojo.Vip">
|
|
<id property="id" column="id"/>
|
|
<result property="level" column="level"/>
|
|
</association>
|
|
</resultMap>
|
|
|
|
<select id="getClients" resultMap="client_mapping">
|
|
select c.id,c.name,c.ID_Number,c.vip_id,v.id,v.level from client c left join vip v on c.vip_id = v.id;
|
|
</select>
|
|
<select id="getClientById" resultMap="client_mapping">
|
|
select c.id,c.name,c.ID_Number,c.vip_id,v.id,v.level from client c left join vip v on c.vip_id = v.id where c.id = #{id};
|
|
</select>
|
|
|
|
<insert id="addClient">
|
|
insert into client values(null,#{name},#{ID_Number},#{vip_id});
|
|
</insert>
|
|
|
|
<delete id="delClient">
|
|
delete from client where id = #{id};
|
|
</delete>
|
|
|
|
<update id="updateClient">
|
|
update client
|
|
<set>
|
|
<if test="name != null">
|
|
name = #{name},
|
|
</if>
|
|
<if test="ID_Number != null">
|
|
ID_Number = #{ID_Number},
|
|
</if>
|
|
<if test="vip_id != null">
|
|
vip_id = #{vip_id},
|
|
</if>
|
|
</set>
|
|
where id = #{id};
|
|
</update>
|
|
</mapper> |