2.0.30 • Published 2 years ago

@ctsy/controller v2.0.30

Weekly downloads
42
License
ISC
Repository
github
Last release
2 years ago

castle-server框架 控制器基础库

// 基础控制器
// 提供 this._session,this._cookie,this.M,this.R基础操作
import {BaseController} from 'castle-controller'
export default class cc extends BaseController{

}

import Relation from 'castle-relation';
import Model from 'castle-model';
export default class BaseController {
    _ctx: any;
    _config: any;
    _ModelName: string;
    __proto__: any;
    readonly _KeywordFields: Array<string>;
    readonly _KeywordTable: string;
    /**
     * search请求时的允许参与搜索的字段配置
     */
    readonly _WFields: string[];
    /**
     * 保存数据时的字段过滤
     */
    readonly _saveFields: any;
    readonly _searchFields: string[];
    readonly _WTable: string;
    protected readonly _pk: string;
    readonly _model: any;
    constructor(ctx: any);
    protected _checkPermission(): Promise<boolean>;
    /**
     * 发送下载文件,
     * @param path 文件路径
     * @param filename 文件名称
     */
    protected _send(path: string, filename: string): Promise<void>;
    /**
     * 发送下载文件
     * @param content 文件内容
     * @param filename 文件名称
     */
    protected _sendContent(content: any, filename: string): void;
    protected _cookie(name: string, value?: string, options?: Object): any;
    protected _session(name: string, value?: any): Promise<any>;
    /**
     * Web服务中的发送数据
     * @param path
     */
    protected _sendFile(file: string, ext?: string, config?: {}): Promise<void>;
    readonly _files: {
        [index: string]: any;
    };
    protected M(TableName?: string): Model;
    trans: any;
    /**
     * 开启事务
     */
    protected startTrans(): Promise<any>;
    /**
     * 提交数据库事务
     */
    protected commit(): Promise<any>;
    /**
     * 撤销数据库事务
     */
    protected rollback(): Promise<any>;
    protected R(RelationName: string): Promise<Relation>;
    protected I(name: string, options?: Object | any): any;
}


// 支持CURD操作的控制器
//提供 get/save/add/adds/saveW/search/del/delW/replaceW方法
import {Controller} from "castle-controller"
export default class cc extends Controller{

}


import BaseController from './base_controller';
export default class Controller extends BaseController {
    /**
     * 查询请求
     * @param post
     */
    search(post: any): Promise<{
        L: any;
        T: number;
        P: any;
        N: any;
        R: {};
    }>;
    /**
     * 获取单个
     * @param post
     * @param ctx
     */
    get(post: any, ctx: any): Promise<any>;
    /**
     * 添加
     * @param post
     * @param ctx
     */
    add(post: any, ctx: any): Promise<any>;
    /**
     * 删除
     * @param post
     * @param ctx
     */
    del(post: any, ctx: any): Promise<any>;
    /**
     * 更新
     * @param post
     * @param ctx
     */
    save(post: any, ctx: any): Promise<any>;
    /**
     * 条件更新
     * @param post
     * @param ctx
     */
    saveW(post: any, ctx: any): Promise<any>;
    /**
     * 条件删除
     * @param post
     * @param ctx
     */
    delW(post: any, ctx: any): Promise<any>;
    /**
     * 批量添加
     * @param post
     * @param ctx
     */
    adds(post: any, ctx: any): Promise<any>;
    /**
     * 批量替换
     * @param post
     * @param ctx
     */
    replaceW(post: any, ctx: any): Promise<any>;
}

开始支持ejs渲染,

在模块或根路径下创建view目录,

2.0.28

2 years ago

2.0.29

2 years ago

2.0.30

2 years ago

2.0.26

2 years ago

2.0.27

2 years ago

2.0.25

2 years ago

2.0.24

3 years ago

2.0.22

3 years ago

2.0.23

3 years ago

2.0.21

3 years ago

2.0.20

3 years ago

2.0.19

4 years ago

2.0.18

4 years ago

2.0.17

4 years ago

2.0.16

4 years ago

2.0.15

4 years ago

2.0.14

4 years ago

2.0.13

4 years ago

2.0.11

4 years ago

2.0.12

4 years ago

2.0.10

4 years ago

2.0.7

4 years ago

2.0.9

4 years ago

2.0.8

4 years ago

2.0.5

4 years ago

2.0.6

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago