def PermList(self): # 验证 token = self.Post('token') msg = AdminToken.Verify(token, '') if msg != '': return self.GetJSON({'code': 4001, 'msg': msg}) # 参数 perm = self.Post('perm') # 全部菜单 self.__menus = {} model = SysMenu() model.Columns('id', 'fid', 'title', 'url', 'ico', 'controller', 'action') model.Order('sort DESC, id') data = model.Find() for val in data: fid = str(val['fid']) if fid in self.__menus: self.__menus[fid] += [val] else: self.__menus[fid] = [val] # 用户权限 self.__permAll = self.__permArr(perm) # 返回 return self.GetJSON({ 'code': 0, 'msg': '成功', 'list': self._getMenu('0') })
def List(self): # 验证 token = self.Post('token') msg = AdminToken.Verify(token, request.path) if msg != '': return self.GetJSON({'code': 4001, 'msg': msg}) # 参数 data = self.Post('data') page = self.Post('page') limit = self.Post('limit') if not data or not page or not limit: return self.GetJSON({'code': 4000, 'msg': '参数错误!'}) param = Util.JsonDecode(data) fid = Util.Trim(param['fid']) if 'fid' in param.keys() else '' title = Util.Trim(param['title']) if 'title' in param.keys() else '' url = Util.Trim(param['url']) if 'url' in param.keys() else '' # 统计 m = SysMenu() m.Columns('count(*) AS num') m.Where('fid like %s AND title like %s AND url like %s', '%' + fid + '%', '%' + title + '%', '%' + url + '%') total = m.FindFirst() # 查询 m.Columns('id', 'fid', 'title', 'ico', 'FROM_UNIXTIME(ctime, %s) as ctime', 'FROM_UNIXTIME(utime, %s) as utime', 'sort', 'url', 'controller', 'action') m.Where('fid like %s AND title like %s AND url like %s', '%Y-%m-%d %H:%i:%s', '%Y-%m-%d %H:%i:%s', '%' + fid + '%', '%' + title + '%', '%' + url + '%') m.Order('sort DESC', 'fid') m.Page(int(page), int(limit)) list = m.Find() # 数据 for val in list: val['action'] = Util.JsonDecode( val['action']) if str(val['action']) != '' else '' # 返回 return self.GetJSON({ 'code': 0, 'msg': '成功', 'list': list, 'total': total['num'] })