发表于: 2018-01-05 18:38:41

1 548


今日完成:

主要就是给前端修接口。


明日计划:

看能不能要几个bug来改。


成果:


修改的接口一:

一开始我在给角色设定权限的时候默认是不给他父模块的权限的,然后我在登陆的时候需要把父模块和子模块都返回给前端,我就直接遍历子模块获得他的父模块一起返回,但是前端在添加权限的时候把父模块也添加了,就导致了返回的数据中父模块重复出现,现在修改为在获取这个角色权限的时候把父模块的权限都删除,然后再遍历回来,这样防止了勾选了父模块但是没勾选子模块的情况,以防返回一个没有任何权限的父模块。

//通过phonepassword获取用户idphone唯一,可以保证数据唯一。
Long userId=userService.getUserIdByPhoneAndPassword(phone,password);
log.info("login with phone "+phone+" and password "+password);
if(userId!=null) {
log.info(userId+"user login currently");
  //获取用户信息
  User user = userService.getObjectById(userId);
  //获取此用户的权限列表
  List<Rolewithmodule> powerList = rolewithmoduleService.getObjectsByIds(rolewithmoduleService.getRolewithmoduleIdsByRoleId(user.getRoleId(), 0, Integer.MAX_VALUE));
  log.info(userId+"login with power "+powerList);

  List idList = new ArrayList();//模块id列表
  List<Long> parentId = new ArrayList<Long>();
  for (Rolewithmodule rr : powerList) {
idList.add(rr.getModuleId());
  }

List<Module> moduleList = moduleService.getObjectsByIds(idList);
  //删除父模块
  for (int i=0;i<moduleList.size();i++){
if(moduleList.get(i).getParentId()==0){
moduleList.remove(i);
        i--;
     }
}
//遍历模块id列表构建父模块id列表
  for (Module module : moduleList) {
if (!parentId.contains(module.getParentId())) {
parentId.add(module.getParentId());
     }
}
//把父模块放入返回的权限列表中
  moduleList.addAll(moduleService.getObjectsByIds(parentId));


问题二:

前端说返回的标签格式不对,要数组,我修改了,改成了标准的json中的数组样式,就让前端试试,然后看到渲染的标签有"和]这些我添加的符号,然后问他之前是怎么样的,他说之前就正常的啊。我就觉得这个前端不正常。修改后的数组格式是"["吃饭饭","长高高","打豆豆"]"   这样的应该转换一下就能用了吧。


进度:

调试接口。


禅道:

http://task.ptteng.com/zentao/my-task.html




返回列表 返回列表
评论

    分享到