community/community-security-modules/community-security-modules-.../src/main/resources/mapper/PersonMapper.xml

108 lines
3.4 KiB
XML

<?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.zyh.system.mapper.PersonMapper">
<insert id="addPerson">
insert into person values
(0,
#{name},
#{idcard},
#{idcardType},
#{birth},
#{sex},
#{nation},
#{phone},
#{address},
#{houseId},
#{buildId},
#{unit},
#{holdId},
#{pic})
</insert>
<insert id="addPersonTest">
insert into person values
(0,
#{name},
#{idcard},
#{idcardType},
#{birth},
#{sex},
#{nation},
#{phone},
#{address},
#{houseId},
#{buildId},
#{unit},
#{holdId},
#{pic})
</insert>
<update id="updatePerson">
update person set
name = #{name},
idcard = #{idcard},
idcard_type = #{idcardType},
birth = #{birth},
sex = #{sex},
nation = #{nation},
phone = #{phone},
address = #{address},
house_id = #{houseId},
build_id = #{buildId},
unit = #{unit},
hold_id = #{holdId},
pic = #{pic}
where id = #{id}
</update>
<update id="updatepersonNum">
update households set
person_num = person_num-1
where build_id = #{buildId}
and unit = #{unit} and hold_id = #{holdId}
</update>
<update id="updatepersonNumjia">
update households set
person_num = person_num+1
where build_id = #{buildId}
and unit = #{unit} and hold_id = #{holdId}
</update>
<delete id="deletePerson">
delete from person where id = #{id}
</delete>
<select id="getPerson" resultType="com.zyh.common.domain.Person">
select person.*,house.name as housename from person left join house on person.house_id = house.id
</select>
<select id="getBuildId" resultType="java.lang.Integer">
select build_id from building
</select>
<select id="getUnitId" resultType="java.lang.Integer">
select unit from building where build_id = #{buildId}
</select>
<select id="getHoldId" resultType="java.lang.Integer">
select hold_id from households where build_id = #{buildId} and unit = #{unit}
</select>
<select id="getHouseId" resultType="com.zyh.common.domain.House">
select plot_id,name from house
</select>
<select id="searchAdmin" resultType="com.zyh.common.domain.Person">
select * from person
</select>
<select id="stuListWithLimit" resultType="com.zyh.common.domain.PersonTest">
select * from person
</select>
<select id="selectHouseId" resultType="java.lang.Integer">
select plot_id from house where plot_id=#{houseId}
</select>
<select id="selectBuildId" resultType="java.lang.Integer">
select build_id from building where build_id=#{buildId}
</select>
<select id="selectUnit" resultType="java.lang.Integer">
select unit from building where build_id=#{buildId} and unit=#{unit}
</select>
<select id="selectHoldId" resultType="java.lang.Integer">
select hold_id from households where build_id=#{buildId} and unit=#{unit} and hold_id=#{holdId}
</select>
</mapper>