Ejemplo n.º 1
0
    def syndicate_list(self):
        beg = self.get_argument("beg",0)
        count = self.get_argument("count",30)
        search = self.get_argument("search","")
        sort = self.get_argument('sort','id')
        self.logger.info("beg:"+str(beg)+"count:"+str(count))

        com_db = CompanyDao(session=self.session)
        usr_conf_db = UserConfDao(session=self.session)
        syndicate_list = com_db.get_companys(Company.NO_PARENT, search)
        spr_mgrs = usr_conf_db.get_sprmgrs()

        for syndicate in syndicate_list:
            supers_info = []
            for spr_mgr in spr_mgrs:
                if spr_mgr['syndicate_uuid'] == syndicate['uuid']:
                    supers_info.append(spr_mgr['user_name'])
            syndicate['supers'] = supers_info

        syndicate_list.sort(key=lambda com: com[sort])
        self.log_user_action(self.get_token().get("uuid"),"syndicate_list","-")
        result = {
            'result': True,
            'count': len(syndicate_list),
            'syndicates': syndicate_list[int(beg):int(beg)+int(count)] if (int(beg)+int(count)) <= len(syndicate_list) else syndicate_list[int(beg):]
        }
        return result
Ejemplo n.º 2
0
    def get_supmgrs_infos(self):
        beg = self.get_argument("beg", 0)
        count = self.get_argument("count", 30)
        search = self.get_argument("search", "")
        sort = self.get_argument("sort", "telephone")
        self.logger.info("sort:" + sort)

        results = []

        usr_rules_db = UserConfDao(session=self.session)
        supmgr_list = usr_rules_db.get_sprmgrs()
        for supmgr in supmgr_list:
            if supmgr['user_name'].find(
                    search) == -1 and supmgr['telephone'].find(search) == -1:
                continue
            results.append(supmgr)
        results.sort(key=lambda manager: manager[sort])
        # 日志
        self.log_user_action(self.get_token().get("uuid"), "get_supmgrs_info",
                             "-")

        result = {
            "result":
            True,
            "count":
            len(results),
            "sup_mgrs":
            results[int(beg):int(beg) + int(count)] if
            (int(beg) + int(count)) <= len(results) else results[int(beg):]
        }
        return result