Example #1
0
 def yc_new_upload(self, file_path, status=1):
     ret = yield db_helper.insert_into_table_return_id(self._get_inst(),
                                                       self._executor,
                                                       'yc_temp',
                                                       path=file_path,
                                                       status=status)
     raise gen.Return(ret)
Example #2
0
 def add_download_detail(self, **kwargs):
     if 'upload_date' not in kwargs:
         kwargs['upload_date'] = self.today()
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.download_detail_tab,
         **kwargs)
     raise gen.Return(ret)
Example #3
0
 def insert_into_uid_set(self, set_id, uid_set):
     size = len(uid_set)
     if size == 0:
         raise gen.Return(True)
     if size == 1:
         uid = uid_set.pop()
         sql = 'SELECT uid FROM %s WHERE set_id=%s AND uid=%s' % (
             self.uid_set_detail_tab, set_id, uid)
         ret = yield self._executor.async_select(self._get_inst(True), sql)
         if not ret:
             ret = yield db_helper.insert_into_table_return_id(
                 self._get_inst(),
                 self._executor,
                 self.uid_set_detail_tab,
                 uid=uid,
                 set_id=set_id)
     else:
         uids = tuple(uid_set)
         sql = 'SELECT uid FROM %s WHERE set_id=%s AND uid in %s' % (
             self.uid_set_detail_tab, set_id, uids)
         ret = yield self._executor.async_select(self._get_inst(True), sql)
         for item in ret:
             uid_set.remove(item['uid'])
         ret = yield self.create_uid_set_detail(set_id, uid_set)
     raise gen.Return(ret)
Example #4
0
 def add_notify_item(self, job_id, uid, notify_type):
     ret = yield db_helper.insert_into_table_return_id(self._get_inst(),
                                                       self._executor,
                                                       self.notify_tab,
                                                       job_id=job_id,
                                                       uid=uid,
                                                       type=notify_type)
     raise gen.Return(ret)
Example #5
0
 def create_new_job(self, with_mark=True, **kwargs):
     if 'time' not in kwargs:
         kwargs['time'] = self.now()
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.record_tab, **kwargs)
     if ret and with_mark:
         self.update_job_mark(ret, kwargs['invoker'],
                              type_define.STATUS_JOB_INVOKED_BY_MYSELF)
     raise gen.Return(ret)
Example #6
0
 def add_job_uid_path_detail(self, job_id, index, uid=None, set_id=None):
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(),
         self._executor,
         self.uid_path_detail_table,
         job_id=job_id,
         uid=uid,
         set_id=set_id,
         order_index=index)
     raise gen.Return(ret)
Example #7
0
 def add_account(self, **kwargs):
     if 'account' not in kwargs:
         sql = 'SELECT MAX(id) AS max_id FROM %s' % self.account_tab
         max_id = yield self._executor.async_select(self._get_inst(True), sql)
         if max_id:
             kwargs['account'] = '%s%s' % (self.account_prefix, 10000 + max_id[0]['max_id'])
         else:
             kwargs['account'] = '%s%s' % (self.account_prefix, 10001)
     ret = yield db_helper.insert_into_table_return_id(self._get_inst(), self._executor, self.account_tab, **kwargs)
     raise gen.Return({'id': ret, 'account': kwargs['account']} if ret else None)
Example #8
0
 def add_job_node(self, is_comment=False, **kwargs):
     if 'time' not in kwargs:
         kwargs['time'] = self.now()
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.node_tab, **kwargs)
     if ret and not is_comment:
         yield self.update_job(kwargs['job_id'],
                               mod_time=kwargs['time'],
                               last_operator=kwargs['sender_id'])
     raise gen.Return(ret)
Example #9
0
 def create_uid_set_detail(self, set_id, uid_set):
     for uid in uid_set:
         ret = yield db_helper.insert_into_table_return_id(
             self._get_inst(),
             self._executor,
             self.uid_set_detail_tab,
             uid=uid,
             set_id=set_id)
         if not ret:
             raise gen.Return(False)
     raise gen.Return(True)
Example #10
0
 def add_job_auto_path(self, dept_list, uid_list, **kwargs):
     id = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.auto_path_tab, **kwargs)
     if id:
         if 'pre_path_id' in kwargs:
             yield self.update_job_auto_path(kwargs['pre_path_id'],
                                             next_path_id=id)
         if 'next_path_id' in kwargs:
             yield self.update_job_auto_path(kwargs['next_path_id'],
                                             pre_path_id=id)
         if 'to_leader' not in kwargs or not kwargs['to_leader']:
             yield self.update_job_auto_path_details(
                 id, dept_list, uid_list)
     raise gen.Return(id)
Example #11
0
 def update_job_memo(self, job_type, memo):
     sql = "SELECT * FROM job_memo WHERE type=%s" % job_type
     exist = yield self._executor.async_select(self._get_inst(True), sql)
     if exist:
         sql = "UPDATE job_memo SET memo='%s' WHERE type=%s" % (memo,
                                                                job_type)
         ret = yield self._executor.async_update(self._get_inst(), sql)
     else:
         ret = yield db_helper.insert_into_table_return_id(self._get_inst(),
                                                           self._executor,
                                                           'job_memo',
                                                           type=job_type,
                                                           memo=memo)
     raise gen.Return(ret)
Example #12
0
 def set_common_config(self, config_type, key, label):
     sql = 'SELECT * FROM %s WHERE type=%s AND key_id=%s' % (
         self.config_tab, config_type, key)
     exist = yield self._executor.async_select(self._get_inst(True), sql)
     if exist:
         yield db_helper.update_table_values(self._get_inst(),
                                             self._executor,
                                             exist[0]['id'],
                                             self.config_tab,
                                             label=label)
     else:
         yield db_helper.insert_into_table_return_id(self._get_inst(),
                                                     self._executor,
                                                     self.config_tab,
                                                     type=config_type,
                                                     key_id=key,
                                                     label=label)
     raise gen.Return(True)
Example #13
0
 def update_job_mark(self, job_id, uid, status, branch_id=None):
     sql = 'SELECT * FROM %s WHERE uid=%s AND job_id=%s' % (self.mark_tab,
                                                            uid, job_id)
     if branch_id:
         sql += ' AND branch_id=%s' % branch_id
     exist = yield self._executor.async_select(self._get_inst(True), sql)
     if exist:
         ret = yield db_helper.update_table_values(self._get_inst(),
                                                   self._executor,
                                                   exist[0]['id'],
                                                   self.mark_tab,
                                                   status=status)
     else:
         info = {'job_id': job_id, 'uid': uid, 'status': status}
         if branch_id:
             info['branch_id'] = branch_id
         ret = yield db_helper.insert_into_table_return_id(
             self._get_inst(), self._executor, self.mark_tab, **info)
     raise gen.Return(ret)
Example #14
0
 def add_node_attachment(self, **kwargs):
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.attach_tab, **kwargs)
     raise gen.Return(ret)
Example #15
0
 def add_protect_question(self, **kwargs):
     ret = yield db_helper.insert_into_table_return_id(self._get_inst(), self._executor, self.question_tab, **kwargs)
     raise gen.Return(ret)
Example #16
0
 def add_dept(self, **kwargs):
     ret = yield db_helper.insert_into_table_return_id(self._get_inst(), self._executor, self.dept_tab, **kwargs)
     raise gen.Return(ret)
Example #17
0
 def add_outer_link(self, **kwargs):
     if 'mod_time' not in kwargs:
         kwargs['mod_time'] = self.now()
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.link_tab, **kwargs)
     raise gen.Return(ret)
Example #18
0
 def add_job_auto_path_detail(self, **kwargs):
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.auto_path_detail_tab,
         **kwargs)
     raise gen.Return(ret)
Example #19
0
 def add_job_timer_task(self, **kwargs):
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.timer_task_tab, **kwargs)
     raise gen.Return(ret)
Example #20
0
 def create_admin_job(self, **kwargs):
     kwargs['mod_time'] = self.now()
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.admin_job_tab, **kwargs)
     raise gen.Return(ret)
Example #21
0
 def cerate_broadcast(self, **kwargs):
     ret = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.broadcast_tab, **kwargs)
     raise gen.Return(ret)
Example #22
0
 def create_uid_set(self):
     set_id = yield db_helper.insert_into_table_return_id(
         self._get_inst(), self._executor, self.uid_set_tab)
     raise gen.Return(set_id)