|
|
@@ -1,8 +1,19 @@ |
|
|
|
package cc.smtweb.system.bpm.web.sys.dev; |
|
|
|
|
|
|
|
import cc.smtweb.framework.core.annotation.SwBody; |
|
|
|
import cc.smtweb.framework.core.annotation.SwService; |
|
|
|
import cc.smtweb.framework.core.common.AbstractEnum; |
|
|
|
import cc.smtweb.framework.core.common.R; |
|
|
|
import cc.smtweb.framework.core.common.SwMap; |
|
|
|
import cc.smtweb.framework.core.mvc.service.AbstractHandler; |
|
|
|
import cc.smtweb.framework.core.mvc.service.SwListData; |
|
|
|
import cc.smtweb.framework.core.session.UserSession; |
|
|
|
import cc.smtweb.framework.core.util.PubUtil; |
|
|
|
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService; |
|
|
|
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* Created by 1 at 2022-08-03 16:09:30 |
|
|
@@ -13,15 +24,39 @@ public class EnumComboService extends DynPageService { |
|
|
|
//public final static String TYPE_DEMO = "demo"; |
|
|
|
@Override |
|
|
|
protected AbstractHandler createHandler(String type) { |
|
|
|
if (TYPE_LOAD.equals(type)) return new ComboHandler.EnumLoadHandler(); |
|
|
|
return super.createHandler(type); |
|
|
|
} |
|
|
|
|
|
|
|
/* demo |
|
|
|
|
|
|
|
//自定义 |
|
|
|
public R demo(@SwBody SwMap params, UserSession us) { |
|
|
|
return pageHandler(params, us, TYPE_DEMO, handler -> ((DemoHandler)handler).demo()); |
|
|
|
public R loadOne(@SwBody SwMap params, UserSession us) { |
|
|
|
SwListData swListData = buildListData(params.readString("cls")); |
|
|
|
DynRetBean bean = DynRetBean.createList(swListData); |
|
|
|
return R.success(bean); |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
private SwListData buildListData(String cls) { |
|
|
|
if (PubUtil.isEmpty(cls)) return SwListData.create(new ArrayList(), 0); |
|
|
|
List<SwMap> list = new ArrayList<>(); |
|
|
|
try { |
|
|
|
AbstractEnum e; |
|
|
|
try { |
|
|
|
e = (AbstractEnum) Class.forName(cls).getDeclaredField("inst").get(null); |
|
|
|
} catch (Exception e1) { |
|
|
|
e = (AbstractEnum) Class.forName(cls).getDeclaredField("instance").get(null); |
|
|
|
} |
|
|
|
for (Object v : e.mapAll.values()) { |
|
|
|
AbstractEnum.EnumBean bean = (AbstractEnum.EnumBean) v; |
|
|
|
SwMap row = new SwMap(); |
|
|
|
row.put("value", bean.value.toString()); |
|
|
|
row.put("name", bean.name); |
|
|
|
list.add(row); |
|
|
|
} |
|
|
|
} catch (Exception ue) { |
|
|
|
return SwListData.create(new ArrayList(), 0); |
|
|
|
} |
|
|
|
return SwListData.create(list, 0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |