From 47854f531bd87b8f7f6cfeaba91e87cf497193ce Mon Sep 17 00:00:00 2001
From: yanghui <2536613402@qq.com>
Date: 星期四, 08 十二月 2022 14:46:58 +0800
Subject: [PATCH] #feat 还原
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java | 88 ++++++++++++++++++++++++++++++++++++++++---
1 files changed, 81 insertions(+), 7 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
index 03574a5..1149166 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java
@@ -4,8 +4,13 @@
import javax.annotation.Resource;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.codec.Base64;
import com.panzhihua.common.model.vos.user.AdministratorsUserVO;
import com.panzhihua.common.service.user.UserService;
+import com.panzhihua.service_community.dao.ComEventMapper;
+import com.panzhihua.service_community.entity.ComEvent;
+import com.panzhihua.service_community.util.MyAESUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
@@ -43,6 +48,9 @@
@Resource
private UserService userService;
+ @Resource
+ private ComEventMapper comEventMapper;
+
/**
* 新增社区
*
@@ -53,9 +61,6 @@
@Override
@Transactional
public R<ComStreetVO> addStreet(ComStreetVO comStreetVO) {
- String password = comStreetVO.getPassword();
- String encode = new BCryptPasswordEncoder().encode(password);
- comStreetVO.setPassword(encode);
ComStreetDO comStreetDO = new ComStreetDO();
LambdaQueryWrapper<ComStreetDO> param = new QueryWrapper<ComStreetDO>().lambda();
param.eq(ComStreetDO::getName, comStreetVO.getName());
@@ -79,6 +84,10 @@
BeanUtils.copyProperties(comStreetVO, comStreetDO);
int insert = comStreetDAO.insert(comStreetDO);
if (insert > 0) {
+ AdministratorsUserVO administratorsUserVO1=new AdministratorsUserVO();
+ administratorsUserVO1.setUserId(Long.parseLong(r.getData().toString()));
+ administratorsUserVO1.setStreetId(comStreetDO.getStreetId());
+ userService.updateStreet(administratorsUserVO1);
ComStreetDO comStreetDO1 = comStreetDAO.selectOne(param);
BeanUtils.copyProperties(comStreetDO1, comStreetVO);
return R.ok(comStreetVO);
@@ -130,10 +139,10 @@
if (ObjectUtils.isEmpty(comStreetDO)) {
return R.fail();
}
- ComActVO comActVO = new ComActVO();
- BeanUtils.copyProperties(comStreetDO, comActVO);
- comActVO.setAreaName(comActDAO.selectAreaName(comActVO.getAreaCode()));
- return R.ok(comActVO);
+ ComStreetVO comStreetVO = new ComStreetVO();
+ BeanUtils.copyProperties(comStreetDO, comStreetVO);
+ comStreetVO.setAdministrativeRegions(comStreetDAO.retrieveRegions(comStreetVO.getAreaCode().toString()));
+ return R.ok(comStreetVO);
}
/**
@@ -159,6 +168,9 @@
LambdaQueryWrapper<ComStreetDO> userLambdaQueryWrapper = Wrappers.lambdaQuery();
if (pageComStreetDTO.getName() != null) {
userLambdaQueryWrapper.like(ComStreetDO::getName, pageComStreetDTO.getName());
+ }
+ if (pageComStreetDTO.getAreaCode() != null) {
+ userLambdaQueryWrapper.like(ComStreetDO::getAreaCode, pageComStreetDTO.getAreaCode());
}
Page userPage = new Page(pageNum, pageSize);
IPage<ComStreetDO> doPager =
@@ -189,4 +201,66 @@
return R.fail();
}
+
+ /**
+ * 修改街道信息
+ * @param comStreetVO 街道信息
+ * */
+ @Override
+ public R update(ComStreetVO comStreetVO) {
+ ComStreetDO comStreetDO=new ComStreetDO();
+ BeanUtils.copyProperties(comStreetVO,comStreetDO );
+ return R.ok(comStreetDAO.updateById(comStreetDO));
+ }
+
+ /**
+ * 删除街道
+ * */
+ @Override
+ public R remove(Long id) {
+ //是否有未结事件
+ List<Long> longs = comActDAO.selectCommunityByStreetId(id);
+ List<ComEvent> comEvents = comEventMapper.selectList(new QueryWrapper<ComEvent>().lambda().in(ComEvent::getEventProcessStatus, (4), (6), (7), (8)).in(ComEvent::getRequestUserCommunity, longs));
+ if (comEvents.size()!=0){
+ return R.fail("有未结事件不可删除");
+ }
+ comStreetDAO.deleteById(id);
+ return R.ok();
+ }
+
+ @Override
+ public R removeCommunity(Long id) {
+ //是否有未结案件
+ List<ComEvent> comEvents = comEventMapper.selectList(new QueryWrapper<ComEvent>().lambda().in(ComEvent::getEventProcessStatus, (4), (6), (7), (8)).eq(ComEvent::getRequestUserCommunity, id));
+ if (comEvents.size()!=0){
+ return R.fail("有未结事件不可删除");
+ }
+ comActDAO.deleteById(id);
+ return R.ok();
+ }
+
+ @Override
+ public R repassCommunity(ComActVO comActVO) {
+ ComActDO comActDO=new ComActDO();
+ try {
+ comActDO.setPassword(MyAESUtil.Encrypt(comActVO.getPassword(),"Ryo7M3n8loC5Abcd" ));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ comActDO.setCommunityId(comActVO.getCommunityId());
+ return R.ok(comActDAO.updateById(comActDO));
+ }
+
+ @Override
+ public R repssStreet(ComStreetVO comActVO) {
+ ComStreetDO comStreetDO=new ComStreetDO();
+ try {
+ comStreetDO.setPassword(MyAESUtil.Encrypt(comActVO.getPassword(),"Ryo7M3n8loC5Abcd" ));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ comStreetDO.setStreetId(comActVO.getStreetId());
+ return R.ok(comStreetDAO.updateById(comStreetDO));
+ }
+
}
--
Gitblit v1.7.1