From 5f36b7bb9fb215908b1b9b39a972dfe312016bf9 Mon Sep 17 00:00:00 2001 From: Null <281575458@qq.com> Date: 星期三, 17 三月 2021 12:32:17 +0800 Subject: [PATCH] 后台车辆新增和查询接口 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java | 70 ++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 1 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java index 481784d..63294d9 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngCarServiceImpl.java @@ -1,16 +1,25 @@ package com.panzhihua.service_community.service.impl; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.dtos.community.ComMngCarAppletDTO; +import com.panzhihua.common.model.dtos.community.ComMngCarSaveDTO; +import com.panzhihua.common.model.dtos.community.PageComMngCarDTO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComMngCarVO; +import com.panzhihua.common.model.vos.user.SysUserVO; +import com.panzhihua.common.service.user.UserService; import com.panzhihua.service_community.dao.ComMngCarDAO; +import com.panzhihua.service_community.dao.ComMngStructAreaDAO; import com.panzhihua.service_community.model.dos.ComMngCarDO; +import com.panzhihua.service_community.model.dos.ComMngStructAreaDO; import com.panzhihua.service_community.service.ComMngCarService; import org.springframework.beans.BeanUtils; -import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; import javax.annotation.Resource; import java.util.ArrayList; @@ -27,6 +36,10 @@ @Resource private ComMngCarDAO comMngCarDAO; + @Resource + private ComMngStructAreaDAO comMngStructAreaDAO; + @Resource + private UserService userService; @Override public R addComMngCarApplet(ComMngCarAppletDTO comCvtBusinessDTO) { @@ -55,4 +68,59 @@ }); return R.ok(comMngCarVOS); } + + @Override + public R pageQueryComMngCar(PageComMngCarDTO pageComMngCarDTO) { + Page page = new Page<>(); + Long pageNum = pageComMngCarDTO.getPageNum(); + Long pageSize = pageComMngCarDTO.getPageSize(); + if (null == pageNum || 0 == pageNum) { + pageNum = 1l; + } + if (null == pageSize || 0 == pageSize) { + pageSize = 10l; + } + page.setSize(pageSize); + page.setCurrent(pageNum); + IPage<ComMngCarVO> iPage = comMngCarDAO.pageQueryComMngCar(page, pageComMngCarDTO); + return R.ok(iPage); + } + + @Override + public R saveComMngCar(ComMngCarSaveDTO comMngCarSaveDTO) { + int count = comMngCarDAO.selectCount(new QueryWrapper<ComMngCarDO>().lambda().eq(ComMngCarDO::getPlateNum, comMngCarSaveDTO.getPlateNum())); + if (count > 0) { + return R.ok("车辆已存在"); + } + ComMngStructAreaDO comMngStructAreaDO = comMngStructAreaDAO.selectById(comMngCarSaveDTO.getAreaId()); + if (ObjectUtils.isEmpty(comMngStructAreaDO)) { + return R.fail("小区不存在"); + } + if (ObjectUtils.isEmpty(comMngCarSaveDTO.getMobile())) { + return R.fail("车主手机号码不能为空"); + } + ComMngCarDO comMngCarDO = new ComMngCarDO(); + BeanUtils.copyProperties(comMngCarSaveDTO, comMngCarDO); + comMngCarDO.setAreaName(comMngStructAreaDO.getAreaName()); + comMngCarDO.setCommunityId(comMngStructAreaDO.getCommunityId()); + comMngCarDO.setCreateAt(new Date()); + comMngCarDO.setSource(2); + R<SysUserVO> sysUserVOR = userService.getSysUserVOByPhone(comMngCarSaveDTO.getMobile()); + if(R.isOk(sysUserVOR)){ + SysUserVO sysUserVO = JSONObject.parseObject(JSONObject.toJSONString(sysUserVOR.getData()),SysUserVO.class); + comMngCarSaveDTO.setUserId(sysUserVO.getUserId()); + } + if(null!=comMngCarDO.getId() && comMngCarDO.getId()!=0){ + boolean update = this.updateById(comMngCarDO); + if (update) { + return R.ok(); + } + }else{ + boolean insert = this.save(comMngCarDO); + if (insert) { + return R.ok(); + } + } + return R.fail(); + } } -- Gitblit v1.7.1