码迷,mamicode.com
首页 > 其他好文 > 详细

关于上级机构的冲突性测试bug修复

时间:2016-04-06 00:36:09      阅读:388      评论:0      收藏:0      [点我收藏+]

标签:

描述:

1.上级机构可以为空。

2.机构添加时,选择了上级机构,在未提交前,另一用户将该机构删除,然后前一用户再提交表单,提示会保存成功,本操作应该保存失败。

  思路:在上级机构不为空时,保存前进行查询判断,如果保存前一刻查询该机构存在则可以保存成功,否则保存提示“保存失败,请检查机构是否存在,再重试!”;

    @RequiresPermissions("sys:office:edit")
    @RequestMapping(value = "save")
    public String save(Office office, Model model, RedirectAttributes redirectAttributes) {      
        if(Global.isDemoMode()){
            addMessage(redirectAttributes, "演示模式,不允许操作!");
            return "redirect:" + adminPath + "/sys/office/";}
        if (!beanValidator(model, office)){
            return form(office, model);
        }
        if("".equals(office.getParent().getName())){
            officeService.save(office);        
            if(office.getChildDeptList()!=null){
                Office childOffice = null;
                for(String id : office.getChildDeptList()){
                    childOffice = new Office();
                    childOffice.setName(DictUtils.getDictLabel(id, "sys_office_common", "未知"));
                    childOffice.setParent(office);
                    childOffice.setArea(office.getArea());
                    childOffice.setType("2");
                    childOffice.setGrade(String.valueOf(Integer.valueOf(office.getGrade())+1));
                    childOffice.setUseable(Global.YES);
                    officeService.save(childOffice);
                }
            }        
            addMessage(redirectAttributes, "保存机构‘" + office.getName() + "‘成功");    
            }else{    
//        if(!("".equals(office.getParent().getName()))){//添加下级机构
            int m = officeService.findByParentId(office.getParent().getName());
            if(m==0){
                addMessage(redirectAttributes, "保存失败,请检查机构是否存在,再重试!" );
            }else{        
            officeService.save(office);        
            if(office.getChildDeptList()!=null){
                Office childOffice = null;
                for(String id : office.getChildDeptList()){
                    childOffice = new Office();
                    childOffice.setName(DictUtils.getDictLabel(id, "sys_office_common", "未知"));
                    childOffice.setParent(office);
                    childOffice.setArea(office.getArea());
                    childOffice.setType("2"); 
childOffice.setGrade(String.valueOf(Integer.valueOf(office.getGrade())+1)); childOffice.setUseable(Global.YES); officeService.save(childOffice); } } addMessage(redirectAttributes, "保存机构‘" + office.getName() + "‘成功"); } } String id = "0".equals(office.getParentId()) ? "" : office.getParentId(); return "redirect:" + adminPath + "/sys/office/forlist?id="+id+"&parentIds="+office.getParentIds(); }

 

关于上级机构的冲突性测试bug修复

标签:

原文地址:http://www.cnblogs.com/banxian-yi/p/5357365.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!