Exemple #1
0
def handleCvupdate(data: schemas.CVupdate,
                   current_user: models.User = Depends(validate_auth),
                   db: Session = Depends(get_db)):
    cv = db.query(models.CVinfo).filter(
        and_(
            models.CVinfo.sno == data.sno,
            models.CVinfo.department == current_user.Department_name)).first()
    if not cv:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='简历信息不存在')
    try:
        if data.state:
            cv.state = data.state
            # 添加记录
            record = models.Record(Owner=current_user.Department_name,
                                   Operator=current_user.Nick,
                                   Operation='将' + cv.name + '的简历状态设置为' +
                                   data.state)
            db.add(record)
            db.commit()
        else:
            cv.sign = data.sign
            record = models.Record(Owner=current_user.Department_name,
                                   Operator=current_user.Nick,
                                   Operation='标记了' +
                                   cv.name if data.sign else '取消了对' + cv.name +
                                   '的标记')
            db.add(record)
            db.commit()
        return {'code': 0}
    except:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='数据库异常')
Exemple #2
0
def handleUpdateShow(current_user: models.User = Depends(validate_auth),
                     Show: bool = Body(..., embed=True),
                     db: Session = Depends(get_db)):
    try:
        current_user.Department.Show = Show
        # 更新记录
        record = models.Record(Owner=current_user.Department_name,
                               Operator=current_user.Nick,
                               Operation='打开了部门展示' if Show else '关闭了部门展示')
        db.add(record)
        db.commit()
        return {'code': 0}
    except:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='展示状态切换失败')
Exemple #3
0
def handleUpdateMsg(current_user: models.User = Depends(validate_auth),
                    Message: List[str] = Body(..., embed=True),
                    db: Session = Depends(get_db)):
    try:
        current_user.Department.Message = str(Message)
        # 添加记录
        record = models.Record(Owner=current_user.Department_name,
                               Operator=current_user.Nick,
                               Operation='更新了信息模板')
        db.add(record)
        db.commit()
        return {'code': 0}
    except:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='信息模板更新失败')
Exemple #4
0
def handleRefuse(refuse_lis: List[schemas.Setting_param],
                 current_user: models.User = Depends(validate_auth),
                 db: Session = Depends(get_db)):
    try:
        for refuse_user in refuse_lis:
            user = db.query(models.User).filter(
                models.User.Openid == refuse_user.Openid).first()
            if user:
                record = models.Record(Owner=current_user.Department_name,
                                       Operator=current_user.Nick,
                                       Operation='拒绝了' + user.Nick + '的管理员申请')
                db.delete(user)
                db.add(record)
        db.commit()
    except:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='拒绝申请失败')
    return {'code': 0}
Exemple #5
0
async def sendEmail(token: str = Form(None),
                    files: List[UploadFile] = File(None),
                    recipients: str = Form(...),
                    text: str = Form(...),
                    subject: str = Form(...),
                    db: Session = Depends(get_db)):
    if not token:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='你没有发送邮件的权限')
    if recipients:
        try:
            # 字符串转化为列表
            recipients = recipients.split(',')
            if files:
                await utils.send_email(recipients, subject, text, files)
            else:
                await utils.send_email(recipients, subject, text)
            # 添加记录
            token_decode = jwt.decode(token,
                                      Config.SECRET_KEY,
                                      algorithms=Config.ALGORITHM)
            openid = token_decode['openid']
            current_user = db.query(
                models.User).filter(models.User.Openid == openid).first()
            record = models.Record(Owner=current_user.Department_name,
                                   Operator=current_user.Nick,
                                   Operation='发送了邮件')
            db.add(record)
            db.commit()
            return {'code': 0}
        except:
            raise HTTPException(
                status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                detail='邮件发送失败')
    raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                        detail='没有简历被选中')
Exemple #6
0
def setCVComment(data: schemas.CVcomment,
                 current_user: models.User = Depends(get_user),
                 db: Session = Depends(get_db)):
    cv = db.query(models.CVinfo).filter(
        and_(
            models.CVinfo.sno == data.sno,
            models.CVinfo.department == current_user.Department_name)).first()
    if not cv:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='简历信息不存在')
    try:
        comment_dic = eval(cv.comment)
        comment_dic[current_user.Nick] = data.comment
        cv.comment = str(comment_dic)
        # 添加记录
        record = models.Record(Owner=current_user.Department_name,
                               Operator=current_user.Nick,
                               Operation='对' + cv.name + '进行了面试评价')
        db.add(record)
        db.commit()
        return {'code': 0}
    except:
        raise HTTPException(status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
                            detail='数据库异常')