Commit 65c8cebc by s_guodong

update

parent cf9af92d
package com.ceb.gjjs.mda.resource.base;
import com.brilliance.mda.runtime.mda.driver.compile.processor.ModuleAnnotationProcess;
import com.brilliance.mda.runtime.request.BaseVO;
import com.brilliance.mda.runtime.response.ResponseSet;
import com.brilliance.mda.support.service.ICommonService;
import org.springframework.web.bind.annotation.RequestBody;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import java.util.Set;
/**
* @author wangguangchao
* @create 2021-09-24 11:51
*/
public abstract class AbstractCommonResource<V extends BaseVO> {
protected abstract ICommonService getCommonService();
@Path("/init")
@POST
public ResponseSet<V> init(@RequestBody V req) {
req.setNeedInit(true);
return getCommonService().init(req);
}
@Path("/checkAll")
@POST
public ResponseSet checkAll(@RequestBody V req) {
return getCommonService().checkAll(req);
}
@Path("/saveData")
@POST
public ResponseSet<V> saveData(@RequestBody V req) {
return getCommonService().saveData(req);
}
@Path("/confirmData")
@POST
public ResponseSet<V> confirmData(@RequestBody V req) {
return getCommonService().confirmData(req);
}
@Path("/pending")
@POST
public ResponseSet<V> pending(@RequestBody V req) {
return getCommonService().pending(req);
}
@Path("/executeCheck/{rule}")
@POST
public ResponseSet<V> executeCheck(@PathParam("rule") String rule, @RequestBody V req) {
String[] ruleArr = rule.split(",");
setInitFlag(req, ModuleAnnotationProcess.needInitCheck, ruleArr);
return getCommonService().executeCheck(req, ruleArr);
}
@Path("/executeRule/{rule}")
@POST
public ResponseSet<V> executeRule(@PathParam("rule") String rule, @RequestBody V req) {
String[] ruleArr = rule.split(",");
setInitFlag(req, ModuleAnnotationProcess.needInitRule, ruleArr);
ResponseSet<V> res = getCommonService().executeRule(req, ruleArr);
return res;
}
@Path("/executeDefault/{rule}")
@POST
public ResponseSet<V> executeDefault(@PathParam("rule") String rule, @RequestBody V req) {
String[] ruleArr = rule.split(",");
return getCommonService().executeDefault(req, ruleArr);
}
@Path("/executeNotify")
@POST
public ResponseSet<V> executeNotify(@RequestBody V req) {
return getCommonService().executeNotify(req);
}
@Path("/executeDocpan")
@POST
public ResponseSet<V> executeDocpan(@RequestBody V req) {
return getCommonService().executeDocpan(req);
}
@Path("/executeDocpanDetail")
@POST
public ResponseSet<V> executeDocpanDetail(@RequestBody V req) {
return getCommonService().executeDocpanDetail(req);
}
private void setInitFlag(V req, Set<String> needInitSet, String[] ruleArr) {
Class<? extends AbstractCommonResource> aClass = this.getClass();
Path annotation = aClass.getAnnotation(Path.class);
String path = annotation.value();
for (String rule : ruleArr) {
if (needInitSet.contains(path + "@" + rule)) {
req.setNeedInit(true);
return;
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment