package com.vci.server.portal.service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import com.vci.server.base.persistence.dao.BaseService;
|
import com.vci.server.portal.dao.impl.PLPageDefinationEntityDaoImpl;
|
import com.vci.server.portal.entity.PLPageDefinationEntity;
|
import com.vci.server.portal.entity.PLTabPageEntity;
|
|
public class PLPageDefinationEntityService extends BaseService{
|
// private PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
private static PLPageDefinationEntityService instance = null;
|
|
private PLPageDefinationEntityService(){
|
|
}
|
|
public static PLPageDefinationEntityService getInstance(){
|
if(instance == null){
|
instance = new PLPageDefinationEntityService();
|
}
|
return instance;
|
}
|
|
/**
|
*新增对象
|
* @param obj
|
* @throws Throwable
|
*/
|
public boolean savePLPageDefinationEntity(PLPageDefinationEntity obj) throws Throwable {
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
daoImpl.saveOrUpdate(obj);
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
public boolean batchSavePLPageDefinationEntity(PLPageDefinationEntity[] objs) throws Throwable {
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
List<PLPageDefinationEntity> list = new ArrayList<PLPageDefinationEntity>();
|
int batchNum = 200;
|
for (int i = 0; i < objs.length; i++) {
|
list.add(objs[i]);
|
if ((i + 1) % batchNum == 0) {
|
daoImpl.saveOrUpdateAll(list);
|
list = new ArrayList<PLPageDefinationEntity>();
|
}
|
}
|
daoImpl.saveOrUpdateAll(list);
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
/**
|
* 更新对象
|
* @param obj
|
* @return
|
* @throws Throwable
|
*/
|
public boolean updatePLPageDefinationEntity(PLPageDefinationEntity obj) throws Throwable{
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
PLPageDefinationEntity objGet = daoImpl.getById(obj.getId());
|
if (objGet == null) {
|
daoImpl.saveOrUpdate(obj);
|
} else {
|
// objGet.setId(obj.getId());
|
objGet.setPlTabPageOId(obj.getPlTabPageOId());
|
objGet.setPlType(obj.getPlType());
|
objGet.setPlDefination(obj.getPlDefination());
|
objGet.setDesc(obj.getDesc());
|
objGet.setName(obj.getName());
|
objGet.setSeq(obj.getSeq());
|
daoImpl.saveOrUpdate(objGet);
|
}
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
/**
|
* 删除对象
|
* @param obj
|
* @return
|
* @throws Throwable
|
*/
|
public boolean deletePLPageDefinationEntity(PLPageDefinationEntity obj) throws Throwable{
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
daoImpl.delete(obj);
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据Id删除指定的对象
|
* @param id
|
* @return
|
* @throws Throwable
|
*/
|
public boolean deletePLPageDefinationEntityById(String id) throws Throwable{
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
PLPageDefinationEntity obj = daoImpl.getById(id);
|
if (obj != null) {
|
daoImpl.delete(obj);
|
}
|
return true;
|
}catch(Throwable e){
|
throw e;
|
}
|
|
}
|
|
/**
|
* 根据ID获取指定的PLPageDefination
|
* @param plOId
|
* @return
|
* @throws Throwable
|
*/
|
public PLPageDefinationEntity getPLPageDefinationEntityById(String plOId) throws Throwable {
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
PLPageDefinationEntity obj = daoImpl.getById(plOId);
|
return obj;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
/**
|
* 根据plPageContextOId获取指定的PLPageDefinationArray
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLPageDefinationEntity> getPLPageDefinationEntitysByPageContextOId(String plPageContextOId) throws Throwable{
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
List<PLPageDefinationEntity> list = daoImpl.findEntities("from PLPageDefinationEntity where plPageContextOId = '" + plPageContextOId + "' order by seq");
|
return list;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
/**
|
* 获取所有结果集,缓存使用
|
* @author lmh,20150727
|
* @return
|
* @throws Throwable
|
*/
|
public List<PLPageDefinationEntity> getAllPLPageDefinations() throws Throwable{
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
List<PLPageDefinationEntity> list = daoImpl.findEntities("from PLPageDefinationEntity order by seq");
|
return list;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
|
public List<PLPageDefinationEntity> getAllPLPageDefinationsWithNoConf() throws Throwable{
|
try {
|
PLPageDefinationEntityDaoImpl daoImpl = new PLPageDefinationEntityDaoImpl();
|
List list = daoImpl.findEntities("select plOId, plPageContextOId, plType, name, seq from PLPageDefinationEntity order by seq");
|
List<PLPageDefinationEntity> rList = new ArrayList<PLPageDefinationEntity>();
|
for (Object obj : list) {
|
Object[] array = (Object[]) obj;
|
PLPageDefinationEntity entity = new PLPageDefinationEntity();
|
entity.setPlOId(array[0].toString());
|
entity.setPlTabPageOId(array[1].toString());
|
entity.setPlType(Short.parseShort(array[2].toString()));
|
entity.setName(array[3].toString());
|
entity.setSeq(Short.parseShort(array[4].toString()));
|
rList.add(entity);
|
}
|
return rList;
|
}catch(Throwable e){
|
throw e;
|
}
|
}
|
}
|