项目编号:BS-PT-064
一,项目简介
本项目基于Springboot实现开发了一个漫画主题的网站,实现了一个比漂亮的动漫连载的网站系统。前端用户注册登陆后可以在线查看漫画连载信息等,对个人信息进行管理等操作。后台管理用户登陆后可以实现用户管理,动漫管理,反馈管理,更新预告管理,漫画排行管理等相关功能模块,界面设计优雅大方,比较适合做毕业设计和课程设计使用。
二,环境介绍
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA或eclipse
后台开发技术:Springboot+Mybatis
前后开发技术:Layui+Bootstrap
三,系统展示
系统前端展示
用户注册
登陆
个人中心
后台管理 admin/111111
用户管理
漫画管理
最近更新
更新预告
精品力荐
友情链接
漫画排行
反馈列表
四,核心代码展示
package com.mhd.manhuadui.web; import com.mhd.manhuadui.Pojo.Admin; import com.mhd.manhuadui.Pojo.Comicrank; import com.mhd.manhuadui.Pojo.MyService; import com.mhd.manhuadui.Service.AdminService; import com.mhd.manhuadui.Util.MD5Util; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.util.List; import java.util.Properties; @Controller @RequestMapping("/admin") //@SessionAttributes(value = {"a_id","adminname","adminpassword"}) public class AdminController { @Autowired private AdminService adminService; //进入后台首先跳转到登录页面 @GetMapping public String LoginPage() { return "admin/lyear_pages_login"; } //转向后台主页 @GetMapping("/a") public String index() { return "admin/index"; } /** * 管理员注销登录 * @param session * @return */ @GetMapping("/loginout") public String loginout(HttpSession session) { session.removeAttribute("admin"); return "redirect:/admin"; } /** *管理员登录验证 */ @PostMapping("/logincheck") public String logincheck(@RequestParam String adminname, @RequestParam String adminpassword, HttpSession session, RedirectAttributes attributes, HttpServletRequest request, Model model) { Admin a=new Admin(); a.setAdminname(adminname); a.setAdminpassword(MD5Util.code(adminpassword)); Admin admin = adminService.adminlogin(a); if(admin!=null) { session.setAttribute("admin",admin); // attributes.addFlashAttribute("admin",admin); model.addAttribute("admin",admin); //如果登录成功跳转到管理员首页,防止表单重复提交 return "redirect:/admin/main.html"; } else { attributes.addFlashAttribute("error","账号或者密码错误"); return "redirect:/admin"; } } @GetMapping("/top") public String top() { return "admin/top"; } /** * 获取服务器信息 * @return */ @GetMapping("/right") public String right(MyService myService,HttpServletRequest request,Model model) { //服务器环境 Properties props = MyService.getSystemProperties(); String system = props.getProperty("os.name"); //java版本 String jdkversion =props.getProperty("java.specification.version"); //数据库版本号 String sqlname = adminService.getMysql(); //服务器IP地址 String ipaddress = request.getLocalAddr(); //服务器主机名 String domainname = request.getLocalName(); myService.setSystem(system); myService.setJdkversion(jdkversion); myService.setSqlname(sqlname); myService.setIpaddress(ipaddress); myService.setDomainname(domainname); model.addAttribute("myService",myService); model.addAttribute("usernumber",adminService.getUsernumber()); model.addAttribute("mhinfonumber",adminService.getMhinfonumber()); return "admin/right"; } @GetMapping("/left") public String left() { return "admin/left"; } }
package com.mhd.manhuadui.web; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.mhd.manhuadui.Pojo.Img; import com.mhd.manhuadui.Pojo.Mhinfo; import com.mhd.manhuadui.Pojo.Mhlist; import com.mhd.manhuadui.Service.ComicmainService; import com.mhd.manhuadui.Service.ComicrankService; import com.mhd.manhuadui.Service.TrailerService; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import javax.jws.WebParam; import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; import java.util.*; /** * 后台漫画管理控制器 */ @Controller @RequestMapping("/admin") public class ComicmainController { @Autowired ComicmainService comicmainService; /** * 倒序显示列表 * @param model * @param start * @param size * @return * @throws Exception */ @GetMapping("/comicmain") public String comicmain(Model model, @RequestParam(value = "start", defaultValue = "0") int start, @RequestParam(value = "size", defaultValue = "5") int size) throws Exception { PageHelper.startPage(start,size,"id desc"); List<Mhinfo> list = new ArrayList<>(); list = comicmainService.getAll(); PageInfo<Mhinfo> page= new PageInfo<>(list); model.addAttribute("page",page); return "admin/Comicmain"; } /** * 跳转到添加漫画页面 */ @GetMapping("/addcomic") public String addcomic() { return "admin/addcomic"; } /** * *跳转到更新漫画页面 */ @GetMapping("updatecomic") public String updatecomic() { return "admin/updatecomic"; } /** * 添加漫画 */ @GetMapping("/AddComicCheck") public String Addcomic(Model model, RedirectAttributes attributes, @RequestParam String mhname, @RequestParam String authorname, @RequestParam Integer size, @RequestParam String announcement, @RequestParam String state, @RequestParam String category, @RequestParam String type, @RequestParam String region, @RequestParam String Introduction, @RequestParam String alias, @RequestParam String imgurl ) { // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS"); // Date date = new Date(); // String updatetime = sdf.format(date); Mhinfo mhinfo = new Mhinfo(); mhinfo.setMhname(mhname); mhinfo.setAuthorname(authorname); mhinfo.setSize(size); mhinfo.setAnnouncement(announcement); mhinfo.setState(state); mhinfo.setCategory(category); mhinfo.setType(type); mhinfo.setRegion(region); mhinfo.setIntroduction(Introduction); mhinfo.setAlias(alias); mhinfo.setImgname("我是图片"); mhinfo.setImgurl(imgurl); mhinfo.setUpdatetime(new Date()); if(mhinfo!=null) { comicmainService.savemh(mhinfo); System.out.println("添加成功"); attributes.addFlashAttribute("message","添加成功,你可以继续添加或者关闭页面"); return "redirect:/admin/addcomic"; } else { System.out.println("添加失败"); attributes.addFlashAttribute("error","添加失败"); return "redirect:/admin/addcomic"; } } /** * 删除漫画 */ @GetMapping("/deletemh") public String deletemh(@RequestParam Integer id) { comicmainService.remove(id); System.out.println("删除成功"+id); return "redirect:/admin/comicmain"; } /** * 获取漫画内容 */ @GetMapping("/getId") public String getId(int id,Model model) { Mhinfo mhinfo = new Mhinfo(); mhinfo = comicmainService.getId(id); model.addAttribute("list",mhinfo); return "admin/updatecomic"; } /** * 更新漫画 */ @GetMapping("/update") public String update(Model model, RedirectAttributes attributes, @RequestParam String mhname, @RequestParam String authorname, @RequestParam Integer size, @RequestParam String announcement, @RequestParam String state, @RequestParam String category, @RequestParam String type, @RequestParam String region, @RequestParam String Introduction, @RequestParam String alias, @RequestParam String imgurl, @RequestParam Integer id){ Mhinfo mhinfo = new Mhinfo(); mhinfo.setId(id); mhinfo.setMhname(mhname); mhinfo.setAuthorname(authorname); mhinfo.setSize(size); mhinfo.setAnnouncement(announcement); mhinfo.setState(state); mhinfo.setCategory(category); mhinfo.setType(type); mhinfo.setRegion(region); mhinfo.setIntroduction(Introduction); mhinfo.setAlias(alias); mhinfo.setImgurl(imgurl); mhinfo.setUpdatetime(new Date()); comicmainService.updatecomic(mhinfo); System.out.println("更新成功"); return "redirect:/admin/comicmain"; } /** * 漫画模糊查询 */ @GetMapping("/serachmh") public String serachmh(@RequestParam String nameorauthor,Model model) { List<Mhinfo> list = new ArrayList<>(); list = comicmainService.getnameorau(nameorauthor); if(list.toString().equals("[]")) { model.addAttribute("message","没有搜索到相关数据"); return "admin/comicserach"; } else { model.addAttribute("list", list); return "admin/comicserach"; } } /** * 获取漫画名跳转到添加章节列表 */ @GetMapping("/addtitle") public String addtitle(String name,Model model) { int id = comicmainService.sidbyname(name); System.err.println(id); model.addAttribute("id",id); return "admin/addtitle"; } /** * 显示章节列表 */ @GetMapping("/titlelist") public String titlelist(Integer id,Model model) { List<Mhlist> list = new ArrayList<>(); Mhinfo m = new Mhinfo(); m = comicmainService.getId(id); list = comicmainService.getmhlist(id); model.addAttribute("list",list); model.addAttribute("m",m); return "admin/titlelist"; } /** * 添加章节列表 */ @GetMapping("/AddTitle") public String AddTitle(RedirectAttributes attributes,@RequestParam int id,@RequestParam String title) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); String time = sdf.format(date); Mhlist m = new Mhlist(); m.setM_id(id); m.setCreatetime(time); m.setTitle(title); comicmainService.savemhlist(m); System.out.println("保存成功"); attributes.addFlashAttribute("message","添加成功,可以继续添加或者关闭会话框"); return "redirect:/admin/success"; } @GetMapping("/success") public String success() { return "admin/success"; } /** * 漫画图片显示列表 * @param id * @param model * @return */ @GetMapping("/mhimglist") public String mhimglist(Integer id,Model model) { List<Img> list = new ArrayList<>(); list = comicmainService.imglist(id); String name = comicmainService.Selectnamebyid(id); String title = comicmainService.Selecttitlebyid(id); model.addAttribute("list",list); model.addAttribute("name",name); model.addAttribute("title",title); return "admin/mhlist"; } /** * 跳转到上传漫画图片页面 */ @GetMapping("/addmhImg") public String addmhimg() { return "admin/addmhImg"; } /** * 上传漫画图片 */ @GetMapping("/addmhimgcheck") public String addmhimgcheck(@RequestParam Integer id,@RequestParam String imgurl,RedirectAttributes attributes) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); String createtime = sdf.format(date); Img i = new Img(); i.setI_id(id); i.setImgurl(imgurl); i.setCreatetime(createtime); comicmainService.Saveimg(i); System.out.println("添加成功"+imgurl); attributes.addFlashAttribute("message","添加成功你可以继续添加或者关闭会话框"); return "redirect:/admin/addmhImg"; } }
package com.mhd.manhuadui.web; import com.mhd.manhuadui.Pojo.Comicrank; import com.mhd.manhuadui.Service.ComicrankService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; /** * 漫画排名控制器 */ @Controller @RequestMapping("/admin") public class ComicrankController { @Autowired ComicrankService comicrankService; /** * 漫画排名 * @return */ @GetMapping("/comicrank") public String comicrank(Model model) throws Exception { List<Comicrank> list = comicrankService.getComicPaiming(); if(list!=null) { model.addAttribute("c2",list); return "admin/Comicrank"; } else { System.err.println("获取内容失败"); return "redirect:/admin/index"; } } /** * 更新漫画排名 * @param c_id * @param c_name * @param c_words * @return */ @GetMapping("/updatepaiming") public String updatecomicrank(@RequestParam int c_id,@RequestParam String c_name,@RequestParam String c_words) { Comicrank comicrank = new Comicrank(); comicrank.setC_id(c_id); comicrank.setC_name(c_name); comicrank.setC_words(c_words); comicrankService.updategetid(comicrank); System.out.println("更新成功"); return "redirect:/admin/comicrank"; // System.err.println("更心失败"); // return "admin/updatecomicrank"; } @GetMapping("/getid") public String getId(int c_id,Model model) { Comicrank comicrank = comicrankService.getone(c_id); model.addAttribute("c",comicrank); return "admin/updatecomicrank"; } }
五,项目总结
表结构模型如下: