Exemplo n.º 1
0
    def get(self, id):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None

        # 文章详情信息获取
        dbsession = _connectDBdata_()
        dbarticleinfo = dbsession.query(article, employee_article.is_invalid)\
            .join(employee_article, and_(employee_article.article_id == article.id, employee_article.employee_id == user.employee.id))\
            .filter(article.id == id, employee_article.is_invalid == 0).one_or_none()
        if dbarticleinfo is None:
            return None, 404, None

        dbsession.query(employee_article)\
            .filter(and_(employee_article.article_id == id, employee_article.employee_id == user.employee.id, employee_article.is_read == 0))\
            .update({'is_read': 1})

        reponse = {}
        reponse['id'] = dbarticleinfo[0].id
        reponse['title'] = dbarticleinfo[0].title
        reponse['source'] = dbarticleinfo[0].source_site
        reponse['source_url'] = dbarticleinfo[0].url
        reponse['content'] = dbarticleinfo[0].text
        reponse['time'] = dbarticleinfo[0].publish_time.strftime(
            '%Y/%m/%d %H:%M:%S')

        dbsession.commit()
        dbsession.close()
        return reponse, 200, None
Exemplo n.º 2
0
 def __init__(self, session_id, authorization, blueprint):
     self.authorization = authorization
     self.session_id = session_id
     self.blueprint = blueprint
     dbsession = _connectDBdata_()
     self.valid = dbsession.query(session).filter(
         session.id == session_id).count() > 0
     dbsession.close()
Exemplo n.º 3
0
 def session(self):
     if self._session is None:
         if self.valid and self.session_id:
             # TODO: test
             dbsession = _connectDBdata_()
             self._session = dbsession.query(session).filter(
                 session.id == self.session_id).one()
             dbsession.close()
     return self._session
Exemplo n.º 4
0
 def employee(self):
     if self._employee is None:
         if self.valid:
             sess = self.session
             if sess:
                 dbsession = _connectDBdata_()
                 self._employee = dbsession.query(employee).filter(
                     employee.id == sess.employee_id).one_or_none()
                 dbsession.close()
     return self._employee
Exemplo n.º 5
0
    def get(self):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None
        respone = {}
        dbsession = _connectDBdata_()

        # 获取用户信息
        dbemployee = dbsession.query(
            employee.realname,
            employee.picture).filter(employee.id == user.employee.id).one()
        var_employ = {}
        var_employ['realname'] = dbemployee[0]
        var_employ['picture'] = alicdnserver + dbemployee[1]
        respone['employee'] = var_employ

        # 新增公司舆情数
        respone['new_company_news'] = dbsession.query(article.id)\
            .join(company_article, article.id == company_article.article_id)\
            .join(follow_company, follow_company.company_id == company_article.company_id)\
            .join(employee_article, employee_article.article_id == article.id)\
            .filter(and_(follow_company.is_follow == 1, employee_article.is_invalid == 0, follow_company.employee_id == user.employee.id, employee_article.employee_id == user.employee.id, employee_article.is_read == 0))\
            .count()

        # 新增行业舆情数
        respone['new_industry_news'] = dbsession.query(article.id)\
            .join(industry_article, article.id == industry_article.article_id)\
            .join(follow_industry, follow_industry.industry_id == industry_article.industry_id)\
            .join(employee_article, employee_article.article_id == article.id)\
            .filter(and_(follow_industry.is_follow == 1, employee_article.is_invalid == 0, follow_industry.employee_id == user.employee.id, employee_article.employee_id == user.employee.id, employee_article.is_read == 0))\
            .count()

        # 公司第一页舆情列表
        var_articles = []
        db = dbsession.query(article.id, article.title, company.company_name, article.publish_time, employee_article.is_read)\
            .join(company_article, article.id == company_article.article_id)\
            .join(follow_company, follow_company.company_id == company_article.company_id)\
            .join(company, company.id == company_article.company_id)\
            .join(employee_article, employee_article.article_id == article.id)\
            .filter(and_(follow_company.is_follow == 1, employee_article.is_invalid == 0, follow_company.employee_id == user.employee.id, employee_article.employee_id == user.employee.id))\
            .order_by(article.publish_time.desc(),article.id.desc()).limit(20)
        dbsession.close()
        for row in db:
            var_article = {}
            var_article['id'] = row[0]
            var_article['title'] = row[1]
            var_article['follow_type'] = 1
            var_article['follow_name'] = row[2]
            var_article['time'] = row[3].strftime('%Y/%m/%d %H:%M:%S')
            var_article['is_read'] = row[4]
            var_articles.append(var_article)
        respone['articles'] = var_articles
        return respone, 200, None
