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 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 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 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 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 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 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"