文末获取源码
开发语言:Java
使用框架:spring boot
前端技术:JavaScript、Vue.js 、css3
开发工具:IDEA/MyEclipse/Eclipse、Visual Studio Code
数据库:MySQL 5.7/8.0
数据库管理工具:phpstudy/Navicat
JDK版本:Java jdk8
Maven:apache-maven 3.8.1-bin
目录
一、前言介绍
本系统采用B/S模式,后端部分基于Java的springboot框架进行开发。前端部分:前端框架采用了比较流行的渐进式JavaScript框架Vue.js。使用Vue-Router和Vuex实现动态路由和全局状态管理,Ajax实现前后端通信,Element UI组件库,使页面快速成型,项目前端通过栅格布局实现响应式,可适应PC端、平板端、手机端等不同屏幕大小尺寸的完美布局展示。
后端部分:采用springboot作为开发框架,同时集成MyBatis、Redis等相关技术。
灾情救援系统主要功能模块包括首页、轮播图、公告栏、管理员、普通用户、审核员、灾情资讯、灾情资讯分类、灾情救援、救援计划、调度方案、灾情分类、物资分类、物资管理、物资入库、物资发放、物资库存。
二、系统功能
本灾情救援系统主要包括三大功能模块,即用户功能模块和管理员功能模块、审核员、用户模块。
(1)管理员模块:系统中的核心用户是管理员,管理员登录后,通过管理员来管理后台系统。主要功能有:首页、站点管理(轮播图、公告栏),用户管理(管理员、普通用户、审核员)内容管理(灾情资讯、灾情资讯分类),更多管理(灾情救援、救援计划、调度方案、灾情分类、物资分类、物资管理、物资入库、物资发放、物资库存)等功能。
(2)教师用户:首页、更多管理(灾情救援、救援计划、调度方案)等功能。
(3)前台用户:首页、公告消息、灾情资讯、灾情救援等功能。
三、前台用户功能
3.1用户首页模块
3.2灾情资讯模块
3.3灾情救援模块
3.4个人资料模块
四、管理员功能模块
4.1管理员首页模块
4.2审核员管理模块
4.3灾情资讯管理模块
4.4灾情救援管理模块
4.5调度方案管理模块
五、部分核心代码
5.1物资入库关键代码
*/
@Autowired
public MaterialController(MaterialService service) {
setService(service);
}
@PostMapping("/add")
@Transactional
public Map<String, Object> add(HttpServletRequest request) throws IOException {
Map<String,Object> paramMap = service.readBody(request.getReader());
this.addMap(paramMap);
String sql = "SELECT MAX(material_id) AS max FROM "+"material";
Query select = service.runCountSql(sql);
Integer max = (Integer) select.getSingleResult();
sql = "UPDATE `material_management` INNER JOIN `material` ON material_management.material_name=material.material_name SET material_management.quantity_of_materials = material_management.quantity_of_materials + material.receipt_quantity WHERE material.material_id="+max;
select = service.runCountSql(sql);
select.executeUpdate();
return success(1);
}
}
5.2物资发放关键代码
*/
@Autowired
public MaterialDistributionController(MaterialDistributionService service) {
setService(service);
}
@PostMapping("/add")
@Transactional
public Map<String, Object> add(HttpServletRequest request) throws IOException {
Map<String,Object> paramMap = service.readBody(request.getReader());
this.addMap(paramMap);
String sql = "SELECT MAX(material_distribution_id) AS max FROM "+"material_distribution";
Query select = service.runCountSql(sql);
Integer max = (Integer) select.getSingleResult();
sql = ("SELECT count(*) count FROM `material_management` INNER JOIN `material_distribution` ON material_management.material_name=material_distribution.material_name WHERE material_management.quantity_of_materials < material_distribution.issued_quantity AND material_distribution.material_distribution_id="+max).replaceAll("<","<");
select = service.runCountSql(sql);
Integer count = Integer.valueOf(String.valueOf(select.getSingleResult()));
if(count>0){
sql = "delete from "+"material_distribution"+" WHERE "+"material_distribution_id"+" ="+max;
select = service.runCountSql(sql);
select.executeUpdate();
return error(30000,"库存不足!");
}
sql = "UPDATE `material_management` INNER JOIN `material_distribution` ON material_management.material_name=material_distribution.material_name SET material_management.quantity_of_materials = material_management.quantity_of_materials - material_distribution.issued_quantity WHERE material_distribution.material_distribution_id="+max;
select = service.runCountSql(sql);
select.executeUpdate();
return success(1);
}
}
5.3用户登录关键代码
/**
* 登录
* @param data
* @param httpServletRequest
* @return
*/
@PostMapping("login")
public Map<String, Object> login(@RequestBody Map<String, String> data, HttpServletRequest httpServletRequest) {
log.info("[执行登录接口]");
String username = data.get("username");
String email = data.get("email");
String phone = data.get("phone");
String password = data.get("password");
List resultList = null;
Map<String, String> map = new HashMap<>();
if(username != null && "".equals(username) == false){
map.put("username", username);
resultList = service.select(map, new HashMap<>()).getResultList();
}
else if(email != null && "".equals(email) == false){
map.put("email", email);
resultList = service.select(map, new HashMap<>()).getResultList();
}
else if(phone != null && "".equals(phone) == false){
map.put("phone", phone);
resultList = service.select(map, new HashMap<>()).getResultList();
}else{
return error(30000, "账号或密码不能为空");
}
if (resultList == null || password == null) {
return error(30000, "账号或密码不能为空");
}
//判断是否有这个用户
if (resultList.size()<=0){
return error(30000,"用户不存在");
}
User byUsername = (User) resultList.get(0);
Map<String, String> groupMap = new HashMap<>();
groupMap.put("name",byUsername.getUserGroup());
List groupList = userGroupService.select(groupMap, new HashMap<>()).getResultList();
if (groupList.size()<1){
return error(30000,"用户组不存在");
}
UserGroup userGroup = (UserGroup) groupList.get(0);
//查询用户审核状态
if (!StringUtils.isEmpty(userGroup.getSourceTable())){
String sql = "select examine_state from "+ userGroup.getSourceTable() +" WHERE user_id = " + byUsername.getUserId();
String res = String.valueOf(service.runCountSql(sql).getSingleResult());
if (res==null){
return error(30000,"用户不存在");
}
if (!res.equals("已通过")){
return error(30000,"该用户审核未通过");
}
}
//查询用户状态
if (byUsername.getState()!=1){
return error(30000,"用户非可用状态,不能登录");
}
String md5password = service.encryption(password);
if (byUsername.getPassword().equals(md5password)) {
// 存储Token到数据库
AccessToken accessToken = new AccessToken();
accessToken.setToken(UUID.randomUUID().toString().replaceAll("-", ""));
accessToken.setUser_id(byUsername.getUserId());
tokenService.save(accessToken);
// 返回用户信息
JSONObject user = JSONObject.parseObject(JSONObject.toJSONString(byUsername));
user.put("token", accessToken.getToken());
JSONObject ret = new JSONObject();
ret.put("obj",user);
return success(ret);
} else {
return error(30000, "账号或密码不正确");
}
}
5.4用户注册关键代码
/**
* 注册
* @param user
* @return
*/
@PostMapping("register")
public Map<String, Object> signUp(@RequestBody User user) {
// 查询用户
Map<String, String> query = new HashMap<>();
query.put("username",user.getUsername());
List list = service.select(query, new HashMap<>()).getResultList();
if (list.size()>0){
return error(30000, "用户已存在");
}
user.setUserId(null);
user.setPassword(service.encryption(user.getPassword()));
service.save(user);
return success(1);
}
/**
* 用户ID:[0,8388607]用户获取其他与用户相关的数据
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id")
private Integer userId;
/**
* 账户状态:[0,10](1可用|2异常|3已冻结|4已注销)
*/
@Basic
@Column(name = "state")
private Integer state;
/**
* 所在用户组:[0,32767]决定用户身份和权限
*/
@Basic
@Column(name = "user_group")
private String userGroup;
/**
* 上次登录时间:
*/
@Basic
@Column(name = "login_time")
private Timestamp loginTime;
/**
* 手机号码:[0,11]用户的手机号码,用于找回密码时或登录时
*/
@Basic
@Column(name = "phone")
private String phone;
/**
* 手机认证:[0,1](0未认证|1审核中|2已认证)
*/
@Basic
@Column(name = "phone_state")
private Integer phoneState;
/**
* 用户名:[0,16]用户登录时所用的账户名称
*/
@Basic
@Column(name = "username")
private String username;
/**
* 昵称:[0,16]
*/
@Basic
@Column(name = "nickname")
private String nickname;
/**
* 密码:[0,32]用户登录所需的密码,由6-16位数字或英文组成
*/
@Basic
@Column(name = "password")
private String password;
/**
* 邮箱:[0,64]用户的邮箱,用于找回密码时或登录时
*/
@Basic
@Column(name = "email")
private String email;
/**
* 邮箱认证:[0,1](0未认证|1审核中|2已认证)
*/
@Basic
@Column(name = "email_state")
private Integer emailState;
/**
* 头像地址:[0,255]
*/
@Basic
@Column(name = "avatar")
private String avatar;
/**
* 创建时间:
*/
@Basic
@Column(name = "create_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp createTime;
@Basic
@Transient
private String code;
}