Exemplo n.º 6
0
    def delete(self):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.employee.id is None:
            return None, 403, None

        follow_type = self.json['follow_type']
        id = self.json['id']

        datenow = datetime.now()
        dbsession = _connectDBdata_()

        try:
            #取消关注公司信息
            if follow_type == 1:
                dbcompanyinfo = dbsession.query(follow_company).filter(
                    and_(follow_company.employee_id == user.employee.id),
                    follow_company.company_id == id).one_or_none()
                if dbcompanyinfo is not None:
                    dbcompanyinfo.is_follow = 0
                    dbcompanyinfo.unfollow_time = datenow
                    dbsession.add(dbcompanyinfo)
                    dbsession.query(employee_follow).filter(
                        employee_follow.id == user.employee.id,
                        employee_follow.company_count - 1 >= 0).update({
                            'company_count':
                            employee_follow.company_count - 1
                        })
            #取消关注行业信息
            if follow_type == 2:
                for row in dbsession.execute(
                        'select id from industry where FIND_IN_SET(id,getChildrenOrg({id}))'
                        .format(id=id)).fetchall():
                    dbindustryinfo = dbsession.query(follow_industry).filter(
                        and_(follow_industry.employee_id == user.employee.id,
                             follow_industry.industry_id == row[0]),
                        follow_industry.is_follow == 1).one_or_none()
                    if dbindustryinfo is not None:
                        dbindustryinfo.is_follow = 0
                        dbindustryinfo.unfollow_time = datenow
                        dbsession.add(dbindustryinfo)
                        dbsession.query(employee_follow).filter(
                            and_(employee_follow.id == user.employee.id),
                            employee_follow.industry_count - 1 >= 0).update({
                                'industry_count':
                                employee_follow.industry_count - 1
                            })
            dbsession.commit()
            return None, 204, None
        except:
            return None, 400, None
        finally:
            dbsession.close()
Exemplo n.º 7
0
    def get(self):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None

        dbsession = _connectDBdata_()
        dbfollow = dbsession.query(employee_follow).filter(
            employee_follow.id == user.employee.id).one()
        respone = {}
        # 公司关注信息
        if dbfollow.company_count > 0:
            db = dbsession.query(company.id, company.company_name, company.short_name).join(follow_company, company.id == follow_company.company_id).filter(
                and_(follow_company.employee_id == user.employee.id), follow_company.is_follow == 1).order_by(follow_company.follow_time.desc()).all()
            dbsession.close()
            companyinfoarray = []
            for row in db:
                companyinfodic = {}
                companyinfodic['id'] = row[0]
                companyinfodic['company_name'] = row[1]
                companyinfodic['short_name'] = row[2]
                companyinfoarray.append(companyinfodic)
            respone['company'] = companyinfoarray
        else:
            dbsession.close()
            respone['company'] = []
        # 行业关注信息
        if dbfollow.industry_count > 0:
            db = dbsession.query(industry).join(follow_industry, industry.id == follow_industry.industry_id).filter(and_(
                follow_industry.employee_id == user.employee.id), follow_industry.is_follow == 1).order_by(follow_industry.follow_time.desc()).all()
            dbsession.close()
            industryinfoarray = []
            for row in db:
                if row.parent_id is not None:
                    parents = [(t1) for t1 in db if t1.id == row.parent_id]
                    if len(parents) > 0:
                        continue
                children = [(t1) for t1 in db if t1.parent_id == row.id]
                industryinfodic = {}
                industryinfodic['id'] = row.id
                industryinfodic['industry_name'] = row.industry_name
                industryinfodic['children_count'] = len(children)
                industryinfodic['children_industry'] = factorial(row.id, db)
                industryinfoarray.append(industryinfodic)
            respone['industry'] = industryinfoarray
        else:
            dbsession.close()
            respone['industry'] = []
        return respone, 200, None
