package com.vci.server.portal.service; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.List; import com.vci.server.base.persistence.dao.BaseService; import com.vci.server.portal.dao.impl.PLActionEntityDaoImpl; import com.vci.server.portal.dao.impl.PLTypeActionEntityDaoImpl; import com.vci.server.portal.entity.PLActionEntity; import com.vci.server.portal.entity.PLTypeActionEntity; public class PLTypeActionEntityService extends BaseService{ private static PLTypeActionEntityService instance = null; private DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd"); private PLTypeActionEntityService(){ } public static PLTypeActionEntityService getInstance(){ if(instance == null){ instance = new PLTypeActionEntityService(); } return instance; } /** * 新增action对象 * @param obj * @throws Throwable */ public boolean savePLTypeActionEntity(PLTypeActionEntity obj) throws Throwable { try { PLTypeActionEntityDaoImpl daoImpl = new PLTypeActionEntityDaoImpl(); daoImpl.saveOrUpdate(obj); return true; } catch(Throwable e){ throw e; } } /** * 删除action对象 * @param obj * @return * @throws Throwable */ public boolean deletePLActionEntity(PLTypeActionEntity obj) throws Throwable{ try { PLTypeActionEntityDaoImpl daoImpl = new PLTypeActionEntityDaoImpl(); daoImpl.delete(obj); return true; } catch(Throwable e){ throw e; } } public List getAllTypeAction() throws Throwable{ try { PLTypeActionEntityDaoImpl daoImpl = new PLTypeActionEntityDaoImpl(); //String sql = " from PLTypeActionEntity"; return daoImpl.loadAll(); } catch(Throwable e){ throw e; } } /** * 根据Id删除指定的action对象 * @param id * @return * @throws Throwable */ public boolean deletePLTypeActionEntityByTypeAndAction(String type, String actionoId) throws Throwable{ try { PLTypeActionEntityDaoImpl daoImpl = new PLTypeActionEntityDaoImpl(); StringBuilder sql = new StringBuilder("select t.* from PLTYPEACTION t where t.typeName=? and t.actionoid=?"); List loadAll = daoImpl.findEntites(sql.toString(), new Object[]{type, actionoId}, "", PLTypeActionEntity.class); if (loadAll != null && loadAll.size() > 0) { for(PLTypeActionEntity action: loadAll){ daoImpl.delete(action); } } return true; } catch(Throwable e){ throw e; } } /** * 获取type下所有PLAction * @return * @throws Throwable */ public List getAllPLActionEntityByType(String type) throws Throwable{ try { PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl(); StringBuilder sql = new StringBuilder("select p.* from PLAction p, PLTYPEACTION t where p.ploid=t.actionoId and t.typeName=? order by p.plCode"); List loadAll = daoImpl.findEntites(sql.toString(), new Object[]{type}, "", PLActionEntity.class); return loadAll; } catch(Throwable e){ throw e; } } }