功能配置-》自定义controller
1、controller定义
用于定义后端交互的controller,通过指定后端controller定义的request mapping,用户可以自定义增删改查的逻辑。平台默认会指定为”/je”。
2、开发自定义action(controller)
import com.je.common.base.DynaBean;
import com.je.common.base.mvc.AbstractPlatformController;
import com.je.common.base.mvc.BaseMethodArgument;
import com.je.common.base.result.BaseRespResult;
import com.je.common.base.util.StringUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping(value = "/je/myController")
public class MyController extends AbstractPlatformController {
@ResponseBody
@PostMapping(value = "/save")
public BaseRespResult save(BaseMethodArgument param, HttpServletRequest request) {
//获取前端传参
String A = getStringParameter(request, "A_CODE");
String B = getStringParameter(request, "B_CODE");
//编号生成规则
String codeGenFieldInfo = getStringParameter(request, "codeGenFieldInfo");
String tableCode = param.getTableCode();
DynaBean dynaBean = new DynaBean(tableCode, true);
//设置系统字段默认值,设置sy_系统字段默认值
commonService.buildModelCreateInfo(dynaBean);
//构建编号
if (StringUtil.isNotEmpty(codeGenFieldInfo)) {
commonService.buildCode(codeGenFieldInfo, dynaBean);
}
dynaBean.setStr("A_CODE", A);
dynaBean.setStr("B_CODE", B);
metaService.insert(dynaBean);
return BaseRespResult.successResult(dynaBean);
}
}
3、升级项目,升级成功后,需要清理一下契约缓存,否则调用接口404
4.测试
最后编辑: 于春辉 文档更新时间: 2024-11-08 17:00 作者:于春辉