Exemplo n.º 8
0
 def get(self):
     user = self.get_current_user()
     if not user.valid:
         return None, 401, None
     if user.session.employee_id is None:
         return None, 403, None
     dbsession = _connectDBdata_()
     dbemployeefollow = dbsession.query(employee_follow).filter(
         employee_follow.id == user.employee.id).one_or_none()
     dbsession.close()
     if dbemployeefollow is not None:
         response = {
             'company': dbemployeefollow.company_count,
             'industry': dbemployeefollow.industry_count
         }
         return response, 200, None
     return None, 200, None
Exemplo n.º 9
0
    def post(self):
        code = self.json['code']
        random = self.json['random']
        # 获取微信opneid等信息
        url = 'https://api.weixin.qq.com/sns/jscode2session?appid={APPID}&secret={SECRET}&js_code={JSCODE}&grant_type=authorization_code'.format(
            APPID=appid, SECRET=appscred, JSCODE=code)
        req = urllib.request.Request(url)
        with urllib.request.urlopen(req) as response:
            the_page = response.read()
        the_page_utf_8 = the_page.decode('utf-8')
        weixininfo = json.loads(the_page_utf_8)
        if weixininfo.get('openid') is None:
            return {'code': 400, 'message': 'code 无效'}, 400, None

        session_key = weixininfo['session_key']
        openid = weixininfo['openid']
        unionid = weixininfo.get('unionid', None)

        # #微信信息插入session表
        respone = {}
        id = uuid.uuid1()
        expiretime = datetime.now() + timedelta(days=7)
        sessioninfo = session(id=str(id),
                              openid=openid,
                              session_key=session_key,
                              random=random,
                              expire_time=expiretime,
                              unionid=unionid)
        respone['session'] = sessioninfo.id
        respone['expire_time'] = sessioninfo.expire_time.strftime(
            '%Y/%m/%d %H:%M:%S')

        #判断employee是否绑定openid,绑定给session的employee赋值
        dbsession = _connectDBdata_()
        dbemployeeid = dbsession.query(
            employee.id).filter_by(openid=openid).one_or_none()
        if dbemployeeid:
            sessioninfo.employee_id = dbemployeeid[0]
            respone['is_binding'] = 1
        else:
            respone['is_binding'] = 0
        dbsession.add(sessioninfo)
        dbsession.commit()
        dbsession.close()
        return respone, 200, None
Exemplo n.º 10
0
    def post(self):
        user = self.get_current_user()
        if not user.valid:
            return {"code": 0, "message": "未登录"}, 401, None

        username = self.json['username']
        password = self.json['password']
        # 判断账户密码是否输入
        if username and password:
            dbsession = _connectDBdata_()
            try:
                dbemployee = dbsession.query(employee).filter_by(
                    username=username).one_or_none()
                # 判断账号是否存在
                if dbemployee and dbemployee.password:
                    passwordmd5 = hashlib.md5()
                    passwordmd5.update(password.encode(encoding='utf-8'))
                    # 判断密码正确性
                    if dbemployee.password == passwordmd5.hexdigest().upper():
                        # 判断employee是否已绑定openid,否则执行绑定操作
                        if dbemployee.openid is not None and dbemployee.openid != user.session.openid:
                            return {
                                "code": 400,
                                "message": "账号已绑定其他微信"
                            }, 400, None
                        dbemployee.session_key = user.session.session_key
                        dbemployee.openid = user.session.openid
                        dbemployee.unionid = user.session.unionid
                        dbsession.add(dbemployee)
                        user.session.employee_id = dbemployee.id
                        dbsession.add(user.session)
                        dbsession.commit()
                        return None, 204, None
                    else:
                        return {"code": 400, "message": "密码错误"}, 400, None
                else:
                    return {"code": 400, "message": "账号不存在"}, 400, None
            except:
                return {"code": 400, "message": "登录失败,请刷新重试"}, 400, None
            finally:
                dbsession.close()
        else:
            return {"code": 400, "message": "请输入账号或者密码"}, 400, None
Exemplo n.º 11
0
    def put(self, id):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None

        dbsession = _connectDBdata_()
        try:
            dbsession.query(employee_article).filter(
                and_(employee_article.employee_id == user.employee.id,
                     employee_article.article_id == id,
                     employee_article.is_invalid == 0)).update({
                         'is_invalid': 1
                     })
            dbsession.commit()
            return None, 204, None
        except:
            return None, 400, None
        finally:
            dbsession.close()
