package com.gic.haoban.manage.service.service.impl;

import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.manage.service.dao.mapper.StaffPrivacyUseLogMapper;
import com.gic.haoban.manage.service.entity.TabStaffPrivacyUseLog;
import com.gic.haoban.manage.service.pojo.bo.StaffPrivacyUseLogBO;
import com.gic.haoban.manage.service.service.StaffPrivacyUseLogService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author xuwenqian
 * @date 2021/12/15 10:46
 */
@Service
public class StaffPrivacyUseLogServiceImpl implements StaffPrivacyUseLogService {

    @Autowired
    private StaffPrivacyUseLogMapper staffPrivacyUseLogMapper;


    @Override
    public int insert(StaffPrivacyUseLogBO staffPrivacyUseLogBO) {
        TabStaffPrivacyUseLog tabStaffPrivacyUseLog = new TabStaffPrivacyUseLog();
        BeanUtils.copyProperties(staffPrivacyUseLogBO, tabStaffPrivacyUseLog);
        Date date = new Date();
        tabStaffPrivacyUseLog.setCreateTime(date);
        tabStaffPrivacyUseLog.setUpdateTime(date);
        return staffPrivacyUseLogMapper.insert(tabStaffPrivacyUseLog);
    }

    @Override
    public StaffPrivacyUseLogBO getByStaffId(String staffId) {
        TabStaffPrivacyUseLog tabStaffPrivacyUseLog = staffPrivacyUseLogMapper.getByStaffId(staffId);
        return EntityUtil.changeEntityByOrika(StaffPrivacyUseLogBO.class, tabStaffPrivacyUseLog);
    }

    @Override
    public StaffPrivacyUseLogBO getByUserId(String userId) {
        TabStaffPrivacyUseLog tabStaffPrivacyUseLog = staffPrivacyUseLogMapper.getByUserId(userId);
        return EntityUtil.changeEntityByOrika(StaffPrivacyUseLogBO.class, tabStaffPrivacyUseLog);
    }
}
