def GetRole_User(self,user_Id): ''' 函数名:GetRole_User 作用:从数据库获取对应的用户的角色信息 参数: 1、user_Id:用户ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' Sql_GetRole_User = "******" \ %(user_Id) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="GetRole_User", Sql=Sql_GetRole_User) mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_GetRole_User) RetList = [] for e in DataList: tmp={} tmp['role_Id'] =e[0] tmp['role_Name']=e[1] RetList.append(tmp) return json.dumps(RetList)
def Del_Role(self,RoleId): ''' 函数名:Del_Role 作用:根据角色ID从数据库中删除一个角色 参数: 1、RoleId:角色ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: mMySqlDBConnect = MySqlDBConnect() Sql_DelRole = "DELETE FROM `Role` WHERE (`role_Id`='%s')" %(RoleId) Sql_DelAuthGroup = "DELETE FROM `Role_AuthorityGroup` WHERE (`role_Id`='%s') "%(RoleId) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="Del_Role", Sql=Sql_DelRole) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="Del_Role", Sql=Sql_DelAuthGroup) SqlList =[] SqlList.append(Sql_DelAuthGroup) SqlList.append(Sql_DelRole) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def GetAllAuth(self,page,rows): Sql_GetAllAuth = "select Authority.authority_Id, Authority.authority_ChName from Authority limit %d,%d" % \ ( (page-1)*rows, rows) Sql_GetAllAuth_total = "select count(authority_Id) from Authority " print "Sql_GetAuthGroup_Auth:"+Sql_GetAllAuth mMySqlDBConnect = MySqlDBConnect() Ret = {} DataList=mMySqlDBConnect.excute(Sql_GetAllAuth) Ret_Data_List = [] for e in DataList: tmp={} tmp['authority_Id']=e[0] tmp['authority_ChName']=e[1] Ret_Data_List.append(tmp) Ret["rows"]=Ret_Data_List; DataList=mMySqlDBConnect.excute(Sql_GetAllAuth_total) Ret["total"]=DataList[0][0]; mMySqlDBConnect.CloseDB() return json.dumps(Ret)
def CheckUserRole_Pw(self,UserName,UserPw,RoleID): Sql_CheckRole = "SELECT * FROM Role_User where Role_User.role_Id =%s;" % (RoleID) Sql_CheckPw = "SELECT * FROM User where User.user_Name ='%s' and User.user_Pw = '%s'" \ % (UserName,UserPw) ############记录SQL语句 logging.info("###################################") logging.info(">>Class:Login_DAOIml") logging.info(">>Methon:CheckUserRole_Pw") logging.info(">>Sql:"+re.sub(r'\s+', ' ', Sql_CheckRole)) logging.info("###################################") logging.info(" ") ############记录SQL语句 logging.info("###################################") logging.info(">>Class:Login_DAOIml") logging.info(">>Methon:CheckUserRole_Pw") logging.info(">>Sql:"+re.sub(r'\s+', ' ', Sql_CheckPw)) logging.info("###################################") logging.info(" ") mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_CheckRole) if len(DataList) == 0 : return "user don't have this role" DataList=mMySqlDBConnect.excute(Sql_CheckPw) if len(DataList) == 0 : return "no this user" mMySqlDBConnect.CloseDB() return "SUCCESS"
def GetRoleAuthorities(self,RoleID): Sql_GetRoleAuth = 'select Authority.authority_Id from Authority where Authority.authority_Id in \ (select Auth_AuthGroup.auth_Id from Auth_AuthGroup where Auth_AuthGroup.authGroup_Id in \ (select AuthorityGroup.authority_Group_Id from AuthorityGroup where AuthorityGroup.authority_Group_Id in \ (select Role_AuthorityGroup.authority_Group_Id from Role_AuthorityGroup where Role_AuthorityGroup.role_Id=%s)\ )\ )' % (RoleID) ############记录SQL语句 logging.info("###################################") logging.info(">>Class:Login_DAOIml") logging.info(">>Methon:GetRoleAuthorities") logging.info(">>Sql:"+re.sub(r'\s+', ' ', Sql_GetRoleAuth)) logging.info("###################################") logging.info(" ") mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_GetRoleAuth) ###########用户权限列表,第i个元素的值当为1时,代表了权限ID为i的权限,当前用户是拥有的。注:第0位,不代表权限 AuthList = [] if len(DataList) == 0: AuthList=[0] else: AuthList = [0]*(max(DataList)[0]+1) for e in DataList: AuthList[ int(e[0]) ] = 1 mMySqlDBConnect.CloseDB() return AuthList
def CheckAuth_UserIsHave(self,AuthEnName,User_AuthList): Sql_Auth_value = "select Authority.authority_Id from Authority where Authority.authority_EnName = '%s'" % AuthEnName ############记录SQL语句 logging.info("###################################") logging.info(">>Class:Login_DAOIml") logging.info(">>Methon:CheckAuth_UserIsHave") logging.info(">>Sql:"+re.sub(r'\s+', ' ', Sql_Auth_value)) logging.info("###################################") logging.info(" ") mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_Auth_value) if len(DataList) == 0 : raise Exception("DataList length is 0 in GetAuthorityValue") mMySqlDBConnect.CloseDB() ####如果要检查的权限,不在当前的用户列表权限之中 if int(DataList[0][0]) >= len(User_AuthList): return False ####如果要检查的权限,在当前的列表中的标识符为0 if User_AuthList[ int(DataList[0][0]) ] == 0 : return False return True
def Del_User(self,UserId): ''' 函数名:Del_User 作用:根据用户ID从数据库中删除一个角色 参数: 1、UserId:用户ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: mMySqlDBConnect = MySqlDBConnect() Sql_DelUser = "******" %(UserId) Sql_DelRole = "DELETE FROM `Role_User` WHERE (`user_Id`='%s') "%(UserId) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="Del_User", Sql=Sql_DelUser) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="Del_User", Sql=Sql_DelRole) SqlList =[] SqlList.append(Sql_DelRole) SqlList.append(Sql_DelUser) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def GetRole_AuthGroup(self,RoleId): ''' 函数名:GetRole_AuthGroup 作用:从数据库获取对应的角色的权限组信息 参数: 1、RoleId:角色ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' Sql_GetAuthGroup = "select AuthorityGroup.authority_Group_Id, AuthorityGroup.authority_Group_Name \ from AuthorityGroup where AuthorityGroup.authority_Group_Id in \ (select Role_AuthorityGroup.authority_Group_Id from Role_AuthorityGroup where Role_AuthorityGroup.role_Id = %s )" \ %(RoleId) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="GetRole_AuthGroup", Sql=Sql_GetAuthGroup) mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_GetAuthGroup) RetList = [] for e in DataList: tmp={} tmp['authority_Group_Id']=e[0] tmp['authority_Group_Name']=e[1] RetList.append(tmp) return json.dumps(RetList)
def Del_AuthGroup(self,AuthGroupId): ''' 函数名:Del_AuthGroup 作用:根据权限组ID从数据库中删除一个权限组 参数: 1、AuthGroupId:权限组ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: mMySqlDBConnect = MySqlDBConnect() Sql_DelAuths = "DELETE FROM `Auth_AuthGroup` WHERE (`authGroup_Id`='%s')" %(AuthGroupId) Sql_DelAuthGroup = "DELETE FROM `AuthorityGroup` WHERE (`authority_Group_Id`='%s') "%(AuthGroupId) SqlList =[] SqlList.append(Sql_DelAuths) SqlList.append(Sql_DelAuthGroup) Proj_Logging.Log_Sql(Class="AuthGroup_DAOIml", Methon="Del_AuthGroup", Sql=Sql_DelAuths) Proj_Logging.Log_Sql(Class="AuthGroup_DAOIml", Methon="Del_AuthGroup", Sql=Sql_DelAuthGroup) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def ListAllLogInfo(self, S_ParaList, page, rows): Sql_ListAllLogInfo ="SELECT * FROM AccessLogInfo \ where AccessLogInfo.log_AccessTime >='%s 00:00:00' and \ AccessLogInfo.log_AccessTime <='%s 23:59:59' and \ AccessLogInfo.log_userName like '%s' and \ AccessLogInfo.log_Ip = '%s' and \ AccessLogInfo.log_IsExce=%s \ limit %d,%d" % \ (S_ParaList['StartTime'] , S_ParaList['EndTime'] , S_ParaList['AccessUser'] , S_ParaList['Ip'] , S_ParaList['IsExec'] , (page-1)*rows, rows) Sql_ListAllLogInfo_totle ="SELECT count(*) FROM AccessLogInfo \ where AccessLogInfo.log_AccessTime >='%s 00:00:00' and \ AccessLogInfo.log_AccessTime <='%s 23:59:59' and \ AccessLogInfo.log_userName like '%s' and \ AccessLogInfo.log_Ip = '%s' and \ AccessLogInfo.log_IsExce=%s" \ % \ (S_ParaList['StartTime'] , S_ParaList['EndTime'] , S_ParaList['AccessUser'] , S_ParaList['Ip'] , S_ParaList['IsExec'] ) print Sql_ListAllLogInfo mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_ListAllLogInfo) Ret = {} Ret_Data_List = [] for object in DataList: Tmp={} Tmp["sysLogId"] = object[0]; Tmp["log_userName"] = object[1]; Tmp["log_Action"] = object[2]; Tmp["log_Methon"] = object[3]; Tmp["log_ParaList"] = object[4]; Tmp["log_AccessTime"] = str(object[5]); Tmp["log_ExecTime"] = object[6]; Tmp["log_IsExce"] = object[7]; Tmp["log_Message_ExceInfo"] = object[8]; Tmp["log_Cause_ExceInfo"] = object[9]; Tmp["log_Localized_ExceInfo"] = object[10]; Tmp["log_Ip"] = object[11]; Ret_Data_List.append(Tmp) Ret["rows"]=Ret_Data_List; DataList=mMySqlDBConnect.excute(Sql_ListAllLogInfo_totle) Ret["total"]=DataList[0][0]; mMySqlDBConnect.CloseDB() return json.dumps(Ret)
def GetRoleInfo(self): mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute("select * from Role") mMySqlDBConnect.CloseDB() RetList = [] for e in DataList: tmp={} tmp['role_Id']=e[0] tmp['role_Name']=e[1] RetList.append(tmp) return json.dumps(RetList)
def GetLastLogInfo(self,Ip): Sql_GetLastLogInfo = "SELECT max(log_AccessTime) FROM AccessLogInfo where \ AccessLogInfo.log_Ip ='%s'" % Ip; print "Sql_GetLastLogInfo:"+Sql_GetLastLogInfo mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_GetLastLogInfo) mMySqlDBConnect.CloseDB() RetList = {} RetList['LastLogInfoTime']=str(DataList[0][0]) return json.dumps(RetList)
def ListAllIpInDB(self): Sql_ListAllIpInDB = "SELECT AccessLogInfo.log_Ip as ip FROM AccessLogInfo group by AccessLogInfo.log_Ip" print "Sql_ListAllIpInDB:"+Sql_ListAllIpInDB mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_ListAllIpInDB) mMySqlDBConnect.CloseDB() RetList = [] for e in DataList: tmp={} tmp['ip']=e[0] RetList.append(tmp) return json.dumps(RetList)
def Edit_AuthGroup(self,AuthList,AuthGroupName,AuthGroupId): ''' 函数名:Edit_AuthGroup 作用:根据权限列表,权限组名,权限组ID更新一个权限组记录 参数: 1、AuthList:权限列表 2、AuthGroupName:权限组名称 3、AuthGroupId:权限组ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: SqlList =[] mMySqlDBConnect = MySqlDBConnect() #############检查数据库中是否有相同的权限组名称 DataList=mMySqlDBConnect.excute("select count(*) from AuthorityGroup \ where AuthorityGroup.authority_Group_Name = '%s' \ and AuthorityGroup.authority_Group_Id != '%s' " % (AuthGroupName,AuthGroupId)) if int(DataList[0][0] ) != 0: mMySqlDBConnect.CloseDB() return "重复权限组名" Sql_EditAuthGroup = "UPDATE `AuthorityGroup` SET `authority_Group_Name`='%s' WHERE (`authority_Group_Id`=%s)"%(AuthGroupName,AuthGroupId) Sql_DelAuthGroup = "DELETE FROM `Auth_AuthGroup` WHERE (`authGroup_Id`='%s') "%(AuthGroupId) SqlList.append(Sql_EditAuthGroup) SqlList.append(Sql_DelAuthGroup) Proj_Logging.Log_Sql(Class="AuthGroup_DAOIml", Methon="Edit_AuthGroup", Sql=Sql_EditAuthGroup) Proj_Logging.Log_Sql(Class="AuthGroup_DAOIml", Methon="Edit_AuthGroup", Sql=Sql_DelAuthGroup) #############添加权限组 for e in AuthList: Sql = "INSERT INTO `Auth_AuthGroup` (`auth_authGroup`,`auth_Id`,`authGroup_Id`) VALUES (NULL,'%s','%s')" % (e,AuthGroupId) Proj_Logging.Log_Sql(Class="AuthGroup_DAOIml", Methon="Edit_AuthGroup", Sql=Sql) SqlList.append(Sql) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def GetAuthGroup_Auth(self,AuthGroupId): Sql_GetAuthGroup_Auth = "select Authority.authority_Id, Authority.authority_ChName \ from Authority where Authority.authority_Id in \ (select Auth_AuthGroup.auth_Id from Auth_AuthGroup where Auth_AuthGroup.authGroup_Id = %s )" \ %(AuthGroupId) mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_GetAuthGroup_Auth) RetList = [] for e in DataList: tmp={} tmp['authority_Id']=e[0] tmp['authority_ChName']=e[1] RetList.append(tmp) return json.dumps(RetList)
def Edit_User(self,RoleList,UserName,UserPw,UserId): ''' 函数名:Edit_User 作用:根据角色列表、用户名、用户密码、用户ID在数据库中更新用户 参数: 1、RoleList:角色列表 2、UserName:用户名称 3、UserPw:用户密码 4、UserId:用户ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: SqlList =[] mMySqlDBConnect = MySqlDBConnect() #############检查数据库中是否有相同的用户名称 DataList=mMySqlDBConnect.excute("select count(*) from User \ where User.user_Name = '%s' \ and User.user_Id != '%s' " % (UserName,UserId)) if int(DataList[0][0] ) != 0: mMySqlDBConnect.CloseDB() return "重复用户名" Sql_EditUser = "******"%(UserName,UserPw,UserId) Sql_DelRole = "DELETE FROM `Role_User` WHERE (`user_Id`='%s') "%(UserId) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="Edit_User", Sql=Sql_EditUser) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="Edit_User", Sql=Sql_DelRole) SqlList.append(Sql_EditUser) SqlList.append(Sql_DelRole) #############添加用户 for e in RoleList: Sql = "INSERT INTO `Role_User` (`user_Role_Id`,`user_Id`,`role_Id`) VALUES (NULL,'%s','%s')" % (UserId,e) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="Edit_User", Sql=Sql) SqlList.append(Sql) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def Edit_Role(self,AuthGroupList,RoleName,RoleId): ''' 函数名:Edit_Role 作用:根据权限组列表,角色名,角色ID更新一个角色记录 参数: 1、AuthGroupList:权限组列表 2、RoleName:角色名称 3、RoleId:角色ID 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: SqlList =[] mMySqlDBConnect = MySqlDBConnect() #############检查数据库中是否有相同的角色名称 DataList=mMySqlDBConnect.excute("select count(*) from Role \ where Role.role_Name = '%s' \ and Role.role_Id != '%s' " % (RoleName,RoleId)) if int(DataList[0][0] ) != 0: mMySqlDBConnect.CloseDB() return "重复角色名" Sql_EditRole = "UPDATE `Role` SET `role_Name`='%s' WHERE (`role_Id`=%s)"%(RoleName,RoleId) Sql_DelRole = "DELETE FROM `Role_AuthorityGroup` WHERE (`role_Id`='%s') "%(RoleId) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="Edit_Role", Sql=Sql_EditRole) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="Edit_Role", Sql=Sql_DelRole) SqlList.append(Sql_EditRole) SqlList.append(Sql_DelRole) #############添加权限组 for e in AuthGroupList: Sql = "INSERT INTO `Role_AuthorityGroup` (`role_authGroup_Id`,`role_Id`,`authority_Group_Id`) VALUES (NULL,'%s','%s')" % (RoleId,e) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="Edit_Role", Sql=Sql) SqlList.append(Sql) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def GetUser(self,page,rows): ''' 函数名:GetUser 作用:从数据库获取所有的用户信息 参数: 1、page:前台datagrid的page值 2、rows:前台datagrid的page值 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' Sql_GetUser ="******" % \ ( (page-1)*rows, rows) Sql_GetUser_Totle ="select count(*) from User" Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="GetUser", Sql=Sql_GetUser_Totle) mMySqlDBConnect = MySqlDBConnect() DataList=mMySqlDBConnect.excute(Sql_GetUser) Ret = {} Ret_Data_List = [] for object in DataList: Tmp={} Tmp["user_Id"] = object[0]; Tmp["user_Name"] = object[1]; Tmp["user_Pw"] = object[2]; Ret_Data_List.append(Tmp) Ret["rows"]=Ret_Data_List; DataList=mMySqlDBConnect.excute(Sql_GetUser_Totle) Ret["total"]=DataList[0][0]; mMySqlDBConnect.CloseDB() return json.dumps(Ret)
def Add_AuthGroup(self,AuthList,AuthGroupName): ''' 函数名:Add_AuthGroup 作用:根据权限列表和权限名在数据库中添加新的权限组 参数: 1、AuthList:权限列表 2、AuthGroupName:权限组名称 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: mMySqlDBConnect = MySqlDBConnect() #############检查数据库中是否有相同的权限组名称 DataList=mMySqlDBConnect.excute("select count(*) from AuthorityGroup where AuthorityGroup.authority_Group_Name = '%s'" % (AuthGroupName)) if int(DataList[0][0] ) != 0: mMySqlDBConnect.CloseDB() return "重复权限组名" #############添加权限组 SqlList =[] Sql_AddAuthGroup = "INSERT INTO `AuthorityGroup` (`authority_Group_Id`,`authority_Group_Name`) VALUES (NULL,'%s')" % (AuthGroupName) SqlList.append(Sql_AddAuthGroup) Proj_Logging.Log_Sql(Class="AuthGroup_DAOIml", Methon="Add_AuthGroup", Sql=Sql_AddAuthGroup) mMySqlDBConnect.excuteDML(SqlList) Sql_ReturnId = "SELECT LAST_INSERT_ID();" DataList=mMySqlDBConnect.excute(Sql_ReturnId) #############添加权限组 SqlList =[] for e in AuthList: Sql = "INSERT INTO `Auth_AuthGroup` (`auth_authGroup`,`auth_Id`,`authGroup_Id`) VALUES (NULL,'%s','%s')" % (e,DataList[0][0]) Proj_Logging.Log_Sql(Class="AuthGroup_DAOIml", Methon="Add_AuthGroup", Sql=Sql) SqlList.append(Sql) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def Add_User(self,RoleList,UserName,UserPw): ''' 函数名:Add_User 作用:根据角色列表、用户名、用户密码在数据库中添加新的用户 参数: 1、RoleList:角色列表 2、UserName:用户名称 3、UserPw:用户密码 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: mMySqlDBConnect = MySqlDBConnect() #############检查数据库中是否有相同的用户名称 DataList=mMySqlDBConnect.excute("select count(*) from User where User.user_Name = '%s'" % (UserName)) if int(DataList[0][0] ) != 0: mMySqlDBConnect.CloseDB() return "重复用户名" #############添加用户 SqlList =[] Sql_AddUser = "******" % (UserName,UserPw) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="Add_User", Sql=Sql_AddUser) SqlList.append(Sql_AddUser) mMySqlDBConnect.excuteDML(SqlList) Sql_ReturnId = "SELECT LAST_INSERT_ID();" DataList=mMySqlDBConnect.excute(Sql_ReturnId) #############添加角色 SqlList =[] for e in RoleList: Sql = "INSERT INTO `Role_User` (`user_Role_Id`,`user_Id`,`role_Id`) VALUES (NULL,'%s','%s')" % (DataList[0][0],e) Proj_Logging.Log_Sql(Class="User_DAOIml", Methon="Add_User", Sql=Sql) SqlList.append(Sql) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"
def Add_Role(self,AuthGroupList,RoleName): ''' 函数名:Add_Role 作用:根据权限组列表和角色名在数据库中添加新的角色 参数: 1、AuthGroupList:权限组列表 2、RoleName:角色名称 返回值:返回前台json格式 可能的异常: 1、SQL语句返回异常 ''' try: mMySqlDBConnect = MySqlDBConnect() #############检查数据库中是否有相同的角色名称 DataList=mMySqlDBConnect.excute("select count(*) from Role where Role.role_Name = '%s'" % (RoleName)) if int(DataList[0][0] ) != 0: mMySqlDBConnect.CloseDB() return "重复角色名" #############添加角色 SqlList =[] Sql_AddRole = "INSERT INTO `Role` (`role_Id`,`role_Name`) VALUES (NULL,'%s')" % (RoleName) SqlList.append(Sql_AddRole) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="Add_Role", Sql=Sql_AddRole) mMySqlDBConnect.excuteDML(SqlList) Sql_ReturnId = "SELECT LAST_INSERT_ID();" DataList=mMySqlDBConnect.excute(Sql_ReturnId) #############添加权限组 SqlList =[] for e in AuthGroupList: Sql = "INSERT INTO `Role_AuthorityGroup` (`role_authGroup_Id`,`role_Id`,`authority_Group_Id`) VALUES (NULL,'%s','%s')" % (DataList[0][0],e) Proj_Logging.Log_Sql(Class="Role_DAOIml", Methon="Add_Role", Sql=Sql) SqlList.append(Sql) mMySqlDBConnect.excuteDML(SqlList) mMySqlDBConnect.CloseDB() except Exception, e: raise e return "no success"