From d108c3fd9c50d23e03629776f13615d11504416d Mon Sep 17 00:00:00 2001
From: Null <281575458@qq.com>
Date: 星期五, 12 三月 2021 10:44:50 +0800
Subject: [PATCH] 便民服务后台接口
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActServiceImpl.java | 64 +++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActServiceImpl.java
index a251b6d..55dad24 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActServiceImpl.java
@@ -1,8 +1,10 @@
package com.panzhihua.service_community.service.impl;
+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.panzhihua.common.model.dtos.community.PageComActDTO;
+import com.panzhihua.common.model.dtos.user.PageFeedBackDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComActVO;
import com.panzhihua.common.model.vos.community.ComMngStructOtherBuildVO;
@@ -10,10 +12,12 @@
import com.panzhihua.service_community.model.dos.ComActDO;
import com.panzhihua.service_community.service.ComActService;
import org.springframework.beans.BeanUtils;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -34,11 +38,20 @@
*/
@Override
public R addCommunity(ComActVO comActVO) {
+ String password = comActVO.getPassword();
+ String encode = new BCryptPasswordEncoder().encode(password);
+ comActVO.setPassword(encode);
ComActDO comActDO=new ComActDO();
+ Integer integer = comActDAO.selectCount(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getName, comActVO.getName()));
+ if (integer>0) {
+ return R.fail("社区已经存在");
+ }
BeanUtils.copyProperties(comActVO,comActDO);
int insert = comActDAO.insert(comActDO);
if (insert>0) {
- return R.ok();
+ ComActDO comActDO1 = comActDAO.selectOne(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getName, comActVO.getName()));
+ BeanUtils.copyProperties(comActDO1,comActVO);
+ return R.ok(comActVO);
}
return R.fail();
}
@@ -52,9 +65,26 @@
@Override
public R putCommunity(ComActVO comActVO) {
ComActDO comActDO=new ComActDO();
+ String password = comActVO.getPassword();
+ String account = comActVO.getAccount();
+ Long communityId = comActVO.getCommunityId();
+// String contacts = comActVO.getContacts();
+ int a=0;
+ if (!ObjectUtils.isEmpty(password)) {
+ String encode = new BCryptPasswordEncoder().encode(password);
+ comActVO.setPassword(encode);
+ a=1;
+ }
+// if(!ObjectUtils.isEmpty(account)||!ObjectUtils.isEmpty(contacts)){
+// a=1;
+// }
BeanUtils.copyProperties(comActVO,comActDO);
int update = comActDAO.updateById(comActDO);
if (update>0) {
+ if (a==1) {
+// 修改登录账户的密码
+ comActDAO.updateAccountPassword(comActVO.getPassword(),account,communityId);
+ }
return R.ok();
}
return R.fail();
@@ -113,7 +143,39 @@
return R.ok(iPage);
}
+ /**
+ * 查询平台所有的社区
+ *
+ * @return 社区集合 按照创建顺序倒序排列
+ */
+ @Override
+ public R listCommunityAll() {
+ List<ComActDO> comActDOS = comActDAO.selectList(new QueryWrapper<ComActDO>().lambda().eq(ComActDO::getState, 0).orderByDesc(ComActDO::getCreateAt));
+ List<ComActVO> comActVOS=new ArrayList<>();
+ if (!ObjectUtils.isEmpty(comActDOS)) {
+ comActDOS.forEach(comActDO -> {
+ ComActVO comActVO=new ComActVO();
+ BeanUtils.copyProperties(comActDO,comActVO);
+ comActVOS.add(comActVO);
+ });
+ }
+ return R.ok(comActVOS);
+ }
+ /**
+ * 删除社区
+ *
+ * @param communityId 社区id
+ * @return 删除结果
+ */
+ @Override
+ public R delectCommunity(Long communityId) {
+ int delete = comActDAO.deleteById(communityId);
+ if (delete>0) {
+ return R.ok();
+ }
+ return R.fail();
+ }
}
--
Gitblit v1.7.1