def find(self,s):
        pp_diy = r"^借书\Z"

        if re.search(pp_diy, str(s.content)):
            from app.model.dll_library import getLib
            from app.model.db_user import User
            temUser = User(s.userName)
            id = temUser.query("ss_num")
            password = temUser.query("password_inf")
            if temUser.query("bind") == 0:
                return '您还未绑定,请先<a href="' + URL + 'bind'+str(s.userName)+'">绑定</a>'
            else:
                book_info, status = getLib(id, password)
                cnt = 1
                if status == '-3':
                    res = '绑定的信息有误,请重新<a href="' + URL + 'bind'+str(s.userName)+'">绑定</a>'
                    return res
                elif not book_info:
                    res = "你还没有借书哦~~~"
                    return res
                else:
                    res = "以下是你借的书及到期时间: \n"
                    for i in book_info:
                        res = res + str(cnt) + ". 《" + i['book']+ "》\n" + "到期时间:" + i['duetime'] +'\n'
                        cnt += 1
                return res + "回复'xj+序号'(如xj1)即可续借相应书籍~~"
        else:
            return 0
Beispiel #2
0
def grade(id):
    JSESSIONID = ""
    if request.method == "GET":
        temUser = User(wxid=id)
        if temUser.query("wxid") == -1:
            return render_template("result.html", words="您还没有绑定帐号,请绑定后重试")
        resp = make_response(render_template("easy_grade.html"))
        return resp
    else:
        imgcode = request.form["imgcode"]
        JSESSIONID = request.cookies.get("JSESSIONID")

        temUser = User(wxid=id)
        id = temUser.query("ss_num")
        pwd = temUser.query("password_edu")

        grade = gradeResult(id, pwd, imgcode, JSESSIONID)
        if grade == -1:
            return render_template("easy_grade.html", info="验证码错误")
        if grade == -2:
            return render_template("easy_grade.html", info="学号或密码错误")
        if grade == -3:
            return render_template("grade.html", info="会话超时")

        grade = MySQLdb.escape_string(str(grade))  # 转换为正常格式
        temUser.update(grade=grade)
        return render_template("result.html", words="成绩更新成功", back=1)
    def find(self,s):
        pp_diy = ur"^xj"

        if re.search(pp_diy, str(s.content)):
            from app.model.dll_library import getLib
            from app.model.db_user import User
            temUser = User(s.userName)
            id = temUser.query("ss_num")
            password = temUser.query("password_inf")
            if temUser.query("bind") == 0:
                return '您还未绑定,请先<a href="' + URL + 'bind' +str(s.userName)+'">绑定</a>'
            append = s.content[2:]
            if append:
                status = getLib(id, password, append)[1]
                if status == '1':
                    res = "续借成功,回复[借书]查看详情"
                elif status == '-1':
                    res = '这本书已达到续借限制,无法续借'
                elif status == '-2':
                    res = '这本书不能续借哦~~'
                elif status == '0':
                    res = '请输入正确的序号(如xj1)'
                elif status == '-3':
                    res = '绑定的信息有误,请重新<a href="http://4.wx4321.sinaapp.com/bind'+str(s.userName)+'">绑定</a>'
                else:
                    pass
            else:
                res = '请输入正确的序号(如xj1)'
            return res
        else:
            return 0
    def find(self,s):
        pp_diy = "成绩"

        if re.search(pp_diy, str(s.content)):
            from app.model.db_user import User
            temUser = User(s.userName)
            res=""
            if not temUser.isbind():
                return '您还未绑定,请先<a href="' + URL + 'bind'+str(s.userName)+'">绑定</a>'
            else:
                grade_list = ""
                try:
                    grade_list = list(eval(temUser.query("grade").decode("utf8")))
                except Exception:
                    pass
            add = '<a href="' + URL + 'grade'+str(s.userName)+'">点此更新成绩</a>'
            if grade_list == "":
                pass
            else:
                for i in grade_list:
                    res = res + "\n" + str(i['name']) + " " + str(i['grade'])
            return res + "\n" + add
        else:
            return 0