一、项目简介
本项目基于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";
}
@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";
}
@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;
@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";
}
@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;
@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";
}
}
@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";
}
}
五、项目总结
表结构模型如下:
以上就是基于Springboot的漫画网站平台设计与实现的详细内容,更多关于Springboot漫画网站的资料请关注编程网其它相关文章!