发起审核的时候新增关联关系
parent
728aa92f0c
commit
40307148ac
|
|
@ -4,11 +4,13 @@ import com.fjrcloud.community.framework.common.pojo.CommonResult;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySimpleRespVO;
|
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySimpleRespVO;
|
||||||
import com.fjrcloud.community.module.community.service.community.CommunityService;
|
import com.fjrcloud.community.module.community.service.community.CommunityService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -28,8 +30,10 @@ public class AppCommunityController {
|
||||||
|
|
||||||
@GetMapping("/simple-list")
|
@GetMapping("/simple-list")
|
||||||
@Operation(summary = "获取小区精简列表")
|
@Operation(summary = "获取小区精简列表")
|
||||||
public CommonResult<List<CommunitySimpleRespVO>> getCommunitySimpleList() {
|
@Parameter(name = "all", description = "是否获取全部小区(忽略租户隔离),默认false", example = "false")
|
||||||
List<CommunitySimpleRespVO> list = communityService.getAppCommunitySimpleList();
|
public CommonResult<List<CommunitySimpleRespVO>> getCommunitySimpleList(
|
||||||
|
@RequestParam(value = "all", required = false, defaultValue = "false") Boolean all) {
|
||||||
|
List<CommunitySimpleRespVO> list = communityService.getAppCommunitySimpleList(all);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,9 @@ public interface CommunityService {
|
||||||
/**
|
/**
|
||||||
* 获取小区精简列表(App端)
|
* 获取小区精简列表(App端)
|
||||||
*
|
*
|
||||||
|
* @param all 是否获取全部小区(忽略租户隔离)
|
||||||
* @return 小区精简列表
|
* @return 小区精简列表
|
||||||
*/
|
*/
|
||||||
List<CommunitySimpleRespVO> getAppCommunitySimpleList();
|
List<CommunitySimpleRespVO> getAppCommunitySimpleList(Boolean all);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -379,9 +379,17 @@ public class CommunityServiceImpl implements CommunityService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CommunitySimpleRespVO> getAppCommunitySimpleList() {
|
public List<CommunitySimpleRespVO> getAppCommunitySimpleList(Boolean all) {
|
||||||
// App端查询当前租户下的小区列表
|
List<CommunityDO> communities;
|
||||||
List<CommunityDO> communities = communityMapper.selectList();
|
|
||||||
|
if (Boolean.TRUE.equals(all)) {
|
||||||
|
// 获取全部小区,忽略租户隔离
|
||||||
|
communities = TenantUtils.executeIgnore(() -> communityMapper.selectList());
|
||||||
|
} else {
|
||||||
|
// 只获取当前租户下的小区
|
||||||
|
communities = communityMapper.selectList();
|
||||||
|
}
|
||||||
|
|
||||||
return communities.stream()
|
return communities.stream()
|
||||||
.map(community -> CommunitySimpleRespVO.builder()
|
.map(community -> CommunitySimpleRespVO.builder()
|
||||||
.id(community.getId())
|
.id(community.getId())
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import com.fjrcloud.community.module.community.dal.mysql.memberhouse.MemberHouse
|
||||||
import com.fjrcloud.community.module.community.service.community.CommunityService;
|
import com.fjrcloud.community.module.community.service.community.CommunityService;
|
||||||
import com.fjrcloud.community.module.member.dal.dataobject.user.MemberUserDO;
|
import com.fjrcloud.community.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
import com.fjrcloud.community.module.member.service.user.MemberUserService;
|
import com.fjrcloud.community.module.member.service.user.MemberUserService;
|
||||||
|
import com.fjrcloud.community.module.member.service.user.MemberUserTenantRelService;
|
||||||
import com.fjrcloud.community.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
|
import com.fjrcloud.community.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
|
||||||
import com.fjrcloud.community.module.system.service.oauth2.OAuth2TokenService;
|
import com.fjrcloud.community.module.system.service.oauth2.OAuth2TokenService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -60,6 +61,9 @@ public class MemberHouseServiceImpl implements MemberHouseService {
|
||||||
@Resource
|
@Resource
|
||||||
private OAuth2TokenService oauth2TokenService;
|
private OAuth2TokenService oauth2TokenService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserTenantRelService memberUserTenantRelService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createMemberHouse(MemberHouseSaveReqVO createReqVO) {
|
public Long createMemberHouse(MemberHouseSaveReqVO createReqVO) {
|
||||||
|
|
@ -96,6 +100,13 @@ public class MemberHouseServiceImpl implements MemberHouseService {
|
||||||
memberHouse.setTenantId(createReqVO.getCommunityId());
|
memberHouse.setTenantId(createReqVO.getCommunityId());
|
||||||
memberHouseMapper.insert(memberHouse);
|
memberHouseMapper.insert(memberHouse);
|
||||||
|
|
||||||
|
// 5. 将用户关联到该小区(租户),如果是第一个小区则设为默认
|
||||||
|
List<MemberHouseDO> userHouses = memberHouseMapper.selectListByMemberId(memberHouse.getMemberId());
|
||||||
|
boolean isFirstHouse = userHouses.size() == 1;
|
||||||
|
memberUserTenantRelService.assignUserToTenant(memberHouse.getMemberId(), createReqVO.getCommunityId(), isFirstHouse);
|
||||||
|
log.info("[createMemberHouseForApp][用户({}) 发起房屋审核,自动关联租户({}),是否默认({})]",
|
||||||
|
memberHouse.getMemberId(), createReqVO.getCommunityId(), isFirstHouse);
|
||||||
|
|
||||||
return memberHouse.getId();
|
return memberHouse.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -308,6 +319,13 @@ public class MemberHouseServiceImpl implements MemberHouseService {
|
||||||
memberHouse.setTenantId(createReqVO.getCommunityId());
|
memberHouse.setTenantId(createReqVO.getCommunityId());
|
||||||
memberHouseMapper.insert(memberHouse);
|
memberHouseMapper.insert(memberHouse);
|
||||||
|
|
||||||
|
// 4. 将用户关联到该小区(租户),如果是第一个小区则设为默认
|
||||||
|
List<MemberHouseDO> userHouses = memberHouseMapper.selectListByMemberId(memberId);
|
||||||
|
boolean isFirstHouse = userHouses.size() == 1;
|
||||||
|
memberUserTenantRelService.assignUserToTenant(memberId, createReqVO.getCommunityId(), isFirstHouse);
|
||||||
|
log.info("[createMemberHouseForApp][用户({}) 发起房屋审核,自动关联租户({}),是否默认({})]",
|
||||||
|
memberId, createReqVO.getCommunityId(), isFirstHouse);
|
||||||
|
|
||||||
return memberHouse.getId();
|
return memberHouse.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,7 +423,7 @@ public class MemberHouseServiceImpl implements MemberHouseService {
|
||||||
|
|
||||||
// 8. 如果小区变了,需要重新登录(生成新token)
|
// 8. 如果小区变了,需要重新登录(生成新token)
|
||||||
if (communityChanged) {
|
if (communityChanged) {
|
||||||
log.info("会员[{}]切换小区:从[{}]切换到[{}],房屋地址:{}",
|
log.info("会员[{}]切换小区:从[{}]切换到[{}],房屋地址:{}",
|
||||||
memberId, currentTenantId, communityId, houseAddress);
|
memberId, currentTenantId, communityId, houseAddress);
|
||||||
|
|
||||||
// 在新小区租户上下文中生成新的token
|
// 在新小区租户上下文中生成新的token
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue