

/*=============================================================================================
	author:ZhaoJun
	version:1.2
	email:2732810281@qq.com
=============================================================================================*/

 
//严格模式
/*-------------------------------------------------------------------------------------------*/	
    'use strict';
/*-------------------------------------------------------------------------------------------*/
    
// 用户文章
/*-------------------------------------------------------------------------------------------*/	
    class article
    {
        addToken(req)
        {
            let doc = 
            {   
                base:{group:"用户-文章",descript:"添加文章",requestMethod:"post"},
                service:{path:"/sql",method:"insert",db:"main"},
                requestParam:  
                {                                               
                    title:{...$DbMysqlr.su_article.title,value:'测试标题',field:true},   
                    content:{...$DbMysqlr.su_article.content,value:'2111',field:true}, 
                    image:{...$DbMysqlr.su_article.image,field:true}, 
                },                  
                fun(param)    
                {                
                    param.field.time=Date.now()/1000
                    param.field.userid=req.token.id
                    param.table='su_article'
                }   
            };
 
            
            this.$doc=doc
        }  

        delToken(req)
        {
            let doc = 
            {                    
                base:{group:"用户-文章",descript:"删除文章",requestMethod:"post"},
                service:{path:"/sql",method:"delete",db:"main"},
                requestParam:  
                {
                    id:{...$DbMysqlr.su_article.id,field:true}, 
                },                  
                fun(param)    
                {       
                    param.where.userid=req.token.id
                    param.table='su_article'
                } 
            };
 
            this.$doc=doc
        }

        updateToken(req)
        {
            let doc = 
            {                    
                base:{group:"用户-文章",descript:"更新文章",requestMethod:"post"},
                service:{path:"/sql",method:"update",db:"main"},
                requestParam:  
                {
                    id:{...$DbMysqlr.su_article.id,where:true},                                                 
                    title:{...$DbMysqlr.su_article.title,delete:true,field:true},   
                    content:{...$DbMysqlr.su_article.content,delete:true,field:true}, 
                    image:{...$DbMysqlr.su_article.image,delete:true,field:true}, 
                },                  
                fun(param)    
                {       
                    param.where.userid=req.token.id
                    param.table='su_article'
                } 
            };
 
            this.$doc=doc
        }

        getToken(req)
        {
            let doc = 
            {                    
                base:{group:"用户-文章",descript:"获取自己的文章",requestMethod:"post"},
                service:{path:"/sql",method:"select",db:"main"},
                requestParam:{},                  
                fun(param)    
                {    
                    param.key="title,content,image,time"    
                    param.where.userid=req.token.id
                    param.table='su_article'
                } 
            };
 
            this.$doc=doc
        }

    }
/*-------------------------------------------------------------------------------------------*/    
module.exports=article;