|
|
|
|
@ -1,18 +1,25 @@
|
|
|
|
|
package com.sky.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.sky.constant.MessageConstant;
|
|
|
|
|
import com.sky.constant.PasswordConstant;
|
|
|
|
|
import com.sky.constant.StatusConstant;
|
|
|
|
|
import com.sky.context.BaseContext;
|
|
|
|
|
import com.sky.dto.EmployeeDTO;
|
|
|
|
|
import com.sky.dto.EmployeeLoginDTO;
|
|
|
|
|
import com.sky.entity.Employee;
|
|
|
|
|
import com.sky.exception.AccountLockedException;
|
|
|
|
|
import com.sky.exception.AccountNotFoundException;
|
|
|
|
|
import com.sky.exception.BaseException;
|
|
|
|
|
import com.sky.exception.PasswordErrorException;
|
|
|
|
|
import com.sky.mapper.EmployeeMapper;
|
|
|
|
|
import com.sky.service.EmployeeService;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.DigestUtils;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class EmployeeServiceImpl implements EmployeeService {
|
|
|
|
|
|
|
|
|
|
@ -39,7 +46,9 @@ public class EmployeeServiceImpl implements EmployeeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//密码比对
|
|
|
|
|
// TODO 后期需要进行md5加密,然后再进行比对
|
|
|
|
|
//进行md5加密
|
|
|
|
|
password = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
|
|
|
|
|
|
|
|
if (!password.equals(employee.getPassword())) {
|
|
|
|
|
//密码错误
|
|
|
|
|
throw new PasswordErrorException(MessageConstant.PASSWORD_ERROR);
|
|
|
|
|
@ -54,4 +63,31 @@ public class EmployeeServiceImpl implements EmployeeService {
|
|
|
|
|
return employee;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增员工
|
|
|
|
|
*
|
|
|
|
|
* @param employeeDTO
|
|
|
|
|
*/
|
|
|
|
|
public void save(EmployeeDTO employeeDTO) {
|
|
|
|
|
Employee employee = new Employee();
|
|
|
|
|
|
|
|
|
|
//对象属性拷贝
|
|
|
|
|
BeanUtils.copyProperties(employeeDTO, employee);
|
|
|
|
|
|
|
|
|
|
//设置账号的状态,默认正常状态 1表示正常 0表示锁定
|
|
|
|
|
employee.setStatus(StatusConstant.ENABLE);
|
|
|
|
|
|
|
|
|
|
//设置密码,默认密码123456
|
|
|
|
|
employee.setPassword(DigestUtils.md5DigestAsHex(PasswordConstant.DEFAULT_PASSWORD.getBytes()));
|
|
|
|
|
|
|
|
|
|
//设置当前记录的创建时间和修改时间
|
|
|
|
|
employee.setCreateTime(LocalDateTime.now());
|
|
|
|
|
employee.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
|
|
//设置当前记录创建人id和修改人id
|
|
|
|
|
employee.setCreateUser(BaseContext.getCurrentId());
|
|
|
|
|
employee.setUpdateUser(BaseContext.getCurrentId());
|
|
|
|
|
|
|
|
|
|
employeeMapper.insert(employee);//后续步骤定义
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|