use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class SystemTemplateLogicServiceImpl method createParam.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysTemplateParamVO> createParam(SysTemplateParamVO sysTemplateParam, String templateOid) throws ServiceException, Exception {
if (sysTemplateParam == null || super.isBlank(templateOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysTemplateVO sysTemplate = new SysTemplateVO();
sysTemplate.setOid(templateOid);
DefaultResult<SysTemplateVO> mResult = this.sysTemplateService.findObjectByOid(sysTemplate);
if (mResult.getValue() == null) {
throw new ServiceException(mResult.getSystemMessage().getValue());
}
sysTemplate = mResult.getValue();
sysTemplateParam.setTemplateId(sysTemplate.getTemplateId());
return this.sysTemplateParamService.saveObject(sysTemplateParam);
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class BaseService method findObjectByOid.
@SuppressWarnings("unchecked")
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public DefaultResult<T> findObjectByOid(T object) throws ServiceException, Exception {
if (object == null || !(object instanceof BaseValueObj)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
Class<T> valueObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 0);
Class<E> entityObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 1);
E entityObject = entityObjectClass.newInstance();
T objectByOid = null;
try {
this.doMapper(object, entityObject, this.getMapperIdVo2Po());
E entityByOid = this.findByOid(entityObject);
if (entityByOid != null) {
objectByOid = valueObjectClass.newInstance();
this.doMapper(entityByOid, objectByOid, this.getMapperIdPo2Vo());
}
} catch (Exception e) {
e.printStackTrace();
}
DefaultResult<T> result = new DefaultResult<T>();
if (objectByOid != null && !StringUtils.isBlank(((BaseValueObj) objectByOid).getOid())) {
result.setValue(objectByOid);
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
}
return result;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class BaseService method findByUK.
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
@SuppressWarnings("unchecked")
public DefaultResult<T> findByUK(T object) throws ServiceException, Exception {
if (object == null || !(object instanceof BaseValueObj)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
Class<T> valueObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 0);
Class<E> entityObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 1);
E entityObject = entityObjectClass.newInstance();
T objectByUK = null;
try {
this.doMapper(object, entityObject, this.getMapperIdVo2Po());
E entityByUK = this.getBaseDataAccessObject().findByUK(entityObject);
if (entityByUK != null) {
objectByUK = valueObjectClass.newInstance();
this.doMapper(entityByUK, objectByUK, this.getMapperIdPo2Vo());
}
} catch (Exception e) {
e.printStackTrace();
}
DefaultResult<T> result = new DefaultResult<T>();
if (objectByUK != null && !StringUtils.isBlank(((BaseValueObj) objectByUK).getOid())) {
result.setValue(objectByUK);
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
}
return result;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class BaseService method saveOrMergeObject.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@SuppressWarnings({ "rawtypes", "unchecked" })
private DefaultResult<T> saveOrMergeObject(String type, boolean checkUK, T object) throws ServiceException, Exception {
if (object == null || !(object instanceof BaseValueObj)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
DefaultResult<T> result = new DefaultResult<T>();
Class<T> valueObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 0);
Class<E> entityObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 1);
E entityObject = entityObjectClass.newInstance();
this.doMapper(object, entityObject, getMapperIdVo2Po());
if (checkUK) {
int countByUK = 1;
try {
countByUK = this.getBaseDataAccessObject().countByUK(entityObject);
} catch (Exception e) {
e.printStackTrace();
}
if (countByUK > 0) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_IS_EXIST));
}
}
((BaseEntity) entityObject).setOid(this.generateOid());
((BaseEntity) entityObject).setCuserid(this.getAccountId());
((BaseEntity) entityObject).setCdate(this.generateDate());
E insertEntity = null;
try {
if ("save".equals(type)) {
insertEntity = this.getBaseDataAccessObject().save(entityObject);
} else {
insertEntity = this.getBaseDataAccessObject().merge(entityObject);
}
} catch (Exception e) {
e.printStackTrace();
}
if (insertEntity != null && ((BaseEntity) insertEntity).getOid() != null) {
T insertValueObj = valueObjectClass.newInstance();
this.doMapper(insertEntity, insertValueObj, getMapperIdPo2Vo());
result.setValue(insertValueObj);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS)));
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_FAIL)));
}
return result;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class BaseService method deleteObject.
@SuppressWarnings({ "unchecked", "rawtypes" })
@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
public DefaultResult<Boolean> deleteObject(T object) throws ServiceException, Exception {
if (object == null || !(object instanceof BaseValueObj)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
Class<E> entityObjectClass = GenericsUtils.getSuperClassGenricType(getClass(), 1);
E entityObject = entityObjectClass.newInstance();
((BaseEntity) entityObject).setOid(((BaseValueObj) object).getOid());
boolean status = false;
if (this.countByOid(entityObject) > 0) {
this.delete(entityObject);
status = true;
}
result.setValue(status);
if (status) {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DELETE_SUCCESS)));
} else {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DELETE_FAIL)));
}
return result;
}
Aggregations