def Upimg(self): # 验证 token = self.Post('token') msg = AdminToken.Verify(token, request.path) if msg != '': return self.GetJSON({'code': 4001, 'msg': msg}) # 参数 name = self.Post('name') base64 = self.Post('base64') if not base64: return self.GetJSON({'code': 4000, 'msg': '参数错误!'}) # 类型 if name != 'logo' and name != 'login_bg': return self.GetJSON({'code': 4000, 'msg': '类型错误!'}) # 上传 img = Upload.Base64({'path': self.ImgDir, 'base64': base64}) if not img: return self.GetJSON({'code': 5000, 'msg': '上传失败!'}) # 数据 m = SysConfigM() m.Columns('val') m.Where('name=%s', name) imgData = m.FindFirst() m.Set({'val': self.ImgDir + img}) m.Where('name=%s', name) if not m.Update(): return self.GetJSON({'code': 5000, 'msg': '上传失败!'}) # 清理 rmImg = imgData['val'] FileEo.RemoveAll(rmImg) # 返回 return self.GetJSON({ 'code': 0, 'msg': '成功', 'img': Data.Img(self.ImgDir + img) })
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) })
def GetConfig(self): config = SysConfig() config.Columns('name', 'val') config.Where('name in ("title","copy","logo","login_bg")') data = config.Find() # 数据 list = {} for val in data: if val['name'] == 'logo' or val['name'] == 'login_bg': list[val['name']] = Data.Img(val['val']) else: list[val['name']] = val['val'] return self.GetJSON({'code': 0, 'msg': '成功', 'list': list})
def UpImg(self): # 验证 token = self.Post('token') msg = AdminToken.Verify(token, '') if msg != '' : return self.GetJSON({'code':4001, 'msg':msg}) # 参数 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':'上传失败!'}) # 返回 return self.GetJSON({'code':0, 'msg':'成功', 'img':Data.Img(self.ImgDir+img)})
def Token(self): # 验证 token = self.Post('token') msg = ApiToken.Verify(token, '') if msg != '' : return self.GetJSON({'code':4001, 'msg':msg}) # 参数 uinfo = self.Post('uinfo') tData = ApiToken.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['uname'] = tData['uname'] info['img'] = Data.Img(info['img']) return self.GetJSON({'code':0, 'msg':'成功', 'token_time':tData['time'], 'uinfo':info})
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})
def List(self): # 验证 token = self.Post('token') msg = AdminToken.Verify(token, request.path) if msg != '': return self.GetJSON({'code': 4001, 'msg': msg}) # 查询 m = SysConfigM() m.Columns('name', 'val') data = m.Find() # 数据 list = {} for val in data: if val['name'] == 'logo' or val['name'] == 'login_bg': list[val['name']] = Data.Img(val['val']) else: list[val['name']] = val['val'] # 返回 return self.GetJSON({'code': 0, 'msg': '成功', 'list': list})