def get(self): args = search_parser.parse_args() usid = args.get('id') project_name = args.get('project_name') starttime = args.get('starttime') endtime = args.get('endtime') page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] conditions = [] if isinstance(usid, int): conditions.append(UserServiceItem.id == usid) if project_name: conditions.append( UserServiceItem.project_name.contains(project_name)) if isinstance(starttime, int) and isinstance(endtime, int): conditions.append( int(starttime) <= UserServiceItem.timestamp <= int(endtime)) pagination = UserServiceItem.query.filter(and_(*conditions)).paginate( page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(UserServiceItemSchema, many=True) data = schema.dump(pagination).data return {Const.RESULT_KEY: data}, Const.STATUS_OK
def get(self): args = search_parser.parse_args() page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] pagination = Schedule.query.paginate(page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(ScheduleSchema, many=True) data = schema.dump(pagination).data return {Const.RESULT_KEY: data}, Const.STATUS_OK
def get(self): args = search_parser.parse_args() padid = args.get('id') page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] pagination = PhaseAttachmentDetail.query.filter_by(paid=padid).paginate(page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(PhaseAttachmentDetailSchema, many=True) data = schema.dump(pagination).data return {Const.RESULT_KEY: data}, Const.STATUS_OK
def get(self): args = search_parser.parse_args() pid = args.get('id') name = args.get('name') contact_name = args.get('contact_name') industry = args.get('industry') phase_index = args.get('phase_index') contact_phone = args.get('contact_phone') starttime = args.get('starttime') endtime = args.get('endtime') page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] conditions = [] if isinstance(pid, int): conditions.append(Project.id == pid) if name: conditions.append(Project.name.contains(name)) if contact_name: conditions.append(Project.contact_name.contains(contact_name)) if industry in Industry.__members__.keys(): conditions.append(Project.industry == Industry[industry]) if phase_index: conditions.append(Project.phase_index == phase_index) if contact_phone: conditions.append(Project.contact_phone.contains(contact_phone)) if isinstance(starttime, int) and isinstance(endtime, int): conditions.append(int(starttime) <= Project.gmt_create <= int(endtime)) pagination = Project.query.filter(and_(*conditions)).paginate(page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(ProjectSchema, many=True) # , exclude=('comments.project_id', 'phases.project_id')) data = schema.dump(pagination).data return {Const.RESULT_KEY: data}, Const.STATUS_OK
def get(self): conditions = [] args = search_parser.parse_args() uid = args.get('id') name = args.get('name') email = args.get('email') phone = args.get('phone') company_industry = args.get('company_industry') company_name = args.get('company_name') page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] if isinstance(uid, int): conditions.append(Startup.id == uid) if name: conditions.append(Startup.name.contains(name)) if email: conditions.append(Startup.email.contains(email)) if phone: conditions.append(Startup.phone.contains(phone)) if company_industry in Industry.__members__.keys(): conditions.append( Startup.company_industry == Industry[company_industry]) if company_name: conditions.append(Startup.company_name.contains(company_name)) pagination = Startup.query.filter(and_(*conditions)).paginate( page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(StartupSchema, many=True) data = schema.dump(pagination).data return {Const.RESULT_KEY: data}, Const.STATUS_OK
def get(self, csiid=None): user = user_manager.current_user if csiid is None: args = custom_service_list_parser.parse_args() page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(CustomServiceItemSchema, many=True) raw_projects_ids = Project.query.filter_by( owner_id=user.id).values(Project.id) try: projects_ids = list(zip(*raw_projects_ids))[0] except Exception as e: print(e) projects_ids = [] try: raw_ph_ids = ProjectPhase.query.filter( ProjectPhase.project_id.in_(projects_ids)).values( ProjectPhase.id ) ph_ids = list(zip(*raw_ph_ids))[0] except Exception as e: ph_ids = [] custom_service_items = CustomServiceItem.query.filter( CustomServiceItem.ppid.in_(ph_ids)).paginate( page, per_page=per_page, error_out=False ) result = schema.dump(custom_service_items).data else: item = CustomServiceItem.query.get_or_404(csiid) schema = CustomServiceItemSchema() result = schema.dump(item).data return {Const.RESULT_KEY: result}, Const.STATUS_OK
def get(self, pid=None): user = user_manager.current_user if pid is not None: project = Project.query.filter_by(owner_id=user.id, id=pid).first() if project is not None: for phase in project.phases: phase.phase_name = phase.phase.name schema = ProjectSchema(exclude=('comments.project_id', 'phases.project_id')) result = schema.dump(project).data else: result = {} else: args = project_search_parser.parse_args() pid = args.get('id') name = args.get('name') contact_name = args.get('contact_name') industry = args.get('industry') phase_index = args.get('phase_index') contact_phone = args.get('contact_phone') starttime = args.get('starttime') endtime = args.get('endtime') page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] conditions = [ Project.owner_id == user.id, ] if isinstance(pid, int): conditions.append(Project.id == pid) if name: conditions.append(Project.name.contains(name)) if contact_name: conditions.append(Project.contact_name.contains(contact_name)) if industry in Industry.__members__.keys(): conditions.append(Project.industry == Industry[industry]) if phase_index: conditions.append(Project.phase_index == phase_index) if contact_phone: conditions.append( Project.contact_phone.contains(contact_phone)) if isinstance(starttime, int) and isinstance(endtime, int): conditions.append( int(starttime) <= Project.gmt_create <= int(endtime)) pagination = Project.query.filter(and_(*conditions)).paginate( page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(ProjectSchema, many=True) result = schema.dump(pagination).data return {Const.RESULT_KEY: result}, Const.STATUS_OK
def get(self, scid=None): if scid is not None: schema = ServiceItemCategorySchema() sc = ServiceItemCategory.query.get_or_404(scid) result = schema.dump(sc).data else: schema = PaginationSchema() args = service_category_search_parser.parse_args() page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] pagination = ServiceItemCategory.query.paginate(page, per_page=per_page, error_out=False) schema.declared_fields['items'] = fields.Nested(ServiceItemCategorySchema, many=True) result = schema.dump(pagination).data return {Const.RESULT_KEY: result}, Const.STATUS_OK
def get(self): conditions = [] args = search_parser.parse_args() phase_name = args.get('phase_name') attachment_name = args.get('attachment_name') status = args.get('status') starttime = args.get('starttime') endtime = args.get('endtime') page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] if phase_name: conditions.append(PhaseAttachment.phase_name.contains(phase_name)) if attachment_name: conditions.append( PhaseAttachment.attachment_name.contains(attachment_name)) if status in AttachmentStatus.__members__.values(): conditions.append(PhaseAttachment.status == status) if isinstance(starttime, int) and isinstance(endtime, int): conditions.append( int(starttime) <= PhaseAttachment.timestamp <= int(endtime)) pagination = PhaseAttachment.query.filter(and_(*conditions)).paginate( page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested(PhaseAttachmentSchema, many=True) data = schema.dump(pagination).data return {Const.RESULT_KEY: data}, Const.STATUS_OK
def get(self): args = search_parser.parse_args() csid = args.get('id') category_id = args.get('category_id') status = args.get('status') project_name = args.get('project_name') title = args.get('title') description = args.get('description') starttime = args.get('starttime') endtime = args.get('endtime') page = args.get('page') per_page = current_app.config['ITEM_COUNT_PER_PAGE'] conditions = [] # 通过 ID 查询 if isinstance(csid, int): conditions.append(CustomServiceItem.id == csid) # 通过类别查询 if isinstance(category_id, int): conditions.append(CustomServiceItem.category_id == category_id) # 通过状态查询 if status in ServiceStatus.__members__.keys(): conditions.append( CustomServiceItem.status == ServiceStatus[status]) # 通过项目名查询 if project_name: conditions.append( CustomServiceItem.project_name.contains(project_name)) # 通过标题查询 if title: conditions.append(CustomServiceItem.title.contains(title)) # 通过描述查询 if description: conditions.append( CustomServiceItem.description.contains(description)) # 通过创建时间查询 if isinstance(starttime, int) and isinstance(endtime, int): conditions.append( int(starttime) <= CustomServiceItem.timestamp <= int(endtime)) pagination = CustomServiceItem.query.filter( and_(*conditions)).paginate(page, per_page=per_page, error_out=False) schema = PaginationSchema() schema.declared_fields['items'] = fields.Nested( CustomServiceItemSchema, many=True) data = schema.dump(pagination).data return {Const.RESULT_KEY: data}, Const.STATUS_OK