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.MemberCoinTixian;
import com.izouma.awesomeadmin.service.MemberCoinTixianService;
import com.izouma.awesomeadmin.dao.MemberCoinTixianMapper;

/**
*  service接口实现类
*/
@Service
public class MemberCoinTixianServiceImpl implements MemberCoinTixianService{

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

    @Autowired
    private MemberCoinTixianMapper memberCoinTixianMapper;

    @Override
    public List<MemberCoinTixian> getMemberCoinTixianList(MemberCoinTixian record) {

        logger.info("getMemberCoinTixianList");
        try {

        return memberCoinTixianMapper.queryAllMemberCoinTixian(record);
        } catch (Exception e) {
        logger.error("getMemberCoinTixianList", e);
        }

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

        logger.info("getMemberCoinTixianByPage");
        try {

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

        return memberCoinTixianMapper.queryMemberCoinTixianByPage(parameter);
        } catch (Exception e) {
        logger.error("getMemberCoinTixianByPage", e);
        }

        return null;
    }

    @Override
    public MemberCoinTixian getMemberCoinTixianById(String id) {

        logger.info("getMemberCoinTixianyId");
        try {

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

        return null;
    }

    @Override
    public MemberCoinTixian getMemberCoinTixian(MemberCoinTixian record) {

        logger.info("getMemberCoinTixian");
        try {

            return memberCoinTixianMapper.queryMemberCoinTixian(record);
        } catch (Exception e) {
        logger.error("getMemberCoinTixian", e);
        }

        return null;
    }

    @Override
    public boolean createMemberCoinTixian(MemberCoinTixian record) {

        logger.info("createMemberCoinTixian");
        try {

            int updates = memberCoinTixianMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteMemberCoinTixian(String id) {

        logger.info("deleteMemberCoinTixian");
        try {

             int updates = memberCoinTixianMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateMemberCoinTixian(MemberCoinTixian record) {

        logger.info("updateMemberCoinTixian");
        try {

            int updates = memberCoinTixianMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

