Based on Springboot+Vue community volunteer management platform

Author's homepage: Programming Paper Cranes

About the author: Java, front-end, and Python have been developed for many years, and have worked as engineers, project managers, and architects.

Main content: Java project development, Python project development, university data and AI project development, microcontroller project design, interview technology compilation, latest technology sharing

Collect, like and don’t get lost. It’s good to follow the author.

Get the source code at the end of the article

 Item number: BS-PT-114

1. Environmental introduction

Locale: Java: jdk1.8

Database: Mysql: mysql5.7

Application server: Tomcat: tomcat8.5.31

Development tools: IDEA or eclipse

Development technology: Springboot+Vue

2. Project introduction

This project is based on Springboot+Vue to develop and implement a community volunteer management platform system with front-end and back-end separation. After registering and logging in, front-end users can view relevant activity information, training information, news consultation information, etc., and apply to participate in activities and volunteer training activities, discuss online forums, and view the activities and training they have participated in in the personal center. The background administrator mainly manages personnel information, activity information, training information, information information, message information, carousel information, etc. For details, please refer to the system function display below.

Three, system display

System homepage

 Volunteer activity

 Training Information

 event registration

 online forum

User Management

 News management

 Carousel management

 Volunteer inquiries

 Event registration management

 training management

 Forum management

Fourth, the core code display

package com.spring.controller;

import com.jntoo.db.*;
import com.jntoo.db.utils.*;
import com.spring.dao.*;
import com.spring.entity.*;
import com.spring.service.*;
import com.spring.util.*;
import java.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import tk.mybatis.mapper.entity.Example;

/**
 * 报名 */
@Controller
public class BaomingController extends BaseController {

    @Autowired
    private BaomingMapper dao;

    @Autowired
    private BaomingService service;

    @Autowired
    private ZhiyuanService serviceRead;

    /**
     *  后台列表页
     *
     */
    @RequestMapping("/baoming_list")
    public String list() {
        // 检测是否有登录,没登录则跳转到登录页面
        if (!checkLogin()) {
            return showError("尚未登录", "./login.do");
        }

        String order = Request.get("order", "id"); // 获取前台提交的URL参数 order  如果没有则设置为id
        String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort  如果没有则设置为desc

        Example example = new Example(Baoming.class); //  创建一个扩展搜索类
        Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类
        String where = " 1=1 "; // 创建初始条件为:1=1
        where += getWhere(); // 从方法中获取url 上的参数,并写成 sql条件语句
        criteria.andCondition(where); // 将条件写进上面的扩展条件类中
        if (sort.equals("desc")) { // 判断前台提交的sort 参数是否等于  desc倒序  是则使用倒序,否则使用正序
            example.orderBy(order).desc(); // 把sql 语句设置成倒序
        } else {
            example.orderBy(order).asc(); // 把 sql 设置成正序
        }
        int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 获取前台提交的URL参数 page  如果没有则设置为1
        page = Math.max(1, page); // 取两个数的最大值,防止page 小于1
        List<Baoming> list = service.selectPageExample(example, page, 12); // 获取当前页的行数
        // 将列表写给界面使用
        assign("list", list);
        assign("orderby", order); // 把当前排序结果写进前台
        assign("sort", sort); // 把当前排序结果写进前台
        assign("where", where); // 把当前条件写给前台
        return "baoming_list"; // 使用视图文件:WebRoot\baoming_list.jsp
    }

    /**
     *  获取前台搜索框填写的内容,并组成where 语句
     */
    public String getWhere() {
        String where = " ";
        // 判断URL 参数zhiyuanid是否大于0
        if (Request.getInt("zhiyuanid") > 0) {
            // 大于0 则写入条件
            where += " AND zhiyuanid='" + Request.getInt("zhiyuanid") + "' ";
        }
        // 以下是判断搜索框中是否有输入内容,判断是否前台是否有填写相关条件,符合则写入sql搜索语句
        if (!Request.get("biaoti").equals("")) {
            where += " AND biaoti LIKE '%" + Request.get("biaoti") + "%' ";
        }
        if (!Request.get("fenlei").equals("")) {
            where += " AND fenlei ='" + Request.get("fenlei") + "' ";
        }
        return where;
    }

