我会尽力解释.
我使用Play Framework 2,我会做很多CRUD操作.他们中有些人会identitcal,所以我想吻和DRY所以起初我在想包含一个抽象类list
,details
,create
,update
和delete
方法,与通用对象,并通过指定要使用哪个对象扩展这个类(型号和表格):
public abstract class CrudController extends Controller {
protected static Model.Finder<Long, Model> finder = null;
protected static Form<Model> form = null;
public static Result list() {
// some code here
}
public static Result details(Long id) {
// some code here
}
public static Result create() {
// some code here
}
public static Result update(Long id) {
// some code here
}
public static Result delete(Long …
Run Code Online (Sandbox Code Playgroud)