Ejemplo n.º 1
0
 def get_user_by(self,
                 seqid=None,
                 phoneNumber=None,
                 email=None,
                 token=None,
                 nickname=None):
     '''
     查询用户信息
     return: 用户对象
     '''
     if seqid:
         strSql = 'select * from [User] where seqid=?'
         return DB.ExecSqlQuery(strSql, seqid)
     elif phoneNumber:
         strSql = 'select * from [User] where phoneNumber=?'
         return DB.ExecSqlQuery(strSql, phoneNumber)
     elif email:
         strSql = 'select * from [User] where email=?'
         return DB.ExecSqlQuery(strSql, email)
     elif token:
         strSql = 'select * from [User] where token=?'
         return DB.ExecSqlQuery(strSql, token)
     elif nickname:
         strSql = 'select * from [User] where nickname=?'
         return DB.ExecSqlQuery(strSql, nickname)
     else:
         pass
Ejemplo n.º 2
0
    def get_letter_by(self, userid=None, friendid=None, status=None):
        '''
        获取聊天记录
        return 消息字典
        '''
        # 获取未读信息
        if status == 0 and friendid:
            strSql = f"select * from Letter where status={status} and userid={userid} and friendid={friendid} order by seqid"
            return DB.ExecSqlQuery(strSql)

        # 获取聊天信息
        if userid and friendid:
            strSql = f"select * from Letter where userid={userid} and friendid={friendid} order by seqid"
            return DB.ExecSqlQuery(strSql)
Ejemplo n.º 3
0
 def get_all_art(self, artNum):
     '''
     获取所有用户所有动态
     artNum: 获取的动态数量
     return 多个动态字典
     '''
     strSql = f'select TOP ({artNum}) {strSqlItem} where Article.isPublic=1 order by Article.doTime DESC'
     return DB.ExecSqlQuery(strSql)
Ejemplo n.º 4
0
 def get_friends(self, userid):
     '''
     获取所有好友
     userid: 用户seqid
     return 好友seqid列表
     '''
     strSql = f'select * from RelationUsers where userid in ({userid})'
     return DB.ExecSqlQuery(strSql)
Ejemplo n.º 5
0
 def get_avatar(self, userid):
     '''
     获取头像
     userid: 用户id
     return 图片对象 or false
     '''
     strSql = 'select * from Img where imgType=2 and imgUser=? order by seqid'
     return DB.ExecSqlQuery(strSql, userid)
Ejemplo n.º 6
0
 def get_all_comments(self, relationArtId):
     '''
     获取动态所有的评论
     relationArtId: 评论关联的动态seqid
     return: 所有评论数据 字典
     '''
     strSql = 'select * from T_Comment where relationArticlesId=? order by doTime DESC'
     return DB.ExecSqlQuery(strSql, relationArtId)
Ejemplo n.º 7
0
 def get_comment(self, seqid):
     '''
     获取单个评论
     seqid: 评论seqid
     return: 评论数据 字典
     '''
     strSql = 'select * from T_Comment where seqid=?'
     return DB.ExecSqlQuery(strSql, seqid)
Ejemplo n.º 8
0
 def get_friend(self, userid, friendid):
     '''
     查询好友
     userid: 用户seqid
     return true or false
     '''
     strSql = 'select * from RelationUsers where userid=? and friendid=?'
     rows, _ = DB.ExecSqlQuery(strSql, userid, friendid)
     if rows:
         return True
     else:
         return False
Ejemplo n.º 9
0
 def get_img_by(self,
                imgName=None,
                headPic=None,
                picValue=None,
                imgType=None,
                imgUser=None,
                imgArticle=None):
     '''
     获取多个图片
     返回 字典数据
     '''
     if imgName:
         strSql = 'select * from Img where imgName=?'
         return DB.ExecSqlQuery(strSql, imgName)
     elif headPic:
         strSql = 'select * from Img where headPic=?'
         return DB.ExecSqlQuery(strSql, headPic)
     elif picValue:
         strSql = 'select * from Img where picValue=?'
         return DB.ExecSqlQuery(strSql, picValue)
     elif imgType:
         strSql = 'select * from Img where imgType=?'
         return DB.ExecSqlQuery(strSql, imgType)
     elif imgUser:
         strSql = 'select * from Img where imgUser=? and imgType=1'
         return DB.ExecSqlQuery(strSql, imgUser)
     elif imgArticle:
         strSql = 'select * from Img where  imgArticle=?'
         return DB.ExecSqlQuery(strSql, imgArticle)
     else:
         pass
Ejemplo n.º 10
0
    def select_likes(self, seqid=None, artid=None):
        '''
        查询点赞记录
        seqid:  用户seqid
        srtid:  动态seqid
        return: id列表
        '''
        # 查询某个用户的某条动态点赞记录
        if seqid and artid:
            strSql = 'select seqid from RelationLikes where userid=? and artid=?'
            return DB.ExecSqlQuery(strSql, seqid, int(artid))

        # 查询某个用户所有点赞记录
        elif seqid and not artid:
            strSql = 'select artid from RelationLikes where userid=?'
            return DB.ExecSqlQuery(strSql, int(seqid))

        # 查询某个动态点赞的所有用户
        elif not seqid and artid:
            strSql = 'select userid from RelationLikes where artid=?'
            return DB.ExecSqlQuery(strSql, int(artid))
        else:
            pass
Ejemplo n.º 11
0
 def get_user_all_arts(self, relationUserId, isPublic=1):
     '''
     搜索某个用户所有动态
     relationUserId: 动态所属用户的id
     isPublic: 是否公开 0不公开, 1公开, 2所有
     return 多个动态字典
     '''
     if isPublic == 2:
         strSql = f'select {strSqlItem} where relationUserId=? order by Article.doTime DESC'
     elif isPublic == 1:
         strSql = f'select {strSqlItem} where relationUserId=? and Article.isPublic=1 order by Article.doTime DESC'
     elif isPublic == 0:
         strSql = f'select {strSqlItem} where relationUserId=? and Article.isPublic=0 order by Article.doTime DESC'
     return DB.ExecSqlQuery(strSql, int(relationUserId))
Ejemplo n.º 12
0
    def get_user_one_art(self, artSeqid, isPublic=1):
        '''
        获取单个动态
        artSeqid: 动态id
        isPublic: 是否公开 0不公开, 1公开, 2所有
        return 单个动态字典
        '''
        if isPublic == 2:
            strSql = f'select {strSqlItem} where Article.seqid=?'
        elif isPublic == 1:
            strSql = f'select {strSqlItem} where Article.seqid=? and Article.isPublic=1'
        elif isPublic == 0:
            strSql = f'select {strSqlItem} where Article.seqid=? and Article.isPublic=0'

        return DB.ExecSqlQuery(strSql, artSeqid)
Ejemplo n.º 13
0
 def get_admin(self, seqid=None, userName=None):
     if seqid:
         strSql = f'select * from T_admin where seqid={seqid}'
     elif userName:
         strSql = f'select * from T_admin where userName={userName}'
     return DB.ExecSqlQuery(strSql)