| | |
| | | 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; |
| | | |
| | |
| | | */ |
| | | @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(); |
| | | } |
| | |
| | | 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(); |
| | | } |
| | | |
| | | |
| | | } |