You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
44 lines
1.5 KiB
package web.controller;
|
|
|
|
import core.service.BaseService;
|
|
import core.util.DBAction;
|
|
import db.model.AbstractModel;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Created by reborn on 2017/9/14.
|
|
*/
|
|
public abstract class BaseController<T extends AbstractModel>{
|
|
protected Logger log=LogManager.getLogger();
|
|
|
|
@Resource
|
|
public BaseService baseService;
|
|
|
|
@ResponseBody
|
|
@RequestMapping(value = "{action}", produces = "application/json;charset=UTF-8")
|
|
public <T extends AbstractModel> T curd(@PathVariable DBAction action,T model) {
|
|
log.info(model.tableNote()+ "进行" + action.getCh() + "操作请求");
|
|
return baseService.curd(action, model);
|
|
}
|
|
|
|
@ResponseBody
|
|
@RequestMapping(value = "batch/{action}", produces = "application/json;charset=UTF-8")
|
|
public <T extends AbstractModel> List<T> find(@PathVariable DBAction action,T queryCommand,Integer firstResult,Integer maxResults){
|
|
if(action.equals(DBAction.BR)) {
|
|
return baseService.find(queryCommand, firstResult, maxResults);
|
|
}else{
|
|
throw new RuntimeException("非法操作:" + action);
|
|
}
|
|
}
|
|
|
|
|
|
public abstract boolean checkAction(DBAction action);
|
|
}
|
|
|