外卖项目day02-启用禁用员工账号_代码开发和功能测试
This commit is contained in:
@@ -99,4 +99,13 @@ public class EmployeeController {
|
||||
PageResult pageResult = employeeService.pageQuery(employeePageQueryDTO);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
@ApiOperation("启用禁用员工")
|
||||
@PostMapping("/status/{status}")
|
||||
public Result startOrStop(@PathVariable Integer status,Long id) {
|
||||
log.info("启用禁用员工:{},{}",status,id);
|
||||
employeeService.startOrStop(status,id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,5 +26,16 @@ public interface EmployeeMapper {
|
||||
"values (#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{createTime},#{updateTime},#{createUser},#{updateUser})")
|
||||
void insert(Employee employee);
|
||||
|
||||
/**
|
||||
* 员工分页查询
|
||||
* @param epqyDTO
|
||||
* @return
|
||||
*/
|
||||
Page<Employee> pageQuery(EmployeePageQueryDTO epqyDTO);
|
||||
|
||||
/**
|
||||
* 员工修改
|
||||
* @param employee
|
||||
*/
|
||||
void update(Employee employee);
|
||||
}
|
||||
|
||||
@@ -27,4 +27,11 @@ public interface EmployeeService {
|
||||
* @return
|
||||
*/
|
||||
PageResult pageQuery(EmployeePageQueryDTO employeePageQueryDTO);
|
||||
|
||||
/**
|
||||
* 启用禁用员工
|
||||
* @param status 员工状态:1- 启用 0- 禁用
|
||||
* @param id 生效的员工ID
|
||||
*/
|
||||
void startOrStop(Integer status, Long id);
|
||||
}
|
||||
|
||||
@@ -109,4 +109,17 @@ public class EmployeeServiceImpl implements EmployeeService {
|
||||
return new PageResult(total,records);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startOrStop(Integer status, Long id) {
|
||||
//将要修改的数据保存到实体对象
|
||||
/* Employee employee = new Employee();
|
||||
//普通写法
|
||||
employee.setId(id);
|
||||
employee.setStatus(status);*/
|
||||
Employee employee = Employee.builder().id(id).status(status).build();
|
||||
//注意:启用禁用员工只是,员工修改sql中的一部分功能
|
||||
employeeMapper.update(employee);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,23 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.sky.mapper.EmployeeMapper">
|
||||
<update id="update">
|
||||
update employee
|
||||
<set>
|
||||
<if test="name != null and name !=''"> name = #{name},</if>
|
||||
<if test="username != null and username !=''"> username = #{username},</if>
|
||||
<if test="password != null and password !=''"> password = #{password},</if>
|
||||
<if test="phone != null and phone !=''"> phone = #{phone},</if>
|
||||
<if test="sex != null and sex !=''"> sex = #{sex},</if>
|
||||
<if test="idNumber != null and idNumber !=''"> id_number = #{idNumber},</if>
|
||||
<if test="status != null "> status = #{status},</if>
|
||||
<if test="createTime != null "> create_time = #{createTime},</if>
|
||||
<if test="updateTime != null "> update_time = #{updateTime},</if>
|
||||
<if test="createUser != null "> create_user = #{createUser},</if>
|
||||
<if test="updateUser != null "> update_user = #{updateUser},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<select id="pageQuery" resultType="com.sky.entity.Employee">
|
||||
select * from employee
|
||||
<where>
|
||||
|
||||
Reference in New Issue
Block a user