use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class SystemProgramLogicServiceImpl method createMultiName.
/**
* 產生 tb_sys_prog_multi_name 資料
*
* @param multiName
* @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<SysProgMultiNameVO> createMultiName(SysProgMultiNameVO multiName) throws ServiceException, Exception {
if (null == multiName || super.isBlank(multiName.getProgId()) || super.isBlank(multiName.getName()) || super.isBlank(multiName.getLocaleCode())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
if (LocaleLanguageUtils.getMap().get(multiName.getLocaleCode()) == null) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
}
SysProgVO sysProg = new SysProgVO();
sysProg.setProgId(multiName.getProgId());
DefaultResult<SysProgVO> progResult = this.sysProgService.findByUK(sysProg);
if (progResult.getValue() == null) {
throw new ServiceException(progResult.getSystemMessage().getValue());
}
super.setStringValueMaxLength(multiName, "name", 100);
return this.sysProgMultiNameService.saveObject(multiName);
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class SystemFormLogicServiceImpl method update.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysFormVO> update(SysFormVO form, String templateOid) throws ServiceException, Exception {
if (null == form || super.isBlank(templateOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
DefaultResult<SysFormVO> oldResult = this.sysFormService.findObjectByOid(form);
if (oldResult.getValue() == null) {
throw new ServiceException(oldResult.getSystemMessage().getValue());
}
form.setFormId(oldResult.getValue().getFormId());
super.setStringValueMaxLength(form, "description", MAX_DESCRIPTION_LENGTH);
SysFormTemplateVO template = this.findTemplate(templateOid);
form.setTemplateId(template.getTplId());
return this.sysFormService.updateObject(form);
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class SystemMenuLogicServiceImpl method findForMenuSettingsEnableAndAll.
/**
* 找出選單設定功能要的
* 已在選單的程式 與 同SYS的程式
*
* map 中的 key
* enable - 已在選單的程式
* all - 同SYS的程式
*
* @param folderProgramOid
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.SELECT })
@Override
public Map<String, List<SysProgVO>> findForMenuSettingsEnableAndAll(String folderProgramOid) throws ServiceException, Exception {
if (StringUtils.isBlank(folderProgramOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
SysProgVO sysProg = new SysProgVO();
sysProg.setOid(folderProgramOid);
DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
if (spResult.getValue() == null) {
throw new ServiceException(spResult.getSystemMessage().getValue());
}
sysProg = spResult.getValue();
Map<String, List<SysProgVO>> dataMap = new HashMap<String, List<SysProgVO>>();
SysMenuVO sysMenu = new SysMenuVO();
List<SysProgVO> enableList = null;
List<SysProgVO> allList = null;
sysMenu.setProgId(sysProg.getProgId());
sysMenu.setParentOid(ZeroKeyProvide.OID_KEY);
DefaultResult<SysMenuVO> smResult = this.sysMenuService.findByUK(sysMenu);
if (smResult.getValue() != null) {
sysMenu = smResult.getValue();
enableList = this.sysProgService.findForInTheFolderMenuItems(sysProg.getProgSystem(), sysMenu.getOid(), MenuItemType.ITEM);
}
allList = this.sysProgService.findForSystemItems(sysProg.getProgSystem());
if (enableList == null) {
enableList = new ArrayList<SysProgVO>();
}
if (allList == null) {
allList = new ArrayList<SysProgVO>();
}
dataMap.put("enable", enableList);
dataMap.put("all", allList);
return dataMap;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method updateUserRole.
/**
* 更新帳戶的role
*
* @param accountOid
* @param roles
* @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<Boolean> updateUserRole(String accountOid, List<String> roles) throws ServiceException, Exception {
if (super.isBlank(accountOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
AccountVO account = new AccountVO();
account.setOid(accountOid);
DefaultResult<AccountVO> aResult = this.accountService.findObjectByOid(account);
if (aResult.getValue() == null) {
throw new ServiceException(aResult.getSystemMessage().getValue());
}
account = aResult.getValue();
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
result.setValue(false);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
this.deleteUserRoleByAccount(account);
for (int i = 0; roles != null && i < roles.size(); i++) {
String roleOid = roles.get(i).trim();
if (super.isBlank(roleOid)) {
continue;
}
RoleVO role = new RoleVO();
role.setOid(roleOid);
DefaultResult<RoleVO> rResult = this.roleService.findObjectByOid(role);
if (rResult.getValue() == null) {
throw new ServiceException(rResult.getSystemMessage().getValue());
}
role = rResult.getValue();
UserRoleVO userRole = new UserRoleVO();
userRole.setAccount(account.getAccount());
userRole.setRole(role.getRole());
userRole.setDescription("");
DefaultResult<UserRoleVO> urResult = this.userRoleService.saveObject(userRole);
if (urResult.getValue() == null) {
throw new ServiceException(urResult.getSystemMessage().getValue());
}
}
result.setValue(true);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
return result;
}
use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.
the class RoleLogicServiceImpl method createPermission.
/**
* 產生 TB_ROLE_PERMISSION 資料
*
* @param permission
* @param roleOid
* @return
* @throws ServiceException
* @throws Exception
*/
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<RolePermissionVO> createPermission(RolePermissionVO permission, String roleOid) throws ServiceException, Exception {
if (super.isBlank(roleOid) || permission == null || super.isBlank(permission.getPermission())) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
RoleVO role = new RoleVO();
role.setOid(roleOid);
DefaultResult<RoleVO> rResult = this.roleService.findObjectByOid(role);
if (rResult.getValue() == null) {
throw new ServiceException(rResult.getSystemMessage().getValue());
}
role = rResult.getValue();
if (Constants.SUPER_ROLE_ADMIN.equals(role.getRole()) || Constants.SUPER_ROLE_ALL.equals(role.getRole())) {
throw new ServiceException("Administrator or super role no need to set permission!");
}
permission.setRole(role.getRole());
if (super.defaultString(permission.getDescription()).length() > MAX_DESCRIPTION_LENGTH) {
permission.setDescription(permission.getDescription().substring(0, MAX_DESCRIPTION_LENGTH));
}
return this.rolePermissionService.saveObject(permission);
}
Aggregations