package org.linlinjava.jz.db.service.hm;

import org.linlinjava.jz.db.dao.HmTasktimeConfigMapper;
import org.linlinjava.jz.db.domain.HmTasktimeConfig;
import org.linlinjava.jz.db.domain.HmTasktimeConfigExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 36952
 *
 */
@Service
public class HmTasktimeConfigService {

	@Autowired
	HmTasktimeConfigMapper hmTasktimeConfigMapper;

	/**
	 * 获取拜访类的完成时间的时长
	 * 
	 * @return
	 */
	public Integer getVistTaskTime() {
		HmTasktimeConfigExample example = new HmTasktimeConfigExample();
		example.or().andTaskTypeEqualTo(1);// 1拜访类，2跟进类
//		Column selective []= {};
		HmTasktimeConfig taskf = hmTasktimeConfigMapper.selectOneByExampleSelective(example,
				HmTasktimeConfig.Column.termTime);

		return taskf.getTermTime();
	}

	/**
	 * 获取跟进类的完成时间的时长
	 * 
	 * @return
	 */
	public Integer getFollowTaskTime() {
		HmTasktimeConfigExample example = new HmTasktimeConfigExample();
		example.or().andTaskTypeEqualTo(2);// 1拜访类，2跟进类
		HmTasktimeConfig taskf = hmTasktimeConfigMapper.selectOneByExampleSelective(example,
				HmTasktimeConfig.Column.termTime);

		return taskf.getTermTime();
	}

	/**
	 * 修改拜访类或跟进类任务完成时常期限
	 * @param id
	 * @param termTime
	 * @return
	 */
	public Integer updateTermTime(Long id, Integer termTime) {
		HmTasktimeConfig record = new HmTasktimeConfig();
		record.setId(id);
		record.setTermTime(termTime);
		return hmTasktimeConfigMapper.updateByPrimaryKeySelective(record);
	}

}
