基于javaweb+mysql的springboot汉服文化bbs系统(java+springboot+thymeleaf+html+layui+bootstrap+mysql)

基于javaweb+mysql的springboot汉服文化bbs系统(java+springboot+thymeleaf+html+layui+bootstrap+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot汉服文化bbs系统(java+springboot+thymeleaf+html+layui+bootstrap+mysql)

项目介绍

汉服文化bbs系统,主要分为前后台。共分两种角色:管理员与普通用户;

管理员可登录前后台,普通用户仅可登录前台;普通用户登录后可发布、修改、删除自己的文章; 前台主要功能包括: 首页:文章列表、公告列表、汉服舞曲; 汉服形制:汉服发展史、汉服名词; 汉服礼仪; 汉服穿搭:汉服妆容、汉服摄影; 汉服活动:汉服事记; 推荐:汉服店铺、汉服推荐、汉服体验; 后台主要功能包括: 文章管理:查询、删除; 店铺推荐:新增推荐店、查看、修改、删除; 汉服体验店推荐:新增体验店、查看、修改、删除; 社团推荐:新增社团、查看、修改、删除; 汉服舞曲:新增舞曲、查看、删除; 公告管理:新增公告、查看、修改、删除; 留言管理:查询、修改、删除;

评论管理:查询、修改、删除;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

6.数据库:MySql 5.7版本;

技术栈

  1. 后端:SpringBoot

  2. 前端:Thymeleaf+html+layui+jQuery+bootstrap

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目,输入http://localhost:8080/ 登录

@RequestMapping("experience")
@RestController
@Scope("prototype")
public class ExperienceController {
    @Value("${web.upload-path}")
    private String path;
    @Autowired
    private ExperienceService experienceService;

    @RequestMapping("/findPage")
    public ObjDat<Experience> findPage(Experience experience, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return experienceService.findPage(experience,page-1,limit);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Experience experience, HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");

        if(user==null){
            return JsonResult.error("请登录");
        }
        if(experience.getId()==null){
            experience.setUid(user.getId());
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            experience.setPath(imgname);
        }
        String str=experienceService.edit(experience);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
        return musicService.findById(id);
    }
}

@RequestMapping("store")
@RestController
@Scope("prototype")
public class StoreController {
    @Value("${web.upload-path}")
    private String path;
    @Autowired
    private StoreService storeService;

    @RequestMapping("/findPage")
    public ObjDat<Store> findPage(Store store, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return storeService.findPage(store,page-1,limit);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Store store, HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
        if(user==null){
            return JsonResult.error("请登录");
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
        }
    }

    @RequestMapping("/delById")
    public JsonResult delById(Integer id){
        return musicService.delById(id);
    }

    @RequestMapping("/findById")
    public JsonResult findById(Integer id){
        return musicService.findById(id);
    }
}

@RequestMapping("store")
@RestController
@Scope("prototype")
public class StoreController {
    @Value("${web.upload-path}")
    private String path;
    @Autowired
    private StoreService storeService;

    @RequestMapping("/findPage")
    public ObjDat<Store> findPage(Store store, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return storeService.findPage(store,page-1,limit);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Store store, HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
        if(user==null){
            return JsonResult.error("请登录");
    public JsonResult findById(Integer id){
        return signService.findById(id);
    }

}

@RequestMapping("/user")
@RestController
@Scope("prototype")
public class UserController {
    @Autowired
    private UserService userService;

    @Value("${web.upload-path}")
    private String path;

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, User user) throws IOException {
        String str=userService.edit(user);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    }

    @RequestMapping("/login")
    public JsonResult login(User user, HttpServletRequest request) throws Exception{
        return userService.login(user,request);
    }

    @RequestMapping("/registered")
    public JsonResult registered(User user){
        return userService.registered(user);
    }
    public JsonResult findByWear(@RequestParam(value="number", defaultValue="6")int number){
        return articleService.findByWear(number);
    }

    /*汉服形制热门查询*/
    @RequestMapping("/findByShape")
    public JsonResult findByShape(@RequestParam(value="number", defaultValue="6")int number){
        return articleService.findByShape(number);
    }

    /*汉服活动热门查询*/
    @RequestMapping("/findByActivity")
    public JsonResult findByActivity(@RequestParam(value="number", defaultValue="6")int number){
        return articleService.findByActivity(number);
    }

    /*按类型查询分页查询*/
    @RequestMapping("/findPageByType")
    public ObjDat<Article> findPageByType(Article article, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return articleService.findPageByType(article,page-1,limit);
    }

    /*按类型查询分页查询*/
    @RequestMapping("/findArticleByUid")
    public JsonResult findArticleByUid(int uid){
        return articleService.findArticleByUid(uid);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Article article,HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
        if(article.getId()==null){
            article.setUid(user.getId());
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            article.setPath(imgname);
        }
        String str=articleService.edit(article);
        if(str.equals("成功")){
        return articleService.findByWear(number);
    }

    /*汉服形制热门查询*/
    @RequestMapping("/findByShape")
    public JsonResult findByShape(@RequestParam(value="number", defaultValue="6")int number){
        return articleService.findByShape(number);
    }

    /*汉服活动热门查询*/
    @RequestMapping("/findByActivity")
    public JsonResult findByActivity(@RequestParam(value="number", defaultValue="6")int number){
        return articleService.findByActivity(number);
    }

    /*按类型查询分页查询*/
    @RequestMapping("/findPageByType")
    public ObjDat<Article> findPageByType(Article article, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return articleService.findPageByType(article,page-1,limit);
    }

    /*按类型查询分页查询*/
    @RequestMapping("/findArticleByUid")
    public JsonResult findArticleByUid(int uid){
        return articleService.findArticleByUid(uid);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Article article,HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
        if(article.getId()==null){
            article.setUid(user.getId());
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            article.setPath(imgname);
        }
        String str=articleService.edit(article);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            article.setPath(imgname);
        }
        String str=articleService.edit(article);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    }

    @RequestMapping("/delById")
    public JsonResult delById(Integer id){
        return articleService.delById(id);
    }

    @RequestMapping("/findById")
    public JsonResult findById(Integer id){
        return articleService.findById(id);
    }

    //上传图片
    @RequestMapping(value = "upload",method = RequestMethod.POST)
    public @ResponseBody
    String uploads(HttpServletRequest request, @RequestParam("myFileName")MultipartFile head) throws JSONException, IOException {
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            //根据wangEditor的服务端接口,造一个JSON对象返回
            JSONObject json = new JSONObject();
            JSONArray array = new JSONArray();
            json.put("errno",0);
            json.put("data",array);
            return json.toString();
        }else{
            return null;
        }
    }
}

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public JsonResult registered(User user) {
        //判断帐号格式
        if(user.getUsername()==null || user.getUsername().length()<5){
            return JsonResult.error("帐号格式不正确,长度必须大于等于5位");
        }
        //判断当前帐号是否存在
        QueryWrapper<User> qw=new QueryWrapper<User>();
        qw.eq("username",user.getUsername());
        User item=userDao.selectOne(qw);
        if(item!=null){
            return JsonResult.error("帐号以存在");
        }

        if(!user.getPassword().equals(user.getPasswordTwo())){
            return JsonResult.error("两次密码不同");
        }
        user.setName(user.getUsername());
        user.setRole("user");
        //保存
        userDao.insert(user);
        return JsonResult.success();
    }

    }

    @RequestMapping("/article_list")
    public String articleList(){
        return "article_list";
    }

    @RequestMapping("/community_list")
    public String communityList(){
        return "community_list";
    }

    @RequestMapping("/store_list")
    public String storeList(){
        return "store_list";
    }

    @RequestMapping("/feedback_list")
    public String feedbackList(){
        return "feedback_list";
    }

    @RequestMapping("/sign_list")
    public String signList(){
        return "sign_list";
    }

    @RequestMapping("/comments_list")
    public String commentsList(){
        return "comments_list";
    }

    @RequestMapping("/experience_list")
    public String experienceList(){
        return "experience_list";
    }

    @RequestMapping("/music_list")
    public String musicList(){
        return "music_list";
    }
}


    @RequestMapping("/logout")
    public String logout(HttpServletRequest request){
        request.getSession().setAttribute("user",null);
        return "home";
    }

    @RequestMapping("/login")
    public String login(){
        return "login";
    }

    @RequestMapping("/register")
    public String register(){
        return "register";
    }

    @RequestMapping("/article_list")
    public String articleList(){
        return "article_list";
    }

    @RequestMapping("/community_list")
    public String communityList(){
        return "community_list";
    }

    @RequestMapping("/store_list")
    public String storeList(){
        return "store_list";
    }

    @RequestMapping("/feedback_list")
    public String feedbackList(){
        return "feedback_list";
    }

    @RequestMapping("/sign_list")
    public String signList(){
        return "sign_list";
    }

    @RequestMapping("/comments_list")
    public String commentsList(){
        return "comments_list";
    }
    public ObjDat<Article> findPageByType(Article article, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return articleService.findPageByType(article,page-1,limit);
    }

    /*按类型查询分页查询*/
    @RequestMapping("/findArticleByUid")
    public JsonResult findArticleByUid(int uid){
        return articleService.findArticleByUid(uid);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Article article,HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
        if(article.getId()==null){
            article.setUid(user.getId());
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            article.setPath(imgname);
        }
        String str=articleService.edit(article);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    }

    @RequestMapping("/delById")
    public JsonResult delById(Integer id){
        return articleService.delById(id);
    }


