接口相关信息
controller层
/*
* 启用禁用员工账号
* */
@PostMapping("/status/{status}")
@ApiOperation("启用禁用员工账号")
public Result startOrStop(@PathVariable Integer status, Long id) {
log.info("启用禁用员工{},{}",status,id);
employeeService.startOrStop(status,id);
return Result.success();
}
service和serviceimpl层
/*
*启用禁用员工账号
* */
void startOrStop(Integer status, Long id);
/*
* 启用禁用员工账号
* */
@Override
public void startOrStop(Integer status, Long id) {
Employee employee=new Employee();
employee.setStatus(status);
employee.setId(id);
employeeMapper.update(employee);
}
mapper层和xml配置文件
因为sql比较复杂所以使用在XML文件下配置动态SQL的方式实现功能
void update(Employee employee);
<!--更新员工信息-->
<update id="update" parameterType="Employee">
update employee
/*前面是employee的属性*/
<set>
<if test="name != null"> name = #{name},</if>
<if test="username != null"> username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="phone != null"> phone = #{phone}, </if>
<if test="sex != null"> sex = #{sex},</if>
<if test="idNumber != null"> id_number = #{idNumber},</if>
<if test="updateTime != null">update_Time = #{updateTime},</if>
<if test="updateUser != null">update_User = #{updateUser},</if>
/*因为用了set标签所以最后这里也加,*/
<if test="status != null">status = #{status},</if>
</set>
where id=#{id}
</update>