tlias管理系统--员工管理--修改员工实现完毕
This commit is contained in:
@@ -31,7 +31,9 @@
|
|||||||
<update id="update">
|
<update id="update">
|
||||||
update emp
|
update emp
|
||||||
<set>
|
<set>
|
||||||
<if test="username != null">username=#{username},</if>
|
<if test="username != null">
|
||||||
|
username=#{username},
|
||||||
|
</if>
|
||||||
<if test="name != null">name=#{name},</if>
|
<if test="name != null">name=#{name},</if>
|
||||||
<if test="gender != null">gender=#{gender},</if>
|
<if test="gender != null">gender=#{gender},</if>
|
||||||
<if test="image != null">image=#{image},</if>
|
<if test="image != null">image=#{image},</if>
|
||||||
|
|||||||
@@ -61,4 +61,19 @@ public class EmpController {
|
|||||||
Emp emp = empService.getEmpById(id);
|
Emp emp = empService.getEmpById(id);
|
||||||
return Result.success(emp);
|
return Result.success(emp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
修改员工
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public Result updateEmp(@RequestBody Emp emp){
|
||||||
|
log.info("修改员工:{}",emp);
|
||||||
|
//调用业务层修改功能
|
||||||
|
empService.update(emp);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,4 +56,10 @@ public interface EmpMapper {
|
|||||||
*/
|
*/
|
||||||
@Select("select * from emp where id = #{id}")
|
@Select("select * from emp where id = #{id}")
|
||||||
Emp getEmpById(Integer id);
|
Emp getEmpById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改员工信息
|
||||||
|
* @param emp
|
||||||
|
*/
|
||||||
|
void update(Emp emp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,4 +39,9 @@ public interface EmpService {
|
|||||||
*/
|
*/
|
||||||
Emp getEmpById(Integer id);
|
Emp getEmpById(Integer id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改员工信息
|
||||||
|
* @param emp
|
||||||
|
*/
|
||||||
|
void update(Emp emp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,4 +101,15 @@ public class EmpServiceImpl implements EmpService {
|
|||||||
return emp;*/
|
return emp;*/
|
||||||
return empMapper.getEmpById(id);
|
return empMapper.getEmpById(id);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 修改员工信息
|
||||||
|
* @param emp
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void update(Emp emp) {
|
||||||
|
//补充更新时间
|
||||||
|
emp.setUpdateTime(LocalDateTime.now());
|
||||||
|
//调用mapper执行update语句
|
||||||
|
empMapper.update(emp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,4 +27,40 @@
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<update id="update">
|
||||||
|
update emp
|
||||||
|
<set>
|
||||||
|
<if test="username != null and username != ''">
|
||||||
|
username = #{username},
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="password != null and password != ''">
|
||||||
|
password = #{password},
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="gender != null">
|
||||||
|
gender = #{gender},
|
||||||
|
</if>
|
||||||
|
<if test="image != null and image != ''">
|
||||||
|
image = #{image},
|
||||||
|
</if>
|
||||||
|
<if test="job != null">
|
||||||
|
job = #{job},
|
||||||
|
</if>
|
||||||
|
<if test="entrydate != null">
|
||||||
|
entrydate = #{entrydate},
|
||||||
|
</if>
|
||||||
|
<if test="deptId != null">
|
||||||
|
dept_id = #{deptId},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time = #{updateTime},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id};
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user