package com.db.service.impl;

import com.db.service.ITestService;
import com.db.service.dao.ITestDao;
import com.db.service.model.TTest;
import com.elab.core.dao.IBaseDaoSupport;
import com.elab.core.services.impl.CommonServiceAdaptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author : liukx
 * @create : 2018/5/17 13:45
 * @email : liukx@elab-plus.com
 */
@Service
public class TestServiceImpl extends CommonServiceAdaptor<TTest> implements ITestService {

    @Autowired
    private ITestDao testDao;

    @Override
    protected IBaseDaoSupport<TTest> getBaseDaoSupport() {
        return testDao;
    }

    @Override
    public List<TTest> selectByList(TTest obj) throws Exception {

//        if (StringUtils.isEmpty(obj.getUsername())) {
//            throw new BusinessException("aa","用户名称不能为空");
//        }

        return super.selectByList(obj);
    }

    @Override
    @Transactional
    public int updateByExample(TTest test) {
        int update = testDao.updateByExample(test);
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return update;
    }
}
