def get_list_with_searchtext(args): searchText = args['data'].get('search', '') pageSize = args['data'].get('pageSize', 0) pageIndex = args['data'].get('pageIndex', 20) sort = args['data'].get('sort', 20) pageIndex = (lambda pIndex: pIndex if pIndex != None else 0)(pageIndex) pageSize = (lambda pSize: pSize if pSize != None else 20)(pageSize) items = models.HCSLS_TrainProfession().aggregate() items.left_join(models.auth_user_info(), "created_by", "username", "uc") items.left_join(models.auth_user_info(), "modified_by", "username", "um") items.project( profession_code=1, profession_name=1, profession_name2=1, field_code=1, note=1, lock=1, ordinal=1, created_by="uc.login_account", created_on="created_on", modified_on="switch(case(modified_on!='',modified_on),'')", modified_by="switch(case(modified_by!='',um.login_account),'')", ) if(searchText != None): items.match("contains(profession_name, @name)",name=searchText) if(sort != None): items.sort(sort) return items.get_page(pageIndex, pageSize)
def update_role_code(args): try: if args['data'] != None: lock.acquire() if args['data'].has_key('role_code') and args['data'].has_key('users'): user_names = [x["username"]for x in args['data']['users']] ret = models.auth_user_info().update( dict( role_code = args['data']['role_code'] ), "username in {0}", user_names) lock.release() return ret return dict( error = "request parameter is not exist" ) except Exception as ex: logger.debug(ex) lock.release() raise(ex)
def remove_role_code_by_role(roles): try: lock.acquire() ret = models.auth_user_info().update(dict(role_code=None), "role_code in {0}", roles) lock.release() return ret except Exception as ex: logger.debug(ex) lock.release() raise (ex)
def get_user_info_by_user_name(args): return models.auth_user_info().aggregate().project(display_name = 1, login_account = 1, username = 1).match('username == {0}', args['data']['username']).get_item()