Example #1
0
 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
Example #2
0
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)
Example #3
0
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)
Example #4
0
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)
Example #5
0
 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))