基於Springboot實現高校社團管理系統的設計與實現

一、項目簡介

本項目基於Springboot+Mybatis開發實現瞭一個高校社團管理系統,系統包含三個角色:管理員、團長、會員。管理員主要是做一些基礎數據的管理,比較用戶管理,新聞管理,活動審批,社團創建審批等等,會員可以申請加入相關的社團,也可自己申請社團,管理員審批通過後成為團長,可以申請開展相關的活動。團長登陸後可以審批申請加入本社團的申請信息,並管理和查看相關的社團用戶信息。各角色進入均可以查看發佈的新聞信息。

二、環境介紹

語言環境:Java:  jdk1.8

數據庫:Mysql: mysql5.7   Redis緩存數據庫

應用服務器:Tomcat:  tomcat8.5.31

開發工具:IDEA或eclipse

後臺開發技術:Springboot+Mybatis+SpringCache緩存框架

前端開發技術:Jquery+AjAX+JSP

三、系統展示

下面展示一下系統的相關功能模塊:

管理員登陸後主要操作功能

登陸註冊界面

主界面

查看社團活動信息

用戶管理

社團管理

審核 管理

新聞管理

團長登陸系統後

申請創建活動

管理本社團成員

審核加入社團申請

學生登陸

申請創建社團

申請加入社團

四、核心代碼展示

package com.example.association2.controller;
 
import com.example.association2.service.impl.ActivityServiceImpl;
import com.example.association2.service.impl.AssociationMemberServiceImpl;
import com.example.association2.utils.PicUtil;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
 
@Controller
public class ActivityController {
    @Autowired
    private AssociationMemberServiceImpl associationMemberService;
    @Autowired
    private ActivityServiceImpl activityService;
 
    @GetMapping("/activities")//所有活動頁面
    public String toActivities(HttpServletRequest httpServletRequest,
                               @RequestParam(name = "key", required = true) int key) {//key判斷點擊的活動分類
        if (key == 0) {//所有活動
            httpServletRequest.setAttribute("activityList", activityService.findAllActivityAndName());
            httpServletRequest.setAttribute("key", key);
        } else if (key == 1) {//文體類活動
            httpServletRequest.setAttribute("activityList", activityService.findActivityAndNameByAssociationType(key));
            httpServletRequest.setAttribute("key", key);
        } else if (key == 2) {//學術類活動
            httpServletRequest.setAttribute("activityList", activityService.findActivityAndNameByAssociationType(key));
            httpServletRequest.setAttribute("key", key);
        } else if (key == 3) {//公益類活動
            httpServletRequest.setAttribute("activityList", activityService.findActivityAndNameByAssociationType(key));
            httpServletRequest.setAttribute("key", key);
        }
        return "jsp/activity";
    }
 
    @GetMapping("/activity")//活動詳情頁面
    public String act_detail(HttpServletRequest httpServletRequest,
                             @RequestParam(name = "activityId", required = true) int activityId) {
        String imglocation[] = activityService.findActivityById(activityId).getPicture().split(";");//把活動圖片路徑和分號切割後返回正確的圖片路徑
        httpServletRequest.setAttribute("imgLocation", imglocation);
        int imgNum = imglocation.length;
        httpServletRequest.setAttribute("imgNum", imgNum);//獲取圖片數量
        httpServletRequest.setAttribute("activity", activityService.findActivityById(activityId));
        return "jsp/act_detail";//活動詳情頁面
    }
 
    @GetMapping("/activityApply")//申請活動頁面
    public String toApply(HttpServletRequest httpServletRequest) {
        HttpSession session = httpServletRequest.getSession();
        int userId = (int) session.getAttribute("userId");
        httpServletRequest.setAttribute("associationId", associationMemberService.findassociationIdByUserId(userId));
        return "jsp/act_apply";
    }
 