@RequestMapping("music")
@RestController
@Scope("prototype")
public class MusicController {
    @Value("${web.upload-path}")
    private String path;
    @Autowired
    private MusicService musicService;

    @RequestMapping("/findPage")
    public ObjDat<Music> findPage(Music music, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return musicService.findPage(music,page-1,limit);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Music music, HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
        if(user==null){
            return JsonResult.error("请登录");
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            music.setPath(imgname);
        }
        String str=musicService.edit(music);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    }

    @RequestMapping("/delById")
    public JsonResult delById(Integer id){
        return musicService.delById(id);
    }

            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            experience.setPath(imgname);
        }
        String str=experienceService.edit(experience);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    } @RequestMapping("/delById")
    public JsonResult delById(Integer id){
        return experienceService.delById(id);
    }

    @RequestMapping("/findById")
    public JsonResult findById(Integer id){
        return experienceService.findById(id);
    }

}

    private String path;
    @Autowired
    private ExperienceService experienceService;

    @RequestMapping("/findPage")
    public ObjDat<Experience> findPage(Experience experience, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return experienceService.findPage(experience,page-1,limit);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Experience experience, HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");

        if(user==null){
            return JsonResult.error("请登录");
        }
        if(experience.getId()==null){
            experience.setUid(user.getId());
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            experience.setPath(imgname);
        }
        String str=experienceService.edit(experience);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    } @RequestMapping("/delById")
    public JsonResult delById(Integer id){
        return experienceService.delById(id);
    }

    @RequestMapping("/findById")
    public JsonResult findById(Integer id){
        return experienceService.findById(id);
    }

}

    @RequestMapping("/logout")
    public String logout(HttpServletRequest request){
        request.getSession().setAttribute("user",null);
        return "home";
    }

    @RequestMapping("/login")
    public String login(){
        return "login";
    }

    @RequestMapping("/register")
    public String register(){
        return "register";
    }

    @RequestMapping("/article_list")
    public String articleList(){
        return "article_list";
    }

    @RequestMapping("/community_list")
    public String communityList(){
        return "community_list";
    }

    @RequestMapping("/store_list")
    public String storeList(){
        return "store_list";
    }

    @RequestMapping("/feedback_list")
    public String feedbackList(){
        return "feedback_list";
    }

    @RequestMapping("/sign_list")
    public String signList(){
        return "sign_list";
    }

    @RequestMapping("/comments_list")
    public String commentsList(){
        return "comments_list";
    }

    @RequestMapping("/experience_list")
    public String experienceList(){
        return "experience_list";
    }

    @RequestMapping("/music_list")
