示例#1
0
def get_token(phone, password):
    r = db.query_one('select password, salt from user where phone = %s and pass=1' % phone)
    if r is not None and util.bcrypt_check(password=password + r['salt'], hashed=r['password']):
        new_token = util.generate_access_token(password)
        db.execute('update user set token = "%s" where phone = "%s"' % (new_token, phone))
        return db.query_one(
            'select user.id, user.phone, user.token, user_settings.city, user_settings.cityId, user_settings.appliable '
            'from user join user_settings on user_settings.user = user.id where user.phone = %s' % phone)
    return None
示例#2
0
文件: job.py 项目: coocol/server_app
def apply_job(user_id, job_id):
    sql = 'select id from apply_job where user = %s and job = %s' % (user_id, job_id)
    if _db.query_one(sql) is None:
        _db.insert('apply_job', {'user': user_id, 'job': job_id})
        _db.execute('update job set apply = apply + 1 where id = %s' % job_id)
        r = _db.query_one('select company from job where id = %s' % job_id)
        _db.execute('update company_info set apply = apply + 1 where company = %s' % r['company'])
        return True
    return False
示例#3
0
文件: job.py 项目: coocol/server_app
def collect_job(user_id, job_id):
    sql = 'select id from collect_job where user = %s and job = %s' % (user_id, job_id)
    if _db.query_one(sql) is None:
        _db.insert('collect_job', {'user': user_id, 'job': job_id})
        _db.execute('update job set collect = collect + 1 where id = %s' % job_id)
        return True
    return False
示例#4
0
def register_user(phone, password):
    token = util.generate_access_token(password)
    salt = util.generate_salt()
    db.execute('update user set token = "%s", password = "******", salt = "%s", pass = 1 where phone = "%s"'
               % (token, util.bcrypt_password(password + salt), salt, phone))
    uid = db.query_one('select id from user where phone = %s' % phone)['id']
    db.insert('user_settings', {'user': uid})
    db.insert('user_info', {'user': uid, 'nick': phone})
示例#5
0
def get_enter_info(enterprise_id):
    sql = 'select ' \
          'e.id, e.company as companyId, e.name, e.address, ' \
          'e.time, e.nick, e.introduction, e.jobs, e.apply, e.collect ' \
          'from company_info as e where e.company = %s' % enterprise_id
    r = _db.query_one(sql)
    if r is not None:
        r['time'] = unicode(r['time'])[0:10]
    return r
示例#6
0
def get_enter_info(enterprise_id):
    sql = 'select ' \
          'e.id, e.company as companyId, e.name, e.address, ' \
          'e.time, e.nick, e.introduction, e.jobs, e.apply, e.collect ' \
          'from company_info as e where e.company = %s' % enterprise_id
    r = _db.query_one(sql)
    if r is not None:
        r['time'] = unicode(r['time'])[0: 10]
    return r
示例#7
0
def login(email, password):
    r = _db.query_one(
        'select id, email, password, salt from company where email = %s' %
        email)
    if r is None:
        return {'status': False, 'msg': '该邮箱未被注册'}
    if not util.bcrypt_check(password + r['salt'], r['password']):
        return {'status': False, 'msg': '邮箱或密码错误'}
    else:
        return {'status': True, 'cid': r['id']}
示例#8
0
def register_company(email, password):
    salt = util.generate_salt()
    _db.insert(
        'company', {
            'email': email,
            'password': util.bcrypt_password(password + salt),
            'salt': salt
        })
    cid = _db.query_one('select id from company where email = %s' % email)
    _db.insert('company_info', {'company': cid})
    return True
示例#9
0
文件: job.py 项目: coocol/server_web
def get_job_info(job_id):
    sql = 'select ' \
          'j.id, j.name, j.address, j.time, j.apply, j.collect, j.company as companyId, ' \
          'j.content, j.requirement, j.period, j.salary, j.other, c.name as company ,c.nick ' \
          'from job as j ' \
          'join company_info as c ' \
          'on j.company = c.company and j.id = %s;' % job_id
    r = _db.query_one(sql)
    if r is not None:
        r['time'] = unicode(r['time'])[0:10]
    return r
