New file |
| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.property.CommonPage; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComPropertyVO; |
| | | import com.panzhihua.common.model.vos.user.AdministratorsUserVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.service_community.entity.ComActSocialOrg; |
| | | import com.panzhihua.service_community.entity.ComProperty; |
| | | import com.panzhihua.service_community.dao.ComPropertyDao; |
| | | import com.panzhihua.service_community.service.ComPropertyService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * (ComProperty)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2021-09-18 10:46:51 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComPropertyServiceImpl extends ServiceImpl<ComPropertyDao, ComProperty> implements ComPropertyService { |
| | | @Resource |
| | | private ComPropertyDao comPropertyDao; |
| | | @Resource |
| | | private UserService userService; |
| | | @Override |
| | | public R pageList(CommonPage commonPage) { |
| | | return R.ok(comPropertyDao.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage)); |
| | | } |
| | | |
| | | @Override |
| | | public R selectById(Long id) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R insert(ComPropertyVO comPropertyVO) { |
| | | if(comPropertyVO!=null){ |
| | | ComProperty comProperty=new ComProperty(); |
| | | BeanUtils.copyProperties(comPropertyVO,comProperty); |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | administratorsUserVO.setType(3); |
| | | administratorsUserVO.setAccount(comPropertyVO.getAccount()); |
| | | administratorsUserVO.setPassword(comPropertyVO.getPassword()); |
| | | administratorsUserVO.setRoleId(comPropertyVO.getRoleId()); |
| | | administratorsUserVO.setCommunityId(comPropertyVO.getCommunityId()); |
| | | administratorsUserVO.setAreaId(comPropertyVO.getAreaId()); |
| | | administratorsUserVO.setName(comPropertyVO.getContactName()); |
| | | administratorsUserVO.setPhone(comPropertyVO.getPhone()); |
| | | R r=userService.addUserBackstageProperty(administratorsUserVO); |
| | | if(R.isOk(r)){ |
| | | comProperty.setUserId(Long.parseLong(r.getData().toString())); |
| | | comProperty.setCreateTime(DateUtil.date()); |
| | | this.comPropertyDao.insert(comProperty); |
| | | return R.ok(); |
| | | } |
| | | return R.fail(r.getMsg()); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R update(ComPropertyVO comPropertyVO) { |
| | | if(comPropertyVO!=null){ |
| | | ComProperty comProperty=new ComProperty(); |
| | | BeanUtils.copyProperties(comPropertyVO,comProperty); |
| | | this.comPropertyDao.updateById(comProperty); |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R delete(Long id) { |
| | | ComProperty comProperty=comPropertyDao.selectById(id); |
| | | if(comProperty!=null){ |
| | | if(comProperty.getUserId()!=null){ |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | administratorsUserVO.setUserId(comProperty.getUserId()); |
| | | administratorsUserVO.setCommunityId(comProperty.getCommunityId()); |
| | | userService.deleteUserBackstage(administratorsUserVO); |
| | | this.comPropertyDao.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | return R.fail("用户账号错误"); |
| | | } |
| | | } |