    @PostMapping("/activity")//提交活動申請
    @ResponseBody
    public String addAct(@RequestParam String title,
                         String description,
                         int associationId,
                         String startTime,
                         String endTime,
                         String location,
                         float material,
                         @RequestParam(name = "base64Data0", required = false) String base64Data0,
                         @RequestParam(name = "base64Data1", required = false) String base64Data1,
                         @RequestParam(name = "base64Data2", required = false) String base64Data2,
                         HttpServletRequest httpServletRequest) {
        String picture1 = "";
        String picture2 = "";
        String picture3 = "";
        String picture = "";
        if (base64Data0 == null || "".equals(base64Data0)) {
            //提示上傳圖片錯誤
        } else {
            picture1 = PicUtil.pictureUtil(base64Data0, httpServletRequest);
            picture = picture1;
        }
        if (base64Data1 == null || "".equals(base64Data1)) {
            //提示上傳圖片錯誤
        } else {
            picture2 = PicUtil.pictureUtil(base64Data1, httpServletRequest);
            picture = picture + ";" + picture2;
        }
        if (base64Data2 == null || "".equals(base64Data2)) {
            //提示上傳圖片錯誤
        } else {
            picture3 = PicUtil.pictureUtil(base64Data2, httpServletRequest);
            picture = picture + ";" + picture3;
        }
 
        activityService.addActivity(title, description, associationId, startTime, endTime, location, material, picture);
        //HttpSession session = httpServletRequest.getSession();
        String result = "1";
        return result;
    }
 
    @RequestMapping("/applyResult")//活動申請結果頁面
    public String toresult() {
        return "jsp/apply_result";
    }
 
    @RequestMapping("/actDelete")
    public ModelAndView actDelete(@RequestParam(name = "activityId", required = true) int activityId) {
        activityService.deleteActivity(activityId);
        int bar = 2;
        ModelAndView mv = new ModelAndView();
        mv.addObject("bar", bar);
        mv.setViewName("forward:assManage");
        return mv;
    }
    //查看申請的活動圖片
    @RequestMapping("/actPicture")
    public String act_picture(HttpServletRequest httpServletRequest,
                             @RequestParam(name = "activityId", required = true) int activityId) {
        String imglocation[] = activityService.findActivityById(activityId).getPicture().split(";");//把活動圖片路徑和分號切割後返回正確的圖片路徑
        httpServletRequest.setAttribute("imgLocation", imglocation);
        int imgNum = imglocation.length;
        httpServletRequest.setAttribute("imgNum", imgNum);//獲取圖片數量
        httpServletRequest.setAttribute("activity", activityService.findActivityById(activityId));
        return "jsp/manage/act_picture";//活動詳情頁面
    }
    @RequestMapping("/toActModify")//活動修改頁面
    public String toAssModify(@RequestParam(name = "activityId", required = true) int activityId,
                              HttpServletRequest httpServletRequest) {
        String imglocation[] = activityService.findActivityAndNameById(activityId).getPicture().split(";");//把活動圖片路徑和分號切割後返回正確的圖片路徑
        httpServletRequest.setAttribute("imgLocation", imglocation);
        int imgNum = imglocation.length;
        httpServletRequest.setAttribute("imgNum", imgNum);//獲取圖片數量
        httpServletRequest.setAttribute("act", activityService.findActivityAndNameById(activityId));
        return "jsp/manage/act_modify";
    }
    @RequestMapping("/actModify")//提交活動修改
    @ResponseBody
    public String actModify( @RequestParam(name = "activityId", required = true)int activityId,
                             int activityStatus,
                             @RequestParam String title,
                             String description,
                             int associationId,
                             String startTime,
                             String endTime,
                             String location,
                             float material,
                             @RequestParam(name = "base64Data0", required = false) String base64Data0,
                             @RequestParam(name = "base64Data1", required = false) String base64Data1,
                             @RequestParam(name = "base64Data2", required = false) String base64Data2,
                             HttpServletRequest httpServletRequest) {
        String picture1 = "";
        String picture2 = "";
        String picture3 = "";
        String picture = "";
        if("data".equals(base64Data0.substring(0,4))){//本地上傳的圖片
            if (base64Data0 == null || "".equals(base64Data0)) {
                //提示上傳圖片錯誤
            } else {
                picture1 = PicUtil.pictureUtil(base64Data0, httpServletRequest);
                picture = picture1;
            }
            if (base64Data1 == null || "".equals(base64Data1)) {
                //提示上傳圖片錯誤
            } else {
                picture2 = PicUtil.pictureUtil(base64Data1, httpServletRequest);
                picture = picture + ";" + picture2;
            }
            if (base64Data2 == null || "".equals(base64Data2)) {
                //提示上傳圖片錯誤
            } else {
                picture3 = PicUtil.pictureUtil(base64Data2, httpServletRequest);
                picture = picture + ";" + picture3;
            }
        }else {//是從數據庫讀取的圖片
            if (base64Data0 == null || "".equals(base64Data0)) {
                //提示上傳圖片錯誤
            } else {
                picture1 = base64Data0;
                picture = picture1;
            }
            if (base64Data1 == null || "".equals(base64Data1)) {
                //提示上傳圖片錯誤
            } else {
                picture2 = base64Data1;
                picture = picture + ";" + picture2;
            }
            if (base64Data2 == null || "".equals(base64Data2)) {
                //提示上傳圖片錯誤
            } else {
                picture3 =base64Data2;
                picture = picture + ";" + picture3;
            }
        }
        activityService.updateActivity(title,description,associationId,startTime,endTime,location,picture,material,activityStatus,activityId);
        String result = "1";
        return result;
    }
 
