标签:node util 增删改查 分享 build mode json mvc spring
1.play项目的结构
app中主要的包有controllers,filters,models,service,utils.
conf的文件主要有mysql.conf,application.conf,routes;
POST /v1/tasks/:taskId/reward controllers.TaskApplicantsController.reward(taskId : Int)
分别对应http方法 url 类中的方法
play2框架的构建工具用的是sbt,build.sbt是其构建工具
2.play框架的增删改查
@Inject private MyCacheApi cache; public Result create() { JsonNode body = request().body().asJson(); String title = ApplicationHelper.getParamsInPath(body, Constants.TITLE, true); Users user = Users.getUser(cache.getUserId(request())); try { checkPermission(user); } catch (Exception e) { return badRequest(ApplicationHelper.getErrorJson(CodeConstants.INVALID_PARAM_ERROR, e.getMessage())); } Council council = new Council(); council.setTitle(title); council.insert(); return ok(Json.toJson(council)); }
public Result delete(int sectionId) { Sections sections = Sections.getSection(sectionId); if (sections != null) { sections.delete(); } return ok(); }
public Result update(Integer councilId) { JsonNode body = request().body().asJson(); String title = null; try { title = ApplicationHelper.getParamsInPath(body, Constants.TITLE, true); } catch (Exception e) { return badRequest(ApplicationHelper.getErrorJson(CodeConstants.INVALID_PARAM_ERROR, e.getMessage())); } Council council = Council.get(councilId); council.setTitle(title); council.update(); return ok(Json.toJson(council)); }
public Result get(Integer level) { Levels levels = Levels.get(level); try { return ok(Json.toJson(levels)); } catch (Exception e) { return badRequest(ApplicationHelper.getErrorJson(CodeConstants.INVALID_PARAM_ERROR, e.getMessage())); } }
标签:node util 增删改查 分享 build mode json mvc spring
原文地址:http://www.cnblogs.com/jianpanaq/p/7218215.html