发表于: 2017-06-22 23:13:13

2 1020


今天完成的事情:

今天一天都在写接口,【动态搜索图片】、【保存排序】、【修改图片状态】、【删除图片】、【新增图片】、【获取单个图片详情】、【编辑图片】……


明天计划的事情:

明天计划先将登陆和退出接口写完,再看后台管理模块的接口(即公共接口)。


遇到的问题:

今天看后台管理模块,一直没搞懂role角色表中的权限是如何表示的?代表了什么意思?

{"1":[],"2":["create","update","delete","sort"],"3":["create","update","delete","sort"],"6":["create","update","delete","sort"],"7":["create","update","delete","sort"],"64":[],"65":["create","delete","sort"],"66":["create","update","delete","sort"],"67":[],"68":["create","update","delete","sort"]}


收获:

刚开始写接口的时候,我在想,service中可以写那么多方法,怎么调用?写service中的方法和每种方法的sql语句一定是一件头痛的事。

后来才知道,并不需要为每一种修改、新增等写一个sql。特别是编辑和新增,是通过先直接修改完整的实体类,再将实体类update给dao,不再需要为每一种编辑都写一个sql语句。

今天都在写接口代码。这些接口也大同小异,没什么难度。暂时还没测试接口。所以也不知道该写什么……

先贴一个保存排序的接口:

@RequestMapping(value = "/a/u/picture/order/ ", method = RequestMethod.POST)
public String sort(HttpServletRequest request,
              HttpServletResponse response, ModelMap model,
              @RequestBody List<Long> ids) throws Exception {

log.info("sort article : ids= " + ids);

  try {
int size = pictureService.countPictureIds();
     /* 保存排序的数量和数据库中图片的数量不同、无法插入排序 */
     if (size != ids.size()){
log.error("there is not all the picture");
        model.addAttribute("code", -13000 );
     }

List<Picture> lists = this.pictureService.getObjectsByIds(ids);

     /*保存pictureOrder排序*/
     Long index = 5L;
     for (Picture picture : lists) {
picture.setPictureOrder(index);
        index = index + 5;
     }
pictureService.updateList(lists);

  }
catch (Throwable t) {
t.printStackTrace();
     log.error(t.getMessage());
     log.error("save order error ");
     model.addAttribute("code", -1);
     return "/common/fail";
  }

model.addAttribute("code", 0);
  return "common/success";
}



返回列表 返回列表
评论

    分享到