package cn.hmsoft.frame.service;

import java.time.LocalDateTime;

import cn.hmsoft.application.SpringHelper;
import cn.hmsoft.frame.data.model.FrameOptr;
import cn.hmsoft.frame.data.model.FrameOptrLog;

/********************
 * service 基类
 * @author zxq
 * @create 2019-07-01 21:59:32
 * @version 2.0.0
 * @email: revisit@126.com
 * @Company: www.hmsoft.cn
 */
public class FrameService {

	protected FrameOptrLog log(FrameOptr optr, String businessType, Object... values) {
		FrameOptrLog log = new FrameOptrLog();
		if (optr != null)
			log.setOptr_id(optr.getOptr_id());
		else
			log.setOptr_id(-1);
		log.setLog_time(LocalDateTime.now());
		log.setLog_type(businessType);
		StringBuilder value = new StringBuilder("");
		
		for (Object obj : values) {
			if (obj != null) {
				value.append(obj.toString()).append("~");
			}
		}
		if(value.length()>0) {
			value.deleteCharAt(value.length()-1);
			log.setLog_param(value.toString());
		}
		SpringHelper.AppGobalDao.insert(log);
		return log;
	}
}
