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.TableShouyiYaopinxinxi;
import com.izouma.awesomeadmin.service.TableShouyiYaopinxinxiService;
import com.izouma.awesomeadmin.dao.TableShouyiYaopinxinxiMapper;

/**
*  service接口实现类
*/
@Service
public class TableShouyiYaopinxinxiServiceImpl implements TableShouyiYaopinxinxiService{

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

    @Autowired
    private TableShouyiYaopinxinxiMapper tableShouyiYaopinxinxiMapper;

    @Override
    public List<TableShouyiYaopinxinxi> getTableShouyiYaopinxinxiList(TableShouyiYaopinxinxi record) {

        logger.info("getTableShouyiYaopinxinxiList");
        try {

        return tableShouyiYaopinxinxiMapper.queryAllTableShouyiYaopinxinxi(record);
        } catch (Exception e) {
        logger.error("getTableShouyiYaopinxinxiList", e);
        }

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

        logger.info("getTableShouyiYaopinxinxiByPage");
        try {

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

        return tableShouyiYaopinxinxiMapper.queryTableShouyiYaopinxinxiByPage(parameter);
        } catch (Exception e) {
        logger.error("getTableShouyiYaopinxinxiByPage", e);
        }

        return null;
    }

    @Override
    public TableShouyiYaopinxinxi getTableShouyiYaopinxinxiById(String id) {

        logger.info("getTableShouyiYaopinxinxiyId");
        try {

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

        return null;
    }

    @Override
    public TableShouyiYaopinxinxi getTableShouyiYaopinxinxi(TableShouyiYaopinxinxi record) {

        logger.info("getTableShouyiYaopinxinxi");
        try {

            return tableShouyiYaopinxinxiMapper.queryTableShouyiYaopinxinxi(record);
        } catch (Exception e) {
        logger.error("getTableShouyiYaopinxinxi", e);
        }

        return null;
    }

    @Override
    public boolean createTableShouyiYaopinxinxi(TableShouyiYaopinxinxi record) {

        logger.info("createTableShouyiYaopinxinxi");
        try {

            int updates = tableShouyiYaopinxinxiMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteTableShouyiYaopinxinxi(String id) {

        logger.info("deleteTableShouyiYaopinxinxi");
        try {

             int updates = tableShouyiYaopinxinxiMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateTableShouyiYaopinxinxi(TableShouyiYaopinxinxi record) {

        logger.info("updateTableShouyiYaopinxinxi");
        try {

            int updates = tableShouyiYaopinxinxiMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

