关于后端:基于SSM的爱心互助及物品回收管理系统

25次阅读

共计 11396 个字符,预计需要花费 29 分钟才能阅读完成。


  博主介绍:✌退职 Java 研发工程师、专一于程序设计、源码分享、技术交换、专一于 Java 技术畛域和毕业设计✌

项目名称

基于 SSM 的爱心互助及物品回收管理系统

下载地址

基于 SSM 的爱心互助及物品回收管理系统

视频演示

基于 SSM 的爱心互助及物品回收管理系统_哔哩哔哩_bilibili

零碎介绍

3.2 需要剖析

基于 SSM 的爱心互助及物品回收管理系统的次要性能角色包含受捐者、管理员以及捐赠者三个方面,首先受捐者进行零碎注册并进行登录,登录后填写受捐表单,捐赠者选中受捐对象后,填写捐献表单,管理员后盾审核,如果审核通过即可实现业务流程,如果审核不通过则返回给捐赠者从新填写捐献表单。具体流程图见图 3.1 所示。

编辑

图 3.1 零碎数据流图(1 层)

从功能模块的划分上分为前台零碎和后盾零碎:

前台性能包含了:首页模块、网站布告模块、爱心信息模块、求助信息模块、物品回收模块、捐款信息模块、留言反馈模块、集体核心模块、登录模块以及注册模块。

后盾性能包含了:登录模块、集体核心(批改明码、个人信息)、网站布告模块、用户治理模块、爱心信息模块、捐献信息管理模块、求助信息管理模块、求助信息管理模块、支援信息管理模块、物品回收治理模块、爱心支取治理模块、捐献信息管理模块、我的珍藏治理模块、管理员治理模块、留言板治理模块、系统管理模块(轮播图治理、新闻征询治理模块)。

通过前台用户和管理员后盾的数据操作,零碎后盾通过接口的模式与前台进行数据传输,通过数据库的数据减少、批改、删除与查问操作保证数据的一致性。

4 零碎设计

4.1 零碎总体设计

对于零碎的搭建须要参考软件设计的标准规范,而不是依据本人的编码教训进行开发,比方对于对象实体的字段命名须要应用驼峰法进行书写,对于数据库的字段类型设计须要依据业务的理论进行设计并且准寻储存量越小越好的准则,因为随着零碎体量的增大,有可能会对系统的查问、批改等操作有影响。

一个我的项目的开始是最重要的,所以后期的需要剖析和功能分析是要害,否者前期开发进去后,我的项目的成果也不会是预期设想那样。从主观和主观的角度上思考剖析该项目标需要起源,再针对需要定制功能分析,性能确定后设计数据库表关联,才是开发以及最初的重点项目测试。测试实现能够该我的项目在第一阶段才算告一段落。

为了实现这一课题从论文设计到零碎的搭建,领有一套残缺的技术框架常识以及业务知识是非常重要的,首先咱们须要对系统的业务需要进行考察,通过文献的查问以及理论的用户需要上进行调研,其次须要对各种技术进行筛选,抉择咱们须要的技术语言以及框架结构猜呢可能熟能生巧的将零碎开发进去。

本次零碎选用的是 Java 这一开发语言,Java 因为其弱小的 API 实现收到了很多开发者的青睐,有时候其余语言须要用很长的一段代码写进去的货色,Java 曾经实现了这个办法,咱们只须要调用其中的一个 API 即可。数据库咱们悬着的是 Mysql 数据库,最初技术选好了须要对系统进行开发并且对论文设计进行斟酌,并且零碎的测试也是十分必要的。零碎的性能结构图如下图所示。

编辑

图 4.1 零碎性能结构图

4.2 零碎具体设计

依据需要对系统的进行设计,其中包含用例图、类图、程序图、流动图、功能模块图。零碎角色包含受捐者、管理员以及捐赠者。性能层次结构见图 2 所示。具体性能包含:

①前台次要性能

