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.

66 lines
2.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="comxyp.mapper.EmployeeMapper">
<!--根据用户名查询员工信息-->
<select id="findNameLogin" resultType="comxyp.pojo.Employee">
select * from employee_table where username = #{username}
</select>
<!--保存用户-->
<insert id="saveUser" parameterType="comxyp.pojo.Employee">
insert into employee_table(id,username,password,name,sex,deptId)
values (#{id},#{username},#{password},#{name},#{sex},#{deptId})
</insert>
<select id="getEmployeeCountByDeptId" resultType="int">
<!-- 根据部门编号查询该部门下的员工数量 -->
select count(1) from employee_table where deptId = #{deptId}
</select>
<!--更新个人信息-->
<update id="updateUser" parameterType="comxyp.pojo.Employee">
update employee_table set username=#{username}, name = #{name},sex = #{sex}, deptId = #{deptId} where id=#{id}
</update>
<!--更新密码-->
<update id="updatePassword" parameterType="comxyp.pojo.Employee">
update employee_table set password=#{password} where id=#{id}
</update>
<!--查询密码-->
<select id="selectPassword" parameterType="Integer" resultType="String">
select password from employee_table where id=#{id}
</select>
<!--查询员工信息-->
<select id="employeeList" resultType="comxyp.pojo.User">
select * from user_table
</select>
<!--添加员工-->
<insert id="addEmployee" parameterType="comxyp.pojo.User">
insert into user_table(id,empname,sex,deptname,address,hireDate,remark) values (#{id},#{empname},#{sex},#{deptname},#{address},#{hireDate},#{remark})
</insert>
<!--修改员工-->
<update id="updateEmployee" parameterType="comxyp.pojo.User">
update user_table
<set>
<if test="empname!=null and empname!=''">
empname = #{empname},
</if>
<if test="sex!=null and sex!=''">
sex = #{sex},
</if>
<if test="deptname!=null and deptname!=''">
deptname = #{deptname},
</if>
<if test="address!=null and address!=''">
sex = #{address},
</if>
<if test="hireDate!=null and hireDate!=''">
hireDate = #{hireDate},
</if>
<if test="remark!=null and remark!=''">
remark = #{remark}
</if>
</set>
where id=#{id}
</update>
<!--删除员工-->
<delete id="deleteEmployee" parameterType="String">
delete from user_table where id=#{id}
</delete>
</mapper>