use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class SystemJreportLogicServiceImpl method createParam.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysJreportParamVO> createParam(SysJreportParamVO reportParam, String reportOid) throws ServiceException, Exception {
if (reportParam == null || super.isBlank(reportOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
DefaultResult<SysJreportVO> mResult = this.sysJreportService.findForSimple(reportOid);
if (mResult.getValue() == null) {
throw new ServiceException(mResult.getSystemMessage().getValue());
}
SysJreportVO report = mResult.getValue();
reportParam.setReportId(report.getReportId());
return this.sysJreportParamService.saveObject(reportParam);
}
use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class ApplicationSystemLogicServiceImpl method update.
/**
* 更新 TB_SYS 資料
*
* @param sys
* @param iconOid
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysVO> update(SysVO sys, String iconOid) throws ServiceException, Exception {
if (null == sys || StringUtils.isBlank(sys.getOid())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysIconVO sysIcon = new SysIconVO();
sysIcon.setOid(iconOid);
DefaultResult<SysIconVO> iconResult = this.sysIconService.findObjectByOid(sysIcon);
if (iconResult.getValue() == null) {
throw new ServiceException(iconResult.getSystemMessage().getValue());
}
sys.setIcon(iconResult.getValue().getIconId());
return this.sysService.updateObject(sys);
}
use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method findForProgramRoleEnableAndAll.
/**
* 找出全部的role與某程式menu所屬的role
*
* map 中的 key
* enable - 程式menu的role
* all - 所有role
*
* @param programOid
* @return
* @throws ServiceException
* @throws Exception
*/
@Override
public Map<String, List<RoleVO>> findForProgramRoleEnableAndAll(String programOid) throws ServiceException, Exception {
if (StringUtils.isBlank(programOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysProgVO sysProg = new SysProgVO();
sysProg.setOid(programOid);
DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
if (spResult.getValue() == null) {
throw new ServiceException(spResult.getSystemMessage().getValue());
}
sysProg = spResult.getValue();
Map<String, List<RoleVO>> roleMap = new HashMap<String, List<RoleVO>>();
List<RoleVO> enableRole = this.roleService.findForProgram(sysProg.getProgId());
List<RoleVO> allRole = this.roleService.findForAll();
roleMap.put("enable", enableRole);
roleMap.put("all", allRole);
return roleMap;
}
use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method copyAsNew.
/**
* 拷備一份role
*
* @param fromRoleOid
* @param role
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<RoleVO> copyAsNew(String fromRoleOid, RoleVO role) throws ServiceException, Exception {
if (role == null || super.isBlank(role.getRole()) || super.isBlank(fromRoleOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
super.setStringValueMaxLength(role, "description", MAX_DESCRIPTION_LENGTH);
DefaultResult<RoleVO> result = this.roleService.saveObject(role);
RoleVO oldRole = new RoleVO();
oldRole.setOid(fromRoleOid);
DefaultResult<RoleVO> fromResult = this.roleService.findObjectByOid(oldRole);
if (fromResult.getValue() == null) {
throw new ServiceException(fromResult.getSystemMessage().getValue());
}
oldRole = fromResult.getValue();
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("role", oldRole.getRole());
List<TbRolePermission> permissions = this.rolePermissionService.findListByParams(paramMap);
for (int i = 0; permissions != null && i < permissions.size(); i++) {
RolePermissionVO permission = new RolePermissionVO();
this.rolePermissionService.fillToValueObject(permission, permissions.get(i));
permission.setOid(null);
permission.setRole(result.getValue().getRole());
this.rolePermissionService.saveObject(permission);
}
// 選單menu role 也copy一份
List<TbSysMenuRole> menuRoles = this.sysMenuRoleService.findListByParams(paramMap);
for (int i = 0; menuRoles != null && i < menuRoles.size(); i++) {
SysMenuRoleVO menuRole = new SysMenuRoleVO();
this.sysMenuRoleService.fillToValueObject(menuRole, menuRoles.get(i));
menuRole.setOid(null);
menuRole.setRole(result.getValue().getRole());
this.sysMenuRoleService.saveObject(menuRole);
}
return result;
}
use of com.netsteadfast.greenstep.base.exception.ServiceException in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method getDefaultUserRole.
/**
* 使用者設的role-id(角色), 它設定在 tb_sys_code中
*
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
public String getDefaultUserRole() throws ServiceException, Exception {
String role = "";
SysCodeVO sysCode = new SysCodeVO();
sysCode.setType(DEFAULT_ROLE_CODE_TYPE);
sysCode.setCode(DEFAULT_ROLE_CODE);
DefaultResult<SysCodeVO> result = this.sysCodeService.findByUK(sysCode);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
sysCode = result.getValue();
role = sysCode.getParam1();
if (super.isBlank(role)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("role", role);
if (this.roleService.countByParams(params) != 1) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
return role;
}
Aggregations