def AddRoleUser(request): try: roleId = request.POST['roleId'] except: userId = None try: targetIds = request.POST['targetIds'] except: targetIds = None returnValue = 0 response = HttpResponse() for id in str(targetIds).split(','): UserRoleService.AddUserToRole(CommonUtils.Current(response, request), id, roleId) returnValue = returnValue + 1 if returnValue > 0: response.content = json.dumps({ 'Success': True, 'Data': '1', 'Message': '添加成功!' }) return response else: response.content = json.dumps({ 'Success': False, 'Data': '0', 'Message': '添加失败!' }) return response
def AddUserToRole(request): try: userId = request.POST['userId'] except: userId = None try: targetIds = request.POST['targetIds'] except: targetIds = None response = HttpResponse() returnValue = UserRoleService.AddUserToRole( CommonUtils.Current(response, request), userId, targetIds) if returnValue: response.content = json.dumps({ 'Success': True, 'Data': '1', 'Message': '添加成功!' }) return response else: response.content = json.dumps({ 'Success': False, 'Data': '0', 'Message': '添加失败!' }) return response