package cn.hmsoft.frame.service;

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

import cn.hmsoft.frame.data.dao.FrameDictNameDao;
import cn.hmsoft.frame.data.model.FrameDict;
import cn.hmsoft.frame.data.model.FrameDictName;
import cn.hmsoft.frame.util.FrameAssertUtil;

@Service
public class FrameDictNameService extends FrameService {

	@Autowired
	private FrameDictNameDao daoName;

	public void addDictType(FrameDictName type) {
		FrameDictName ty = this.daoName.find(FrameDictName.class, "dict_name", type.getDict_name());
		FrameAssertUtil.isNull(ty, "字典  " + type.getDict_name() + " 已经存在，请检查");
		this.daoName.insert(type);
	}

	public void editDictType(FrameDictName type) {
		this.daoName.update(type);
	}

	public void deleteDictType(String type_name) {
		this.daoName.delete(FrameDictName.class, "dict_name", type_name);
		this.daoName.delete(FrameDict.class, "dict_name", type_name);
	}

}
