Ejemplo n.º 1
0
    def delete(self):
        req = request.get_json()
        action_type = int(req.get('a', 1))
        object_id = req.get('object_id', None)

        action = Action.objects(user=g.user, action_type=action_type, object_id=object_id, is_del=False).first()
        if not action:
            return Ans(-1, msg='不存在该记录')
        action.is_del = True
        action.save()
        return Ans(0)
Ejemplo n.º 2
0
    def post(self):
        req = request.get_json()
        object_id = req.get('object_id', None)

        if object_id:
            if not House.objects.with_id(object_id) and not Merchant.objects.with_id(object_id):
                return Ans(-1, msg='对象不存在')

        if Action.objects(user=g.user, action_type=req.get('action_type', None), object_id=object_id, is_del=False).first():
            return Ans(-1, msg='记录已存在')

        action = Action(
            user=g.user,
            action_type=req.get('action_type', None),
            object_id=object_id,

            addition=req.get('addition', None),
        ).save()
        return Ans(0, data=action.to_json())