    /**
     * 报名人列表
     */
    @RequestMapping("/baoming_list_baomingren")
    public String listbaomingren() {
        // 检测是否有登录,没登录则跳转到登录页面
        if (!checkLogin()) {
            return showError("尚未登录", "./login.do");
        }

        String order = Request.get("order", "id"); // 获取前台提交的URL参数 order  如果没有则设置为id
        String sort = Request.get("sort", "desc"); // 获取前台提交的URL参数 sort  如果没有则设置为desc

        Example example = new Example(Baoming.class); //  创建一个扩展搜索类
        Example.Criteria criteria = example.createCriteria(); // 创建一个扩展搜索条件类
        // 初始化一个条件,条件为:报名人=当前登录用户
        String where = " baomingren='" + session.getAttribute("username") + "' ";
        where += getWhere();

        criteria.andCondition(where); // 将条件写入
        if (sort.equals("desc")) { // 注释同list
            example.orderBy(order).desc(); // 注释同list
        } else {
            example.orderBy(order).asc(); // 注释同list
        }

        int page = request.getParameter("page") == null ? 1 : Integer.valueOf(request.getParameter("page")); // 注释同list
        page = Math.max(1, page); // 注释同list

        List<Baoming> list = service.selectPageExample(example, page, 12);

        request.setAttribute("list", list);
        assign("orderby", order);
        assign("sort", sort);
        assign("where", where);
        return "baoming_list_baomingren";
    }

    @RequestMapping("/baoming_add")
    public String add() {
        int id = Request.getInt("id"); // 根据id 获取 志愿模块中的数据
        Zhiyuan readMap = serviceRead.find(id);
        // 将数据行写入给前台jsp页面
        request.setAttribute("readMap", readMap);
        return "baoming_add";
    }

    @RequestMapping("/baomingadd")
    public String addWeb() {
        if (!checkLogin()) {
            return showError("尚未登录", "./");
        }
        int id = Request.getInt("id"); // 根据id 获取 志愿模块中的数据
        Zhiyuan readMap = serviceRead.find(id);
        request.setAttribute("readMap", readMap);
        return "baomingadd";
    }

    @RequestMapping("/baoming_updt")
    public String updt() {
        int id = Request.getInt("id");
        // 获取行数据,并赋值给前台jsp页面
        Baoming mmm = service.find(id);
        request.setAttribute("mmm", mmm);
        request.setAttribute("updtself", 0);
        return "baoming_updt";
    }

    /**
     * 添加内容
     * @return
     */
    @RequestMapping("/baominginsert")
    public String insert() {
        String tmp = "";
        Baoming post = new Baoming(); // 创建实体类
        // 设置前台提交上来的数据到实体类中
        post.setZhiyuanid(Request.getInt("zhiyuanid"));

        post.setBiaoti(Request.get("biaoti"));

        post.setFenlei(Request.get("fenlei"));

        post.setKaishishijian(Request.get("kaishishijian"));

        post.setJieshushijian(Request.get("jieshushijian"));

        post.setDidian(Request.get("didian"));

        post.setLianxiren(Request.get("lianxiren"));

        post.setLianxidianhua(Request.get("lianxidianhua"));

        post.setZhiyuanzhexingming(Request.get("zhiyuanzhexingming"));

        post.setShouji(Request.get("shouji"));

        post.setBaomingren(Request.get("baomingren"));

        post.setZhiyuanid(Request.getInt("zhiyuanid"));

        service.insert(post); // 插入数据
        int charuid = post.getId().intValue();
        Query.execute("UPDATE zhiyuan SET yibaoming=yibaoming+1 WHERE id='" + request.getParameter("zhiyuanid") + "'");

        return showSuccess("保存成功", Request.get("referer").equals("") ? request.getHeader("referer") : Request.get("referer"));
    }

