package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.OperationRecordMapper;
import com.ruoyi.system.domain.OperationRecord;
import com.ruoyi.system.service.IOperationRecordService;

/**
 * 操作记录Service业务层处理
 * 
 * @author boman
 * @date 2025-05-16
 */
@Service
public class OperationRecordServiceImpl implements IOperationRecordService 
{
    @Autowired
    private OperationRecordMapper operationRecordMapper;

    /**
     * 查询操作记录
     * 
     * @param id 操作记录主键
     * @return 操作记录
     */
    @Override
    public OperationRecord selectOperationRecordById(Long id)
    {
        return operationRecordMapper.selectOperationRecordById(id);
    }

    /**
     * 查询操作记录列表
     * 
     * @param operationRecord 操作记录
     * @return 操作记录
     */
    @Override
    public List<OperationRecord> selectOperationRecordList(OperationRecord operationRecord)
    {
        return operationRecordMapper.selectOperationRecordList(operationRecord);
    }

    /**
     * 新增操作记录
     * 
     * @param operationRecord 操作记录
     * @return 结果
     */
    @Override
    public int insertOperationRecord(OperationRecord operationRecord)
    {
        SysUser user = SecurityUtils.getLoginUser().getUser();
        operationRecord.setUserId(user.getUserId());
        operationRecord.setUserName(user.getNickName());
        operationRecord.setCreateTime(DateUtils.getNowDate());
        return operationRecordMapper.insertOperationRecord(operationRecord);
    }

    /**
     * 修改操作记录
     * 
     * @param operationRecord 操作记录
     * @return 结果
     */
    @Override
    public int updateOperationRecord(OperationRecord operationRecord)
    {
        operationRecord.setUpdateTime(DateUtils.getNowDate());
        return operationRecordMapper.updateOperationRecord(operationRecord);
    }

    /**
     * 批量删除操作记录
     * 
     * @param ids 需要删除的操作记录主键
     * @return 结果
     */
    @Override
    public int deleteOperationRecordByIds(Long[] ids)
    {
        return operationRecordMapper.deleteOperationRecordByIds(ids);
    }

    /**
     * 删除操作记录信息
     * 
     * @param id 操作记录主键
     * @return 结果
     */
    @Override
    public int deleteOperationRecordById(Long id)
    {
        return operationRecordMapper.deleteOperationRecordById(id);
    }
}
