def post(self): func = self.get_args(['appCode', 'name', 'code', 'customJson', 'remark'], '') func['id'] = int(self.get_arg('id', '0')) func['parentID'] = int(self.get_arg('parentID', '0')) func['sort'] = int(self.get_arg('sort', '0')) msg = self.check_str_empty_input(func, ['code', 'name', 'appCode']) if str_helper.is_null_or_empty(msg) == False: self.out_fail(code = 1001, msg = msg) return btype = str_helper.check_num_abc__(func['code']) if btype == False: self.out_fail(code = 1001, msg = '编号参数只允许输入英文字母、数字和下划线') return func['user'] = self.get_oper_user() if func['id'] <= 0: self.check_oper_right(right = state.operAdd) if func['parentID'] <= 0: func['path'] = '%s.%s' % (func['appCode'], func['code']) else: func['path'] = '%s.%s' % ((func_logic.query_one_by_id(func['parentID'])).get('path'), func['code']) func['status'] = state.Boole['true'] f = func_logic.query_one_by_path(path = func['path']) if None != f: self.out_fail(code = 102003) return try: result = func_logic.add(appCode = func['appCode'], name = func['name'], code = func['code'], parentID = func['parentID'], path = func['path'], customJson = func['customJson'], sort = func['sort'], status = func['status'], remark = func['remark'], user = func['user']) nf = func_logic.query_one_by_path(func['path']) self.write_oper_log(action = 'funcCreate', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = '', endStatus= str_helper.json_encode(nf)) except error.RightError as e: self.out_fail(code=e.code) return else: self.check_oper_right(right = state.operEdit) try: of = func_logic.query_one_by_id(func['id']) func_logic.update(id = func['id'], name = func['name'],sort = func['sort'], customJson = func['customJson'],remark = func['remark'],user = func['user']) nf = func_logic.query_one_by_id(func['id']) self.write_oper_log(action = 'funcEdit', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = str_helper.json_encode(of), endStatus= str_helper.json_encode(nf)) except error.RightError as e: self.out_fail(code=e.code) return self.out_ok()
def post(self): func = self.get_args(['appCode', 'name', 'code', 'customJson', 'rights', 'remark'], '') func['id'] = int(self.get_arg('id', '0')) func['parentID'] = int(self.get_arg('parentID', '0')) func['sort'] = int(self.get_arg('sort', '0')) msg = self.check_str_empty_input(func, ['code', 'name', 'rights', 'appCode']) if str_helper.is_null_or_empty(msg) == False: self.out_fail(code = 1001, msg = msg) return btype = str_helper.check_num_abc__(func['code']) if btype == False: self.out_fail(code = 1001, msg = '编号参数只允许输入英文字母、数字和下划线') return func['user'] = self.get_oper_user() if func['id'] <= 0: self.check_oper_right(right = state.operAdd) if func['parentID'] <= 0: func['path'] = '%s.%s' % (func['appCode'], func['code']) else: func['path'] = '%s.%s' % ((func_logic.query_one_by_id(func['parentID'])).get('path'), func['code']) func['status'] = state.Boole['true'] f = func_logic.query_one_by_path(path = func['path']) if None != f: self.out_fail(code = 102003) return try: result = func_logic.add(appCode = func['appCode'], name = func['name'], code = func['code'], parentID = func['parentID'], path = func['path'], rights = func['rights'], customJson = func['customJson'], sort = func['sort'], status = func['status'], remark = func['remark'], user = func['user']) nf = func_logic.query_one_by_path(func['path']) self.write_oper_log(action = 'funcCreate', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = '', endStatus= str_helper.json_encode(nf)) except error.RightError as e: self.out_fail(code=e.code) return else: self.check_oper_right(right = state.operEdit) try: of = func_logic.query_one_by_id(func['id']) func_logic.update(id = func['id'], name = func['name'], sort = func['sort'], rights = func['rights'], customJson = func['customJson'], remark = func['remark'], user = func['user']) nf = func_logic.query_one_by_id(func['id']) self.write_oper_log(action = 'funcEdit', targetType = 3, targetID = str(nf['id']), targetName = nf['name'], startStatus = str_helper.json_encode(of), endStatus= str_helper.json_encode(nf)) except error.RightError as e: self.out_fail(code=e.code) return self.out_ok()
def get(self): id = int(self.get_arg('id', '0')) func = func_logic.query_one_by_id(id) if None != func: json = str_helper.json_encode(func) self.out_ok(data=json) else: self.out_fail(1002)
def post(self): id = int(self.get_arg('id', '0')) user = self.get_oper_user() try: of = func_logic.query_one_by_id(id) type = func_logic.delete(id = id, user = user) if type: self.write_oper_log(action = 'funcDelete', targetType = 3, targetID = str(of['id']), targetName = of['name'], startStatus = str_helper.json_encode(of), endStatus= '') self.out_ok() else: self.out_fail(code = 101) except error.RightError as e: self.out_fail(code=e.code)