예제 #1
0
 def selAnswer(self, totalright, continueright, dbCursor=None):
     #处理题目
     data = Smart_Mysql.query(
         "SELECT * FROM tbActAnswer WHERE NOT EXISTS ( \
                             SELECT iQuestionId FROM tbActAnswerLog WHERE \
                             tbActAnswerLog.iQuestionId = tbActAnswer.id \
                             AND iUserId = %s) ORDER BY RAND() LIMIT 1",
         param=[self.user_id],
         dbCursor=dbCursor)
     question_id = data[0].get('id')
     Smart_Mysql.insert(
         "INSERT INTO tbActAnswerLog SET iUserId=%s, \
                                 iQuestionId=%s, iAnswerIndex=-1, iRight=-1, \
                                 iTotalRight=%s, iContinueRight=%s",
         param=[self.user_id, question_id, totalright, continueright],
         dbCursor=dbCursor)
     return data[0]
예제 #2
0
    def main(self, user_id):
        user_id = user_id
        data = {}
        sql = "select id from tbActSignin where iUserId = %s AND \
            to_days(dtCreateTime)=to_days(now())"

        check = Smart_Mysql.query(sql, param=[user_id])
        if check:
            data['ret'] = -2
            data['msg'] = '打卡失败:已经打卡'
        else:
            sql = "INSERT INTO tbActSignin SET iUserId = %s"
            suc = Smart_Mysql.insert(sql, param=[user_id])
            if suc:
                data['ret'] = 0
                data['msg'] = '打卡成功'
            else:
                data['ret'] = -2
                data['msg'] = '打卡出现异常'
        return data
예제 #3
0
 def selQuestion(self, question_id, dbCursor=None):
     # 根据id查题目
     sql = f"SELECT * FROM tbActAnswer WHERE id = {question_id}"
     return Smart_Mysql.query(sql, dbCursor=dbCursor)
예제 #4
0
    def checkLog(self, dbCursor=None):
        # 查询最新一条记录
        sql = f"SELECT * FROM tbActAnswerLog WHERE iUserId = {self.user_id} \
                ORDER BY dtCreateTime DESC LIMIT 1 FOR UPDATE"

        return Smart_Mysql.query(sql, dbCursor=dbCursor)