From 560db6a1036201e7e2ac50f34ad4a418f17eaba6 Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期一, 06 六月 2022 11:01:11 +0800 Subject: [PATCH] bug修改 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComStreetServiceImpl.java | 91 +++++++++++++++++++++++++++++---------------- 1 files changed, 58 insertions(+), 33 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 20bd18e..370380c 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 @@ -1,5 +1,17 @@ package com.panzhihua.service_community.service.impl; +import java.util.List; + +import javax.annotation.Resource; + +import com.panzhihua.common.model.vos.user.AdministratorsUserVO; +import com.panzhihua.common.service.user.UserService; +import org.springframework.beans.BeanUtils; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; + import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -15,14 +27,6 @@ import com.panzhihua.service_community.model.dos.ComActDO; import com.panzhihua.service_community.model.dos.ComStreetDO; import com.panzhihua.service_community.service.ComStreetService; -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; /** * @author: llming @@ -36,17 +40,19 @@ @Resource private ComStreetDAO comStreetDAO; + @Resource + private UserService userService; + /** * 新增社区 * - * @param comStreetVO 街道信息 + * @param comStreetVO + * 街道信息 * @return 新增结果 */ @Override - public R addStreet(ComStreetVO comStreetVO) { - String password = comStreetVO.getPassword(); - String encode = new BCryptPasswordEncoder().encode(password); - comStreetVO.setPassword(encode); + @Transactional + public R<ComStreetVO> addStreet(ComStreetVO comStreetVO) { ComStreetDO comStreetDO = new ComStreetDO(); LambdaQueryWrapper<ComStreetDO> param = new QueryWrapper<ComStreetDO>().lambda(); param.eq(ComStreetDO::getName, comStreetVO.getName()); @@ -55,23 +61,39 @@ param.eq(ComStreetDO::getAreaCode, comStreetVO.getAreaCode()); Integer integer = comStreetDAO.selectCount(param); if (integer > 0) { - return R.fail("街道已经存在"); + return R.fail(500, "街道已经存在"); } - BeanUtils.copyProperties(comStreetVO, comStreetDO); - int insert = comStreetDAO.insert(comStreetDO); - if (insert > 0) { - ComStreetDO comStreetDO1 = comStreetDAO.selectOne(param); - BeanUtils.copyProperties(comStreetDO1, comStreetVO); - return R.ok(comStreetVO); + AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); + administratorsUserVO.setType(3); + administratorsUserVO.setAccount(comStreetVO.getAccount()); + administratorsUserVO.setPassword(comStreetVO.getPassword()); + administratorsUserVO.setSocialType(1); + administratorsUserVO.setRoleId(777777777L); + administratorsUserVO.setStreetId(0L); + administratorsUserVO.setName(comStreetVO.getName()); + R r=userService.addUserBackstageProperty(administratorsUserVO); + if(R.isOk(r)){ + 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); + } + return R.fail(500, ""); } - return R.fail(); + return R.fail("账号已存在"); } - /** * 查询街道 * - * @param comStreetVO 街道名 + * @param comStreetVO + * 街道名 * @return 社区集合 */ @Override @@ -99,7 +121,8 @@ /** * 社区详情 * - * @param streetId 街道id + * @param streetId + * 街道id * @return 社区详情 */ @Override @@ -117,7 +140,8 @@ /** * 分页查询社区 * - * @param pageComStreetDTO 查询参数 + * @param pageComStreetDTO + * 查询参数 * @return 分页集合 */ @Override @@ -126,10 +150,10 @@ Long pageNum = pageComStreetDTO.getPageNum(); Long pageSize = pageComStreetDTO.getPageSize(); if (null == pageNum || 0 == pageNum) { - pageNum = 1l; + pageNum = 1L; } if (null == pageSize || 0 == pageSize) { - pageSize = 10l; + pageSize = 10L; } page.setSize(pageSize); page.setCurrent(pageNum); @@ -138,21 +162,23 @@ userLambdaQueryWrapper.like(ComStreetDO::getName, pageComStreetDTO.getName()); } Page userPage = new Page(pageNum, pageSize); - IPage<ComStreetDO> doPager = comStreetDAO.selectPage(userPage, userLambdaQueryWrapper.orderByDesc(ComStreetDO::getCreateAt)); + IPage<ComStreetDO> doPager = + comStreetDAO.selectPage(userPage, userLambdaQueryWrapper.orderByDesc(ComStreetDO::getCreateAt)); return R.ok(doPager); } - /** * 批量删除街道 * - * @param streetIds 社区id + * @param streetIds + * 社区id * @return 删除结果 */ @Override public R delectStreat(List<Long> streetIds) { - //不能删除,已经绑定了社区的街道 - LambdaQueryWrapper<ComActDO> comActDOParam = new QueryWrapper<ComActDO>().lambda().in(ComActDO::getStreetId, streetIds); + // 不能删除,已经绑定了社区的街道 + LambdaQueryWrapper<ComActDO> comActDOParam = + new QueryWrapper<ComActDO>().lambda().in(ComActDO::getStreetId, streetIds); List<ComActDO> comActDOS = comActDAO.selectList(comActDOParam); if (comActDOS != null && comActDOS.size() > 0) { return R.fail("删除失败,批量删除街道中,街道下有社区无法删除!"); @@ -163,6 +189,5 @@ } return R.fail(); } - } -- Gitblit v1.7.1