package vip.xiaonuo.disk.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
import vip.xiaonuo.disk.domain.OperationLogBean;
import vip.xiaonuo.disk.mapper.OperationLogMapper;
import vip.xiaonuo.disk.util.PageQuery;
import vip.xiaonuo.disk.util.TableDataInfo;
import vip.xiaonuo.disk.vo.operationLog.OperationLogBeanVo;
import  vip.xiaonuo.disk.service.IOperationLogService;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service
@Transactional(rollbackFor=Exception.class)
public class OperationLogService  extends ServiceImpl<OperationLogMapper, OperationLogBean> implements IOperationLogService {

    @Resource
    OperationLogMapper operationLogMapper;


    @Override
    public List<OperationLogBeanVo> selectOperationLog(String type) {
        String userId = StpLoginUserUtil.getLoginUser().getId();
        List<OperationLogBeanVo> result = operationLogMapper.selectOperationLog(type,userId);
        return result;
    }

    @Override
    public void insertOperationLog(OperationLogBean operationlogBean) {
        operationLogMapper.insert(operationlogBean);

    }

    @Override
    public TableDataInfo<Map<String,Object>> getAllList(String type, String startDate, String endDate, String userName, PageQuery pageQuery) {
        Page<Map<String,Object>> result = operationLogMapper.getAllList(type,startDate,endDate,userName,pageQuery.build());
        return TableDataInfo.build(result);
    }


}