    @RequestMapping("/toAddAct")
    public String toAddAss(int associationId,HttpServletRequest httpServletRequest) {
        httpServletRequest.setAttribute("associationId",associationId);
        return "jsp/manage/act_add";
    }
 
    @PostMapping("/actAdd")//活動添加業務邏輯
    @ResponseBody
    public String actAdd(@RequestParam String title,
                         String description,
                         int associationId,
                         String startTime,
                         String endTime,
                         String location,
                         float material,
                         @RequestParam(name = "base64Data0", required = false) String base64Data0,
                         @RequestParam(name = "base64Data1", required = false) String base64Data1,
                         @RequestParam(name = "base64Data2", required = false) String base64Data2,
                         HttpServletRequest httpServletRequest) {
        String picture1 = "";
        String picture2 = "";
        String picture3 = "";
        String picture = "";
        if (base64Data0 == null || "".equals(base64Data0)) {
            //提示上傳圖片錯誤
        } else {
            picture1 = PicUtil.pictureUtil(base64Data0, httpServletRequest);
            picture = picture1;
        }
        if (base64Data1 == null || "".equals(base64Data1)) {
            //提示上傳圖片錯誤
        } else {
            picture2 = PicUtil.pictureUtil(base64Data1, httpServletRequest);
            picture = picture + ";" + picture2;
        }
        if (base64Data2 == null || "".equals(base64Data2)) {
            //提示上傳圖片錯誤
        } else {
            picture3 = PicUtil.pictureUtil(base64Data2, httpServletRequest);
            picture = picture + ";" + picture3;
        }
 
        activityService.addActivity(title, description, associationId, startTime, endTime, location, material, picture);
        //HttpSession session = httpServletRequest.getSession();
        String result = "1";
        return result;
    }
 
    @RequestMapping("/actApplyPass")//活動申請通過
    public ModelAndView actApplySuccess(@RequestParam(name = "activityId", required = true) int activityId) {
        activityService.applyPass(activityId);
        int bar = 1;
        ModelAndView mv = new ModelAndView();
        mv.addObject("bar", bar);
        mv.setViewName("forward:applyManage");
        return mv;
    }
    @RequestMapping("/actApplyRefuse")//活動申請拒絕
    public ModelAndView actApplyRefuse(@RequestParam(name = "activityId", required = true) int activityId) {
        activityService.applyRefuse(activityId);
        int bar = 1;
        ModelAndView mv = new ModelAndView();
        mv.addObject("bar", bar);
        mv.setViewName("forward:applyManage");
        return mv;
    }
}
package com.example.association2.controller;
 
import com.example.association2.service.impl.ActivityServiceImpl;
import com.example.association2.service.impl.AssociationMemberServiceImpl;
import com.example.association2.service.impl.AssociationServiceImpl;
import com.example.association2.service.impl.NewsServiceImpl;
import com.example.association2.utils.PicUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;
 
