• springboot高校社团管理系统


    开发工具:IDEA,jdk1.8

    数据库:mysql5.7

    技术:springboot+freemark+jpa

    前台:

    1、社团信息浏览搜索、社团活动风采、新闻信息浏览搜索。

    2、学生注册登录。

    3、登录后可自己申请创建社团,也可申请加入其他社团活动。

    4、管理自己社团的申请人员。

    5个人信息修改及留言等。

    后台:社团审核管理、活动新闻管理、学生管理、留言管理、活动申请审核、活动经费管理等等。
    前台截图:
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    后台截图:
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    package com.jinku.jsj.springboot.controller.admin;
    
    
    import com.aliyuncs.utils.StringUtils;
    import com.jinku.jsj.springboot.bean.CodeMsg;
    import com.jinku.jsj.springboot.bean.PageBean;
    import com.jinku.jsj.springboot.bean.Result;
    import com.jinku.jsj.springboot.constant.SessionConstant;
    import com.jinku.jsj.springboot.entity.admin.User;
    import com.jinku.jsj.springboot.entity.common.Message;
    import com.jinku.jsj.springboot.service.admin.OperaterLogService;
    import com.jinku.jsj.springboot.service.common.MessageService;
    import com.jinku.jsj.springboot.service.common.NewsService;
    import com.jinku.jsj.springboot.util.ValidateEntityUtil;
    import org.springframework.beans.BeanUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpSession;
    
    /**
     * 留言管理 留言列表
     */
    @RequestMapping("/admin/message")
    @Controller
    public class MessageController {
    
        @Autowired
        private MessageService messageService;
    
        @Autowired
        private OperaterLogService operaterLogService;
    
        @Autowired
        private NewsService newsService;
    
        @RequestMapping(value = "/list")
        public String list(Model model, PageBean<Message> pageBean, Message message) {
            model.addAttribute("pageBean", messageService.findList(message, pageBean));
            model.addAttribute("sender",message.getSender()==null?null:message.getSender());
            model.addAttribute("title", "留言列表");
            model.addAttribute("auditStatus",message.getAuditStatus()==null?0:message.getAuditStatus());
            return "admin/message/list";
        }
    
        /**
         * 留言添加页面
         *
         * @param model
         * @return
         */
        @RequestMapping(value = "/add", method = RequestMethod.GET)
        public String add(Model model) {
            model.addAttribute("MessageTitle","留言列表");
            return "admin/message/add";
        }
        /**
         * 后台留言添加
         *
         * @param model
         * @param message
         * @return at wjk
         */
        @ResponseBody
        @RequestMapping(value = "/add", method = RequestMethod.POST)
        public Result<Boolean> add(Model model, Message message, HttpServletRequest request) {
            HttpSession session = request.getSession();
            User user = (User) session.getAttribute(SessionConstant.SESSION_USER_LOGIN_KEY);
            //用统一验证实体方法验证是否合法
            CodeMsg validate = ValidateEntityUtil.validate(message);
            if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
                return Result.error(validate);
            }
            message.setSender(user.getUsername());
            if (messageService.save(message) == null) {
                return Result.error(CodeMsg.ADMIN_MESSAGE_ADD_ERROR);
            }
            operaterLogService.add("添加留言,留言人:" + message.getSender());
            return Result.success(true);
        }
    
        /**
         * 留言编辑页面
         *
         * @param model
         * @param id
         * @return
         */
        @RequestMapping(value = "/edit", method = RequestMethod.GET)
        public String edit(Model model, @RequestParam(name = "id", required = true) Long id) {
            model.addAttribute("MessageTitle","留言列表");
            model.addAttribute("message", messageService.find(id));
            return "admin/message/edit";
        }
        /**
         * 留言编辑
         *
         * @param message
         * @return
         */
        @ResponseBody
        @RequestMapping(value = "/edit", method = RequestMethod.POST)
        public Result<Boolean> edit(Message message,HttpServletRequest request) {
           //用统一验证实体方法验证是否合法
            CodeMsg validate = ValidateEntityUtil.validate(message);
            if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
                return Result.error(validate);
            }
            HttpSession session = request.getSession();
            User user = (User) session.getAttribute(SessionConstant.SESSION_USER_LOGIN_KEY);
            message.setReplyUser(user.getUsername());
            //将提交的留言信息指定字段复制到已存在的message对象中
            Message findbyId = messageService.find(message.getId());
            //把source原来的字段复制到目标对象当中ignoreProperties表示忽略哪些字段 该方法会覆盖新字段内容
            BeanUtils.copyProperties(message, findbyId, "id", "createTime", "updateTime", "sender");
            //到这说明一切通过 开始进行数据库编辑
            if (messageService.save(findbyId) == null) {
                return Result.error(CodeMsg.ADMIN_MESSAGE_EDIT_ERROR);
            }
            operaterLogService.add("编辑留言,留言人:" + findbyId.getSender());
            return Result.success(true);
        }
        /**
         * 留言删除
         * @param ids
         * @return
         */
        @ResponseBody
        @RequestMapping(value = "/delete", method = RequestMethod.POST)
        public Result<Boolean> delete(@RequestParam(name = "ids", required = true) String ids) {
          if (!StringUtils.isEmpty(ids)) {
                String[] splitIds = ids.split(",");
                for (String id : splitIds) {
                    Message message = messageService.find(Long.valueOf(id));
                    if (message != null) {
                        try {
                            messageService.delete(Long.valueOf(id));
                            operaterLogService.add("删除留言,id为:" + id);
                        }catch (Exception e){
                            return Result.error(CodeMsg.ADMIN_MESSAGE_DELETE_ERROR);
                        }
                    }
                }
            }
            return Result.success(true);
        }
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154

    package com.jinku.jsj.springboot.controller.admin;

    import com.jinku.jsj.springboot.bean.CodeMsg;
    import com.jinku.jsj.springboot.bean.PageBean;
    import com.jinku.jsj.springboot.bean.Result;
    import com.jinku.jsj.springboot.entity.home.Student;
    import com.jinku.jsj.springboot.service.admin.OperaterLogService;
    import com.jinku.jsj.springboot.service.home.StudentService;
    import com.jinku.jsj.springboot.util.ValidateEntityUtil;
    import org.apache.commons.lang3.StringUtils;
    import org.springframework.beans.BeanUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;

    import javax.servlet.http.HttpServletRequest;

    /**

    • 后台学生管理
      */

    @RequestMapping(“/admin/student/”)
    @Controller
    public class StudentController {
    @Autowired
    private StudentService studentService ;

    @Autowired
    private OperaterLogService operaterLogService;
    
    /**
     * 学生管理列表
     * @param model
     * @return
     */
    @RequestMapping("/list")
    public String list(Model model, Student student, PageBean pageBean){
        model.addAttribute("pageBean",studentService.findList(student, pageBean));
        model.addAttribute("studentLoginName",student.getLoginName());
        model.addAttribute("title","学生列表");
        return "/admin/student/list";
    }
    
    /**
     * 后台学生添加页面
     */
    @RequestMapping(value = "/add",method = RequestMethod.GET)
    public String add(){
        return "/admin/student/add";
    }
    
    /**
     * 后台学生添加信息操作
     */
    @ResponseBody
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Result add(Model model,Student student){
        CodeMsg validate = ValidateEntityUtil.validate(student);
        if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
            return Result.error(validate);
        }
        if(studentService.findByLoginName(student.getLoginName())!=null){
            return Result.error(CodeMsg.ADMIN_STUDENT_ISEXIST_ERROR);
        }
        if(studentService.save(student)==null){
            return Result.error(CodeMsg.ADMIN_STUDENT_ADD_ERROR);
        }
        return Result.success(true);
    }
    
    /**
     * 编辑学生页面
     * @param model
     * @param id
     * @return
     */
    @RequestMapping(value = "/edit",method = RequestMethod.GET)
    public String edit(Model model, @RequestParam("id")Long id){
        if(studentService.findById(id)!=null){
            model.addAttribute("student",studentService.findById(id));
        }
        return "/admin/student/edit";
    }
    
    
    /**
     * 编辑后台学生信息
     * @param student
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/edit", method = RequestMethod.POST)
    public Result edit(Student student, HttpServletRequest request) {
        //用统一验证实体方法验证是否合法
        CodeMsg validate = ValidateEntityUtil.validate(student);
        if (validate.getCode() != CodeMsg.SUCCESS.getCode()) {
            return Result.error(validate);
        }
      //将提交的学生信息指定字段复制到已存在的student对象中
        Student findbyId = studentService.findById(student.getId());
        //把source原来的字段复制到目标对象当中ignoreProperties表示忽略哪些字段 该方法会覆盖新字段内容
        BeanUtils.copyProperties(student, findbyId, "id", "createTime", "updateTime");
        //到这说明一切通过 开始进行数据库编辑
        if (studentService.save(findbyId) == null) {
            return Result.error(CodeMsg.ADMIN_STUDENT_EDIT_ERROR);
        }
        operaterLogService.add("编辑学生,学生姓名:" + student.getStuName());
        return Result.success(true);
    }
    
    
    /**
     * 学生删除操作
     * @param ids
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Result delete(@RequestParam(name = "ids", required = true) String ids) {
        if (!StringUtils.isEmpty(ids)) {
            String[] splitIds = ids.split(",");
            for (String id : splitIds) {
                Student student = studentService.findById(Long.valueOf(id));
                if (student != null) {
                    try {
                        studentService.delete(Long.valueOf(id));
                        operaterLogService.add("删除学生,id为:" + id);
                    }catch (Exception e){
                        return Result.error(CodeMsg.ADMIN_STUDENT_DELETE_ERROR);
                    }
                }
    
            }
    
        }
        return Result.success(true);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110

    }

  • 相关阅读:
    UE4 C++:TMap容器
    【算法】贪心法
    灵魂一问:一个Java文件的执行全部过程你确定都清楚吗?
    Java EE——常见锁策略和CAS及锁的其他概念
    webpack5 之 构建vue3+js、vue3+ts、vue3 + vue-route、vue3 + pinia
    Python爬虫新手指南及简单实战
    技术开发人员常用的安全浏览器
    LeetCode 141. 环形链表
    高性能高可靠性高扩展性分布式防火墙架构
    Spring/IoC、DI、Bean
  • 原文地址:https://blog.csdn.net/qq_35334787/article/details/126679543