def get_proj_post(proj_id): """通过项目id获取项目招聘宣传贴""" post = ProjRecruitPostMgr.query_first({'proj_id': proj_id}) if not post: post = ProjRecruitPostMgr.create(proj_id=proj_id) post = to_dict(post) return post
def create_or_update_rich_text(bus_type, bus_id, title, text_type, content, sequence=0, subtitle='', rich_text_id=0): if rich_text_id: rich_text = RichTextMgr.get(rich_text_id) RichTextMgr.update(rich_text, title=title, sequence=sequence, rich_text=content, subtitle=subtitle) else: sequence = RichTextMgr.get_last_sequence_by_type( bus_type, bus_id, text_type) + 1 rich_text = RichTextMgr.create(bus_type=bus_type, bus_id=bus_id, title=title, text_type=text_type, sequence=sequence, rich_text=content, subtitle=subtitle) if bus_type == 'post': ProjRecruitPostMgr.modified(bus_id) return to_dict(rich_text)
def update_post(post_id, form): post = ProjRecruitPostMgr.get(post_id) if post is None: return dict(status='error', msg='招聘贴不存在') ProjRecruitPostMgr.update(post, **form) # 新增操作记录 __add_proj_op_log(web_util.get_operator_id(), post.id, proj_constant.PROJ_OP_TYPE_UPDATE, "更改招聘贴信息", 0, 0) return dict(status='ok', data=to_dict(post))
def create_pic(bus_type, bus_id, img_type, url, override): if override: PicMgr.clear_pic_list(bus_type, bus_id, img_type) sequence = 1 else: sequence = PicMgr.get_last_sequence_by_type(bus_type, bus_id, img_type) + 1 if bus_type == 'post': ProjRecruitPostMgr.modified(bus_id) return PicMgr.create(bus_type=bus_type, bus_id=bus_id, img_type=img_type, url=url, sequence=sequence)
def list_posts_by_org(org_id, page, page_size=10): """获取单个公司所有项目招聘宣传贴""" proj_ids = ProjMgr.get_proj_ids_by_org(org_id) filter_condition = {'is_del': 0} expressions = [ProjRecruitPostMgr.model.proj_id.in_(proj_ids)] count = ProjRecruitPostMgr.count(filter_conditions=filter_condition, expressions=expressions) if page_size > 5000: page_size = 5000 records = ProjRecruitPostMgr.query( filter_conditions=filter_condition, expressions=expressions, limit=page_size, offset=(page - 1) * page_size, order_list=[ProjRecruitPostMgr.model.modify_time.desc()]) return {'total_count': count, 'datas': to_dict(records)}
def delete_pic(pic_id): pic = PicMgr.get(pic_id) if pic: PicMgr.delete(pic) if pic.bus_type == 'post': ProjRecruitPostMgr.modified(pic.bus_id)
def delete_rich_text(rich_text_id): rich_text = RichTextMgr.get(rich_text_id) if rich_text: RichTextMgr.delete(rich_text) if rich_text.bus_type == 'post': ProjRecruitPostMgr.modified(rich_text.bus_id)