package com.dgtly.system.service.impl;

import java.util.List;
import com.dgtly.common.utils.DateUtils;
import com.dgtly.system.domain.SysUser;
import com.dgtly.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dgtly.system.mapper.SysMagnetLogMapper;
import com.dgtly.system.domain.SysMagnetLog;
import com.dgtly.system.service.ISysMagnetLogService;
import com.dgtly.common.core.text.Convert;

/**
 * 磁铁日志Service业务层处理
 * 
 * @author dgtly
 * @date 2021-07-29
 */
@Service
public class SysMagnetLogServiceImpl implements ISysMagnetLogService 
{
    @Autowired
    private SysMagnetLogMapper sysMagnetLogMapper;
    @Autowired
    private SysUserMapper userMapper;


    /**
     * 查询磁铁日志
     * 
     * @param id 磁铁日志ID
     * @return 磁铁日志
     */
    @Override
    public SysMagnetLog selectSysMagnetLogById(Long id)
    {
        return sysMagnetLogMapper.selectSysMagnetLogById(id);
    }

    /**
     * 查询磁铁日志列表
     * 
     * @param sysMagnetLog 磁铁日志
     * @return 磁铁日志
     */
    @Override
    public List<SysMagnetLog> selectSysMagnetLogList(SysMagnetLog sysMagnetLog)
    {
        return sysMagnetLogMapper.selectSysMagnetLogList(sysMagnetLog);
    }

    /**
     * 新增磁铁日志
     * 
     * @param sysMagnetLog 磁铁日志
     * @return 结果
     */
    @Override
    public int insertSysMagnetLog(SysMagnetLog sysMagnetLog)
    {
        SysUser user =userMapper.selectUserById(sysMagnetLog.getUserId());
        sysMagnetLog.setLoginName(user.getLoginName());
        sysMagnetLog.setSapEmployeeId(user.getSysUserExt().getSapEmployeeId());
        sysMagnetLog.setCreateTime(DateUtils.getNowDate());
        return sysMagnetLogMapper.insertSysMagnetLog(sysMagnetLog);
    }

    /**
     * 修改磁铁日志
     * 
     * @param sysMagnetLog 磁铁日志
     * @return 结果
     */
    @Override
    public int updateSysMagnetLog(SysMagnetLog sysMagnetLog)
    {
        sysMagnetLog.setUpdateTime(DateUtils.getNowDate());
        return sysMagnetLogMapper.updateSysMagnetLog(sysMagnetLog);
    }

    /**
     * 删除磁铁日志对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysMagnetLogByIds(String ids)
    {
        return sysMagnetLogMapper.deleteSysMagnetLogByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除磁铁日志信息
     * 
     * @param id 磁铁日志ID
     * @return 结果
     */
    @Override
    public int deleteSysMagnetLogById(Long id)
    {
        return sysMagnetLogMapper.deleteSysMagnetLogById(id);
    }
}
