|
|
@ -11,7 +11,6 @@ import web.html.OtherResult; |
|
|
|
import web.html.Table; |
|
|
|
import web.html.Table; |
|
|
|
import web.service.BaseService; |
|
|
|
import web.service.BaseService; |
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
public abstract class TableController<T extends AbstractModel,A extends T,E extends BaseService,D extends OtherResult,B extends Table<D,T>> extends BaseController<T,A,E> { |
|
|
|
public abstract class TableController<T extends AbstractModel,A extends T,E extends BaseService,D extends OtherResult,B extends Table<D,T>> extends BaseController<T,A,E> { |
|
|
@ -20,35 +19,51 @@ public abstract class TableController<T extends AbstractModel,A extends T,E exte |
|
|
|
|
|
|
|
|
|
|
|
private static final int typeIndex=4; |
|
|
|
private static final int typeIndex=4; |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("table") |
|
|
|
protected final B result = (B) getResolvableType(typeIndex).newInstance(); |
|
|
|
public String find(Model model,@ModelAttribute("command") A command,B pageResult) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected TableController() throws IllegalAccessException, InstantiationException { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping("table") |
|
|
|
|
|
|
|
public String find(Model model,@ModelAttribute("command") A command,B pageResult) { |
|
|
|
DBAction action=DBAction.R; |
|
|
|
DBAction action=DBAction.R; |
|
|
|
log.info(tableName+ "进行批量" + action.getCh() + "操作请求"); |
|
|
|
log.info(tableName+ "进行批量" + action.getCh() + "操作请求"); |
|
|
|
B result; |
|
|
|
|
|
|
|
if(checkAction(action)) { |
|
|
|
if(checkAction(action)) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Long rowCount=rowCount(command); |
|
|
|
Long rowCount=rowCount(command); |
|
|
|
if(rowCount>0) { |
|
|
|
if(rowCount>0) { |
|
|
|
List list = find(command, pageResult.getCurrentPage()*pageResult.getPageSize(), pageResult.getPageSize()); |
|
|
|
List list = find(command, pageResult.getCurrentPage()*pageResult.getPageSize(), pageResult.getPageSize()); |
|
|
|
List<D> otherDatas= otherDatas(command); |
|
|
|
List<D> otherDatas= otherDatas(command); |
|
|
|
result= (B) getResolvableType(typeIndex).getConstructor(long.class,int.class,List.class,int.class,Type.class,List.class).newInstance(rowCount, pageResult.getCurrentPage(),list,pageResult.getPageSize() , Type.success,otherDatas); |
|
|
|
result.setCount(rowCount); |
|
|
|
|
|
|
|
result.setCurrentPage(pageResult.getCurrentPage()+1); |
|
|
|
|
|
|
|
result.setDatas(list); |
|
|
|
|
|
|
|
result.setPageSize(pageResult.getPageSize()); |
|
|
|
|
|
|
|
result.setType(Type.success); |
|
|
|
|
|
|
|
result.setOtherData(otherDatas); |
|
|
|
|
|
|
|
result.setPages(); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
result= (B) getResolvableType(typeIndex).getConstructor(Type.class,String.class).newInstance(Type.fail,"没有记录"); |
|
|
|
result.setType(Type.fail); |
|
|
|
|
|
|
|
result.setErrorMsg("没有记录"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (DataAccessException e) { |
|
|
|
} catch (DataAccessException e) { |
|
|
|
log.error(e); |
|
|
|
log.error(e); |
|
|
|
result= (B) getResolvableType(typeIndex).getConstructor(Type.class,String.class).newInstance(Type.fail,"非法操作"); |
|
|
|
result.setType(Type.fail); |
|
|
|
|
|
|
|
result.setErrorMsg("非法操作"); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
result= (B) getResolvableType(typeIndex).getConstructor(Type.class,String.class).newInstance(Type.fail,tableName + "不允许" + action.getCh() + "操作"); |
|
|
|
result.setType(Type.fail); |
|
|
|
|
|
|
|
result.setErrorMsg(tableName + "不允许" + action.getCh() + "操作"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
model.addAttribute("datas", result); |
|
|
|
model.addAttribute("datas", result); |
|
|
|
|
|
|
|
setModel(model); |
|
|
|
return "table"; |
|
|
|
return "table"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void setModel(Model model){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected boolean checkAction(DBAction action) { |
|
|
|
protected boolean checkAction(DBAction action) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|