package com.starry.admin.modules.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.starry.admin.modules.system.mapper.SysOperationLogMapper;
import com.starry.admin.modules.system.module.entity.SysOperationLogEntity;
import com.starry.admin.modules.system.service.ISysOperationLogService;
import com.starry.admin.modules.system.vo.SysOperationLogVo;
import java.util.Arrays;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 操作日志表Service业务层处理
 *
 * @author admin
 */
@Service
public class SysOperationLogServiceImpl extends ServiceImpl<SysOperationLogMapper, SysOperationLogEntity>
        implements
            ISysOperationLogService {

    @Resource
    private SysOperationLogMapper sysOperationLogMapper;

    /**
     * 查询操作日志表
     *
     * @param operId
     *            操作日志表主键
     * @return 操作日志表
     */
    @Override
    public SysOperationLogEntity selectXlOperLogByOperId(Long operId) {
        return sysOperationLogMapper.selectXlOperLogByOperId(operId);
    }

    /**
     * 查询操作日志表列表
     *
     * @param sysOperationLogEntity
     *            操作日志表
     * @return 操作日志表
     */
    @Override
    public IPage<SysOperationLogEntity> selectXlOperLogList(SysOperationLogVo sysOperationLogEntity) {
        return sysOperationLogMapper.selectXlOperLogList(
                new Page<>(sysOperationLogEntity.getPageNum(), sysOperationLogEntity.getPageSize()),
                sysOperationLogEntity);
    }

    /**
     * 新增操作日志表
     *
     * @param sysOperationLogEntity
     *            操作日志表
     * @return 结果
     */
    @Override
    public boolean create(SysOperationLogEntity sysOperationLogEntity) {
        return save(sysOperationLogEntity);
    }

    /**
     * 修改操作日志表
     *
     * @param sysOperationLogEntity
     *            操作日志表
     * @return 结果
     */
    @Override
    public boolean updateXlOperLog(SysOperationLogEntity sysOperationLogEntity) {
        return updateById(sysOperationLogEntity);
    }

    /**
     * 批量删除操作日志表
     *
     * @param operIds
     *            需要删除的操作日志表主键
     * @return 结果
     */
    @Override
    public int deleteXlOperLogByOperIds(Long[] operIds) {
        return sysOperationLogMapper.deleteBatchIds(Arrays.asList(operIds));
    }

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