源码获取:博客首页 "资源" 里下载!
管理员:校园管理(楼栋管理、宿舍管理)、师生管理(学生管理、辅导员管理)、维修管理(维修工管理、维修进度管理)、阅览室管理(座位生成等)、学生信用积分管理、座位预约统计管理等。
学生:登录、修改个人信息、上报宿舍维修信息、查看维修进度、完成维修进度等。
维修工:登录、查看分配给自己的维修任务、标记自己的维修进度等。
运行环境:windows/Linux均可、jdk1.8、mysql5.7、idea/eclipse均可。
学生管理控制层:
@RequestMapping("/stu")
@Controller
public class StudentController {
@Autowired
private StudentService studentService;
@Autowired
private DormitoryService dormitoryService;
@Autowired
CoachDao coachDao;
@Autowired
private RoleService roleService ;
@RequestMapping(value="/list")
public String list(Model model, Student student, PageBean<Student> pageBean){
model.addAttribute("title", "学生列表");
model.addAttribute("name", student.getStudentName());
model.addAttribute("pageBean", studentService.findByName(student, pageBean));
return "admin/student/list";
}
/**
* 学生修改
* @param model
* @param id
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.GET)
public String edit(Model model,@RequestParam(name="id")Long id){
Student byID = studentService.findByID(id);
List<Building> all2 = buildingService.findAll();
List<Dormitory> byBuilding_id = dormitoryService.findByBuilding_Id(byID.getDormitory().getBuilding().getId());
List<Coach> all1 = coachDao.findAll();
model.addAttribute("coachs",all1);
model.addAttribute("dormitorys",byBuilding_id);
model.addAttribute("buildings",all2);
model.addAttribute("student",byID );
return "admin/student/edit";
}
@Autowired
private BuildingService buildingService;
/**
* 角色添加页面
* @param
* @return
*/
@RequestMapping(value="/add",method= RequestMethod.GET)
public String add(Model model){
//查出所有的宿舍
List<Dormitory> all = dormitoryService.findAll();
//查出所有辅导员
List<Building> all2 = buildingService.findAll();
List<Coach> all1 = coachDao.findAll();
//model.addAttribute("dormitorys",all);
model.addAttribute("coachs",all1);
model.addAttribute("buildings",all2);
return "admin/student/add";
}
@RequestMapping(value="delete",method= RequestMethod.POST)
@ResponseBody
public Result delete(long id){
try {
studentService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_ROLE_DELETE_ERROR);
}
return Result.success(true);
}
@RequestMapping(value="/building",method= RequestMethod.POST)
@ResponseBody
public Result getuilding(long id){
List<Dormitory> byBuilding_id = dormitoryService.findByBuilding_Id(id);
return Result.success(byBuilding_id);
}
/**
* 编辑用户信息表单提交处理
* @param
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(Student student){
/**
* 有id是修改需要判断
* 无id是增加无需判断
*/
if (student.getId()!=null){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(student);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
//到这说明一切符合条件,进行数据库保存
Student byID = studentService.findByID(student.getId());
//讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(student,byID, "id","createTime","updateTime","studentNo","role","password");
studentService.save(byID);
}else {
if (!StringUtil.emailFormat(student.getEmail())){
return Result.error(CodeMsg.ADMIN_STUDENT_EMAIL);
}
if (!StringUtil.isMobile(student.getMobile())){
return Result.error(CodeMsg.ADMIN_STUDENT_MOBILE);
}
student.setRole(roleService.findByRoleType(RoleType.STUDENT));
String s = StringUtil.generateSn("S", "");
student.setStudentNo(s);
student.setPassword(s);
studentService.save(student);
}
return Result.success(true);
}
@Autowired
private OperaterLogService operaterLogService;
@Autowired
private DatabaseBakService databaseBakService;
private Logger log = LoggerFactory.getLogger(SystemController.class);
}
后台用户管理控制器:
/**
* 后台用户管理控制器
* @author yy
*
*/
@RequestMapping("/user")
@Controller
public class UserController {
@Autowired
private UserService userService;
@Autowired
private RoleService roleService;
@Autowired
private OperaterLogService operaterLogService;
/**
* 用户列表页面
* @param model
* @param user
* @param pageBean
* @return
*/
@RequestMapping(value="/list")
public String list(Model model,User user,PageBean<User> pageBean){
model.addAttribute("title", "用户列表");
model.addAttribute("username", user.getUsername());
model.addAttribute("pageBean", userService.findList(user, pageBean));
return "admin/user/list";
}
/**
* 新增用户页面
* @param model
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.GET)
public String add(Model model){
model.addAttribute("roles", roleService.findAll());
return "admin/user/add";
}
/**
* 用户添加表单提交处理
* @param user
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
}
//判断用户名是否存在
if(userService.isExistUsername(user.getUsername(), 0l)){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
}
//到这说明一切符合条件,进行数据库新增
if(userService.save(user) == null){
return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
}
operaterLogService.add("添加用户,用户名:" + user.getUsername());
return Result.success(true);
}
/**
* 用户编辑页面
* @param model
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.GET)
public String edit(Model model,@RequestParam(name="id",required=true)Long id){
model.addAttribute("roles", roleService.findAll());
model.addAttribute("user", userService.find(id));
return "admin/user/edit";
}
/**
* 编辑用户信息表单提交处理
* @param user
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> edit(User user){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(user);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(user.getRole() == null || user.getRole().getId() == null){
return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
}
if(user.getId() == null || user.getId().longValue() <= 0){
return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
}
if(userService.isExistUsername(user.getUsername(), user.getId())){
return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
}
//到这说明一切符合条件,进行数据库保存
User findById = userService.find(user.getId());
//讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(user, findById, "id","createTime","updateTime");
if(userService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
}
operaterLogService.add("编辑用户,用户名:" + user.getUsername());
return Result.success(true);
}
/**
* 删除用户
* @param id
* @return
*/
@RequestMapping(value="/delete",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
try {
userService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
}
operaterLogService.add("添加用户,用户ID:" + id);
return Result.success(true);
}
}
建筑控制层:
@Controller
@RequestMapping("/building")
public class BuildingController {
@Autowired
private BuildingService buildingService;
@Autowired
private OperaterLogService operaterLogService;
/**
* 楼栋列表页面
* @param model
* @param building
* @param pageBean
* @return
*/
@RequestMapping(value="/list")
public String list(Model model, Building building, PageBean<Building> pageBean){
model.addAttribute("title", "楼栋列表");
model.addAttribute("campus", building.getCampus());
model.addAttribute("pageBean", buildingService.findList(building, pageBean));
return "admin/building/list";
}
/**
* 新增楼栋页面
* @param model
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.GET)
public String add(Model model){
model.addAttribute("building", buildingService.findAll());
return "admin/building/add";
}
/**
* 楼栋编辑页面
* @param model
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.GET)
public String edit(Model model,@RequestParam(name="id",required=true)Long id){
model.addAttribute("building", buildingService.find(id));
return "admin/building/edit";
}
/**
* 楼栋添加表单提交处理
* @param building
* @return
*/
@RequestMapping(value="/add",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> add(Building building){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(building);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(buildingService.isExistCampusAndBno(building.getCampus(),building.getBno(), 0L)){
return Result.error(CodeMsg.ADMIN_BUILDING_EXIST);
}
//到这说明一切符合条件,进行数据库新增
if(buildingService.save(building) == null){
return Result.error(CodeMsg.ADMIN_BUILDING_ADD_ERROR);
}
operaterLogService.add("添加楼栋,楼栋校区和楼号:" + building.getCampus()+building.getBno());
return Result.success(true);
}
/**
* 编辑楼栋信息表单提交处理
* @param building
* @return
*/
@RequestMapping(value="/edit",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> edit(Building building){
//用统一验证实体方法验证是否合法
CodeMsg validate = ValidateEntityUtil.validate(building);
if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
return Result.error(validate);
}
if(building.getId() == null || building.getId().longValue() <= 0){
return Result.error(CodeMsg.ADMIN_BUILDING_EXIST);
}
if(buildingService.isExistCampusAndBno(building.getCampus(),building.getBno(), building.getId())){
return Result.error(CodeMsg.ADMIN_BUILDING_EXIST);
}
//到这说明一切符合条件,进行数据库保存
Building findById = buildingService.find(building.getId());
//讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
BeanUtils.copyProperties(building, findById, "id","createTime","updateTime");
if(buildingService.save(findById) == null){
return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
}
operaterLogService.add("编辑楼栋,楼栋校区和楼号:" + building.getCampus()+building.getBno());
return Result.success(true);
}
/**
* 删除楼栋
* @param id
* @return
*/
@RequestMapping(value="/delete",method=RequestMethod.POST)
@ResponseBody
public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
try {
buildingService.delete(id);
} catch (Exception e) {
return Result.error(CodeMsg.ADMIN_BUILDING_DELETE_ERROR);
}
operaterLogService.add("添加用户,用户ID:" + id);
return Result.success(true);
}
}
源码获取:博客首页 "资源" 里下载!
本文转载自: https://blog.csdn.net/m0_66863468/article/details/123103505
版权归原作者 qq1334611189 所有, 如有侵权,请联系我们删除。
版权归原作者 qq1334611189 所有, 如有侵权,请联系我们删除。