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.TableNiuseRongliang;
import com.izouma.awesomeadmin.service.TableNiuseRongliangService;
import com.izouma.awesomeadmin.dao.TableNiuseRongliangMapper;

/**
*  service接口实现类
*/
@Service
public class TableNiuseRongliangServiceImpl implements TableNiuseRongliangService{

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

    @Autowired
    private TableNiuseRongliangMapper tableNiuseRongliangMapper;

    @Override
    public List<TableNiuseRongliang> getTableNiuseRongliangList(TableNiuseRongliang record) {

        logger.info("getTableNiuseRongliangList");
        try {

        return tableNiuseRongliangMapper.queryAllTableNiuseRongliang(record);
        } catch (Exception e) {
        logger.error("getTableNiuseRongliangList", e);
        }

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

        logger.info("getTableNiuseRongliangByPage");
        try {

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

        return tableNiuseRongliangMapper.queryTableNiuseRongliangByPage(parameter);
        } catch (Exception e) {
        logger.error("getTableNiuseRongliangByPage", e);
        }

        return null;
    }

    @Override
    public TableNiuseRongliang getTableNiuseRongliangById(String id) {

        logger.info("getTableNiuseRongliangyId");
        try {

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

        return null;
    }

    @Override
    public TableNiuseRongliang getTableNiuseRongliang(TableNiuseRongliang record) {

        logger.info("getTableNiuseRongliang");
        try {

            return tableNiuseRongliangMapper.queryTableNiuseRongliang(record);
        } catch (Exception e) {
        logger.error("getTableNiuseRongliang", e);
        }

        return null;
    }

    @Override
    public boolean createTableNiuseRongliang(TableNiuseRongliang record) {

        logger.info("createTableNiuseRongliang");
        try {

            int updates = tableNiuseRongliangMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteTableNiuseRongliang(TableNiuseRongliang record) {

        logger.info("deleteTableNiuseRongliang");
        try {

             int updates = tableNiuseRongliangMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateTableNiuseRongliang(TableNiuseRongliang record) {

        logger.info("updateTableNiuseRongliang");
        try {

            int updates = tableNiuseRongliangMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

