Search in sources :

Example 71 with ServiceMethodAuthority

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);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysTemplateVO(com.netsteadfast.greenstep.vo.SysTemplateVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 72 with ServiceMethodAuthority

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;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BaseValueObj(com.netsteadfast.greenstep.base.model.BaseValueObj) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 73 with ServiceMethodAuthority

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;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BaseValueObj(com.netsteadfast.greenstep.base.model.BaseValueObj) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 74 with ServiceMethodAuthority

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;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BaseEntity(com.netsteadfast.greenstep.base.model.BaseEntity) BaseValueObj(com.netsteadfast.greenstep.base.model.BaseValueObj) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 75 with ServiceMethodAuthority

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;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BaseEntity(com.netsteadfast.greenstep.base.model.BaseEntity) BaseValueObj(com.netsteadfast.greenstep.base.model.BaseValueObj) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)95 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)91 Transactional (org.springframework.transaction.annotation.Transactional)84 HashMap (java.util.HashMap)32 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)31 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)29 SysVO (com.netsteadfast.greenstep.vo.SysVO)13 LinkedHashMap (java.util.LinkedHashMap)13 Map (java.util.Map)12 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)7 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)7 BaseEntity (com.netsteadfast.greenstep.base.model.BaseEntity)6 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)6 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)6 IOException (java.io.IOException)6 BaseValueObj (com.netsteadfast.greenstep.base.model.BaseValueObj)5 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)5 SysProgVO (com.netsteadfast.greenstep.vo.SysProgVO)5 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)5 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)4