package com.dcsoft.system.visitor.service.impl;

import com.dcsoft.common.core.enums.ExamineEnum;
import com.dcsoft.common.security.utils.SecurityUtils;
import com.dcsoft.system.api.model.LoginUser;
import com.dcsoft.system.visitor.domain.*;
import com.dcsoft.system.visitor.mapper.VisCarryStuffMapper;
import com.dcsoft.system.visitor.mapper.VisExitOutRecordMapper;
import com.dcsoft.system.visitor.mapper.VisitorMapper;
import com.dcsoft.system.visitor.service.IVisCarryStuffService;
import com.dcsoft.system.visitor.service.IVisExitOutRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Service
public class VisExitOutRecordImpl implements IVisExitOutRecordService {

    @Resource
    private VisExitOutRecordMapper visExitOutRecordMapper;

    @Override
    public List<VisExitOutRecordVo> selectList(VisExitOutRecordVo vo) {
        return visExitOutRecordMapper.selectList(vo);
    }

    @Override
    public VisExitOutRecordVo selectExitOutRecordById(Long id) {
        return visExitOutRecordMapper.selectExitOutRecordById(id);
    }

    @Override
    public void insertExitOutRecord(VisExitOutRecordVo vo) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        vo.setCreateBy(loginUser.getUsername());
        visExitOutRecordMapper.insertExitOutRecord(vo);
    }

    @Override
    public void delete(Long[] ids) {
        List<Long> list = Arrays.asList(ids);
        visExitOutRecordMapper.delete(list);
    }

    @Override
    public void confirmPass(VisExitOutRecordVo vo) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        vo.setCreateBy(loginUser.getUsername());
        vo.setUserId(loginUser.getUserid());
        vo.setUserName(loginUser.getUsername());
        visExitOutRecordMapper.insertExitOutRecord(vo);
    }

}
