package org.pp.modules.sys.model;

import org.pp.modules.sys.base.BaseMenu;
import org.pp.modules.sys.service.ApplicationService;

import com.jfinal.aop.Aop;
import com.jfinal.kit.StrKit;

/**
 * Generated by JFinal.
 */
@SuppressWarnings("serial")
public class Menu extends BaseMenu<Menu> {
	private Application app;

	public Application getApp() {
		if(app == null && getAppId() != null) {
			app = Aop.get(ApplicationService.class).findCache(getAppId());
		}
		return app;
	}

	public void setApp(Application app) {
		this.app = app;
	}
	
	public String getIcon(String defaults) {
		String icon = getIcon();
		if(StrKit.isBlank(icon)) {
			icon = defaults;
		}
		if(icon.startsWith("fa-")) {
			icon = icon.substring(3);
		}
		return icon;
	}
}
