huanghongfa
2021-01-07 ae33fef700e5d2558dffb03c8f66358da2545791
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActServiceImpl.java
@@ -12,6 +12,7 @@
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;
@@ -37,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();
    }
@@ -135,7 +145,20 @@
        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();
    }
}