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.ComActSocialOrgVO; |
| | | 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.dao.ComActSocialOrgDao; |
| | | import com.panzhihua.service_community.service.ComActSocialOrgService; |
| | | 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; |
| | | |
| | | /** |
| | | * 社会组织(ComActSocialOrg)表服务实现类 |
| | | * |
| | | * @author makejava |
| | | * @since 2021-09-17 10:45:30 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComActSocialOrgServiceImpl extends ServiceImpl<ComActSocialOrgDao, ComActSocialOrg> implements ComActSocialOrgService { |
| | | @Resource |
| | | private ComActSocialOrgDao comActSocialOrgDao; |
| | | @Resource |
| | | private UserService userService; |
| | | @Override |
| | | public R pageList(CommonPage commonPage) { |
| | | return R.ok(comActSocialOrgDao.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage)); |
| | | } |
| | | |
| | | @Override |
| | | public R selectById(Long id) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R insert(ComActSocialOrgVO comActSocialOrgVO) { |
| | | if(comActSocialOrgVO!=null){ |
| | | ComActSocialOrg comActSocialOrg=new ComActSocialOrg(); |
| | | BeanUtils.copyProperties(comActSocialOrgVO,comActSocialOrg); |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | administratorsUserVO.setType(3); |
| | | administratorsUserVO.setAccount(comActSocialOrgVO.getAccount()); |
| | | administratorsUserVO.setPassword(comActSocialOrgVO.getPassword()); |
| | | administratorsUserVO.setRoleId(comActSocialOrgVO.getRoleId()); |
| | | administratorsUserVO.setCommunityId(comActSocialOrg.getCommunityId()); |
| | | administratorsUserVO.setName(comActSocialOrgVO.getContactName()); |
| | | administratorsUserVO.setPhone(comActSocialOrgVO.getContactPhone()); |
| | | R r=userService.addUserBackstageProperty(administratorsUserVO); |
| | | if(R.isOk(r)){ |
| | | comActSocialOrg.setUserId(Long.parseLong(r.getData().toString())); |
| | | comActSocialOrg.setCreateAt(DateUtil.date()); |
| | | this.comActSocialOrgDao.insert(comActSocialOrg); |
| | | return R.ok(); |
| | | } |
| | | return R.fail(r.getMsg()); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R update(ComActSocialOrgVO comActSocialOrgVO) { |
| | | if(comActSocialOrgVO!=null){ |
| | | ComActSocialOrg comActSocialOrg=new ComActSocialOrg(); |
| | | BeanUtils.copyProperties(comActSocialOrgVO,comActSocialOrg); |
| | | this.comActSocialOrgDao.updateById(comActSocialOrg); |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R delete(Long id) { |
| | | ComActSocialOrg comActSocialOrg=comActSocialOrgDao.selectById(id); |
| | | if(comActSocialOrg!=null){ |
| | | if(comActSocialOrg.getUserId()!=null){ |
| | | AdministratorsUserVO administratorsUserVO=new AdministratorsUserVO(); |
| | | administratorsUserVO.setUserId(comActSocialOrg.getUserId()); |
| | | administratorsUserVO.setCommunityId(comActSocialOrg.getCommunityId()); |
| | | userService.deleteUserBackstage(administratorsUserVO); |
| | | this.comActSocialOrgDao.deleteById(id); |
| | | return R.ok(); |
| | | } |
| | | } |
| | | return R.fail("用户账号错误"); |
| | | } |
| | | } |