public class CommentsController {
    @Autowired
    private CommentsService commentsService;

    @RequestMapping("/findPage")
    public ObjDat<Comments> findPage(Comments comments, HttpServletRequest request, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return commentsService.findPage(comments,page-1,limit);
    }

    @RequestMapping("/edit")
    public JsonResult edit(Comments comments, HttpServletRequest request){
        User user=(User)request.getSession().getAttribute("user");
        if(user==null){
            return JsonResult.error("请登录");
        }

        comments.setUid(user.getId());
        comments.setDate(new Date());
        String str=commentsService.edit(comments);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    }

    @RequestMapping("/delById")
    public JsonResult delById(Integer id){
        return commentsService.delById(id);
    }
    @RequestMapping("/findById")
    public JsonResult findById(Integer id){
        return commentsService.findById(id);
    }
}


@RequestMapping("store")
@RestController
@Scope("prototype")
public class StoreController {
    @Value("${web.upload-path}")
    private String path;
    @Autowired
    private StoreService storeService;

    @RequestMapping("/findPage")
    public ObjDat<Store> findPage(Store store, @RequestParam(value="page", defaultValue="1") int page, @RequestParam(value="limit", defaultValue="10") int limit){
        return storeService.findPage(store,page-1,limit);
    }

    @RequestMapping("/edit")
    public JsonResult edit(MultipartFile head, Store store, HttpServletRequest request) throws IOException {
        User user=(User)request.getSession().getAttribute("user");
        if(user==null){
            return JsonResult.error("请登录");
        }
        if(head!=null){
            File file = new File(path);
            if (!file.exists()) {
                file.mkdirs();
            }
            String imgname= UUID.randomUUID().toString() + head.getOriginalFilename();
            path = path + imgname;
            file = new File(path);
            head.transferTo(file);
            store.setPath(imgname);
        }
        String str=storeService.edit(store);
        if(str.equals("成功")){
            return JsonResult.success("操作成功");
        }else{
            return JsonResult.error("操作失败");
        }
    }

    @RequestMapping("/delById")
    public JsonResult delById(Integer id){

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值