Exemplo n.º 12
0
    def post(self):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None
        follow_type = self.json['follow_type']
        id = self.json['id']

        datenow = datetime.now()
        dbsession = _connectDBdata_()
        try:
            #关注公司信息
            if follow_type == 1:
                dbcompanyinfo = dbsession.query(follow_company).filter(
                    and_(follow_company.employee_id == user.employee.id),
                    follow_company.company_id == id).one_or_none()
                #对已取消进行关注操作
                if dbcompanyinfo:
                    if dbcompanyinfo.is_follow == 1:
                        return None, 204, None
                    dbcompanyinfo.is_follow = 1
                    dbcompanyinfo.follow_time = datenow
                #第一次关注
                else:
                    dbcompanyinfo = follow_company(
                        employee_id=user.employee.id, company_id=id)
                    dbsession.add(dbcompanyinfo)
                dbsession.query(employee_follow).filter(
                    employee_follow.id == user.employee.id).update(
                        {'company_count': employee_follow.company_count + 1})

                #员工关注文章
                faker_employee_article = []
                for row in dbsession.query(company_article.article_id,article.publish_time)\
                    .join(article,article.id == company_article.article_id)\
                    .filter(company_article.company_id == dbcompanyinfo.company_id)\
                .filter(~exists().where(employee_article.article_id == company_article.article_id).where(employee_article.employee_id == user.employee.id)).all():
                    dbemployeearticleinfo = employee_article(
                        employee_id=user.employee.id,
                        article_id=row[0],
                        is_read=0,
                        is_invalid=0,
                        is_send=1,
                        send_time=datenow)
                    if row[1].strftime('%Y/%m/%d') < datenow.strftime(
                            '%Y/%m/%d'):
                        dbemployeearticleinfo.is_read = 1
                    faker_employee_article.append(dbemployeearticleinfo)
                dbsession.add_all(faker_employee_article)
            #关注行业信息
            if follow_type == 2:
                for row in dbsession.execute(
                        'select id from industry where FIND_IN_SET(id,getChildrenOrg({id}))'
                        .format(id=id)).fetchall():
                    dbindustryinfo = dbsession.query(follow_industry).filter(
                        and_(follow_industry.employee_id == user.employee.id,
                             follow_industry.industry_id ==
                             row[0])).one_or_none()
                    #对已取消进行关注操作
                    if dbindustryinfo:
                        if dbindustryinfo.is_follow == 0:
                            dbindustryinfo.is_follow = 1
                            dbindustryinfo.follow_time = datenow
                            dbsession.add(dbindustryinfo)
                        else:
                            continue
                    #第一次关注
                    else:
                        dbindustryinfo = follow_industry(
                            employee_id=user.employee.id, industry_id=row[0])
                        dbsession.add(dbindustryinfo)
                    dbsession.query(employee_follow).filter(
                        employee_follow.id == user.employee.id).update({
                            'industry_count':
                            employee_follow.industry_count + 1
                        })

                    #员工关注文章
                    faker_employee_article = []
                    for row in dbsession.query(industry_article.article_id,article.publish_time)\
                        .join(article,article.id == industry_article.article_id)\
                        .filter(industry_article.industry_id == dbindustryinfo.industry_id)\
                    .filter(~exists().where(employee_article.article_id == industry_article.article_id).where(employee_article.employee_id == user.employee.id)).all():
                        dbemployeearticleinfo = employee_article(
                            employee_id=user.employee.id,
                            article_id=row[0],
                            is_read=0,
                            is_invalid=0,
                            is_send=1,
                            send_time=datenow)
                        if row[1].strftime('%Y/%m/%d') < datenow.strftime(
                                '%Y/%m/%d'):
                            dbemployeearticleinfo.is_read = 1
                        faker_employee_article.append(dbemployeearticleinfo)
                    dbsession.add_all(faker_employee_article)
            dbsession.commit()
            return None, 204, None
        except:
            return None, 400, None
        finally:
            dbsession.close()
