源码获取:俺的博客首页 "资源" 里下载!
项目介绍
本项目分为管理员、用户与跑腿小哥三种角色;
跑腿小哥角色包含以下功能:
跑腿小哥登录,修改个人资料,修改密码,查看服务类型,接单情况管理等功能。
管理员角色包含以下功能:
管理员登录,用户管理,服务类型管理,订单管理,接单管理等功能。
用户角色包含以下功能:
用户登录,修改个人资料,修改密码,查看服务类型,订单管理等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
技术栈
1. 后端:Spring+SpringMVC+Mbytes
2. 前端:JSP+bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入localhost:8080/
用户管理控制层:
@Controller
@RequestMapping(value = "User")
public class UserController {
@Autowired
private UserMapper userMapper;
@RequestMapping(value = "/login.do")
public String login(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
String code = (String) session.getAttribute("code");
String userCode = request.getParameter("code");
if (!code.equals(userCode)) {
model.addAttribute("errMsg", "验证码错误");
return "../login";
}
User user = userMapper.getObjectByName(util);
if (null == user) {
model.addAttribute("errMsg", "登录失败");
return "../login";
}
boolean flag = user.getS_1().equals(util.getS_1());
if (!flag) {
model.addAttribute("errMsg", "登录失败");
return "../login";
}
if (flag && !SysUtil.getSysFlag()) {
model.addAttribute("errMsg", "无法登陆,请联系管理员");
return "../login";
}
session.setAttribute("user_id", user.getId());
session.setAttribute("user_type", user.getS_11());
session.setAttribute("type1", "admin");
session.setAttribute("type2", "admin");
session.setAttribute("name", user.getS_2());
session.setAttribute("username", user.getS_0());
return "../index";
}
@RequestMapping(value = "/updatepwd.do")
public String updatepwd(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
User userTmp = userMapper.selectObject(user_id);
String oldPwd = util.getS_3();
String newPwd = util.getS_4();
String rePwd = util.getS_5();
if (null == oldPwd || "".equals(oldPwd) || null == newPwd
|| "".equals(newPwd) || null == rePwd || "".equals(rePwd)) {
model.addAttribute("errMsg", "密码信息不能为空");
model.addAttribute("util", userTmp);
return "User/updatepwd";
}
if (!newPwd.equals(rePwd)) {
model.addAttribute("errMsg", "确认密码不一致");
model.addAttribute("util", userTmp);
return "User/updatepwd";
}
if (newPwd.equals(oldPwd)) {
model.addAttribute("errMsg", "旧密码不能与新密码一致");
model.addAttribute("util", userTmp);
return "User/updatepwd";
}
if (!oldPwd.equals(userTmp.getS_1())) {
model.addAttribute("errMsg", "旧密码错误");
model.addAttribute("util", userTmp);
return "User/updatepwd";
}
userTmp.setS_1(newPwd);
userMapper.updateObject(userTmp);
return "User/uppwdok";
}
@RequestMapping(value = "/updateinfo.do")
public String updateinfo(HttpServletRequest request, User util, Model model) {
userMapper.updateObject(util);
model.addAttribute("util", util);
model.addAttribute("errMsg", "个人信息修改成功");
return "User/updateinfo";
}
@RequestMapping(value = "/beforepass.do")
public String beforepass(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
util = userMapper.selectObject(user_id);
model.addAttribute("util", util);
return "User/updatepwd";
}
@RequestMapping(value = "/beforeinfo.do")
public String beforeinfo(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
util = userMapper.selectObject(user_id);
model.addAttribute("util", util);
return "User/updateinfo";
}
@RequestMapping(value = "/register.do")
public String register(HttpServletRequest request, User util, Model model) {
HttpSession session = request.getSession();
String code = (String) session.getAttribute("code");
String userCode = request.getParameter("code");
if (!code.equals(userCode)) {
model.addAttribute("errMsg", "验证码错误");
return "../register";
}
User user = userMapper.getObjectByName(util);
if (null != user) {
model.addAttribute("errMsg", "该用户名已经存在");
return "../register";
}
userMapper.insertObject(util);
model.addAttribute("registerMsg", "恭喜您,注册成功!");
return "../login";
}
@RequestMapping(value = "/initUtil.do")
public String initUtil(HttpServletRequest request, Model model) {
return "User/saveOrUpdate";
}
@RequestMapping(value = "/selectUtil.do")
public String selectUtil(HttpServletRequest request, User util, Model model) {
util = userMapper.selectObject(util.getId());
model.addAttribute("util", util);
return "User/saveOrUpdate";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, User util, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
currentPageNo = Integer.parseInt(pageNo);
} catch (Exception e) {
}
List<User> list = userMapper.getObjectList(field, fieldValue);
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "User/find";
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
userMapper.deleteObject(util.getId());
}
return this.getAllUtil(request, util, model);
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, User util, Model model) {
userMapper.deleteObject(util.getId());
return this.getAllUtil(request, util, model);
}
@RequestMapping(value = "/saveOrUpdateObject.do")
public String saveOrUpdateObject(HttpServletRequest request, User util,
Model model) {
List<User> list = userMapper.getObjectList("s_0", util.getS_0());
if (0 == util.getId()) {
if (list.size() > 0) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "User/saveOrUpdate";
}
userMapper.insertObject(util);
} else {
if (list.size() > 1) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "User/saveOrUpdate";
}
userMapper.updateObject(util);
}
return this.getAllUtil(request, util, model);
}
@RequestMapping(value = "/upload.do")
public String upload(@RequestParam MultipartFile[] myfiles,
HttpServletRequest request, User util, Model model)
throws IOException {
for (MultipartFile file : myfiles) {
if (!file.isEmpty()) {
String fileName = file.getOriginalFilename();
String path = request.getSession().getServletContext()
.getRealPath("image")
+ File.separator;
String uploadName = new SimpleDateFormat("yyyyMMddHHmmss")
.format(new Date()) + fileName;
File localFile = new File(path + uploadName);
file.transferTo(localFile);
util.setS_0(uploadName);
util.setS_1(fileName);
util.setS_2(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(new Date()));
}
if (0 == util.getId()) {
userMapper.insertObject(util);
} else {
userMapper.updateObject(util);
}
return this.getAllUtil(request, util, model);
}
return this.getAllUtil(request, util, model);
}
}
订单管理控制层:
@Controller
@RequestMapping(value = "Dingd")
public class DingdController {
@Autowired
private DingdMapper dingdMapper;
@Autowired
private LeixMapper leixMapper;
@Autowired
private UserMapper userMapper;
@RequestMapping(value = "/initUtil.do")
public String initUtil(HttpServletRequest request, Model model) {
List<Leix> listLeix = leixMapper.getObjectList(null, null);
model.addAttribute("listLeix", listLeix);
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
User u = userMapper.selectObject(user_id);
List<User> listUser = new ArrayList<User>();
listUser.add(u);
model.addAttribute("listUser", listUser);
return "Dingd/saveOrUpdate";
}
@RequestMapping(value = "/selectUtil.do")
public String selectUtil(HttpServletRequest request, Dingd util, Model model) {
util = dingdMapper.selectObject(util.getId());
model.addAttribute("util", util);
List<Leix> listLeix = leixMapper.getObjectList(null, null);
model.addAttribute("listLeix", listLeix);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
return "Dingd/saveOrUpdate";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try{
currentPageNo = Integer.parseInt(pageNo);
}catch(Exception e){
}
List<Dingd> list = dingdMapper.getObjectList(field, fieldValue);
List<Dingd> listDingd = new ArrayList<Dingd>();
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
for (Dingd temp : list) {
if (user_id == temp.getUser().getId()) {
listDingd.add(temp);
}
}
if ("user".equals(user_type)) {
list = listDingd;
}
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "Dingd/find";
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, Dingd util, Model model) {
try{
dingdMapper.deleteObject(util.getId());
}catch(Exception e){
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
try{
dingdMapper.deleteObject(util.getId());
}catch(Exception e){}
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/saveOrUpdateObject.do")
public String saveOrUpdateObject(HttpServletRequest request, Dingd util, Model model) {
List<Dingd> list = dingdMapper.getObjectList("s_0", util.getS_0());
List<Leix> listLeix = leixMapper.getObjectList(null, null);
model.addAttribute("listLeix", listLeix);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
if (0 == util.getId()) {
util.setS_6("已发布");
dingdMapper.insertObject(util);
} else {
if (list.size() > 1) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "Dingd/saveOrUpdate";
}
dingdMapper.updateObject(util);
}
return this.getAllUtil(request, model);
}
}
接单管理控制层:
@Controller
@RequestMapping(value = "Jied")
public class JiedController {
@Autowired
private JiedMapper jiedMapper;
@Autowired
private DingdMapper dingdMapper;
@Autowired
private UserMapper userMapper;
@RequestMapping(value = "/initUtil.do")
public String initUtil(HttpServletRequest request, Model model) {
List<Dingd> listDingd = dingdMapper.getObjectList("s_6", "已发布");
model.addAttribute("listDingd", listDingd);
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
User u = userMapper.selectObject(user_id);
List<User> listUser = new ArrayList<User>();
listUser.add(u);
model.addAttribute("listUser", listUser);
return "Jied/saveOrUpdate";
}
@RequestMapping(value = "/selectUtil.do")
public String selectUtil(HttpServletRequest request, Jied util, Model model) {
util = jiedMapper.selectObject(util.getId());
model.addAttribute("util", util);
List<Dingd> listDingd = dingdMapper.getObjectList(null, null);
model.addAttribute("listDingd", listDingd);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
return "Jied/saveOrUpdate";
}
//
@RequestMapping(value = "/passUtil.do")
public String passUtil(HttpServletRequest request, Jied util, Model model) {
util = jiedMapper.selectObject(util.getId());
util.setS_2("订单完成");
jiedMapper.updateObject(util);
Dingd Dingd = dingdMapper.selectObject(util.getDingd().getId());
Dingd.setS_6("订单完成");
dingdMapper.updateObject(Dingd);
model.addAttribute("util", util);
List<Dingd> listDingd = dingdMapper.getObjectList(null, null);
model.addAttribute("listDingd", listDingd);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
return this.getAllUtil(request, model);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/getAllUtil.do")
public String getAllUtil(HttpServletRequest request, Model model) {
String field = request.getParameter("field");
String fieldValue = request.getParameter("fieldValue");
try {
fieldValue = new String(fieldValue.getBytes("iso-8859-1"), "utf-8");
} catch (Exception e) {}
String pageNo = request.getParameter("pageModel.currentPageNo");
int currentPageNo = 1;
try{
currentPageNo = Integer.parseInt(pageNo);
}catch(Exception e){
}
List<Jied> list = jiedMapper.getObjectList(field, fieldValue);
List<Jied> listJied = new ArrayList<Jied>();
HttpSession session = request.getSession();
int user_id = (Integer) session.getAttribute("user_id");
String user_type = (String) session.getAttribute("user_type");
for (Jied temp : list) {
if (user_id == temp.getUser().getId()) {
listJied.add(temp);
}
}
if (!"admin".equals(user_type)) {
list = listJied;
}
PageModel pageModel = new PageModel();
pageModel = pageModel.getUtilByController(list, currentPageNo);
model.addAttribute("pageModel", pageModel);
model.addAttribute("fieldValue", fieldValue);
model.addAttribute("field", field);
return "Jied/find";
}
@RequestMapping(value = "/deleteUtil.do")
public String deleteUtil(HttpServletRequest request, Jied util, Model model) {
try{
jiedMapper.deleteObject(util.getId());
}catch(Exception e){
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/deleteManyUtil.do")
public String deleteManyUtil(HttpServletRequest request, User util,
Model model) {
String ids[] = request.getParameterValues("id");
for (String id : ids) {
util = new User();
util.setId(Integer.parseInt(id));
try{
jiedMapper.deleteObject(util.getId());
}catch(Exception e){}
}
return this.getAllUtil(request, model);
}
@RequestMapping(value = "/saveOrUpdateObject.do")
public String saveOrUpdateObject(HttpServletRequest request, Jied util, Model model) {
List<Jied> list = jiedMapper.getObjectList("s_0", util.getS_0());
List<Dingd> listDingd = dingdMapper.getObjectList(null, null);
model.addAttribute("listDingd", listDingd);
List<User> listUser = userMapper.getObjectList(null, null);
model.addAttribute("listUser", listUser);
if (0 == util.getId()) {
util.setS_0("BH"+System.currentTimeMillis());
Date date1 = new Date() ; //获取系统时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //日期格式
String date = sdf.format(date1); //将系统时间转换成上方指定类型
util.setS_1(date);
util.setS_2("接单中");
jiedMapper.insertObject(util);
Dingd Dingd = dingdMapper.selectObject(util.getDingd().getId());
Dingd.setS_6("接单中");
dingdMapper.updateObject(Dingd);
} else {
if (list.size() > 1) {
model.addAttribute("util", util);
model.addAttribute("errMsg", "该信息已存在!");
return "Jied/saveOrUpdate";
}
jiedMapper.updateObject(util);
}
return this.getAllUtil(request, model);
}
}
源码获取:俺的博客首页 "资源" 里下载!