New file |
| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.ComActFourMemberVO; |
| | | import com.panzhihua.common.model.vos.user.AdministratorsUserVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.service_community.dao.ComMngBuildingDAO; |
| | | import com.panzhihua.service_community.entity.ComActCommittee; |
| | | import com.panzhihua.service_community.entity.ComActFourMember; |
| | | import com.panzhihua.service_community.dao.ComActFourMemberDao; |
| | | import com.panzhihua.service_community.model.dos.ComMngBuildingDO; |
| | | import com.panzhihua.service_community.service.ComActFourMemberService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * (ComActFourMember)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2021-09-23 10:13:31 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActFourMemberServiceImpl extends ServiceImpl<ComActFourMemberDao, ComActFourMember> implements ComActFourMemberService { |
| | | @Resource |
| | | private ComActFourMemberDao comActFourMemberDao; |
| | | @Resource |
| | | private ComMngBuildingDAO comMngBuildingDAO; |
| | | @Resource |
| | | private UserService userService; |
| | | @Override |
| | | public R pageList(CommonPage commonPage) { |
| | | return R.ok(comActFourMemberDao.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage)); |
| | | } |
| | | |
| | | @Override |
| | | public R insert(ComActFourMemberVO comActFourMemberVO) { |
| | | if(comActFourMemberVO!=null&&comActFourMemberVO.getJurisdiction()!=null){ |
| | | ComActFourMember comActFourMember=new ComActFourMember(); |
| | | List<String> jurisdictionList=comMngBuildingDAO.find(comActFourMemberVO.getJurisdiction()); |
| | | if(!jurisdictionList.isEmpty()&&jurisdictionList.size()==jurisdictionList.stream().distinct().collect(Collectors.toList()).size()){ |
| | | comActFourMember.setJurisdictionContent(JSON.toJSONString(jurisdictionList)); |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | BeanUtils.copyProperties(comActFourMemberVO,administratorsUserVO); |
| | | administratorsUserVO.setType(3); |
| | | R r=userService.addUserBackstageProperty(administratorsUserVO); |
| | | if(R.isOk(r)){ |
| | | comActFourMemberVO.setUserId(Long.parseLong(r.getData().toString())); |
| | | comActFourMemberVO.setCreateTime(DateUtil.date()); |
| | | BeanUtils.copyProperties(comActFourMemberVO,comActFourMember); |
| | | this.comActFourMemberDao.insert(comActFourMember); |
| | | return R.ok(); |
| | | } |
| | | return R.fail("手机号或账户已存在"); |
| | | } |
| | | return R.fail("绑定管辖区域不能为空或重复"); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R update(ComActFourMemberVO comActFourMemberVO) { |
| | | if(comActFourMemberVO!=null){ |
| | | if(comActFourMemberVO.getIds()!=null){ |
| | | for(Integer id:comActFourMemberVO.getIds()){ |
| | | ComActFourMember comActFourMember=new ComActFourMember(); |
| | | ComActFourMember comActFourMemberBase=this.comActFourMemberDao.selectById(id); |
| | | if(comActFourMemberBase!=null){ |
| | | comActFourMember.setId(comActFourMemberBase.getId()); |
| | | comActFourMember.setUserId(comActFourMemberBase.getUserId()); |
| | | } |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | BeanUtils.copyProperties(comActFourMemberVO,administratorsUserVO); |
| | | userService.putUserBackstage(administratorsUserVO); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | else { |
| | | ComActFourMember comActFourMember=new ComActFourMember(); |
| | | ComActFourMember comActFourMemberBase=this.comActFourMemberDao.selectById(comActFourMemberVO.getId()); |
| | | if(comActFourMemberBase!=null){ |
| | | comActFourMember.setId(comActFourMemberBase.getId()); |
| | | comActFourMember.setUserId(comActFourMemberBase.getUserId()); |
| | | } |
| | | if(comActFourMemberVO.getJurisdiction()!=null){ |
| | | List<String> jurisdictionList=comMngBuildingDAO.find(comActFourMemberVO.getJurisdiction()); |
| | | if(!jurisdictionList.isEmpty()&&jurisdictionList.size()==jurisdictionList.stream().distinct().collect(Collectors.toList()).size()){ |
| | | comActFourMember.setJurisdictionContent(JSON.toJSONString(jurisdictionList)); |
| | | } |
| | | else { |
| | | return R.fail("绑定管辖区域不能为空或重复"); |
| | | } |
| | | } |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | BeanUtils.copyProperties(comActFourMemberVO,administratorsUserVO); |
| | | R r=userService.putUserBackstage(administratorsUserVO); |
| | | if(R.isOk(r)){ |
| | | BeanUtils.copyProperties(comActFourMemberVO,comActFourMember); |
| | | this.comActFourMemberDao.updateById(comActFourMember); |
| | | return R.ok(); |
| | | } |
| | | return R.fail("修改失败"); |
| | | } |
| | | |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R delete(ComActFourMemberVO comActFourMemberVO) { |
| | | if(comActFourMemberVO.getIds()!=null){ |
| | | for(Integer id: comActFourMemberVO.getIds()){ |
| | | ComActFourMember comActFourMember=comActFourMemberDao.selectById(id); |
| | | if(comActFourMember!=null){ |
| | | if(comActFourMember.getUserId()!=null){ |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | administratorsUserVO.setUserId(comActFourMember.getUserId()); |
| | | administratorsUserVO.setCommunityId(comActFourMember.getCommunityId()); |
| | | userService.deleteUserBackstage(administratorsUserVO); |
| | | this.comActFourMemberDao.deleteById(id); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | else { |
| | | ComActFourMember comActFourMember=comActFourMemberDao.selectById(comActFourMemberVO.getId()); |
| | | if(comActFourMember!=null){ |
| | | if(comActFourMember.getUserId()!=null){ |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | administratorsUserVO.setUserId(comActFourMember.getUserId()); |
| | | administratorsUserVO.setCommunityId(comActFourMember.getCommunityId()); |
| | | userService.deleteUserBackstage(administratorsUserVO); |
| | | this.comActFourMemberDao.deleteById(comActFourMemberVO.getId()); |
| | | return R.ok(); |
| | | |
| | | } |
| | | } |
| | | return R.fail("用户账号错误"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public R get(Integer id) { |
| | | return R.ok(comActFourMemberDao.getById(id)); |
| | | } |
| | | } |