package com.shinsoft.sto.service.impl.record;

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.shinsoft.sto.mapper.record.OutrecordMapper;
import com.shinsoft.sto.model.record.Outrecord;
import com.shinsoft.sto.model.system.ResponseCodeMsg;
import com.shinsoft.sto.model.system.ResultJSON;
import com.shinsoft.sto.service.record.OutrecordService;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class OutrecordServiceImpl extends ServiceImpl<OutrecordMapper, Outrecord> implements OutrecordService {

    @Override
    public ResultJSON query(int page, int rows, Map<String, Object> map) {
        try {
            Page<Outrecord> pageParam = new Page<>(page, rows);
            IPage<Outrecord> result = baseMapper.selectOutrecordPage(pageParam, map);
            return ResultJSON.success(result);
        } catch (Exception ex) {
            ex.printStackTrace();
            return ResultJSON.error(ResponseCodeMsg.CODE_EX, ex.getMessage());
        }
    }

    @Override
    public ResultJSON statistics(Map<String, Object> map) {
        try {
            Map<String, Object> stats = baseMapper.selectStatistics(map);
            return ResultJSON.success(stats);
        } catch (Exception ex) {
            ex.printStackTrace();
            return ResultJSON.error(ResponseCodeMsg.CODE_EX, ex.getMessage());
        }
    }
}


