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;
import cn.hmsoft.skill.helper.SkillParamHelper;

@Service
public class EnrolStdRegService {

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



	public void transStdInfo(StdReg std) {
		std.setStd_param1(null);
		std.setStd_param2(null);
		std.setStd_param3(null);
		std.setStd_param4(null);
		std.setStd_param5(null);
		if (std.getStd_image() != null) {
			std.setStd_image(SkillParamHelper.MateialWebPath + "/StdUpload/" + std.getStd_image());
		}
	}

	public StdReg stdFormRemote(SchoolReg school, StdReg std) {
		// 新考生
		if (std.getStd_id() == null) {
			this.daoStd.insert(std);
			this.daoLog.log(school.getSchool_id(),std.getStd_id(), StdLogType.Fetch, null, std.getExam_id(), std.getCert_id(), LocalDateTime.now());
		} else {
			this.daoStd.update(std);
			this.daoLog.log(school.getSchool_id(),std.getStd_id(), StdLogType.ReFetch, null, std.getExam_id(), std.getCert_id(),
					LocalDateTime.now());
		}
		return std;
	}

}
