<?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.landaiqing.mapper.adminMapper">
    <resultMap id="adminMap" type="com.landaiqing.entity.AdminUserEntity">
        <!-- 数据库中字段名称 column="" property="id"  类中成员属性名称-->
        <id column="adminId" property="adminId"></id>
        <result column="adminUserName" property="adminUserName"></result>
        <result column="adminPassword" property="adminPassword"></result>
        <result column="is_valid" property="isValid"></result>
    </resultMap>
    <insert id="insertAdmin" parameterType="com.landaiqing.entity.AdminUserEntity">
        INSERT INTO `admin` (`adminId`, `adminUserName`, `adminPassword`, `is_valid`) VALUES (null, #{adminUserName}, #{adminPassword}, #{isValid});
    </insert>
    <update id="OpenAdmin" parameterType="int">
        UPDATE `admin` SET `is_valid` = 1 WHERE `adminId` = #{adminId};
    </update>
    <update id="CloseAdmin" parameterType="int">
        UPDATE `admin` SET `is_valid` = 0 WHERE `adminId` = #{adminId};
    </update>
    <update id="updateAdmin" parameterType="com.landaiqing.entity.AdminUserEntity">
        UPDATE `admin` SET `adminUserName` = #{adminUserName}, `adminPassword` = #{adminPassword},`is_valid`=#{isValid} WHERE `adminId` = #{adminId};
    </update>
    <delete id="deleteAdmin" parameterType="int">
        DELETE from `admin`  WHERE `adminId` = #{adminId};
    </delete>
    <select id="login" parameterType="com.landaiqing.entity.AdminUserEntity" resultMap="adminMap">
        select  * from  admin where adminUserName=#{adminUserName} and adminPassword=#{adminPassword} and is_valid='1';
    </select>
    <select id="selectAllAdmin" resultMap="adminMap">
        select * from admin;
    </select>
    <select id="getAdminByID" resultType="com.landaiqing.entity.AdminUserEntity">
        select * from admin  where adminId=#{adminId};
    </select>
</mapper>