@Controller
public class AssociationController {
    @Autowired
    private AssociationServiceImpl associationService;
    @Autowired
    private AssociationMemberServiceImpl associationMemberService;
    @Autowired
    private ActivityServiceImpl activityService;
    @Autowired
    private NewsServiceImpl newsService;
    @GetMapping("/associations")//所有社團頁面
    public String index(HttpServletRequest httpServletRequest,
                        @RequestParam(name = "type", required = false, defaultValue = "1") int type) {
        httpServletRequest.setAttribute("type", type);
        httpServletRequest.setAttribute("associationsList", associationService.findAssociationsByType(type));
        httpServletRequest.setAttribute("lastActivity", activityService.findLastActivity());
        return "jsp/mid/index";
    }
 
    //申請創建社團頁面
    @GetMapping("/associationApply")
    public String toApplyAss(HttpServletRequest httpServletRequest) {
        HttpSession session = httpServletRequest.getSession();
        int userId = (int) session.getAttribute("userId");
        httpServletRequest.setAttribute("userId", userId);
        return "jsp/ass_apply";
    }
 
    //提交創建社團申請
    @PostMapping("/associationApply")
    @ResponseBody
    public String addAss(String name,
                         String description,
                         int ownerId,
                         int type,
                         @RequestParam(name = "base64Data", required = true) String base64Data,
                         HttpServletRequest httpServletRequest) {
        String logo = "";
        String s[];
        if (base64Data == null || "".equals(base64Data)) {
            //提示上傳圖片錯誤
        } else {
            logo = PicUtil.pictureUtil(base64Data, httpServletRequest);
            logo = logo.substring(3, logo.length());
            System.out.println(logo);
        }
        associationService.addAssociation(description, name, null, type, ownerId, logo);
        String result = "1";
        return result;
    }
 
    //社團詳情頁面
    @GetMapping("/association")
    public String association(
            @RequestParam(name = "associationId", required = true) int associationId,
            @RequestParam(name = "bar", defaultValue = "1") int bar,
            HttpServletRequest httpServletRequest) {
        switch (bar) {
            case 1:
                //首頁
                httpServletRequest.setAttribute("bar", 1);
                break;
            case 2:
                //成員列表
                httpServletRequest.setAttribute("presidentDes",
                        associationMemberService.findPresidentDesByAssid(associationId));
                httpServletRequest.setAttribute("VicePresidentDes",
                        associationMemberService.findVicePresidentDesByAssid(associationId));
                httpServletRequest.setAttribute("MinisterDes",
                        associationMemberService.findMinisterDesByAssid(associationId));
                httpServletRequest.setAttribute("bar", 2);
                break;
            case 3:
                //活動列表
                httpServletRequest.setAttribute("activityList",
                        activityService.findActivityByAssociationId(associationId));
                httpServletRequest.setAttribute("signatureActivity",associationService.findSignatureActivityName(associationId));
                httpServletRequest.setAttribute("bar", 3);
                break;
        }
        httpServletRequest.setAttribute("association", associationService.findAssociationById(associationId));
        return "jsp/ass_detail";
    }
 
    @RequestMapping("/assManage")
    public String toAssManage(@RequestParam(name = "bar", defaultValue = "1") int bar,
                              HttpServletRequest httpServletRequest) {
        switch (bar) {
            case 1:
                httpServletRequest.setAttribute("assList", associationService.findAllAss());
                httpServletRequest.setAttribute("bar", 1);
                break;
            case 2:
                httpServletRequest.setAttribute("actList", activityService.findAllActivityAndName());
                httpServletRequest.setAttribute("bar", 2);
                break;
 
        }
        return "jsp/manage/ass_manage";
    }
 