示例#10
0
文件: job.py 项目: coocol/server_app
def get_job_info(job_id):
    sql = 'select ' \
          'j.id, j.name, j.address, j.time, j.apply, j.collect, j.company as companyId, ' \
          'j.content, j.requirement, j.period, j.salary, j.other, c.name as company ,c.nick ' \
          'from job as j ' \
          'join company_info as c ' \
          'on j.company = c.company and j.id = %s;' % job_id
    r = _db.query_one(sql)
    if r is not None:
        r['time'] = unicode(r['time'])[0: 10]
    return r
示例#11
0
文件: user.py 项目: coocol/server_app
def upload_resume(user_id, file_name):
    if _db.query_one('select id from resume where user = %s' % user_id) is None:
        _db.insert('resume', {'user': user_id})
    _db.execute('update resume set file = "%s" where user = %s' % (file_name, user_id))
示例#12
0
def check_token(uid, token):
    u = db.query_one('select token from user where id = %s' % uid)
    return u is not None and u['token'] == token
示例#13
0
文件: user.py 项目: coocol/server_app
def update_resume(user_id, field, value):
    if _db.query_one('select id from resume where user = %s' % user_id) is None:
        _db.insert('resume', {'user': user_id})
    _db.execute('update resume set %s = "%s" where user = %s' % (field, value, user_id))
示例#14
0
def is_email_existed(email):
    return _db.query_one('select id from company where email = %s' %
                         email) is not None
示例#15
0
def get_user_info(user_id):
    sql = 'select u.user as Id, u.nick, u.signature, p.phone ' \
          'from user_info as u join user as p on p.id = u.user and u.user = %s' % user_id
    return _db.query_one(sql)
示例#16
0
文件: user.py 项目: coocol/server_app
def get_user_info(user_id):
    sql = 'select u.user as Id, u.nick, u.signature, p.phone ' \
          'from user_info as u join user as p on p.id = u.user and u.user = %s' % user_id
    return _db.query_one(sql)
示例#17
0
def is_enterprise_collected(user_id, enterprise_id):
    sql = 'select id from collect_enterprise where user = %s and company = %s' % (user_id, enterprise_id)
    return _db.query_one(sql) is not None
示例#18
0
def collect(user_id, enter_id):
    sql = 'select id from collect_enterprise where user = %s and company = %s' % (user_id, enter_id)
    if _db.query_one(sql) is None:
        _db.insert('collect_enterprise', {'user': user_id, 'company': enter_id})
        return True
    return False
示例#19
0
文件: job.py 项目: coocol/server_app
def get_user_job_status(job_id, user_id):
    sql = 'select id from apply_job where job = %s and user = %s' % (job_id, user_id)
    is_apply = True if _db.query_one(sql) is not None else False
    sql = 'select id from collect_job where job = %s and user = %s' % (job_id, user_id)
    is_collect = True if _db.query_one(sql) is not None else False
    return {'apply': is_apply, 'collect': is_collect}
示例#20
0
文件: user.py 项目: coocol/server_app
def is_apply(user_id):
    sql = 'select id from resume where user = %s and name is not null and phone is not null and email is not null' % \
          user_id
    return True if _db.query_one(sql) is not None else False
示例#21
0
def get_resume(user_id):
    sql = 'select id, phone, email, birthday, college_time as collegeTime, experience, profess, ' \
          'gender, place, hometown, award, english, description, name ' \
          'from resume where user = %s ' % user_id
    return _db.query_one(sql)
示例#22
0
文件: user.py 项目: coocol/server_app
def get_resume(user_id):
    sql = 'select id, phone, email, birthday, college, college_time as collegeTime, experience, profess, ' \
          'gender, place, hometown, award, english, description, file, name ' \
          'from resume where user = %s ' % user_id
    return _db.query_one(sql)