001package cn.mybatis.mp.generator.config;
002
003import lombok.Getter;
004
005@Getter
006public class ActionConfig {
007
008    /**
009     * 是否启用
010     */
011    private boolean enable = true;
012
013
014    /**
015     * 控制器父类
016     */
017    private String superClass;
018
019    /**
020     * 注入service
021     */
022    private boolean injectService = true;
023
024    /**
025     * 是否含有泛型
026     */
027    private boolean generic;
028
029    /**
030     * 新增
031     */
032    private boolean save = true;
033
034    /**
035     * 修改
036     */
037    private boolean update = true;
038
039    /**
040     * 删除
041     */
042    private boolean deleteById = true;
043
044    /**
045     * 分页
046     */
047    private boolean find = true;
048
049    /**
050     * 单个查询
051     */
052    private boolean getById = true;
053
054    /**
055     * 实体类包名
056     */
057    private String packageName = "action";
058
059    /**
060     * mapper后缀
061     */
062    private String suffix = "Action";
063
064    /**
065     * save update 等返回的类型
066     */
067    private String returnClass;
068
069    /**
070     * 返回的名字
071     */
072    private String returnClassName = "Object";
073
074    /**
075     * 设置是否启用
076     */
077    public ActionConfig enable(boolean enable) {
078        this.enable = enable;
079        return this;
080    }
081
082    /**
083     * 控制器父类
084     */
085    public ActionConfig superClass(String superClass) {
086        this.superClass = superClass;
087        return this;
088    }
089
090    /**
091     * 是否注入service
092     *
093     * @param injectService
094     * @return
095     */
096    public ActionConfig injectService(boolean injectService) {
097        this.injectService = injectService;
098        return this;
099    }
100
101    /**
102     * 启用泛型
103     */
104    public ActionConfig generic(boolean generic) {
105        this.generic = generic;
106        return this;
107    }
108
109    /**
110     * 是否生成save方法
111     *
112     * @param save
113     * @return
114     */
115    public ActionConfig save(boolean save) {
116        this.save = save;
117        return this;
118    }
119
120    /**
121     * 是否生成update方法
122     *
123     * @param update
124     * @return
125     */
126    public ActionConfig update(boolean update) {
127        this.update = update;
128        return this;
129    }
130
131    /**
132     * 是否生成deleteById方法
133     *
134     * @param deleteById
135     * @return
136     */
137    public ActionConfig deleteById(boolean deleteById) {
138        this.deleteById = deleteById;
139        return this;
140    }
141
142    /**
143     * 是否生成find方法
144     *
145     * @param find
146     * @return
147     */
148    public ActionConfig find(boolean find) {
149        this.find = find;
150        return this;
151    }
152
153    /**
154     * 是否生成getById方法
155     *
156     * @param getById
157     * @return
158     */
159    public ActionConfig getById(boolean getById) {
160        this.getById = getById;
161        return this;
162    }
163
164    /**
165     * 控制器的包名
166     *
167     * @param packageName
168     * @return
169     */
170    public ActionConfig packageName(String packageName) {
171        this.packageName = packageName;
172        return this;
173    }
174
175    /**
176     * 控制器的后缀
177     *
178     * @param suffix
179     * @return
180     */
181    public ActionConfig suffix(String suffix) {
182        this.suffix = suffix;
183        return this;
184    }
185
186    /**
187     * 控制器save,update,...等返回的类
188     *
189     * @param returnClass
190     * @return
191     */
192    public ActionConfig returnClass(String returnClass) {
193        this.returnClass = returnClass;
194        int dotIndex = returnClass.lastIndexOf(".");
195        if (dotIndex > 0) {
196            this.returnClassName = returnClass.substring(dotIndex + 1);
197        } else {
198            this.returnClassName = returnClass;
199        }
200        return this;
201    }
202
203
204}