基于javaweb+mysql的springboot垃圾回收管理系统(java+springboot+thymeleaf+html+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot垃圾回收管理系统(java+springboot+thymeleaf+html+mysql)
项目介绍
整体项目封装的非常不错,可圈可点。页面比较出彩,互动性强。 本项目分为管理员、用户两种角色, 管理员的功能如下: 在库垃圾查看: 垃圾基本信息查看界面 可精确查找垃圾信息 垃圾去向模块:管理员可通过垃圾申请出库 员工管理模块:管理员管理员工界面;可查看员工用户的基本信息;精确查找员工用户 公告管理模块:管理员可编辑发布官方公告和重要信息 个人信息管理:编辑个人信息,修改密码 用户的功能包含如下: 垃圾回收模块:可查看入库垃圾的一些信息,如垃圾类型、数量;是否出库、来源和入库时间;可编辑和删除在库垃圾;提供精确定位搜索垃 垃圾去向模块:查看入库垃圾的去向信息,如垃圾数量、是否出库、出库目的地和出库时间;可精确查找运输信息;可以申请运输垃圾列表 员工管理模块:用户的个人信息界面;可更改个人信息
公告管理模块:可查看管理官方公告和一些重要信息
环境需要
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项目:是;
技术栈
-
后端:SpringBoot
-
前端:Thymeleaf+HTML+CSS+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8085/ 登录,端口必须是8085,这里前端页面写死了,需要注意 管理员账号/密码:admin/12345678
用户账号/密码:user/12345678
* </p>
*
*/
@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);
}
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));
}
}
/**
* <p>
* 公告表 前端控制器
* </p>
*
*/
@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")
@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);
}
}
/**
* <p>
* 公告表 前端控制器
* </p>
*
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);
}
}
@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);
}
* </p>
*
*/
@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);
/**
* <p>
* 垃圾入库表 前端控制器
* </p>
*
*/
@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 + "失败!!!");
}
@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);
if(userService.updateByType(userService.getById(userId))){
return Result.getSuccess().setMsg("操作成功");
}else{
return Result.getFailure().setMsg("操作失败");
}
}
@PostMapping("/update")
public Result update(@RequestBody RequestUpdateUserVo requestUpdateUserVo){
User user = userService.getById(requestUpdateUserVo.getId());
BeanUtils.copyProperties(requestUpdateUserVo,user);
if(userService.saveOrUpdate(user)){
return Result.getSuccess().setMsg("修改成功");
}else{
return Result.getFailure().setMsg("修改失败");
}
}
@PostMapping("/changePwd")
public Result changePwd(@RequestBody RequestChangePwdVo requestChangePwdVo){
User user = userService.getById(requestChangePwdVo.getId());
if(!user.getPassword().equals(DigestUtil.md5Hex(requestChangePwdVo.getOldPassword()))){
return Result.getFailure().setMsg("原密码错误");
}
if(requestChangePwdVo.getNewPassword().trim().toCharArray().length < 8){
return Result.getFailure().setMsg("密码位数必须大于8!!!");
}
user.setPassword(DigestUtil.md5Hex(requestChangePwdVo.getNewPassword()));
if(userService.saveOrUpdate(user)){
return Result.getSuccess().setMsg("修改成功");
}else{
return Result.getFailure().setMsg("修改失败");
}
}
/**上传地址*/
@Value("${file.upload.path}")
private String uploadPath;
/**
* 上传图片
* @param file
*/
@RequestMapping("/upload")
}
}
/**
* <p>
* 公告表 前端控制器
* </p>
*
*/
@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())){
public Result delete(@RequestBody RequestUserDeleteVo deleteVo){
if(VoUtilsTool.checkObjFieldIsNull(deleteVo)){
return Result.getFailure().setMsg(StringConst.DELETE_SELECT_ERROR);
}
if(userService.removeByIds(deleteVo.getStringIds())){
return Result.getSuccess().setMsg(StringConst.DELETE_SUCCESS);
}else{
return Result.getFailure().setMsg(StringConst.DELETE_ERROR);
}
}
@PostMapping("/list/{id}")
public Result list(@RequestBody RequestUserListVo userListVo, @PathVariable String id){
int type = userService.getById(id).getType();
if(type== 0 || (type == 1 && userListVo.getType() == 1)){
return Result.getFailure().setMsg("权限不足!!");
}
IPage<ResponseUserListVo> listVoIPage = userService.userList(userListVo,type);
return Result.getSuccess().setData(listVoIPage);
}
@GetMapping("/updateByType/{userId}")
public Result updateByType(@PathVariable String userId){
if(userService.updateByType(userService.getById(userId))){
return Result.getSuccess().setMsg("操作成功");
}else{
return Result.getFailure().setMsg("操作失败");
}
}
@PostMapping("/update")
public Result update(@RequestBody RequestUpdateUserVo requestUpdateUserVo){
User user = userService.getById(requestUpdateUserVo.getId());
BeanUtils.copyProperties(requestUpdateUserVo,user);
if(userService.saveOrUpdate(user)){
return Result.getSuccess().setMsg("修改成功");
}else{
return Result.getFailure().setMsg("修改失败");
}
}
@PostMapping("/changePwd")
public Result changePwd(@RequestBody RequestChangePwdVo requestChangePwdVo){
User user = userService.getById(requestChangePwdVo.getId());
if(!user.getPassword().equals(DigestUtil.md5Hex(requestChangePwdVo.getOldPassword()))){
return Result.getFailure().setMsg("原密码错误");
}
if(requestChangePwdVo.getNewPassword().trim().toCharArray().length < 8){
return Result.getFailure().setMsg("密码位数必须大于8!!!");
}
user.setPassword(DigestUtil.md5Hex(requestChangePwdVo.getNewPassword()));
if(userService.saveOrUpdate(user)){
return Result.getSuccess().setMsg("修改成功");
}else{
/**
* <p>
* 垃圾入库表 前端控制器
* </p>
*
*/
@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 + "失败!!!");
}
}
@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);
if(!PhoneFormatCheckUtils.isPhoneLegal(registerVo.getTel())){
return Result.getFailure().setMsg("手机号格式正确!!!");
}
//用户数据拷贝
User user = new User();
BeanUtils.copyProperties(registerVo,user);
user.setPassword(DigestUtil.md5Hex(registerVo.getPassword()));
user.setId(IdUtil.simpleUUID());
user.setAvatarUrl("\\goodsImg\\avatar.jpg");
//存入数据库中
if(userService.saveOrUpdate(user)){
return Result.getSuccess().setMsg("注册成功!!!");
}else{
return Result.getFailure().setMsg("注册失败!!!");
}
}
@RequestMapping("/login")
public Result login(HttpServletRequest request, @RequestBody RequestLoginVo loginRequestVo){
//System.out.println(loginRequestVo);
HttpSession session = request.getSession();
String trueCaptcha = (String) session.getAttribute(Constants.KAPTCHA_SESSION_KEY);
if(!trueCaptcha.equalsIgnoreCase(loginRequestVo.getCaptcha())){
return Result.getFailure().setMsg(StringConst.CAPTCHA_ERROR);
}
User user;
if(ObjectUtils.isEmpty(userService.queryByUsername(loginRequestVo.getUsernameOrTel()))){
user = userService.queryByTel(loginRequestVo.getUsernameOrTel());
}else{
user = userService.queryByUsername(loginRequestVo.getUsernameOrTel());
}
if(ObjectUtils.isEmpty(user) || !DigestUtil.md5Hex(loginRequestVo.getPassword()).
equals(user.getPassword())){
return Result.getFailure().setMsg(StringConst.LOGIN_ERROR);
}
Map<String,Object> result = new HashMap<>();
result.put("userId",user.getId());
result.put("userType",user.getType());
return Result.getSuccess().setData(result);
}
@GetMapping("/getUserById/{userId}")
public Result getUserById(@PathVariable String userId){
return Result.getSuccess().setData(userService.getUserById(userId));
}
return Result.getSuccess().setData(userService.getUserById(userId));
}
@DeleteMapping("/deleteByIds")
public Result delete(@RequestBody RequestUserDeleteVo deleteVo){
if(VoUtilsTool.checkObjFieldIsNull(deleteVo)){
return Result.getFailure().setMsg(StringConst.DELETE_SELECT_ERROR);
}
if(userService.removeByIds(deleteVo.getStringIds())){
return Result.getSuccess().setMsg(StringConst.DELETE_SUCCESS);
}else{
return Result.getFailure().setMsg(StringConst.DELETE_ERROR);
}
}
@PostMapping("/list/{id}")
public Result list(@RequestBody RequestUserListVo userListVo, @PathVariable String id){
int type = userService.getById(id).getType();
if(type== 0 || (type == 1 && userListVo.getType() == 1)){
return Result.getFailure().setMsg("权限不足!!");
}
IPage<ResponseUserListVo> listVoIPage = userService.userList(userListVo,type);
return Result.getSuccess().setData(listVoIPage);
}
@GetMapping("/updateByType/{userId}")
public Result updateByType(@PathVariable String userId){
if(userService.updateByType(userService.getById(userId))){
return Result.getSuccess().setMsg("操作成功");
}else{
return Result.getFailure().setMsg("操作失败");
}
}
@PostMapping("/update")
public Result update(@RequestBody RequestUpdateUserVo requestUpdateUserVo){
User user = userService.getById(requestUpdateUserVo.getId());
BeanUtils.copyProperties(requestUpdateUserVo,user);
if(userService.saveOrUpdate(user)){
return Result.getSuccess().setMsg("修改成功");
}else{
return Result.getFailure().setMsg("修改失败");
}
}
@PostMapping("/changePwd")
public Result changePwd(@RequestBody RequestChangePwdVo requestChangePwdVo){
User user = userService.getById(requestChangePwdVo.getId());
/**
* <p>
* 垃圾入库表 前端控制器
* </p>
*
*/
@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.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);
}
}