package cn.hmsoft.skill.enrol.service;

import java.time.LocalDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.hmsoft.skill.constants.StdLogType;
import cn.hmsoft.skill.data.dao.std.StdLogDao;
import cn.hmsoft.skill.data.dao.std.StdRegDao;
import cn.hmsoft.skill.data.model.school.SchoolReg;
import cn.hmsoft.skill.data.model.std.StdReg;

@Service
public class EnrolStdInfoService {

	@Autowired
	private StdRegDao daoStd;
	@Autowired
	private StdLogDao daoLog;

	public void save(SchoolReg school, StdReg std, Boolean confirm) {
		std.setStd_param1(null);
		std.setStd_param2(null);
		std.setStd_param3(null);
		std.setStd_param4(null);
		std.setStd_param5(null);
		std.setStd_image(null);
		if (confirm != null && confirm == true)
			std.setConfirm_time(LocalDateTime.now());
		else
			std.setConfirm_time(null);
		this.daoStd.update(std);
		this.daoLog.log(school.getSchool_id(), std.getStd_id(),
				(confirm != null && confirm == true) ? StdLogType.Confirm : StdLogType.Update, null);
	}

}
