def update_by_id(po): obj = BaseService.select_by_id(po) BizUtil.assert_condition(not obj, "id为" + str(po.id) + "的实体不存在") """balabala 写你的逻辑 """ po_dict = bean_util.sqlalchemy_obj_to_dict(po) bean_util.to_obj(obj, **po_dict) return obj
def edit(**arg_dict): """做参数过滤,基础校验等工作""" obj = bean_util.to_obj(TreeDO, **arg_dict) BizUtil.check_assert(obj.id, "id") res = TreeService.edit(obj) if res: return bean_util.sqlalchemy_obj_to_dict(res)
def remove(**arg_dict): """做参数过滤,基础校验等工作""" obj = bean_util.to_obj(TreeDO, **arg_dict) res = TreeService.delete_by_id(obj) TreeService.commit() if res: return bean_util.sqlalchemy_obj_to_dict(res)
def save(**arg_dict): """做参数过滤,基础校验等工作""" obj = bean_util.to_obj(TreeDO, **arg_dict) obj.leaf = True res = TreeService.save(obj) if res: return bean_util.sqlalchemy_obj_to_dict(res)
def test_dic_to_obj(self): param_map = { "tree_level": 1, "valid1": True, "english_name": "test_name" } cate = bean_util.to_obj(TreeDO, **param_map) print(inspect.isclass(cate))