Example #1
0
 def Upimg(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 参数
     base64 = self.Post('base64')
     if not base64: return self.GetJSON({'code': 4000, 'msg': '参数错误!'})
     # 上传
     img = Upload.Base64({'path': self.ImgDir, 'base64': base64})
     if not img: return self.GetJSON({'code': 5000, 'msg': '上传失败!'})
     # 数据
     model = UserInfoM()
     model.Columns('img')
     model.Where('uid=%s', tData['uid'])
     imgData = model.FindFirst()
     model.Set({'img': self.ImgDir + img})
     model.Where('uid=%s', tData['uid'])
     if not model.Update():
         return self.GetJSON({'code': 5000, 'msg': '上传失败!'})
     # 清理
     rmImg = imgData['img']
     FileEo.RemoveAll(rmImg)
     # 返回
     return self.GetJSON({
         'code': 0,
         'msg': '成功',
         'img': Data.Img(self.ImgDir + img)
     })
Example #2
0
 def Edit(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 参数
     data = self.Post('data')
     if not data: return self.GetJSON({'code': 4000, 'msg': '参数错误!'})
     param = Util.JsonDecode(data)
     # 数据
     model = UserInfoM()
     info = {
         'nickname': Util.Trim(param['nickname']),
         'name': Util.Trim(param['name']),
         'gender': Util.Trim(param['gender']),
         'birthday': Util.Strtotime(Util.Trim(param['birthday']),
                                    '%Y-%m-%d'),
         'position': Util.Trim(param['position']),
     }
     model.Set(info)
     model.Where('uid=%s', tData['uid'])
     model.Update()
     # 返回
     info['uname'] = tData['uname']
     info['img'] = param['img']
     info['birthday'] = Util.Date('%Y-%m-%d', info['birthday'])
     return self.GetJSON({'code': 0, 'msg': '成功', 'uinfo': info})
Example #3
0
 def List(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, request.path)
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 查询
     model = UserInfoM()
     model.Columns('nickname', 'name', 'gender',
                   'FROM_UNIXTIME(birthday, %s) as birthday', 'position',
                   'img')
     model.Where('uid=%s', '%Y-%m-%d', str(tData['uid']))
     list = model.FindFirst()
     # 数据
     list['img'] = Data.Img(str(list['img']))
     # 返回
     return self.GetJSON({'code': 0, 'msg': '成功', 'list': list})
Example #4
0
File: user.py Project: webmiss/base
 def Token(self):
   # 验证 request.path
   token = self.Post('token')
   msg = AdminToken.Verify(token, '')
   if msg != '' : return self.GetJSON({'code':4001, 'msg':msg})
   # 参数
   uinfo = self.Post('uinfo')
   tData = AdminToken.Token(token)
   if uinfo!='1' : return self.GetJSON({'code':0, 'msg':'成功', 'token_time':tData['time']})
   # 用户信息
   model = UserInfo()
   model.Columns('nickname','position','name','img')
   model.Where('uid=%s',tData['uid'])
   info = model.FindFirst()
   info['uid'] = str(tData['uid'])
   info['uname'] = tData['uname']
   info['img'] = Data.Img(info['img'])
   return self.GetJSON({'code':0, 'msg':'成功', 'token_time':tData['time'], 'uinfo':info})
Example #5
0
 def UserInfo(self):
     # 验证
     token = self.Post('token')
     msg = AdminToken.Verify(token, '')
     if msg != '': return self.GetJSON({'code': 4001, 'msg': msg})
     tData = AdminToken.Token(token)
     # 配置
     cfg = Tencent.TRTC()
     userId = str(tData['uid'])
     userSin = Signature.UserSig(userId)
     # 数据
     uinfo = {
         'sdk_app_id': cfg['SDKAppID'],
         'user_id': userId,
         'user_sig': userSin,
         'live_domain_name': cfg['PlayDomain'],
     }
     # 返回
     return self.GetJSON({'code': 0, 'msg': '成功', 'uinfo': uinfo})
Example #6
0
 def Edit(self):
   # 验证
   token = self.Post('token')
   msg = AdminToken.Verify(token, request.path)
   if msg != '' : return self.GetJSON({'code':4001, 'msg':msg})
   tData = AdminToken.Token(token)
   # 参数
   passwd = self.Post('passwd')
   passwdNew = self.Post('passwdNew')
   if passwd==passwdNew : return self.GetJSON({'code':4000, 'msg':'不能与原密码相同!'})
   if not Safety.IsRight('passwd', passwd) or not Safety.IsRight('passwd', passwdNew) :
     return self.GetJSON({'code':4000, 'msg':'密码为6~16位!'})
   # 数据
   model = User()
   model.Columns('id')
   model.Where('id=%s AND password=%s', str(tData['uid']), Hash.Md5(passwd))
   uData = model.FindFirst()
   if not uData : return self.GetJSON({'code':4000, 'msg':'当前密码错误!'})
   model.Set({'password':Hash.Md5(passwdNew)})
   model.Where('id=%s', str(tData['uid']))
   if not model.Update() : return self.GetJSON({'code':5000, 'msg':'修改失败!'})
   # 返回
   return self.GetJSON({'code':0, 'msg':'成功'})