a. 爱心信息。用户能够在爱心信息当中查看须要捐助的对象并已于爱心捐助。

b. 捐款信息。用户捐款信息中查看集体捐款信息。

c. 新闻征询。用户在以后性能页面下查看零碎的新闻信息文章。

d. 留言反馈。用户还能够在留言反馈当中写下本人的留言信息,提交给管理员进行查看。

e. 提交求助信息。受捐者能够在求助信息中查看求助对象信息并填写表单申请捐助审核。

f. 捐献品浏览。受捐者能够在物品回收当中查看待回收物品,申请爱心支取。

②后盾次要性能

a. 网站布告治理。管理员治理布告信息,布告信息将会在前台用户界面上展现。

b. 用户治理。对所有前台用户的信息进行查看批改、删除等性能。

c. 爱心信息管理。对用户的爱心捐助进行治理并提供评估性能。

d. 求助信息管理。对求助信息进行进行治理并提供评估性能。

e. 物品回收治理。对回收物品做出增删改查性能治理。

f. 系统管理。管理员对轮播图、新闻征询等信息进行治理。

g. 留言治理。对用户提交的留言信息进行查看并进行回复反馈。

h. 回收定损。管理员对回收的物品进行定损治理。

4.3 数据库设计

数据库是本零碎的外围和根底。一个好的我的项目离不开一个好的数据库设计,初期就须要思考我的项目将来拓展的方向和内容,保留出正当的数据库构造,为将来倒退埋下成长的果实,而后再思考到当初我的项目的方方面面内容,以及相干的关联性,把字段变成表,表和表合成库,最初达到一个残缺成熟的状态。

数据库的设计将会间接影响到我的项目的流程和便携性,如果没有设计好,甚至可能前期将和原设计性能南辕北辙。最开始先梳理分明我的项目流程和需要,在更具需要设计性能,建设二者的根底上设计数据库,既满足性能并且保留肯定的拓展性,为前期批改保留肯定空间,必然前期批改不便。

环境须要

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. 数据库:MySql 5.7 版本;
6. 是否 Maven 我的项目:否;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis
  2. 前端:JSP+CSS+JavaScript+jQuery

应用阐明

  1. 应用 Navicat 或者其它工具,在 mysql 中创立对应名称的数据库,并导入我的项目的 sql 文件;
  2. 应用 IDEA/Eclipse/MyEclipse 导入我的项目,Eclipse/MyEclipse 导入时,若为 maven 我的项目请抉择 maven;
    若为 maven 我的项目,导入胜利后请执行 maven clean;maven install 命令,而后运行;
  3. 将我的项目中 springmvc-servlet.xml 配置文件中的数据库配置改为本人的配置;
  4. 运行我的项目,在浏览器中输出 http://localhost:8080/ 登录

运行截图

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

​编辑

 用户管理控制层:

package com.houserss.controller;

import javax.servlet.http.HttpSession;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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 com.houserss.common.Const;
import com.houserss.common.Const.Role;
import com.houserss.common.ServerResponse;
import com.houserss.pojo.User;
import com.houserss.service.IUserService;
import com.houserss.service.impl.UserServiceImpl;
import com.houserss.util.MD5Util;
import com.houserss.util.TimeUtils;
import com.houserss.vo.DeleteHouseVo;
import com.houserss.vo.PageInfoVo;

/**

  • Created by admin
    */

@Controller
@RequestMapping(“/user/”)
public class UserController {

@Autowired
private IUserService iUserService;

/**
 * 用户登录
 * @param username
 * @param password
 * @param session
 * @return
 */
@RequestMapping(value = "login.do",method = RequestMethod.POST)
@ResponseBody
public ServerResponse<User> login(User user,String uvcode, HttpSession session){String code = (String)session.getAttribute("validationCode");
    if(StringUtils.isNotBlank(code)) {if(!code.equalsIgnoreCase(uvcode)) {return ServerResponse.createByErrorMessage("验证码不正确");
        }
    }
    ServerResponse<User> response = iUserService.login(user.getUsername(),user.getPassword());
    if(response.isSuccess()){session.setAttribute(Const.CURRENT_USER,response.getData());
    }
    return response;
}



}

