Search in sources :

Example 1 with SysProgVO

use of com.netsteadfast.greenstep.vo.SysProgVO in project bamboobsc by billchen198318.

the class SystemMenuLogicServiceImpl method createOrUpdate.

/**
	 * 更新或是新增 TB_SYS_MENU 資料
	 * 
	 * @param folderProgramOid
	 * @param childProgramOidList
	 * @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<Boolean> createOrUpdate(String folderProgramOid, List<String> childProgramOidList) throws ServiceException, Exception {
    if (StringUtils.isBlank(folderProgramOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(false);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    // 找 TB_SYS_PROG 資料
    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();
    // 找出 TB_SYS_MENU 原資料 , 沒有資料就是新增
    SysMenuVO sysMenu = new SysMenuVO();
    sysMenu.setProgId(sysProg.getProgId());
    sysMenu.setParentOid(ZeroKeyProvide.OID_KEY);
    if (this.sysMenuService.countByUK(sysMenu) > 0) {
        // update 更新
        DefaultResult<SysMenuVO> smResult = this.sysMenuService.findByUK(sysMenu);
        if (smResult.getValue() == null) {
            throw new ServiceException(smResult.getSystemMessage().getValue());
        }
        sysMenu = smResult.getValue();
    } else {
        // create new 新產
        sysMenu.setProgId(sysProg.getProgId());
        sysMenu.setParentOid(ZeroKeyProvide.OID_KEY);
        sysMenu.setEnableFlag(YesNo.YES);
        DefaultResult<SysMenuVO> smResult = this.sysMenuService.saveObject(sysMenu);
        if (smResult.getValue() == null) {
            throw new ServiceException(smResult.getSystemMessage().getValue());
        }
        sysMenu = smResult.getValue();
    }
    this.removeMenuChildData(sysMenu);
    this.createOrUpdate(sysMenu, childProgramOidList);
    result.setValue(true);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysMenuVO(com.netsteadfast.greenstep.vo.SysMenuVO) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SysProgVO

use of com.netsteadfast.greenstep.vo.SysProgVO in project bamboobsc by billchen198318.

the class SystemMenuLogicServiceImpl method createOrUpdate.

private void createOrUpdate(SysMenuVO parentSysMenu, List<String> childProgramOidList) throws ServiceException, Exception {
    for (String progOid : childProgramOidList) {
        SysProgVO sysProg = new SysProgVO();
        sysProg.setOid(progOid);
        DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
        if (spResult.getValue() == null) {
            throw new ServiceException(spResult.getSystemMessage().getValue());
        }
        sysProg = spResult.getValue();
        SysMenuVO childSysMenu = new SysMenuVO();
        childSysMenu.setProgId(sysProg.getProgId());
        childSysMenu.setParentOid(parentSysMenu.getOid());
        childSysMenu.setEnableFlag(YesNo.YES);
        DefaultResult<SysMenuVO> result = this.sysMenuService.saveObject(childSysMenu);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysMenuVO(com.netsteadfast.greenstep.vo.SysMenuVO) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO)

Example 3 with SysProgVO

use of com.netsteadfast.greenstep.vo.SysProgVO in project bamboobsc by billchen198318.

the class RoleLogicServiceImpl method updateMenuRole.

/**
	 * 更新存在選單中程式的選單所屬 role
	 * 
	 * @param progOid
	 * @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> updateMenuRole(String progOid, List<String> roles) throws ServiceException, Exception {
    if (super.isBlank(progOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    SysProgVO sysProg = new SysProgVO();
    sysProg.setOid(progOid);
    DefaultResult<SysProgVO> spResult = this.sysProgService.findObjectByOid(sysProg);
    if (spResult.getValue() == null) {
        throw new ServiceException(spResult.getSystemMessage().getValue());
    }
    sysProg = spResult.getValue();
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(false);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("progId", sysProg.getProgId());
    List<TbSysMenuRole> sysMenuRoleList = this.sysMenuRoleService.findListByParams(params);
    for (int i = 0; sysMenuRoleList != null && i < sysMenuRoleList.size(); i++) {
        TbSysMenuRole sysMenuRole = sysMenuRoleList.get(i);
        this.sysMenuRoleService.delete(sysMenuRole);
    }
    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();
        SysMenuRoleVO sysMenuRole = new SysMenuRoleVO();
        sysMenuRole.setProgId(sysProg.getProgId());
        sysMenuRole.setRole(role.getRole());
        DefaultResult<SysMenuRoleVO> smrResult = this.sysMenuRoleService.saveObject(sysMenuRole);
        if (smrResult.getValue() == null) {
            throw new ServiceException(smrResult.getSystemMessage().getValue());
        }
    }
    result.setValue(true);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    return result;
}
Also used : SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) TbSysMenuRole(com.netsteadfast.greenstep.po.hbm.TbSysMenuRole) HashMap(java.util.HashMap) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with SysProgVO

use of com.netsteadfast.greenstep.vo.SysProgVO 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;
}
Also used : UserRoleVO(com.netsteadfast.greenstep.vo.UserRoleVO) SysMenuRoleVO(com.netsteadfast.greenstep.vo.SysMenuRoleVO) RoleVO(com.netsteadfast.greenstep.vo.RoleVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO) List(java.util.List)

Example 5 with SysProgVO

use of com.netsteadfast.greenstep.vo.SysProgVO in project bamboobsc by billchen198318.

the class SystemProgramManagementSaveOrUpdateAction method delete.

/**
	 * 刪除 TB_SYS_PROG 資料
	 * 
	 * @throws ControllerException
	 * @throws AuthorityException
	 * @throws ServiceException
	 * @throws Exception
	 */
private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
    SysProgVO sysProg = new SysProgVO();
    DefaultResult<Boolean> result = this.systemProgramLogicService.delete(this.transformFields2ValueObject(sysProg, new String[] { "oid" }));
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() == null || !result.getValue()) {
        return;
    }
    this.success = IS_YES;
}
Also used : SysProgVO(com.netsteadfast.greenstep.vo.SysProgVO)

Aggregations

SysProgVO (com.netsteadfast.greenstep.vo.SysProgVO)12 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)8 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)5 HashMap (java.util.HashMap)5 Transactional (org.springframework.transaction.annotation.Transactional)4 SysMenuVO (com.netsteadfast.greenstep.vo.SysMenuVO)3 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)2 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)2 TbSysMenuRole (com.netsteadfast.greenstep.po.hbm.TbSysMenuRole)2 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)2 SysMenuRoleVO (com.netsteadfast.greenstep.vo.SysMenuRoleVO)2 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)2 List (java.util.List)2 TbSys (com.netsteadfast.greenstep.po.hbm.TbSys)1 TbSysIcon (com.netsteadfast.greenstep.po.hbm.TbSysIcon)1 TbSysProgMultiName (com.netsteadfast.greenstep.po.hbm.TbSysProgMultiName)1 SysVO (com.netsteadfast.greenstep.vo.SysVO)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1