package com.izouma.awesomeadmin.service.impl;

import java.util.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.izouma.awesomeadmin.constant.AppConstant;
import com.izouma.awesomeadmin.dto.Page;
import com.izouma.awesomeadmin.model.SeeOrder;
import com.izouma.awesomeadmin.service.SeeOrderService;
import com.izouma.awesomeadmin.dao.SeeOrderMapper;

/**
*  service接口实现类
*/
@Service
public class SeeOrderServiceImpl implements SeeOrderService{

    private static Logger logger = Logger.getLogger(SeeOrderServiceImpl.class);

    @Autowired
    private SeeOrderMapper seeOrderMapper;

    @Override
    public List<SeeOrder> getSeeOrderList(SeeOrder record) {

        logger.info("getSeeOrderList");
        try {

        return seeOrderMapper.queryAllSeeOrder(record);
        } catch (Exception e) {
        logger.error("getSeeOrderList", e);
        }

        return null;
    }
    @Override
    public List<SeeOrder> getSeeOrderByPage(Page page, SeeOrder record) {

        logger.info("getSeeOrderByPage");
        try {

        Map<String, Object> parameter = new HashMap<String, Object>();
        parameter.put("record", record);
        parameter.put(AppConstant.PAGE, page);

        return seeOrderMapper.querySeeOrderByPage(parameter);
        } catch (Exception e) {
        logger.error("getSeeOrderByPage", e);
        }

        return null;
    }

    @Override
    public SeeOrder getSeeOrderById(String id) {

        logger.info("getSeeOrderyId");
        try {

            return seeOrderMapper.selectByPrimaryKey(Integer.valueOf(id));
        } catch (Exception e) {
        logger.error("getSeeOrderById", e);
        }

        return null;
    }

    @Override
    public SeeOrder getSeeOrder(SeeOrder record) {

        logger.info("getSeeOrder");
        try {

            return seeOrderMapper.querySeeOrder(record);
        } catch (Exception e) {
        logger.error("getSeeOrder", e);
        }

        return null;
    }

    @Override
    public boolean createSeeOrder(SeeOrder record) {

        logger.info("createSeeOrder");
        try {

            int updates = seeOrderMapper.insertSelective(record);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
            logger.error("createSeeOrder", e);
        }

        return false;
    }

    @Override
    public boolean deleteSeeOrder(String id) {

        logger.info("deleteSeeOrder");
        try {

             int updates = seeOrderMapper.delete(id);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
             logger.error("deleteSeeOrder", e);
        }

        return false;
    }

    @Override
    public boolean updateSeeOrder(SeeOrder record) {

        logger.info("updateSeeOrder");
        try {

            int updates = seeOrderMapper.updateByPrimaryKeySelective(record);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
             logger.error("updateSeeOrder", e);
        }

        return false;
    }
}

