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.OrgTechAchievementService;
import com.goafanti.common.dao.OrgTechAchievementMapper;
import com.goafanti.common.model.OrgTechAchievement;
import com.goafanti.core.mybatis.BaseMybatisDao;
import com.goafanti.core.mybatis.page.Pagination;
@Service
public class OrgTechAchievementServiceImpl extends BaseMybatisDao<OrgTechAchievementMapper> implements OrgTechAchievementService {
	@Autowired
	private OrgTechAchievementMapper orgTechAchievementMapper;

	@SuppressWarnings("unchecked")
	@Override
	public Pagination<OrgTechAchievement> listOrgTechAchievement(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<OrgTechAchievement>)findPage("findOrgTechAchievementListByPage",
				"findOrgTechAchievementCount", params, pageNo, pageSize);
	}

	@Override
	public OrgTechAchievement insert(OrgTechAchievement achievement) {
		orgTechAchievementMapper.insert(achievement);
		return achievement;
	}

	@Override
	public int updateByPrimaryKeySelective(OrgTechAchievement achievement) {
		return orgTechAchievementMapper.updateByPrimaryKeySelective(achievement);
	}

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

	@Override
	public OrgTechAchievement selectByPrimaryKey(String id) {
		return orgTechAchievementMapper.selectByPrimaryKey(id);
	}
}
