苍穹外卖--员工管理--启用禁用员工账号
This commit is contained in:
@@ -100,4 +100,12 @@ public class EmployeeController {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface EmployeeMapper {
|
||||
void insert(Employee employee);
|
||||
|
||||
Page<Employee> pageQuery(EmployeePageQueryDTO employeePageQueryDTO);
|
||||
|
||||
void update(Employee employee);
|
||||
}
|
||||
|
||||
@@ -26,4 +26,9 @@ public interface EmployeeService {
|
||||
* @return
|
||||
*/
|
||||
PageResult pageQuery(EmployeePageQueryDTO employeePageQueryDTO);
|
||||
|
||||
/*
|
||||
启用禁用员工账号
|
||||
*/
|
||||
void startOrStop(Integer status, Long id);
|
||||
}
|
||||
|
||||
@@ -115,4 +115,21 @@ public class EmployeeServiceImpl implements EmployeeService {
|
||||
return new PageResult(total,records);
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用禁用员工账号
|
||||
* @param status
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void startOrStop(Integer status, Long id) {
|
||||
//update employee set status = ? where id = ?;
|
||||
//写法1:普通方式
|
||||
/*Employee employee = new Employee();
|
||||
employee.setId(id);
|
||||
employee.setStatus(status);*/
|
||||
//写法2:构建器创建实体对象
|
||||
Employee employee = Employee.builder().id(id).status(status).build();
|
||||
employeeMapper.update(employee);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.sky.mapper.EmployeeMapper">
|
||||
|
||||
<select id="pageQuery" resultType="com.sky.entity.Employee">
|
||||
select * from employee
|
||||
<where>
|
||||
@@ -11,4 +12,23 @@
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<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>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user