基于javaweb的SpringBoot校园失物招领系统(java+springboot+maven+mybaits+vue+elementui+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可

❗没学过node.js的不要搞前后端分离项目

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

201524122608

211524122608

221524122608

231524122608

251524122608

261524122608

271524122608

281524122608

291524122608

301524122608

基于javaweb的SpringBoot校园失物招领系统(java+springboot+maven+mybaits+vue+elementui+mysql)

项目介绍

基于Springboot + vue实现的校园失物招领系统

本项目分为前后台,包含用户和管理员两个角色

用户:登录、注册、留言板、公告信息、失物招领、失物认领、寻物启事、个人中心、我发布的失物信息、我的失物认领、我发布的寻物启事、寻物启事留言等功能。

管理员:登录、基础数据管理、系统管理、留言板管理、失物信息管理、失物认领管理、寻物启事管理等功能。

技术栈

后端:SpringBoot+Mybaits

前端:Vue+elementui

管理员:
admin 123456

用户:
a1 123456
a2 123456
a3 123456
a5 123456

后端启动类:StartApplication
前端启动命令:npm run serve

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
        caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"修改",strings.toString());
return R.ok();
}



/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
List<XunwuqishiLiuyanEntity> oldXunwuqishiLiuyanList =xunwuqishiLiuyanService.selectBatchIds(Arrays.asList(ids));//要删除的数据
xunwuqishiLiuyanService.deleteBatchIds(Arrays.asList(ids));

caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"删除",oldXunwuqishiLiuyanList.toString());
return R.ok();
}


/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
try {
List<XunwuqishiLiuyanEntity> xunwuqishiLiuyanList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
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
                        dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
YonghuEntity yonghuEntity = new YonghuEntity();
// yonghuEntity.setUsername(data.get(0)); //账户 要改的
// yonghuEntity.setPassword("123456");//密码
// yonghuEntity.setYonghuUuidNumber(data.get(0)); //用户编号 要改的
// yonghuEntity.setYonghuName(data.get(0)); //用户姓名 要改的
// yonghuEntity.setYonghuPhone(data.get(0)); //用户手机号 要改的
// yonghuEntity.setYonghuIdNumber(data.get(0)); //用户身份证号 要改的
// yonghuEntity.setYonghuPhoto("");//详情和图片
// yonghuEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
// yonghuEntity.setYonghuEmail(data.get(0)); //用户邮箱 要改的
// yonghuEntity.setJinyongTypes(Integer.valueOf(data.get(0))); //账户状态 要改的
// yonghuEntity.setCreateTime(date);//时间
yonghuList.add(yonghuEntity);


//把要查询是否重复的字段放入map中
//账户
if(seachFields.containsKey("username")){
List<String> username = seachFields.get("username");
username.add(data.get(0));//要改的
}else{
List<String> username = new ArrayList<>();
username.add(data.get(0));//要改的
seachFields.put("username",username);
}
//用户编号
if(seachFields.containsKey("yonghuUuidNumber")){
List<String> yonghuUuidNumber = seachFields.get("yonghuUuidNumber");
yonghuUuidNumber.add(data.get(0));//要改的
}else{
List<String> yonghuUuidNumber = new ArrayList<>();
yonghuUuidNumber.add(data.get(0));//要改的
seachFields.put("yonghuUuidNumber",yonghuUuidNumber);
}
//用户手机号
if(seachFields.containsKey("yonghuPhone")){
List<String> yonghuPhone = seachFields.get("yonghuPhone");
yonghuPhone.add(data.get(0));//要改的
}else{
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
   }

/**
* 列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
PageUtils page = configService.queryPage(params);
return R.ok().put("data", page);
}

/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
}

/**
* 详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") String id){
ConfigEntity config = configService.selectById(id);
return R.ok().put("data", config);
}

/**
* 根据name获取信息
*/
@RequestMapping("/info")
public R infoByName(@RequestParam String name){
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
return R.ok().put("data", config);
}

/**
* 保存
*/
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
            OutputStream out = child1.getOutputStream();//控制台的输入信息作为输出流
String inStr;
StringBuffer sb = new StringBuffer("");
String outStr;
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(savePath+"/"+fileName), "utf-8"));
while ((inStr = br.readLine()) != null) {
sb.append(inStr + "\r\n");
}
outStr = sb.toString();
OutputStreamWriter writer = new OutputStreamWriter(out, "utf8");
writer.write(outStr);
// 注:这里如果用缓冲方式写入文件的话,会导致中文乱码,用flush()方法则可以避免
writer.flush();
out.close();
br.close();
writer.close();
} catch (Exception e) {
e.printStackTrace();
return R.error("数据导入出错");
}
return R.ok();
}


/**
* 饼状图求和
* @return
*/
@RequestMapping("/pieSum")
public R pieSum(@RequestParam Map<String,Object> params) {
logger.debug("饼状图求和:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.pieSum(params);
return R.ok().put("data", result);
}

/**
* 饼状图统计
* @return
*/
@RequestMapping("/pieCount")
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
    * 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody LiuyanEntity liuyan, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,liuyan:{}",this.getClass().getName(),liuyan.toString());

String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
liuyan.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

Wrapper<LiuyanEntity> queryWrapper = new EntityWrapper<LiuyanEntity>()
.eq("yonghu_id", liuyan.getYonghuId())
.eq("liuyan_name", liuyan.getLiuyanName())
;

logger.info("sql语句:"+queryWrapper.getSqlSegment());
LiuyanEntity liuyanEntity = liuyanService.selectOne(queryWrapper);
if(liuyanEntity==null){
liuyan.setInsertTime(new Date());
liuyan.setCreateTime(new Date());
liuyanService.insert(liuyan);
caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"新增",liuyan.toString());
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}

/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody LiuyanEntity liuyan, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
logger.debug("update方法:,,Controller:{},,liuyan:{}",this.getClass().getName(),liuyan.toString());
LiuyanEntity oldLiuyanEntity = liuyanService.selectById(liuyan.getId());//查询原先数据

String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// liuyan.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
liuyan.setUpdateTime(new Date());

liuyanService.updateById(liuyan);//根据id更新
List<String> strings = caozuorizhiService.clazzDiff(liuyan, oldLiuyanEntity, request,new String[]{"updateTime"});
caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"修改",strings.toString());
return R.ok();
}



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
}





/**
* 留言板
* 后端接口
* @email
*/
@RestController
@Controller
@RequestMapping("/liuyan")
public class LiuyanController {
private static final Logger logger = LoggerFactory.getLogger(LiuyanController.class);


项目链接:
https://javayms.github.io?id=121524522608201on
https://javayms.pages.dev?id=121524522608201on