Exemplo n.º 13
0
    def get(self):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None
        key = self.args['key']
        if key is None or len(key) <= 0:
            return None, 404, None
        follow_type = self.args['follow_type']
        searchtype = 0
        if 'type' in self.args:
            searchtype = self.args['type']
        dbsession = _connectDBdata_()
        infoarray = []
        if follow_type == 1:
            # 公司的信息
            dbcompanyinfo = dbsession.query(company.id, company.company_name, company.short_name)\
                .filter(company.company_name.like('%'+key+'%'))
            if searchtype > 0:
                dbcompanyinfo = dbcompanyinfo.join(follow_company, follow_company.company_id == company.id)\
                    .filter(follow_company.employee_id == user.employee.id, follow_company.is_follow == 1)
            dbcompanyinfo = dbcompanyinfo.all()
            dbsession.close()
            for row in dbcompanyinfo:
                infodic = {}
                infodic['id'] = row[0]
                infodic['company_name'] = row[1]
                infodic['short_name'] = row[2]
                infodic['follow_type'] = 1
                infoarray.append(infodic)
        else:
            # 行业信息
            dbindustryinfo = dbsession.query(
                industry)  #.filter(industry.industry_name.like('%'+key+'%'))
            if searchtype > 0:
                dbindustryinfo = dbindustryinfo.join(follow_industry, follow_industry.industry_id == industry.id)\
                    .filter(follow_industry.employee_id == user.employee.id, follow_industry.is_follow == 1)
            dbindustryinfo = dbindustryinfo.all()
            dbsession.close()
            for row in [
                    t1 for t1 in dbindustryinfo if key in t1.industry_name
            ]:
                children = [(t1) for t1 in dbindustryinfo
                            if t1.parent_id == row.id]
                infodic = {}
                infodic['id'] = row.id
                infodic['industry_name'] = row.industry_name
                infodic['children_count'] = len(children)
                infodic['follow_type'] = 2

                _children = []
                for childrenrow in children:
                    childrendic = {}
                    childrendic['id'] = childrenrow.id
                    childrendic['industry_name'] = childrenrow.industry_name
                    _children.append(childrendic)
                infodic['children'] = _children
                infoarray.append(infodic)
        respone = {'follows': infoarray}
        return respone, 200, None
Exemplo n.º 14
0
    def get(self):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None
        page_index = self.args['page_index']
        follow_type = self.args['follow_type']
        key = ''
        if 'key' in self.args:
            key = self.args['key'].strip()  #TODO 特殊字符过滤

        page_size = 20
        skip = (page_index - 1) * page_size
        take = page_index * page_size

        respone = {}
        articles = []

        # 文章信息获取
        dbsession = _connectDBdata_()
        if follow_type == 1:
            articles = dbsession.query(article.id, article.title, company.company_name, article.publish_time, employee_article.is_read)\
                .join(company_article, article.id == company_article.article_id)\
                .join(follow_company, follow_company.company_id == company_article.company_id)\
                .join(company, company.id == company_article.company_id)\
                .join(employee_article, employee_article.article_id == article.id)\
                .filter(and_(follow_company.is_follow == 1, employee_article.is_invalid == 0, follow_company.employee_id == user.employee.id, employee_article.employee_id == user.employee.id))
            if len(key):
                articles = articles.filter(company.company_name == key)

            # 计算数量
            respone['count'] = articles.count()
            articles = articles.order_by(article.publish_time.desc(),
                                         article.id.desc()).slice(skip, take)
        else:
            articles = dbsession.query(article.id, article.title, industry.industry_name, article.publish_time, employee_article.is_read)\
                .join(industry_article, article.id == industry_article.article_id)\
                .join(follow_industry, follow_industry.industry_id == industry_article.industry_id)\
                .join(industry, industry.id == industry_article.industry_id)\
                .join(employee_article, employee_article.article_id == article.id)\
                .filter(and_(follow_industry.is_follow == 1, employee_article.is_invalid == 0, follow_industry.employee_id == user.employee.id, employee_article.employee_id == user.employee.id))
            if len(key):
                articles = articles.filter(industry.industry_name == key)

            # 计算数量
            respone['count'] = articles.count()
            articles = articles.order_by(article.publish_time.desc(),
                                         article.id.desc()).slice(skip, take)
        dbsession.close()

        articleinfoarray = []
        for row in articles:
            articleinfodic = {}
            articleinfodic['id'] = row[0]
            articleinfodic['title'] = row[1]
            articleinfodic['follow_name'] = row[2]
            articleinfodic['follow_type'] = follow_type
            articleinfodic['is_read'] = row[4]
            articleinfodic['time'] = row[3].strftime('%Y/%m/%d %H:%M:%S')
            articleinfoarray.append(articleinfodic)
        respone['articles'] = articleinfoarray
        return respone, 200, None
