{
"msg":"ok",
"code":1,
"data":[
{
"sheetFrom":2,
"tst":[
{
"actionName":"revoke"
},
],
"ifmBalkNo":"1",
"buttonList":[
"revoke",
"summit"
]
}
]
}
最近做项目,接口速度跟不上,用的是java,刚好可以学以下,问后台要了源码,自己捣鼓一下,我尝试写一个查询语句
我尝试写一个查询语句
结构如上,涉及多表查询,这个我那会阿,
我会一个一个的查,要我写查询上面的结构
最外层的结构好搞,buttonList
,tst
要我来写,要循环查询数据库了,分几步走,代码如下
for (int x = 0; x < list.size(); x++) {
Sheet sheet = list.get(x);
SearchActionsReq actionsReq = new SearchActionsReq();
actionsReq.sheettype= sheet.getSheetType();
actionsReq.step = sheet.getStep();
Log.e("===========查询buttons==========");
List ls = mSheetFlowDao.getActions(actionsReq);
sheet.setButtonList(ls);
Log.e("===========查询tsts==========");
List lss = mSheetFlowDao.getTst(actionsReq);
sheet.tst = lss;
}
我想在mapper里搞定所有,服务器没有参考,看一下后台写的代码,咳咳,我觉得还可以抢救一下,springboot+mybatis就这样吗!!!
public JSONObject getMegList(HttpServletRequest request){
//获取参数
String data=request.getParameter("data");
JSONObject jsondata= JSONObject.parseObject(data);
//获取token
String token = jsondata.getString("token");
JSONObject json=new JSONObject();
JSONObject json1=new JSONObject();
//判断token是否存在
if (token!=null&&!"".equals(token)) {
try {
SysUserToUser sysUserToUser = JwtUtils.decode(token, SysUserToUser.class);
if (sysUserToUser!=null) {
int page = jsondata.getIntValue("page");
Map map=new HashMap();
map.put("param1", page);
map.put("param2", 15);
map.put("param3", sysUserToUser.getId());
List
自己查阅
不多说,上代码
最后,我只要
List list = new ArrayList();
SheetMapper mSearchSheetMapper = mapper(SheetMapper.class);
list = mSearchSheetMapper.searchSheetTask(req);
以前是这样:
List list = new ArrayList();
SheetMapper mSearchSheetMapper = mapper(SheetMapper.class);
list = mSearchSheetMapper.searchSheetTask(req);
======就是它,完全没必要存在
for (int x = 0; x < list.size(); x++) {
Sheet sheet = list.get(x);
SearchActionsReq actionsReq = new SearchActionsReq();
actionsReq.sheettype= sheet.getSheetType();
actionsReq.step = sheet.getStep();
Log.e("===========查询buttons==========");
List ls = mSheetFlowDao.getActions(actionsReq);
sheet.setButtonList(ls);
Log.e("===========查询tsts==========");
List lss = mSheetFlowDao.getTst(actionsReq);
sheet.tst = lss;
}
======
精简了部分代码,这算是一对多的实现方式吧~