作者主页:舒克日记
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文中获取源码
1.运行环境:最好是java jdk1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat7.x,8.X,9.x版本均可
4.硬件环境:windows7/8/10 4G内存以上;或者Mac OS;
5.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven.项目
6.数据库:MySql5.7/8.0等版本均可;
后台框架:Spring Boot、MyBatis
数据库:MySQL
环境:JDK8、TOMCAT、IDEA
1.使用Navicati或者其它工具,在mysql中创建对应sq文件名称的数据库,并导入项目的sql文件;
2.使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3.将项目中config-propertiesi配置文件中的数据库配置改为自己的配置,然后运行;
idea导入源码空间站顶目教程说明(Vindows版)-ssm篇:
http://mtw.so/5MHvZq
源码看好后直接在网站付款下单即可,付款成功会自动弹出百度网盘链接,网站地址:http://codegym.top。
其它问题请关注公众号:IT小舟,关注后发送消息即可,都会给您回复的。若没有及时回复请耐心等待,通常当天会有回复
GarbageController
package com.garbage.demo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.garbage.demo.common.Result;
import com.garbage.demo.entity.Garbage;
import com.garbage.demo.service.IGarbageService;
import com.garbage.demo.utils.StringConst;
import com.garbage.demo.vo.request.RequestDeleteVo;
import com.garbage.demo.vo.request.RequestGarbageAddVo;
import com.garbage.demo.vo.request.RequestGarbageListByTypeVo;
import com.garbage.demo.vo.request.RequestGarbageListVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 垃圾入库表 前端控制器
* </p>
*
* @author lzf
* @since 2020-10-15
*/
@RestController
@RequestMapping("/garbage")
public class GarbageController {
@Autowired
private IGarbageService garbageService;
@PostMapping("/saveOrUpdate")
public Result saveOrUpdate(@RequestBody RequestGarbageAddVo requestGarbageAddVo){
String result;
if(requestGarbageAddVo.getWeight()<0){
return Result.getFailure().setMsg("重量输入错误!!");
}
if(ObjectUtils.isNotEmpty(requestGarbageAddVo.getId())){
result = "修改";
}else{
result = "添加";
}
Garbage garbage = new Garbage();
BeanUtils.copyProperties(requestGarbageAddVo,garbage);
if(garbageService.saveOrUpdate(garbage)){
return Result.getSuccess().setMsg(result + "成功!!!");
}else{
return Result.getFailure().setMsg(result + "失败!!!");
}
}
@DeleteMapping("/deleteByIds")
public Result delete(@RequestBody RequestDeleteVo requestDeleteVo){
if(ObjectUtils.isNotEmpty(requestDeleteVo.getIntegerIds())){
QueryWrapper<Garbage> garbageQueryWrapper = new QueryWrapper<>();
garbageQueryWrapper.isNull("transport_id");
garbageQueryWrapper.in("id",requestDeleteVo.getIntegerIds());
garbageService.remove(garbageQueryWrapper);
return Result.getSuccess().setMsg(StringConst.DELETE_SUCCESS);
}
return Result.getFailure().setMsg(StringConst.DELETE_ERROR);
}
@PostMapping("/list")
public Result list(@RequestBody RequestGarbageListVo garbageListVo){
IPage<Garbage> garbageIPage = garbageService.list(garbageListVo);
return Result.getSuccess().setData(garbageIPage);
}
@GetMapping("/getById/{id}")
public Result getById(@PathVariable Integer id){
return Result.getSuccess().setData(garbageService.getById(id));
}
@PostMapping("/getByType")
public Result getByType(@RequestBody RequestGarbageListByTypeVo garbageListByTypeVo){
IPage<Garbage> garbageIPage = garbageService.getByType(garbageListByTypeVo);
return Result.getSuccess().setData(garbageIPage);
}
@GetMapping("/getByTransportId/{transportId}")
public Result getByTransportId(@PathVariable Integer transportId
,@RequestParam(value = "limit") Integer limit,@RequestParam(value = "page") Integer page){
IPage<Garbage> garbageIPage = garbageService.getByTransportId(transportId,limit ,page);
return Result.getSuccess().setData(garbageIPage);
}
}
NoticeController
package com.garbage.demo.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.garbage.demo.common.Result;
import com.garbage.demo.entity.Notice;
import com.garbage.demo.service.INoticeService;
import com.garbage.demo.utils.StringConst;
import com.garbage.demo.utils.VoUtilsTool;
import com.garbage.demo.vo.request.RequestDeleteVo;
import com.garbage.demo.vo.request.RequestNoticeListVo;
import com.garbage.demo.vo.request.RequestSaveOrUpdateNoticeVo;
import com.garbage.demo.vo.response.ResponseUserListVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 公告表 前端控制器
* </p>
*
* @author lzf
* @since 2020-10-15
*/
@RestController
@RequestMapping("/notice")
public class NoticeController {
@Autowired
INoticeService noticeService;
@PostMapping("/saveOrUpdateNotice")
public Result saveOrUpdateNotice(@RequestBody RequestSaveOrUpdateNoticeVo saveOrUpdateNoticeVo){
if(ObjectUtils.isEmpty(saveOrUpdateNoticeVo.getTitle())){
return Result.getFailure().setMsg(StringConst.NOTICE_IS_NULL);
}
String result = null;
Notice notice;
if(ObjectUtils.isEmpty(saveOrUpdateNoticeVo.getId())){
notice = new Notice();
BeanUtils.copyProperties(saveOrUpdateNoticeVo,notice);
result = "添加";
}else{
notice = noticeService.getById(saveOrUpdateNoticeVo.getId());
BeanUtils.copyProperties(saveOrUpdateNoticeVo,notice);
result = "修改";
}
if(!noticeService.saveOrUpdate(notice)){
return Result.getFailure().setMsg(result +"失败了。");
}
return Result.getSuccess().setMsg(result + "成功啦!");
}
@DeleteMapping("/deleteByIds")
public Result delete(@RequestBody RequestDeleteVo deleteVo){
if(VoUtilsTool.checkObjFieldIsNull(deleteVo)){
return Result.getFailure().setMsg(StringConst.DELETE_SELECT_ERROR);
}
if(noticeService.removeByIds(deleteVo.getIntegerIds())){
return Result.getSuccess().setMsg(StringConst.DELETE_SUCCESS);
}else{
return Result.getFailure().setMsg(StringConst.DELETE_ERROR);
}
}
@PostMapping("/list")
public Result noticeList(@RequestBody RequestNoticeListVo noticeListVo){
IPage<Notice> listVoIPage = noticeService.noticeList(noticeListVo);
return Result.getSuccess().setData(listVoIPage);
}
@GetMapping("/getById/{id}")
public Result getById( @PathVariable Integer id){
return Result.getSuccess().setData(noticeService.getById(id));
}
}