目录
前面内容请移步
个人博客系统的设计与实现免费源码+论文
5.3 博客类别管理模块
5.3.1 添加博客类别
图4-5 添加博客类型时序图
步骤 |
系统行为描述 |
1 |
博主在博客类别信息管理页面点击添加按钮打开添加博客类别弹窗 |
2 |
调用blogType控制层controller的save方法 |
3 |
控制层save方法中调用service层的add方法 |
4 |
调用blogTypeMapper持久层将对应的博客类别信息添加 |
5 |
返回成功添加信息 |
在博客类别管理页面打开添加博客类别弹窗,填写博客类别名称和排序,点击保存按钮,提交到控制层的save方法,传入参数:需要添加的博客类型blogType,调用控制层的方法,在控制层的save()方法中调用服务层的add()方法,添加博客类别的相关信息,持久到数据库中。部分代码如下:
@RequestMapping("/save")
public String save(BlogType blogType,HttpServletResponse response)throws Exception{
int resultTotal=0; // 操作的记录条数
if(blogType.getId()==null){
resultTotal=blogTypeService.add(blogType);
}else{
resultTotal=blogTypeService.update(blogType);
}
JSONObject result=new JSONObject();
if(resultTotal>0){
result.put("success", true);
}else{
result.put("success", false);
}
ResponseUtil.write(response, result);
return null;
}