def okr_okr_delete(self, database): ASKDB().delete_one('okr_keyresults', "ranid='%s'" % (database['ranid'])) getdb = ASKDB().delete_one('okr_objectives', "ranid='%s'" % (database['ranid'])) if (getdb == 30001): return http.send(30001) return http.send(10000)
def sys_userInfo_get(self, database): # 单条数据 username = database['username'] sqllang = "username='******'".format(username) getdb = ASKDB().select_one('sys_userInfo', sqllang) if getdb == None: return http.send(10004) dbData = dict(getdb) del dbData['password'] # 删除密码 return http.send(10000, dbData)
def okr_okr_get(self, database): # username = database['username'] # sqllang = "username='******'".format(username) # sqllang = "okr_objectives.id=okr_keyresults.oid".format(username) getdb = ASKDB().select_all('*', 'okr_objectives', '') if (getdb == 30002): return http.send(30002) # 再次查表获取KR信息 for o in getdb: getkrdb = ASKDB().select_all('*', 'okr_keyresults', "ranid='%s'" % (o['ranid'])) o['KR'] = getkrdb return http.send(10000, getdb)
def sys_userInfo_login(self, database): # 单条数据 username = database['username'] password = database['password'] sqllang = "username='******'".format(username) getdb = ASKDB().select_one('sys_userInfo', sqllang) if getdb == None: return http.send(10002) if check_password_hash(getdb.password, password): dbData = dict(getdb) del dbData['password'] # 删除密码 return http.send(10000, dbData) else: return http.send(10003)
def okr_okrprogress_updata(self, database): krpronum = 0 # kr进度总数 krnum = 0 # kr个数 for kr in database['KR']: ASKDB().update_one( 'okr_keyresults', "progress='%f',confidenceNum='%s'" % (float(kr['progress']), kr['confidenceNum']), "id='%f'" % (kr['id'])) krpronum = krpronum + float(kr['progress']) krnum = krnum + 1 getdb = ASKDB().update_one('okr_objectives', "progress='%s'" % (str(krpronum / krnum)), "ranid='%s'" % (database['ranid'])) if (getdb == 30001): return http.send(30001) return http.send(10000)
def okr_okr_save(self, database): # 单条数据 ranid = ''.join(random.sample(string.ascii_letters + string.digits, 16)) kr = database.pop('KR') for item in kr: item['ranid'] = ranid o = database database['ranid'] = ranid getdb = ASKDB().insert_one('okr_objectives', o) if (getdb == 30001): return http.send(30001) getdb = ASKDB().insert_all('okr_keyresults', kr) if (getdb == 30001): return http.send(30001) return http.send(10000)
def register(): ''' 注册请求 ''' data = request.get_json() userName = data['userName'] password = data['password'] helloCode = data['helloCode'] if 'helloCode' in data else "" if helloCode != '000000': return http.send(10001) params = {'username': userName, 'password': hash_password(password)} return mydb().sys_userInfo_register(params)
def sys_userInfo_register(self, database): # 单条数据 user = database getdb = ASKDB().insert_one('sys_userInfo', user) return http.send(getdb)