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.OrgHonorDatumService;
import com.goafanti.common.dao.OrgHonorDatumMapper;
import com.goafanti.common.model.OrgHonorDatum;
import com.goafanti.core.mybatis.BaseMybatisDao;
import com.goafanti.core.mybatis.page.Pagination;
@Service
public class OrgHonorDatumServiceImpl extends BaseMybatisDao<OrgHonorDatumMapper> implements OrgHonorDatumService {
	@Autowired
	private OrgHonorDatumMapper orgHonorDatumMapper;

	@SuppressWarnings("unchecked")
	@Override
	public Pagination<OrgHonorDatum> listOrgHonorDatum(Integer pageNo, Integer pageSize, String uid) {
		Map<String, Object> params = new HashMap<>();
		
		if (!StringUtils.isBlank(uid)){
			params.put("uid", uid);
		}

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

		if (pageSize == null || pageSize < 0) {
			pageSize = 10;
		}
		return  (Pagination<OrgHonorDatum>)findPage("findOrgHonorDatumListByPage",
				"findOrgHonorDatumCount", params, pageNo, pageSize);
	}

	@Override
	public OrgHonorDatum insert(OrgHonorDatum honor) {
		orgHonorDatumMapper.insert(honor);
		return honor;
	}

	@Override
	public int updateByPrimaryKeySelective(OrgHonorDatum honor) {
		return orgHonorDatumMapper.updateByPrimaryKeySelective(honor);
	}

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

	@Override
	public OrgHonorDatum selectByPrimaryKey(String id) {
		return orgHonorDatumMapper.selectByPrimaryKey(id);
	}
}