管理员管理控制层:

package com.sxl.controller.admin;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sxl.controller.MyController;

@Controller(“adminController”)
@RequestMapping(value = “/admin”)
public class AdminController extends MyController {



@RequestMapping(value = "/index")
public String frame(Model model, HttpServletRequest request)throws Exception {return "/admin/index";}

@RequestMapping(value = "/main")
public String main(Model model, HttpServletRequest request)throws Exception {return "/admin/main";}

@RequestMapping(value = "/tj1")
public String tj1(Model model, HttpServletRequest request)throws Exception {String sql="select DATE_FORMAT(insertDate,'%Y-%m-%d') dates,sum(allPrice) price from t_order order by DATE_FORMAT(insertDate,'%Y-%m-%d')  desc";
    List<Map> list = db.queryForList(sql);
    model.addAttribute("list", list);
    System.out.println(list);
    return "/admin/tj/tj1";
}


@RequestMapping(value = "/password")
public String password(Model model, HttpServletRequest request)throws Exception {return "/admin/password";}


@RequestMapping(value = "/changePassword")
public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {Map admin = getAdmin(request);
    if(oldPassword.equals(admin.get("password").toString())){
        String sql="update t_admin set password=? where id=?";
        db.update(sql, new Object[]{newPassword,admin.get("id")});
        return renderData(true,"1",null);
    }else{return renderData(false,"1",null);
    }
}

}

批改明码业务逻辑:

package com.sxl.controller.admin;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sxl.controller.MyController;

@Controller(“userController”)
@RequestMapping(value = “/user”)
public class UserController extends MyController {



@RequestMapping(value = "/index")
public String frame(Model model, HttpServletRequest request)throws Exception {return "/user/index";}

@RequestMapping(value = "/main")
public String main(Model model, HttpServletRequest request)throws Exception {return "/user/main";}


@RequestMapping(value = "/password")
public String password(Model model, HttpServletRequest request)throws Exception {return "/user/password";}


@RequestMapping(value = "/changePassword")
public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {Map user = getUser(request);
    if(oldPassword.equals(user.get("password").toString())){
        String sql="update t_user set password=? where id=?";
        db.update(sql, new Object[]{newPassword,user.get("id")});
        return renderData(true,"1",null);
    }else{return renderData(false,"1",null);
    }
}
@RequestMapping(value = "/mine")
public String mine(Model model, HttpServletRequest request)throws Exception {

Map user =getUser(request);Map map = db.queryForMap(“select * from t_user where id=?”,new Object[]{user.get(“id”)});model.addAttribute(“map”, map); return “/user/mine”;

}



@RequestMapping(value = "/mineSave")
public ResponseEntity<String> mineSave(Model model,HttpServletRequest request,Long id
    ,String username,String password,String name,String gh,String mobile) throws Exception{
    int result = 0;
        String sql="update t_user set name=?,gh=?,mobile=? where id=?";
        result = db.update(sql, new Object[]{name,gh,mobile,id});
    if(result==1){return renderData(true,"操作胜利",null);
    }else{return renderData(false,"操作失败",null);
    }
}
}

通用治理模块:

package com.sxl.controller;

import java.nio.charset.Charset;
import java.util.Locale;
import java.util.ResourceBundle;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;

import com.sxl.util.JacksonJsonUtil;
import com.sxl.util.StringUtil;
import com.sxl.util.SystemProperties;

