编辑员工业务代码开发
This commit is contained in:
@@ -11,6 +11,7 @@ import com.sky.result.Result;
|
||||
import com.sky.service.EmployeeService;
|
||||
import com.sky.utils.JwtUtil;
|
||||
import com.sky.vo.EmployeeLoginVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -120,4 +121,31 @@ public class EmployeeController {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询员工信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@ApiOperation("根据id查询员工信息")
|
||||
public Result<Employee> getById(@PathVariable Long id){
|
||||
log.info("根据id查询员工信息:{}", id);
|
||||
Employee employee = employeeService.getById(id);
|
||||
return Result.success(employee);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑员工信息
|
||||
* @param employeeDTO
|
||||
* @return
|
||||
*/
|
||||
@PutMapping
|
||||
@ApiOperation("编辑员工信息")
|
||||
public Result update(@RequestBody EmployeeDTO employeeDTO){
|
||||
log.info("编辑员工信息:{}", employeeDTO);
|
||||
employeeService.update(employeeDTO);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,4 +43,13 @@ public interface EmployeeMapper {
|
||||
* @param employee
|
||||
*/
|
||||
void update(Employee employee);
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询员工信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Select("select * from employee where id = #{id}")
|
||||
Employee getById(Long id);
|
||||
}
|
||||
|
||||
@@ -37,4 +37,19 @@ public interface EmployeeService {
|
||||
* @param id
|
||||
*/
|
||||
void startOrStop(Integer status, Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询员工信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Employee getById(Long id);
|
||||
|
||||
|
||||
/**
|
||||
* 编辑员工信息
|
||||
* @param employeeDTO
|
||||
*/
|
||||
void update(EmployeeDTO employeeDTO);
|
||||
}
|
||||
|
||||
@@ -129,4 +129,31 @@ public class EmployeeServiceImpl implements EmployeeService {
|
||||
employeeMapper.update(employee);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询员工信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Employee getById(Long id) {
|
||||
Employee employee = employeeMapper.getById(id);
|
||||
employee.setPassword("******");
|
||||
return employee;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑员工信息
|
||||
* @param employeeDTO
|
||||
*/
|
||||
public void update(EmployeeDTO employeeDTO) {
|
||||
Employee employee = new Employee();
|
||||
BeanUtils.copyProperties(employeeDTO, employee);
|
||||
employee.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
//在拦截器中设置好id
|
||||
employee.setUpdateUser(BaseContext.getCurrentId());
|
||||
employeeMapper.update(employee);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
<update id="update" parameterType="Employee">
|
||||
update employee
|
||||
<set>
|
||||
<if test="name != null and name != ''">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="createTime != null">create_time = #{createTime}</if>
|
||||
<if test="status != null">status = #{status}</if>
|
||||
<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>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user