    @RequestMapping("/toAddAss")
    public String toAddAss() {
        return "jsp/manage/ass_add";
    }
 
 
    @PostMapping("/assAdd")
    @ResponseBody
    public String AddAss(String name,
                         String description,
                         int ownerId,
                         int type,
                         @RequestParam(name = "base64Data", required = true) String base64Data,
                         HttpServletRequest httpServletRequest) {
        String logo = "";
        String s[];
        if (base64Data == null || "".equals(base64Data)) {
            //提示上傳圖片錯誤
        } else {
            logo = PicUtil.pictureUtil(base64Data, httpServletRequest);
            logo = logo.substring(3, logo.length());
            System.out.println(logo);
        }
        String createTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        associationService.addAss(description, name, createTime, type, ownerId, logo);
        String result = "1";
        return result;
    }
 
    @RequestMapping("/assDelete")
    public ModelAndView amDelete(@RequestParam(name = "associationId", required = true) int associationId) {
        associationService.deleteAss(associationId);
        int bar = 2;
        ModelAndView mv = new ModelAndView();
        mv.addObject("bar", bar);
        mv.setViewName("forward:assManage");
        return mv;
 
    }
 
    @RequestMapping("/toAssModify")
    public String toAssModify(@RequestParam(name = "associationId", required = true) int associationId,
                              HttpServletRequest httpServletRequest) {
        httpServletRequest.setAttribute("ass", associationService.findAssociationById(associationId));
        return "jsp/manage/ass_modify";
    }
    @RequestMapping("/assModify")
    @ResponseBody
    public String assModify( @RequestParam(name = "associationId", required = true)int associationId,
                                  String name,
                                  String description,
                                  int ownerId,
                                  int type,
                                  Integer signatureActivity,
                                  @RequestParam(name = "base64Data", required = true) String base64Data,
                                  HttpServletRequest httpServletRequest) {
        String logo = "";
        if("data".equals(base64Data.substring(0,4))) {//本地上傳的圖片
            if (base64Data == null || "".equals(base64Data)) {
 
                //提示上傳圖片錯誤
            } else {
                logo = PicUtil.pictureUtil(base64Data, httpServletRequest);
                logo = logo.substring(3, logo.length());
            }
        }else {
            logo=base64Data.substring(22,base64Data.length()) ;
        }
        associationService.assModify(description,name,type,ownerId,logo,signatureActivity,associationId);
        associationMemberService.updatePresidentByAssociationId(associationId,ownerId);
        String result = "1";
        return result;
    }
 
    @RequestMapping("/applyManage")
    public String toApplyManage(@RequestParam(name = "bar", defaultValue = "1") int bar,
                                HttpServletRequest httpServletRequest) {
        switch (bar) {
            case 1:
                httpServletRequest.setAttribute("actApplyList", activityService.findAllActivityApply());
                httpServletRequest.setAttribute("bar", 1);
                break;
            case 2:
                httpServletRequest.setAttribute("assApplyList", associationService.findAllAssociationsApply());
                httpServletRequest.setAttribute("bar", 2);
                break;
        }
        return "jsp/manage/apply_manage";
    }
 
    @RequestMapping("/assApplyPass")
    public ModelAndView assApplySuccess(@RequestParam(name = "associationId", required = true) int associationId) {
        String createTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        associationService.applyPass(createTime,associationId);
 
        associationMemberService.updatePresidentByAssociationId(associationId,associationService.findOwnerIdByAssociationId(associationId));
 
        associationMemberService.updateUserByAssociationId(associationId,associationService.findOwnerIdByAssociationId(associationId));
 
        int bar = 2;
        ModelAndView mv = new ModelAndView();
        mv.addObject("bar", bar);
        mv.setViewName("forward:applyManage");
        return mv;
    }
 
    @RequestMapping("/assApplyRefuse")
    public ModelAndView assApplyRefuse(@RequestParam(name = "associationId", required = true) int associationId) {
        associationService.applyRefuse(associationId);
        int bar = 2;
        ModelAndView mv = new ModelAndView();
        mv.addObject("bar", bar);
        mv.setViewName("forward:applyManage");
        return mv;
    }
}

以上就是基於Springboot實現高校社團管理系統的設計與實現的詳細內容,更多關於Springboot高校社團管理系統的資料請關註WalkonNet其它相關文章!

推薦閱讀: