项目
思路
po包里是实体类
service里是业务逻辑类
请求页面放在webcontent里面,如index.jsp,写个<a href="控制器类映射名"></a>,给springmvc控制器类,具体业务交给业务层service,给service.impl,涉及数据库操作,Dao->Dao.xml里,resultsType返回类型,结果返回业务层impl,数据返回控制器类
选题名称,选题描述
做什么系统,大概有什么功能
需求分析
1.功能需求分析,有哪些功能模块,各自的功能是什么
2.用例模型的概述,系统的主要参与者有哪些,系统分离出的用例有哪些
3.画用例图,用例模型的说明,参与者有哪些业务
数据库设计
1.概念结构设计,E-R图及其说明
2.逻辑结构设计,关系模式,如:教师(教师号,名字,性别)
3.数据库SQL代码及表设计
类设计
基于MVC划分
1.模型类:
- 永久层:如UserPostDao、TeacherDao等这些接口及其映射文件,如UserPostDao.xml、TeacherDao.xml,这些都放在dao包里,UserPostDao接口代码例如:
package com.dao;
import java.util.List;
import com.po.UserPost;
public interface UserPostDao {
public List<UserPost> selectAllUserPost(String nickName);//查所有用户
public void insertUserPost(UserPost u);
public void deleteUserPost(UserPost u);
}
相应的UserPostDao.xml可以这么写:
<mapper namespace="com.dao.UserPostDao">
<select id="selectAllUserPost" parameterType="String"
resultType="com.po.UserPost">
<if test="_parameter!=null and _parameter!=''">
select * from userPost where nickName LIKE CONCAT(CONCAT('%',#{_parameter}),'%')
</if>
<if test="_parameter==null or _parameter==''">
select * from userPost
</if>
</select>
<select id="insertUserPost" parameterType="com.po.UserPost">
insert into userPost(nickName,password,sex,registerTime)
values(#{nickName},#{password},#{sex},#{registerTime})
</select>
<select id="deleteUserPost" parameterType="com.po.UserPost">
delete from userPost where nickName=#{nickName}
</select>
</mapper>
- 业务层:如UserPostService接口及其实现类UserPostImpl。UserPostService内容和UserPostDao内容一样,UserPostImpl内容如:
package com.service.impl;
import java.util.List;
import com.po.UserPost;
import com.dao.UserPostDao;
import com.service.UserPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/*
* com.service里接口的实现类
* 注意加注解
*/
@Service
@Transactional
public class UserPostServiceImpl implements UserPostService{
@Autowired
private UserPostDao userPostDao;
@Override
public List<UserPost> selectAllUserPost(String nickName) {
return userPostDao.selectAllUserPost(nickName);
}
@Override
public void insertUserPost(UserPost u) {
userPostDao.insertUserPost(u);
}
@Override
public void deleteUserPost(UserPost u) {
userPostDao.deleteUserPost(u);
}
}
2.控制类:如UserPostController,这些类的职责是接受View层的请求,与模型层交互完成业务功能后,再将处理结果反馈给View层。如UserPostController:
package com.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.po.UserPost;
import com.service.UserPostService;
@Controller
@RequestMapping("/userPost")//view层发过来的请求路径是/userPost/addAdminInfo,这里userPost是控制类名
public class UserPostController {
@Autowired
private UserPostService userPostService;
@RequestMapping(value = "/addAdminInfo", produces = "text/html;charset=UTF-8")
@ResponseBody
public String addAdminInfo(UserPost ai) {
try {
userPostService.insertUserPost(ai);
return "{\"success\":\"true\",\"message\":\"新增成功\"}";
} catch (Exception e) {
return "{\"success\":\"false\",\"message\":\"新增失败\"}";
}
}
}
3.视图类:如userList.jsp
类图的设计
(注:我也不知道正不正确,望指正!)
业务流程顺序图
提供用例模型中每个用例的顺序图
如:用户管理用例(添加新用户)