    /**
     * 更新内容
     * @return
     */
    @RequestMapping("/baomingupdate")
    public String update() {
        // 创建实体类
        Baoming post = new Baoming();
        // 将前台表单数据填充到实体类
        if (!Request.get("zhiyuanid").equals("")) post.setZhiyuanid(Request.getInt("zhiyuanid"));
        if (!Request.get("biaoti").equals("")) post.setBiaoti(Request.get("biaoti"));
        if (!Request.get("fenlei").equals("")) post.setFenlei(Request.get("fenlei"));
        if (!Request.get("kaishishijian").equals("")) post.setKaishishijian(Request.get("kaishishijian"));
        if (!Request.get("jieshushijian").equals("")) post.setJieshushijian(Request.get("jieshushijian"));
        if (!Request.get("didian").equals("")) post.setDidian(Request.get("didian"));
        if (!Request.get("lianxiren").equals("")) post.setLianxiren(Request.get("lianxiren"));
        if (!Request.get("lianxidianhua").equals("")) post.setLianxidianhua(Request.get("lianxidianhua"));
        if (!Request.get("zhiyuanzhexingming").equals("")) post.setZhiyuanzhexingming(Request.get("zhiyuanzhexingming"));
        if (!Request.get("shouji").equals("")) post.setShouji(Request.get("shouji"));
        if (!Request.get("baomingren").equals("")) post.setBaomingren(Request.get("baomingren"));

        post.setId(Request.getInt("id"));
        service.update(post); // 更新数据
        int charuid = post.getId().intValue();
        return showSuccess("保存成功", Request.get("referer")); // 弹出保存成功,并跳转到前台提交的 referer 页面
    }

    /**
     *  后台详情
     */
    @RequestMapping("/baoming_detail")
    public String detail() {
        int id = Request.getInt("id");
        Baoming map = service.find(id); // 根据前台url 参数中的id获取行数据
        request.setAttribute("map", map); // 把数据写到前台
        return "baoming_detail"; // 详情页面:WebRoot\baoming_detail.jsp
    }

    /**
     *  删除
     */
    @RequestMapping("/baoming_delete")
    public String delete() {
        if (!checkLogin()) {
            return showError("尚未登录");
        }
        int id = Request.getInt("id"); // 根据id 删除某行数据
        Map map = Query.make("baoming").find(id);

        service.delete(id); // 根据id 删除某行数据
        return showSuccess("删除成功", request.getHeader("referer")); //弹出删除成功,并跳回上一页
    }
}

package com.spring.controller;

import com.alibaba.fastjson.*;
import com.spring.util.*;
import com.spring.util.Request;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 公共路由
 */
@Controller
public class CommonController extends BaseController {

    /**
     * 使用ajax 检测某表中某个字段是否已存在,已存在则无法提交
     * @return
     */
    @RequestMapping(value = "/checkno")
    @ResponseBody
    public String checkon() {
        String table = request.getParameter("table");
        String col = request.getParameter("col");
        String checktype = request.getParameter("checktype");
        String value = request.getParameter(col);
        if (checktype.equals("insert")) {
            if (Query.make(table).where(col, value).count() > 0) {
                return "false";
            } else {
                return "true";
            }
        } else if (checktype.equals("update")) {
            String id = request.getParameter("id") == null ? "" : request.getParameter("id");
            if (Query.make(table).where(col, value).where("id", "neq", id).count() > 0) {
                return "false";
            } else {
                return "true";
            }
        }
        return "false";
    }

