package com.goafanti.cognizance.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.goafanti.cognizance.service.OrgTechCenterDetailService;
import com.goafanti.common.dao.OrgTechCenterDetailMapper;
import com.goafanti.common.model.OrgTechCenterDetail;
import com.goafanti.core.mybatis.BaseMybatisDao;
import com.goafanti.core.mybatis.page.Pagination;
@Service
public class OrgTechCenterDetailServiceImpl extends BaseMybatisDao<OrgTechCenterDetailMapper> implements OrgTechCenterDetailService {
	@Autowired
	private OrgTechCenterDetailMapper orgTechCenterDetailMapper;

	@SuppressWarnings("unchecked")
	@Override
	public Pagination<OrgTechCenterDetail> listOrgTechCenterDetail(Integer pageNo, Integer pageSize, String cid) {
		Map<String, Object> params = new HashMap<>();
		
		if (!StringUtils.isBlank(cid)){
			params.put("cid", cid);
		} else {
			params.put("cid", "-1");
		}

		if (pageNo == null || pageNo < 0) {
			pageNo = 1;
		}

		if (pageSize == null || pageSize < 0) {
			pageSize = 10;
		}
		return  (Pagination<OrgTechCenterDetail>)findPage("findOrgTechCenterDetailListByPage",
				"findOrgTechCenterDetailCount", params, pageNo, pageSize);
	}

	@Override
	public OrgTechCenterDetail insert(OrgTechCenterDetail orgTechCenterDetail) {
		orgTechCenterDetailMapper.insert(orgTechCenterDetail);
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(OrgTechCenterDetail orgTechCenterDetail) {
		return orgTechCenterDetailMapper.updateByPrimaryKeySelective(orgTechCenterDetail);
	}

	@Override
	public int deleteByPrimaryKey(List<String> id) {
		return orgTechCenterDetailMapper.batchDeleteByPrimaryKey(id);
	}

	@Override
	public OrgTechCenterDetail selectByPrimaryKey(String id) {
		return orgTechCenterDetailMapper.selectByPrimaryKey(id);
	}
}
