package com.hfkj.service.impl;

import com.hfkj.dao.SecConfigMapper;
import com.hfkj.entity.SecConfig;
import com.hfkj.entity.SecConfigExample;
import com.hfkj.service.SecConfigService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service("secConfigService")
public class SecConfigServiceImpl implements SecConfigService {

    @Resource
    private SecConfigMapper secConfigMapper;

    @Override
    public void create(SecConfig secConfig) {
        secConfigMapper.insert(secConfig);
    }

    @Override
    public void update(SecConfig secConfig) {
        secConfigMapper.updateByPrimaryKeySelective(secConfig);
    }

    @Override
    public void delete(Integer id) {
        secConfigMapper.deleteByPrimaryKey(id);
    }

    @Override
    public SecConfig queryDetail(Integer id) {
        return secConfigMapper.selectByPrimaryKey(id);
    }

    @Override
    public SecConfig queryDetail(String codeType) {
        SecConfigExample secConfigExample = new SecConfigExample();
        secConfigExample.createCriteria().andCodeTypeEqualTo(codeType);
        List<SecConfig> list = secConfigMapper.selectByExample(secConfigExample);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }


}