    /**
     * 审核数据,将是否审核改为已审核状态,点击一下 是 则变否, 点击一下 否 变为是
     * @return
     */
    @RequestMapping("/sh")
    @ResponseBody
    public String sh() {
        String yuan = request.getParameter("yuan");
        String id = request.getParameter("id");
        String tablename = request.getParameter("tablename");
        String sql = "";
        if (yuan.equals("是")) {
            sql = "update " + tablename + " set issh='否' where id=" + id;
        } else {
            sql = "update " + tablename + " set issh='是' where id=" + id;
        }
        Query.execute(sql);
        if (isAjax()) {
            jsonResult("ok");
            return "";
        }
        return "<script>location.href='" + request.getHeader("Referer") + "';</script>";
    }

    /**
     * 获取表的某行数据
     * @return
     */
    @RequestMapping("/tableAjax")
    @ResponseBody
    public String tableFind() {
        String table = request.getParameter("table");
        String id = request.getParameter("id");
        Map map = Query.make(table).where("id", id).find();
        //JSONObject json = JSONObject.parse(map);
        return JSON.toJSONString(map); //.toString();
    }

    /**
     *   获取某表得某行数据
     *
     */
    @RequestMapping("/selectView")
    public String selectView() {
        String key = request.getParameter("key");
        String table = request.getParameter("table");
        String value = request.getParameter("value");
        Map data = Query.make(table).where(key, value).find();
        return jsonResult(data);
    }

    /**
     *   获取某表得所有数据
     *
     */
    @RequestMapping("/selectAll")
    public String selectAll() {
        String table = request.getParameter("table");
        Query query = Query.make(table);
        if (request.getParameter("where") != null) {
            JSONObject where = JSON.parseObject(Request.get("where"));
            for (Map.Entry entry : where.entrySet()) {
                String key = (String) entry.getKey();
                Object value = entry.getValue();
                if (value instanceof JSONObject) {
                    JSONObject w = (JSONObject) value;
                    query.where(key, w.getString("exp"), w.getString("value"));
                } else if (value instanceof JSONArray) {
                    JSONArray w = (JSONArray) value;
                    query.where(key, (String) w.get(0), w.get(1));
                } else {
                    query.where(key, value);
                }
            }
        }
        if (request.getParameter("limit") != null) {
            query.limit(Request.get("limit"));
        }
        if (request.getParameter("order") != null) {
            query.order(Request.get("order"));
        }
        if (request.getParameter("field") != null) {
            query.field(Request.get("field"));
        }
        List list = query.select();
        return jsonResult(list);
    }

    /**
     * 搜索下拉某表的数据
     * @return
     */
    @RequestMapping("/selectUpdateSearch")
    @ResponseBody
    public String selectUpdateSearch() {
        String table = Request.get("table");
        Query query = Query.make(table);
        String limit = "50";
        JSONObject where = JSON.parseObject(Request.get("where"));
        for (Map.Entry entry : where.entrySet()) {
            String key = (String) entry.getKey();
            Object value = entry.getValue();
            if ("limit".equals(key)) {
                limit = String.valueOf(value);
            } else {
                if (value instanceof JSONObject) {
                    JSONObject w = (JSONObject) value;
                    query.where(key, w.getString("exp"), w.getString("value"));
                } else if (value instanceof JSONArray) {
                    JSONArray w = (JSONArray) value;
                    query.where(key, (String) w.get(0), w.get(1));
                } else {
                    query.where(key, value);
                }
            }
        }
        List list = query.order("id desc").limit(limit).select();
        return JSON.toJSONString(list);
    }
}

5. Display of related works

Practical projects based on Java development, Python development, PHP development, C# development and other related languages

Front-end practical projects developed based on Nodejs, Vue and other front-end technologies

Related works based on WeChat applet and Android APP application development

Development and application of embedded Internet of Things based on 51 microcontroller and other embedded devices

AI intelligent applications based on various algorithms

Various data management and recommendation systems based on big data

 

 

Guess you like

Origin blog.csdn.net/BS009/article/details/132757248