/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.sys.service;

import com.jeeplus.common.persistence.Page;
import com.jeeplus.common.service.CrudService;
import com.jeeplus.modules.sys.dao.MainDictDao;
import com.jeeplus.modules.sys.entity.MainDict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 字典管理Service
 * @author 马鹏波
 * @version 2018-05-30
 */
@Service
@Transactional(readOnly = true)
public class MainDictService extends CrudService<MainDictDao, MainDict> {

	@Autowired
	private MainDictDao mainDictDao;

	public MainDict get(String id) {
		return super.get(id);
	}
	
	public List<MainDict> findList(MainDict mainDict) {
		return super.findList(mainDict);
	}
	
	public Page<MainDict> findPage(Page<MainDict> page, MainDict mainDict) {
		return super.findPage(page, mainDict);
	}
	
	@Transactional(readOnly = false)
	public void save(MainDict mainDict) {
		super.save(mainDict);
	}
	
	@Transactional(readOnly = false)
	public void delete(MainDict mainDict) {
		super.delete(mainDict);
	}

	public MainDict getIdByName(String typeName){
		return mainDictDao.getIdByName(typeName);
	}

	public Boolean getTypeName(String typeName,String id){
		List<MainDict> m= mainDictDao.getTypeName(typeName,id);
		if (m!=null&&m.size()>0){
			return true;
		}else{
			return false;
		}
	}
	/**
	 * 查询字段类型列表
	 * @return
	 */
	public List<String> findTypeList(){
		return dao.findTypeList(new MainDict());
	}
}