def get(self): order_role = self.request.arguments for key, list_order in enumerate(order_role): role_id = list_order[:] list_order = order_role[list_order][0] AdminRole.update(role_id, '', '', list_order, 0) ret = {'code': 0, 'msg': '更新成功'} return self.write(json_encode(ret))
def get(self): page = self.get_argument('page', 1) rows = self.get_argument('rows', 20) sort = self.get_argument('sort', '') order = self.get_argument('order', 'ASC') start = (int(page) - 1) * int(rows) limit = rows role_list = AdminRole.gets(start, limit) total = AdminRole.get_count() response = { 'total': total, 'rows': [obj2dict(role) for role in role_list] } return self.write(json_encode(response))
def post(self): role_name = self.get_argument('role_name', '') self.set_header("Content-Type", "application/json") role = AdminRole.get_by_rolename(role_name) if not role: ret = {'code': 0} else: ret = {'code': 1} return self.write(json_encode(ret))
def post(self): role_name = self.get_argument('role_name', '') description = self.get_argument('description', '') list_order = int(self.get_argument('list_order', 0)) status = int(self.get_argument('status', 0)) if not role_name: ret = {'code': 310, 'msg': self.error_message['310']} return self.write(json_encode(ret)) result = AdminRole.new(role_name, description, list_order, status) if result: ret = {'code': 0, 'msg': '添加成功'} return self.write(json_encode(ret)) else: ret = {'code': 311, 'msg': self.error_message['311']} return self.write(json_encode(ret))
def get(self): role_id = int(self.get_argument('id', 0)) role = AdminRole.get(role_id) return self.render(self.url, info=role)
def get(self): user_id = int(self.get_argument('id', 0)) user = User.get(user_id) roles = AdminRole.gets() return self.render(self.url, info=user, roles=roles)