public class BaseController {

public static final Long EXPIRES_IN = 1000 * 3600 * 24 * 1L;// 1 天

@Autowired
private SystemProperties systemProperties;

/**
 * 取得配置文件内容
 */
public String getConfig(String key) {return systemProperties.getProperties(key);
}

/**
 * 返回服务器地址 like http://192.168.1.1:8441/UUBean/
 */
public String getHostUrl(HttpServletRequest request) {String hostName = request.getServerName();
    Integer hostPort = request.getServerPort();
    String path = request.getContextPath();

    if (hostPort == 80) {return "http://" + hostName + path + "/";} else {return "http://" + hostName + ":" + hostPort + path + "/";}
}

/***
 * 获取以后的 website 门路 String
 */
public static String getWebSite(HttpServletRequest request) {String returnUrl = request.getScheme() + "://"
            + request.getServerName();

    if (request.getServerPort() != 80) {returnUrl += ":" + request.getServerPort();
    }

    returnUrl += request.getContextPath();

    return returnUrl;
}



/**
 * 初始化 HTTP 头.
 * 
 * @return HttpHeaders
 */
public HttpHeaders initHttpHeaders() {HttpHeaders headers = new HttpHeaders();
    MediaType mediaType = new MediaType("text", "html",
            Charset.forName("utf-8"));
    headers.setContentType(mediaType);
    return headers;
}

/**
 * 返回 信息数据
 * 
 * @param status
 * @param msg
 * @return
 */
public ResponseEntity<String> renderMsg(Boolean status, String msg) {if (StringUtils.isEmpty(msg)) {msg = "";}
    String str = "{\"status\":\"" + status + "\",\"msg\":\""+ msg +"\"}";
    ResponseEntity<String> responseEntity = new ResponseEntity<String>(str,
            initHttpHeaders(), HttpStatus.OK);
    return responseEntity;
}

/**
 * 返回 obj 数据
 * 
 * @param status
 * @param msg
 * @param obj
 * @return
 */
public ResponseEntity<String> renderData(Boolean status, String msg,
        Object obj) {if (StringUtils.isEmpty(msg)) {msg = "";}
    StringBuffer sb = new StringBuffer();
    sb.append("{");
    sb.append("\"status\":\"" + status + "\",\"msg\":\""+ msg +"\",");
    sb.append("\"data\":" + JacksonJsonUtil.toJson(obj) + "");
    sb.append("}");

    ResponseEntity<String> responseEntity = new ResponseEntity<String>(sb.toString(), initHttpHeaders(), HttpStatus.OK);
    return responseEntity;
}


/***
 * 获取 IP(如果是多级代理,则失去的是一串 IP 值)*/
public static String getIpAddr(HttpServletRequest request) {String ip = request.getHeader("x-forwarded-for");
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("Proxy-Client-IP");
    }

    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("WL-Proxy-Client-IP");
    }

    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getRemoteAddr();
    }

    if (ip != null && ip.length() > 0) {String[] ips = ip.split(",");
        for (int i = 0; i < ips.length; i++) {if (!"unknown".equalsIgnoreCase(ips[i])) {ip = ips[i];
                break;
            }
        }
    }

    return ip;
}

/**
 * 国际化取得语言内容
 * 
 * @param key
 *            语言 key
 * @param args
 * @param argsSplit
 * @param defaultMessage
 * @param locale
 * @return
 */
public static String getLanguage(String key, String args, String argsSplit,
        String defaultMessage, String locale) {
    String language = "zh";
    String contry = "cn";
    String returnValue = defaultMessage;

    if (!StringUtil.isEmpty(locale)) {
        try {String[] localeArray = locale.split("_");
            language = localeArray[0];
            contry = localeArray[1];
        } catch (Exception e) {}}

    try {
        ResourceBundle resource = ResourceBundle.getBundle("lang.resource",
                new Locale(language, contry));
        returnValue = resource.getString(key);
        if (!StringUtil.isEmpty(args)) {String[] argsArray = args.split(argsSplit);
            for (int i = 0; i < argsArray.length; i++) {returnValue = returnValue.replace("{" + i + "}",
                        argsArray[i]);
            }
        }
    } catch (Exception e) { }

    return returnValue;
}

}

正文完
 0