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.TestDeploy;
import com.izouma.awesomeadmin.service.TestDeployService;
import com.izouma.awesomeadmin.dao.TestDeployMapper;

/**
*  service接口实现类
*/
@Service
public class TestDeployServiceImpl implements TestDeployService{

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

    @Autowired
    private TestDeployMapper testDeployMapper;

    @Override
    public List<TestDeploy> getTestDeployList(TestDeploy record) {

        logger.info("getTestDeployList");
        try {

        return testDeployMapper.queryAllTestDeploy(record);
        } catch (Exception e) {
        logger.error("getTestDeployList", e);
        }

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

        logger.info("getTestDeployByPage");
        try {

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

        return testDeployMapper.queryTestDeployByPage(parameter);
        } catch (Exception e) {
        logger.error("getTestDeployByPage", e);
        }

        return null;
    }

    @Override
    public TestDeploy getTestDeployById(String id) {

        logger.info("getTestDeployyId");
        try {

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

        return null;
    }

    @Override
    public TestDeploy getTestDeploy(TestDeploy record) {

        logger.info("getTestDeploy");
        try {

            return testDeployMapper.queryTestDeploy(record);
        } catch (Exception e) {
        logger.error("getTestDeploy", e);
        }

        return null;
    }

    @Override
    public boolean createTestDeploy(TestDeploy record) {

        logger.info("createTestDeploy");
        try {

            int updates = testDeployMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteTestDeploy(String id) {

        logger.info("deleteTestDeploy");
        try {

             int updates = testDeployMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateTestDeploy(TestDeploy record) {

        logger.info("updateTestDeploy");
        try {

            int updates = testDeployMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

