'''
@Author: hua
@Date: 2020-05-23 19:36:42
@description: 
@LastEditors: hua
@LastEditTime: 2020-06-07 19:58:12
'''
from app.Vendor.Decorator import validator
import json
from app.Model.Guestbook import Guestbook
from app.Vendor.tempDef import backStatus
import time

#添加
@validator(name="title", rules={'required': True,'type': 'string'}, msg= {'required': u'标题是必须的','type': u'标题必须是字符串'})
@validator(name="msg", rules={'required': True,'type': 'string'}, msg= {'required': u'描述是必须的','type': u'排序是字符串'})
async def add(request, **k):
    params = k['params']
    params['add_time'] = int(time.time())
    res = Guestbook().add(params)   
    if res==True:
        return backStatus(request, '留言成功')
    return backStatus(request, '留言失败', 0)