package com.bonus.system.att.service;

import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.att.dao.AttendanceMachineDao;
import com.bonus.system.att.entity.AttendanceMachineBean;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * 考勤机-业务层
 * @author zys
 */
@Service("attendanceMachineService")
public class AttendanceMachineServiceImpl implements AttendanceMachineService {

    @Resource(name = "attendanceMachineDao")
    private AttendanceMachineDao attendanceMachineDao;

    @Override
    public List<AttendanceMachineBean> selectAttendanceMachineList(AttendanceMachineBean bean) {
        return attendanceMachineDao.selectAttendanceMachineList(bean);
    }

    @Override
    public int insertAttendanceMachine(AttendanceMachineBean bean) {
        bean.setCreateUserId(SecurityUtils.getLoginUser().getSysUser().getUserId());
        return attendanceMachineDao.insertAttendanceMachine(bean);
    }

    @Override
    public AttendanceMachineBean selectAttendanceMachineById(Long machineId) {
        return attendanceMachineDao.selectAttendanceMachineById(machineId);
    }

    @Override
    public int updateAttendanceMachine(AttendanceMachineBean bean) {
        bean.setUpdateUserId(SecurityUtils.getLoginUser().getSysUser().getUserId());
        return attendanceMachineDao.updateAttendanceMachine(bean);
    }

    @Override
    public int deleteAttendanceMachine(Long machineId) {
        long updateUserId = SecurityUtils.getLoginUser().getSysUser().getUserId();
        return attendanceMachineDao.deleteAttendanceMachine(machineId, updateUserId);
    }
}
