Describe:
1. The upper body may be empty.
2. When the agency is added, the parent organization is selected, and before the submission, another user deletes the institution, and the previous user submits the form again, prompting the save to be successful and the operation should fail.
Idea: In the upper body is not empty, before saving to query judgment, if you save a moment to query the institution exists can save the success, or save the hint "save failed, please check the organization exists, and then try again!" ”;
@RequiresPermissions ("Sys:office:edit") @RequestMapping (value= "Save") PublicString Save (Office office, model model, Redirectattributes redirectattributes) {if(Global.isdemomode ()) {AddMessage (redirectattributes,"Demo mode, no operation allowed!" "); return"Redirect:" + AdminPath + "/sys/office/";} if(!Beanvalidator (model, office)) { returnform (Office, model); }if("". Equals (Office.getparent (). GetName ())) {officeservice.save (Office); if(Office.getchilddeptlist ()! =NULL) {Office Childoffice=NULL; for(String id:office.getChildDeptList ()) {Childoffice=NewOffice (); Childoffice.setname (Dictutils.getdictlabel (ID,"Sys_office_common", "Unknown")); 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,"Save Agency" + office.getname () + "Success"); }Else{ //if (! (""). Equals (Office.getparent (). GetName () ))) {//Add a subordinate institution intm =Officeservice.findbyparentid (Office.getparent (). GetName ()); if(m==0) {addmessage (redirectattributes,"Save failed, please check if the organization exists, and then try again!" " ); }Else{officeservice.save (office); if(Office.getchilddeptlist ()! =NULL) {Office Childoffice=NULL; for(String id:office.getChildDeptList ()) {Childoffice=NewOffice (); Childoffice.setname (Dictutils.getdictlabel (ID,"Sys_office_common", "Unknown")); 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, "save Agency" + office.getname () + "' Success"); }} String id = "0". Equals (Office.getparentid ())? "" : Office.getparentid (); return "Redirect:" + AdminPath + "/sys/office/forlist?id=" +id+ "&parentids=" + Office.getparentids (); }
Conflicting tests on higher-level institutions bug fixes