def user_Save(self, in_dict, saveKeys): relist, is_succ = Fun.model_save(FaUser, self, in_dict, saveKeys) if is_succ.IsSuccess: # 表示已经添加成功角色 sqlStr = ''' DELETE FROM fa_user_role WHERE fa_user_role.USER_ID = {0} '''.format(relist.ID) print(sqlStr) execObj = db.session.execute(sqlStr) if len(relist.roleIdList) > 0: sqlStr = ''' INSERT INTO fa_user_role (ROLE_ID, USER_ID) SELECT m.ID ROLE_ID, {0} USER_ID FROM fa_role m WHERE m.ID IN ({1}) '''.format(relist.ID, ','.join(str(i) for i in relist.roleIdList)) print(sqlStr) execObj = db.session.execute(sqlStr) db.session.commit() return relist, is_succ
def Role_Save(self, in_dict, saveKeys): relist, is_succ = Fun.model_save(FaRole, self, in_dict, saveKeys) if is_succ.IsSuccess: # 表示已经添加成功角色 sqlStr = ''' DELETE FROM fa_role_module WHERE fa_role_module.ROLE_ID = {0} '''.format(relist.ID) print(sqlStr) execObj = db.session.execute(sqlStr) if len(relist.moduleIdStr) > 0: sqlStr = ''' INSERT INTO fa_role_module (ROLE_ID, MODULE_ID) SELECT {0} ROLE_ID, m.ID MODULE_ID FROM fa_module m WHERE m.ID IN ({1}) '''.format(relist.ID, ','.join(str(i) for i in relist.moduleIdStr)) print(sqlStr) execObj = db.session.execute(sqlStr) db.session.commit() return relist, is_succ
def query_Save(self, in_dict, saveKeys): jsonStr = re.sub(r'\r|\n| ', "", in_dict["QUERY_CFG_JSON"]) jsonStr = re.sub(r'"onComponentInitFunction"((.|\n)+?)},', "", jsonStr) jsonStr = re.sub(r',},', ",", jsonStr) try: x = json.loads(jsonStr) except: return None, AppReturnDTO(False, "列配置信息有误") relist, is_succ = Fun.model_save(FaQuery, self, in_dict, saveKeys) return relist, is_succ
def district_Save(self, in_dict, saveKeys): newParent = None saveKeys.append("ID_PATH") saveKeys.append("REGION") if "PARENT_ID" not in in_dict or in_dict["PARENT_ID"] is None: in_dict["LEVEL_ID"] = 0 in_dict["ID_PATH"] = "." in_dict["REGION"] = 0 else: newParent, is_succ = self.district_single(in_dict["PARENT_ID"]) if newParent is None: return None, AppReturnDTO(False, "上级节点有误") in_dict["LEVEL_ID"] = newParent.LEVEL_ID + 1 in_dict["ID_PATH"] = "{0}{1}.".format(newParent.ID_PATH, in_dict["PARENT_ID"]) in_dict["REGION"] = newParent.REGION pass #用于更新所有子节点的ID_PATH,如果修改过parent_id的话 if "ID" in in_dict and in_dict["ID"] is not None and in_dict["ID"] != 0: if str(in_dict["ID"]) == str(in_dict["PARENT_ID"]): return None, AppReturnDTO(False, "上级不能选择自己") sql = "SELECT ID FROM fa_district WHERE ID_PATH LIKE '%.{0}.%'".format( in_dict["ID"]) childListTuple = db.session.execute(sql).fetchall() childList = [item[0] for item in childListTuple] if int(in_dict["PARENT_ID"]) in childList: return None, AppReturnDTO(False, "上级不能自己子集") nowEnt = FaDistrict.query.filter( FaDistrict.ID == in_dict["ID"]).first() #如果PARENT_ID没有变化则不执行下面语句 if nowEnt.PARENT_ID != in_dict["PARENT_ID"]: if nowEnt is None: return None, AppReturnDTO(False, "ID有误") updateSql = "UPDATE fa_district SET ID_PATH= '{0}{1}.' WHERE ID_PATH LIKE '%{2}{1}.%'" updateSql = updateSql.format(in_dict["ID_PATH"], nowEnt.ID, nowEnt.ID_PATH) print(updateSql) db.session.execute(updateSql) relist, is_succ = Fun.model_save(FaDistrict, self, in_dict, saveKeys) return relist, is_succ
def userInfo_Save(self, in_dict, saveKeys): if "FATHER_ID" in in_dict: fatherUser = FaUser.query.filter_by( ID=in_dict["FATHER_ID"]).first() in_dict["DISTRICT_ID"] = fatherUser.DISTRICT_ID elif 'COUPLE_ID' in in_dict: fatherUser = FaUser.query.filter_by( ID=in_dict["COUPLE_ID"]).first() in_dict["DISTRICT_ID"] = fatherUser.DISTRICT_ID else: pass if "ID" not in in_dict or in_dict["ID"] is None or in_dict["ID"] == 0: in_dict["AUTHORITY"] = "777" in_dict["roleIdList"] = "3" if "roleIdList" not in saveKeys: saveKeys.append('roleIdList') if "AUTHORITY" not in saveKeys: saveKeys.append('AUTHORITY') user, is_succ = Fun.model_save(FaUserInfo, self, in_dict, saveKeys, FaUser) if is_succ.IsSuccess: # 表示已经添加成功角色 userDal = UserDal() parentUser, is_succ = userDal.user_save_extend( user, in_dict, saveKeys) if not is_succ: return user, is_succ # 更新配 if "COUPLE_ID" in in_dict: FaUserInfo.query.filter( FaUserInfo.ID == in_dict["COUPLE_ID"]).update( {FaUserInfo.COUPLE_ID: user.ID}) db.session.commit() return user, is_succ
def module_Save(self, in_dict, saveKeys): relist, is_succ = Fun.model_save(FaModule, self, in_dict, saveKeys) return relist, is_succ
def file_Save(self, in_dict, saveKeys): reEnt,is_succ=Fun.model_save(FaFile, self, in_dict, saveKeys) return reEnt,is_succ
def userInfo_Save(self, in_dict, saveKeys): relist, is_succ = Fun.model_save(FaUserInfo, self, in_dict, saveKeys) return relist, is_succ
def user_Save(self, in_dict, saveKeys): user, is_succ = Fun.model_save(FaUser, self, in_dict, saveKeys) if is_succ.IsSuccess: # 表示已经添加成功角色 return self.user_save_extend(user, in_dict, saveKeys) return user, is_succ