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