Exemplo n.º 15
0
    def post(self):
        user = self.get_current_user()
        if not user.valid:
            return None, 401, None
        if user.session.employee_id is None:
            return None, 403, None

        company_name = self.json['company_name']
        if company_name is None or len(company_name) <= 0:
            return None, 400, None
        short_name = self.json['short_name']
        if short_name is None or len(short_name) <= 0:
            return None, 400, None
        datenow = datetime.now()
        dbsession = _connectDBdata_()
        try:
            dbcompanyinfo = dbsession.query(company).filter(
                company.company_name == company_name).one_or_none()
            # 添加新的公司
            if dbcompanyinfo is None:
                dbcompanyinfo = company(company_name=company_name,
                                        short_name=short_name,
                                        is_chinaipo=0,
                                        url='')
                dbsession.add(dbcompanyinfo)
                dbsession.flush()

                dbfollowcompany = follow_company(employee_id=user.employee.id,
                                                 company_id=dbcompanyinfo.id)
                dbsession.add(dbfollowcompany)
            else:
                dbfollowcompany = dbsession.query(follow_company).filter(
                    follow_company.company_id == dbcompanyinfo.id,
                    follow_company.employee_id ==
                    user.employee.id).one_or_none()
                if dbfollowcompany:
                    # 公司已经存在,且已取消关注数据
                    if dbfollowcompany.is_follow == 0:
                        dbfollowcompany.is_follow = 1
                        dbfollowcompany.follow_time = datetime.now()
                    #公司存在,并且已经关注
                    else:
                        return None, 204, None
                else:
                    # 公司已经存在,无关注数据
                    dbfollowcompany = follow_company(
                        employee_id=user.employee.id,
                        company_id=dbcompanyinfo.id)
                    dbsession.add(dbfollowcompany)
            dbsession.query(employee_follow).filter(
                employee_follow.id == user.employee.id).update(
                    {'company_count': employee_follow.company_count + 1})

            # 公司和文章关联
            dbarticleinfo = dbsession.query(article.id).filter(~exists().where(
                company_article.article_id == article.id).where(
                    company_article.company_id == dbcompanyinfo.id)).filter(
                        article.text.like('%' + short_name + '%')).all()
            companyarticle = []
            for row in dbarticleinfo:
                dbcompanyarticleinfo = company_article(
                    company_id=dbcompanyinfo.id, article_id=row[0])
                companyarticle.append(dbcompanyarticleinfo)
            dbsession.add_all(companyarticle)
            dbsession.flush()

            # 操作员工关注文章
            faker_employee_article = []
            for row in dbsession.query(company_article.article_id, article.publish_time)\
                .join(article, article.id == company_article.article_id)\
                .filter(company_article.company_id == dbcompanyinfo.id)\
                    .filter(~exists().where(employee_article.article_id == company_article.article_id).where(employee_article.employee_id == user.employee.id)).all():
                dbemployeearticleinfo = employee_article(
                    employee_id=user.employee.id,
                    article_id=row[0],
                    is_read=0,
                    is_invalid=0,
                    is_send=1,
                    send_time=datetime.now())
                if row[1].strftime('%Y/%m/%d') < datenow.strftime('%Y/%m/%d'):
                    dbemployeearticleinfo.is_read = 1
                faker_employee_article.append(dbemployeearticleinfo)
            dbsession.add_all(faker_employee_article)
            dbsession.commit()
            dbsession.close()
            # 爬取文
            try:
                key_code = urllib.request.quote(short_name)  # 因为URL里含中文,需要进行编码
                url_all = spiderurl + key_code
                req = urllib.request.Request(url_all)
                response = urllib.request.urlopen(req)
                the_page = response.read()
            except:
                print('爬取失败')
            return None, 204, None
        except:
            return None, 400, None
        finally:
            dbsession.close()