Search in sources :

Example 6 with SystemMessage

use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.

the class SimpleService method deleteEntity.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
public DefaultResult<Boolean> deleteEntity(E object) throws ServiceException, Exception {
    if (object == null || !(object instanceof BaseEntity)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    boolean status = false;
    if (this.countByOid(object) > 0) {
        this.delete(object);
        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;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BaseEntity(com.netsteadfast.greenstep.base.model.BaseEntity) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with SystemMessage

use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.

the class SimpleService method ibatisSelectOneByValue.

@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public DefaultResult<E> ibatisSelectOneByValue(E valueObj) throws ServiceException, Exception {
    if (null == valueObj) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<E> result = new DefaultResult<E>();
    E searchResult = this.getBaseDataAccessObject().ibatisSelectOneByValue(valueObj);
    if (searchResult != null) {
        result.setValue(searchResult);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with SystemMessage

use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.

the class SimpleService method updateEntity.

@SuppressWarnings({ "rawtypes" })
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
public DefaultResult<E> updateEntity(E object) throws ServiceException, Exception {
    if (object == null || !(object instanceof BaseEntity)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<E> result = new DefaultResult<E>();
    try {
        ((BaseEntity) object).setUuserid(this.getAccountId());
        ((BaseEntity) object).setUdate(this.generateDate());
        object = this.getBaseDataAccessObject().update(object);
        if (object != null && ((BaseEntity) object).getOid() != null) {
            result.setValue(object);
            result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (result.getValue() == null) {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BaseEntity(com.netsteadfast.greenstep.base.model.BaseEntity) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with SystemMessage

use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.

the class SimpleService method saveOrMergeEntity.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@SuppressWarnings({ "rawtypes", "unchecked" })
private DefaultResult<E> saveOrMergeEntity(String type, boolean checkUK, E object) throws ServiceException, Exception {
    if (object == null || !(object instanceof BaseEntity)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<E> result = new DefaultResult<E>();
    if (checkUK) {
        int countByUK = 1;
        try {
            countByUK = this.getBaseDataAccessObject().countByUK(object);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (countByUK > 0) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_IS_EXIST));
        }
    }
    ((BaseEntity) object).setOid(this.generateOid());
    ((BaseEntity) object).setCuserid(this.getAccountId());
    ((BaseEntity) object).setCdate(this.generateDate());
    E insertEntity = null;
    try {
        if ("save".equals(type)) {
            insertEntity = this.getBaseDataAccessObject().save(object);
        } else {
            insertEntity = this.getBaseDataAccessObject().merge(object);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (insertEntity != null && ((BaseEntity) insertEntity).getOid() != null) {
        result.setValue(insertEntity);
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS)));
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_FAIL)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BaseEntity(com.netsteadfast.greenstep.base.model.BaseEntity) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with SystemMessage

use of com.netsteadfast.greenstep.base.model.SystemMessage in project bamboobsc by billchen198318.

the class SimpleService method ibatisSelectListByParams.

// ------------------------------------------------------------------------------------
@Transactional(isolation = Isolation.READ_COMMITTED, timeout = 25, readOnly = true)
public DefaultResult<List<E>> ibatisSelectListByParams(Map<String, Object> params) throws ServiceException, Exception {
    if (params == null) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
    }
    DefaultResult<List<E>> result = new DefaultResult<List<E>>();
    List<E> searchList = (List<E>) this.getBaseDataAccessObject().ibatisSelectListByParams(params);
    if (searchList != null && searchList.size() > 0) {
        result.setValue(searchList);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) List(java.util.List) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)53 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)50 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)49 Transactional (org.springframework.transaction.annotation.Transactional)34 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)31 HashMap (java.util.HashMap)13 List (java.util.List)12 Map (java.util.Map)10 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)7 BaseEntity (com.netsteadfast.greenstep.base.model.BaseEntity)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 BaseValueObj (com.netsteadfast.greenstep.base.model.BaseValueObj)5 AggregationMethodVO (com.netsteadfast.greenstep.vo.AggregationMethodVO)3 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)3 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)3 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)3 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)3 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)3 BigDecimal (java.math.BigDecimal)3