package com.my.bus.service.impl;

import com.my.bus.service.ISysOperationLogService;
import com.my.bus.domain.SysOperationLog;
import com.my.bus.mapper.SysOperationLogMapper;
import com.my.common.core.domain.model.LoginUser;
import com.my.common.utils.SecurityUtils;
import com.my.common.utils.uuid.SnowflakeIdWorker;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 日志Service业务层处理
 *
 * @author my
 * @date 2024-12-23
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class SysOperationLogServiceImpl implements ISysOperationLogService {

    private final SysOperationLogMapper sysOperationLogMapper;

    /**
     * 查询日志
     *
     * @param id 日志主键
     * @return 日志
     */
    @Override
    public SysOperationLog selectById(Long id) {
        return sysOperationLogMapper.selectById(id);
    }

    /**
     * 查询日志列表
     *
     * @param sysOperationLog 日志
     * @return 日志
     */
    @Override
    public List<SysOperationLog> selectList(SysOperationLog sysOperationLog) {
        return sysOperationLogMapper.selectList(sysOperationLog);
    }

    /**
     * 新增日志
     *
     * @param sysOperationLog 日志
     * @return 结果
     */
    @Override
    public int insert(SysOperationLog sysOperationLog) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
                sysOperationLog.setId(new SnowflakeIdWorker(0, 0).nextId());
                sysOperationLog.setStatus(0);
            return sysOperationLogMapper.insert(sysOperationLog);
    }

    /**
     * 修改日志
     *
     * @param sysOperationLog 日志
     * @return 结果
     */
    @Override
    public int update(SysOperationLog sysOperationLog) {
        LoginUser loginUser = SecurityUtils.getLoginUser();

        return sysOperationLogMapper.update(sysOperationLog);
    }

    /**
     * 批量删除日志
     *
     * @param ids 需要删除的日志主键
     * @return 结果
     */
    @Override
    public int deleteByIds(Long[] ids) {
        return sysOperationLogMapper.deleteByIds(ids);
    }

    /**
     * 删除日志信息
     *
     * @param id 日志主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id) {
        return sysOperationLogMapper.deleteById(id);
    }

    /**
     * 逻辑删除日志信息
     *
     * @param id 日志主键
     * @return 结果
     */
    @Override
    public int logicDelete(Long id) {

        return sysOperationLogMapper.logicDelete(id);
    }


}
