Exemple #1
0
 def get_report(self, ser):
     with mysql() as cursor:
         sql = 'SELECT * FROM report where ser = %s'
         cursor.execute(sql, (ser, ))
         result = cursor.fetchone()
         # 获取查询结果
         return result
Exemple #2
0
 def list_attachs(self, sers):
     with mysql() as cursor:
         sql = 'SELECT filename FROM attach where ser in (%s)' % ','.join(
             ['%s'] * len(sers))
         cursor.execute(sql, sers)
         result = cursor.fetchall()
         # 获取查询结果
         return result
Exemple #3
0
    def add_report(self, imgs, reportInfo):
        try:
            if imgs:  # 如果有上传图片
                img_ids = []
                for i in imgs:
                    with mysql() as cursor:
                        sql = "INSERT INTO attach(filename) VALUES (%s)"
                        cursor.executemany(sql, (i, ))
                    img_ids.append(str(cursor.lastrowid))
                reportInfo.append(','.join(img_ids))
            else:
                reportInfo.append('')

            with mysql() as cursor:
                sql = "INSERT INTO report(title,content,informer,informerPhone,informerAddress,Attach) VALUES (%s, %s, %s, %s, %s, %s)"
                cursor.execute(sql, reportInfo)
            return 200, '举报已提交'
        except Exception as ex:
            return 500, '举报提交失败'
Exemple #4
0
 def list_report(self, index, rows):
     with mysql() as cursor:
         sql = 'SELECT * FROM report order by ser desc limit %s,%s'
         cursor.execute(sql, (index, rows))
         result = cursor.fetchall()
         sql = 'SELECT count(1) as count FROM report'
         cursor.execute(sql)
         count = cursor.fetchone()
         # 获取查询结果
         return count, result
Exemple #5
0
 def reply_report(self, ser):
     with mysql() as cursor:
         sql = 'update report set IsReply = True,ReplyTime = %s where ser = %s'
         curtime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
         return cursor.execute(sql, (curtime, ser))