作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、腾讯课堂常驻讲师
主要内容:Java项目、Python项目、前端项目、人工智能与大数据、简历模板、学习资料、面试题库、技术互助
收藏点赞不迷路 关注作者有好处
文末获取源码
项目编号:ZJL
一,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
二,项目简介
前台登陆:
本系统用户分为三大类:管理员学生家长和老师。
为这三大类用户提供他们各自的功能:
管理员:校内公告发布、申请公告发布到网站、申请新闻发布到网站、校内新闻、登录及权限验证、注册申请、密码找回、管理本校事务。申请家长身份,维护学生——家长关系(申请新的学生与家长关系,取消学生与家长关系)。消息推送。
老师(按不同的身份权限):登录及权限验证、留言、发布问卷调查、布置作业、考试管理、学籍管理。申请家长身份,维护学生——家长关系(申请新的学生与家长关系,取消学生与家长关系)。消息推送。
学生家长:登录及权限验证、注册申请、密码找回。维护学生——家长关系(申请新的学生与家长关系,取消学生与家长关系)。查看学生作业。即时聊天功能(类似qq群一样)
为实现各用户的功能系统需提供的功能:
网站首页及栏目设置:网站介绍、最近动态、公告、网站新闻、用户登录入口、注册入口、密码找回功能入口。
与用户身份相匹配的个人登录后的功能界面入口:学校用户及学生家长能看到本学校内的公告和校内新闻;与个人权限相匹配的各功能入口。
用户注册及密码找回功能、登录及权限验证功能。
网站页面展示模块:网站介绍、最近动态、学校注册情况、公告、网站新闻、用户登录入口、密码找回功能入口、注册入口。
鉴权及功能入口展示模块:学校用户及学生家长能看到本学校内的公告和校内新闻;与个人权限相匹配的各功能入口。
后台:
系统管理模块:用户帐户管理、权限管理、网站介绍发布、最近动态发布、审核用户注册申请、新闻公告审核、发布系统公告、发布网站新闻。校内新闻管理、申请新闻发布到网站;帐户管理(注册老师用户,为老师用户指定身份角色,激活、禁用帐户);学科年级信息维护、学校班级信息维护、学科信息维护;学校信息维护。
老师应用模块(按不同的身份权限):沟通交流、布置作业、考试管理、学籍管理(录入本班学生信息、分班、学生升、留级、毕业)、个人信息维护。申请家长身份,维护学生——家长关系(申请新的学生与家长关系,取消学生与家长关系)。考虑利用手机进行短信推送信息。
学生家长应用模块:沟通交流、作业下载。维护学生——家长关系(申请新的学生与家长关系,取消学生与家长关系)
三,系统展示
3.1 前后功能
3.2 后台管理
四,核心代码展示
4.1 教室管理
@Controller
@RequestMapping("/classroom")
public class ClassroomController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private ClassroomService classroomService;
@Autowired
private SchoolService schoolService;
@Autowired
private GradeService gradeService;
@Autowired
private TeacherService teacherService;
/**
* 分页查询 返回list对象(通过对象)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByObj.do")
public String findByObj(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response,HttpSession session) {
Pager<Classroom> pagers=new Pager<Classroom>();
Integer schoolId = (Integer) session.getAttribute("schoolId");
if(!isEmpty(classroom.getName())){
Map<String, Object> map = getMap();
map.put("name",classroom.getName());
map.put("schoolId",schoolId);
//模糊查询分页查询
pagers = classroomService.findByMap(map);
}else{
classroom.setSchoolId(schoolId);
//分页查询
pagers = classroomService.findByEntity(classroom);
}
for (Classroom classroom1 : pagers.getDatas()) {
Teacher obj = teacherService.load(classroom1.getId());
if(obj!=null){
classroom1.setTeacherName(obj.getRealName());
}
Grade g=gradeService.load(classroom1.getGradeId());
if(g!=null){
classroom1.setGradeName(g.getName());
}
}
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", classroom);
return "classroom/classroom";
}
/**
* 分页查询 返回list对象(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.do")
public String findByMap(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response,HttpSession session) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(classroom.getName())){
params.put("name", classroom.getName());
}
if(!isEmpty(classroom.getGradeId())){
params.put("gradeId", classroom.getGradeId());
}
if(!isEmpty(classroom.getIsDelete())){
params.put("isDelete", classroom.getIsDelete());
}
//分页查询
Pager<Classroom> pagers = classroomService.findByMap(params);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", classroom);
return "classroom/classroom";
}
/**
* 跳至添加页面
* @return
*/
@RequestMapping(value = "/add.do")
public String add(Model model,HttpSession session) {
Integer schoolId = (Integer) session.getAttribute("schoolId");
School school=new School();
school.setId(schoolId);
List<School> schoolList=schoolService.listAllByEntity(school);
model.addAttribute("schoolList", schoolList);
return "classroom/add";
}
/**
* 添加执行
* @return
*/
@RequestMapping(value = "/exAdd.do")
public String exAdd(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response) {
classroom.setIsDelete(0);
classroom.setStatus(0);
classroomService.insert(classroom);
return "redirect:/classroom/findByObj.do";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update.do")
public String update(Integer id,Model model) {
Classroom obj = classroomService.load(id);
model.addAttribute("obj",obj);
return "classroom/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate.do")
public String exUpdate(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response) {
classroomService.update(classroom);
return "redirect:/classroom/findByObj.do";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete.do")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
classroomService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//classroomService.deleteBySqId("deleteBySql", params);
//状态删除
//Classroom load = classroomService.load(id);
//load.setIsDelete(1);
//classroomService.update(load);
return "redirect:/classroom/findByObj.do";
}
// --------------------------------------- 华丽分割线 ------------------------------
/**
* 通过id查询 返回list json(通过map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByGradeId.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String findByGradeId(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> map = getMap();
map.put("gradeId",classroom.getGradeId());
List<Classroom> classroomList =classroomService.list("listBySqlId", map);
//分页查询
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("obj", classroomList);
return jsonObject.toString();
}
/**
* 分页查询 返回list json(通过对象)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByObj.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String findByObjByEntity(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
Pager<Classroom> pagers = classroomService.findByEntity(classroom);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", classroom);
return jsonObject.toString();
}
/**
* 分页查询 返回list json(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String findByMapMap(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(classroom.getName())){
params.put("name", classroom.getName());
}
if(!isEmpty(classroom.getGradeId())){
params.put("gradeId", classroom.getGradeId());
}
if(!isEmpty(classroom.getIsDelete())){
params.put("isDelete", classroom.getIsDelete());
}
//分页查询
Pager<Classroom> pagers = classroomService.findByMap(params);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", classroom);
return jsonObject.toString();
}
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String exAddJson(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response) {
classroomService.insert(classroom);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
/**
* ajax 修改
* @param
* @return
*/
@RequestMapping(value = "/exUpdate.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String exUpdateJson(Classroom classroom, Model model, HttpServletRequest request, HttpServletResponse response) {
classroomService.update(classroom);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "修改成功");
return jsonObject.toString();
}
/**
* ajax 删除
* @return
*/
@RequestMapping(value = "/delete.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String exDeleteJson(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
classroomService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//classroomService.deleteBySqId("deleteBySql", params);
//状态删除
//Classroom load = classroomService.load(id);
//load.setIsDelete(1);
//classroomService.update(load);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "删除成功");
return jsonObject.toString();
}
/**
* 单文件上传
* @param file
* @param request
* @param model
* @return
*/
@RequestMapping(value = "/saveFile")
public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/upload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* springMvc多文件上传
* @param files
* @param id
* @return
*/
@RequestMapping(value = "/saveFiles")
public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
for(int i = 0;i<files.length;i++){
System.out.println("fileName---------->" + files[i].getOriginalFilename());
if(!files[i].isEmpty()){
int pre = (int) System.currentTimeMillis();
try {
//拿到输出流,同时重命名上传的文件
String filePath = request.getRealPath("/upload");
File f=new File(filePath);
if(!f.exists()){
f.mkdirs();
}
String fileNmae=new Date().getTime() + files[i].getOriginalFilename();
File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
if(!file.exists()){
file.createNewFile();
}
files[i].transferTo(file);
} catch (Exception e) {
e.printStackTrace();
System.out.println("上传出错");
}
}
}
return "";
}
}
4.2 网站内容发布
@Controller
@RequestMapping("/introduction")
public class IntroductionController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private IntroductionService introductionService;
/**
* 前台查询网页介绍
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/queryIntroduction.do")
public String queryIntroduction(Model model, HttpServletRequest request, HttpServletResponse response) {
List<Introduction> introductionList=introductionService.listAll();
model.addAttribute("introductionList", introductionList);
//存储查询条件
model.addAttribute("introductionList", introductionList);
return "introduction/uIntroduction";
}
/**
* 分页查询 返回list对象(通过对象)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByObj.do")
public String findByObj(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
Pager<Introduction> pagers =new Pager<Introduction>();
if(introduction.getTitle()!=null){
Map<String, Object> map = getMap();
map.put("title",introduction.getTitle());
//模糊查询分页查询
pagers = introductionService.findByMap(map);
}else{
//分页查询
pagers = introductionService.findByEntity(introduction);
}
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", introduction);
return "introduction/introduction";
}
/**
* 分页查询 返回list对象(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.do")
public String findByMap(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(introduction.getTitle())){
params.put("title", introduction.getTitle());
}
if(!isEmpty(introduction.getContent())){
params.put("content", introduction.getContent());
}
if(!isEmpty(introduction.getAddTime())){
params.put("addTime", introduction.getAddTime());
}
if(!isEmpty(introduction.getImageUrl())){
params.put("imageUrl", introduction.getImageUrl());
}
//分页查询
Pager<Introduction> pagers = introductionService.findByMap(params);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", introduction);
return "introduction/introduction";
}
/**
* 跳至添加页面
* @return
*/
@RequestMapping(value = "/add.do")
public String add() {
return "introduction/add";
}
/**
* 添加执行
* @return
*/
@RequestMapping(value = "/exAdd.do")
public String exAdd(@RequestParam(value = "file", required = false) MultipartFile file, Introduction introduction,HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/")+"upload/";
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File("D:/my/upload", fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
introduction.setImageUrl("\\upload\\"+fileName);
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
introduction.setAddTime(new Date());
introductionService.insert(introduction);
return "redirect:/introduction/findByObj.do";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update.do")
public String update(Integer id,Model model) {
Introduction obj = introductionService.load(id);
model.addAttribute("obj",obj);
return "introduction/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate.do")
public String exUpdate(@RequestParam(value = "file", required = false) MultipartFile file, Introduction introduction,HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/")+"upload/";
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File("D:/my/upload", fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
if(fileName!=null){
introduction.setImageUrl("\\upload\\"+fileName);
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
introductionService.update(introduction);
return "redirect:/introduction/findByObj.do";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete.do")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
introductionService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//introductionService.deleteBySqId("deleteBySql", params);
//状态删除
//Introduction load = introductionService.load(id);
//load.setIsDelete(1);
//introductionService.update(load);
return "redirect:/introduction/findByObj.do";
}
// --------------------------------------- 华丽分割线 ------------------------------
/**
* 分页查询 返回list json(通过对象)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByObj.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String findByObjByEntity(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
Pager<Introduction> pagers = introductionService.findByEntity(introduction);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", introduction);
return jsonObject.toString();
}
/**
* 分页查询 返回list json(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String findByMapMap(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(introduction.getTitle())){
params.put("title", introduction.getTitle());
}
if(!isEmpty(introduction.getContent())){
params.put("content", introduction.getContent());
}
if(!isEmpty(introduction.getAddTime())){
params.put("addTime", introduction.getAddTime());
}
if(!isEmpty(introduction.getImageUrl())){
params.put("imageUrl", introduction.getImageUrl());
}
//分页查询
Pager<Introduction> pagers = introductionService.findByMap(params);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", introduction);
return jsonObject.toString();
}
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String exAddJson(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
introductionService.insert(introduction);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
/**
* ajax 修改
* @param
* @return
*/
@RequestMapping(value = "/exUpdate.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String exUpdateJson(Introduction introduction, Model model, HttpServletRequest request, HttpServletResponse response) {
introductionService.update(introduction);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "修改成功");
return jsonObject.toString();
}
/**
* ajax 删除
* @return
*/
@RequestMapping(value = "/delete.json", produces=MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@ResponseBody
public String exDeleteJson(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
introductionService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//introductionService.deleteBySqId("deleteBySql", params);
//状态删除
//Introduction load = introductionService.load(id);
//load.setIsDelete(1);
//introductionService.update(load);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "删除成功");
return jsonObject.toString();
}
/**
* 单文件上传
* @param file
* @param request
* @param model
* @return
*/
@RequestMapping(value = "/saveFile")
public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/upload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* springMvc多文件上传
* @param files
* @param id
* @return
*/
@RequestMapping(value = "/saveFiles")
public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
for(int i = 0;i<files.length;i++){
System.out.println("fileName---------->" + files[i].getOriginalFilename());
if(!files[i].isEmpty()){
int pre = (int) System.currentTimeMillis();
try {
//拿到输出流,同时重命名上传的文件
String filePath = request.getRealPath("/upload");
File f=new File(filePath);
if(!f.exists()){
f.mkdirs();
}
String fileNmae=new Date().getTime() + files[i].getOriginalFilename();
File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
if(!file.exists()){
file.createNewFile();
}
files[i].transferTo(file);
} catch (Exception e) {
e.printStackTrace();
System.out.println("上传出错");
}
}
}
return "";
}
}
五,相关作品展示
基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目
基于Nodejs、Vue等前端技术开发的前端实战项目
基于微信小程序和安卓APP应用开发的相关作品
基于51单片机等嵌入式物联网开发应用
基于各类算法实现的AI智能应用
基于大数据实现的各类数据管理和推荐系统