1.技术介绍
java+springmvc+spring+mysql+mybatis+JSP
开发工具:eclipse或IDEA
2.主要功能说明:
1)老人
2)工作人员
3)管理员
个人信息、用户管理、公告管理、老人信息管理、健康评估管理、费用管理、床位管理、日常活动管理、健康档案管理、膳食管理、事故管理、请假管理、员工管理、工资管理、出入登记管理
3.部分代码展示:
package com.it.controller;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.checklogin.SysUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.it.mapper.UserMapper;
import com.it.model.User;
import com.it.util.ImportUtil;
import com.it.util.PageModel;
@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();
List<User> listUser = userMapper.getObjectByName(util);
int i = 0;
User user = null;
if (null != listUser && listUser.size() > 0) {
for (User u : listUser) {
boolean flag = u.getS_1().equals(util.getS_1()) && u.getS_16().equals("Y");
if (flag) {
i = 1;
user = u;
break;
}
}
if (i == 0) {
model.addAttribute("errMsg", "登录失败");
return "../login";
}
} else {
model.addAttribute("errMsg", "登录失败");
return "../login";
}
if (i == 1 && !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/uppwdok";
}
@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) {
List<User> listUser = userMapper.getObjectByName(util);
if (null != listUser && listUser.size() > 0) { //不为空
model.addAttribute("errMsg", "该用户名已经存在");
return "../register";
}
util.setS_2(util.getS_0());
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 {
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) {
try {
userMapper.deleteObject(util.getId());
} catch (Exception e) {
}
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("upload") + 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()));
new ImportUtil().insert(localFile, fileName.replaceAll(".xls", ""));
}
return "Import/ok";
}
return "Import/ok";
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/show.do")
public String show(HttpServletRequest request, User util, Model model) {
String table = "t_user";
String field = "u_username";
String fieldValue = "u_password";
String agg = "count";
List<String> x = new ArrayList<String>();
List<String> y = new ArrayList<String>();
List<Map> list = userMapper.show(table, field, fieldValue, agg);
for (Map<String, Object> map : list) {
x.add(map.get("showname").toString());
y.add(map.get("showvalues").toString());
}
model.addAttribute("x", x);
model.addAttribute("y", y);
return "User/show";
}
}
4.系统演示地址:
链接:https://pan.baidu.com/s/1eduU_19OkbcFa3ZG7RpdOQ
提取码:osca