| | |
| | | import com.tourguide.modules.user.dto.GuideAutoDisableConfigRequest; |
| | | import com.tourguide.modules.user.dto.GuideAutoDisableConfigResponse; |
| | | import com.tourguide.modules.user.dto.GuideProfileUpdateRequest; |
| | | import com.tourguide.modules.user.dto.GuideScenicConfigRequest; |
| | | import com.tourguide.modules.user.dto.GuideScenicConfigResponse; |
| | | import com.tourguide.modules.user.dto.GuideUserCreateRequest; |
| | | import com.tourguide.modules.user.dto.GuideUserDetailResponse; |
| | | import com.tourguide.modules.user.dto.GuideUserDetailUpdateRequest; |
| | |
| | | import com.tourguide.modules.user.mapper.GuideScenicConfigMapper; |
| | | import com.tourguide.modules.user.mapper.GuideTeamMapper; |
| | | import com.tourguide.modules.user.mapper.GuideUserMapper; |
| | | import com.tourguide.modules.operation.entity.OperationCity; |
| | | import com.tourguide.modules.operation.entity.OperationScenicSpot; |
| | | import com.tourguide.modules.operation.mapper.OperationCityMapper; |
| | | import com.tourguide.modules.operation.mapper.OperationScenicSpotMapper; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private final GuideTeamMapper teamMapper; |
| | | private final GuideScenicConfigMapper scenicConfigMapper; |
| | | private final GuideAutoDisableConfigMapper autoDisableConfigMapper; |
| | | private final OperationScenicSpotMapper scenicSpotMapper; |
| | | private final OperationCityMapper cityMapper; |
| | | private final PasswordEncoder passwordEncoder; |
| | | |
| | | public GuideUserService(GuideUserMapper userMapper, GuideTeamMapper teamMapper, |
| | | GuideScenicConfigMapper scenicConfigMapper, |
| | | GuideAutoDisableConfigMapper autoDisableConfigMapper, |
| | | OperationScenicSpotMapper scenicSpotMapper, |
| | | OperationCityMapper cityMapper, |
| | | PasswordEncoder passwordEncoder) { |
| | | this.userMapper = userMapper; |
| | | this.teamMapper = teamMapper; |
| | | this.scenicConfigMapper = scenicConfigMapper; |
| | | this.autoDisableConfigMapper = autoDisableConfigMapper; |
| | | this.scenicSpotMapper = scenicSpotMapper; |
| | | this.cityMapper = cityMapper; |
| | | this.passwordEncoder = passwordEncoder; |
| | | } |
| | | |
| | |
| | | |
| | | public GuideUser findWorkbenchAccessibleById(Long id) { |
| | | GuideUser user = findById(id); |
| | | if (user.getStatus() == null || user.getStatus() == STATUS_PENDING || user.getStatus() == STATUS_CANCELLED) { |
| | | if (user.getStatus() == null || user.getStatus() == STATUS_CANCELLED) { |
| | | throw new BusinessException(401, "导游用户不存在或已注销"); |
| | | } |
| | | return user; |
| | |
| | | List<GuideScenicConfig> scenicConfigs = scenicConfigMapper.selectList( |
| | | new LambdaQueryWrapper<GuideScenicConfig>().eq(GuideScenicConfig::getGuideId, id).orderByAsc(GuideScenicConfig::getId)); |
| | | return new GuideUserDetailResponse(user, team == null ? null : team.getTeamName(), scenicConfigs); |
| | | } |
| | | |
| | | @Transactional |
| | | public List<GuideScenicConfigResponse> addScenicConfig(Long guideId, Long scenicSpotId) { |
| | | findById(guideId); |
| | | OperationScenicSpot scenicSpot = scenicSpotMapper.selectById(scenicSpotId); |
| | | if (scenicSpot == null || scenicSpot.getStatus() == null || scenicSpot.getStatus() != 1) { |
| | | throw new BusinessException(404, "景区不存在或未启用"); |
| | | } |
| | | OperationCity city = scenicSpot.getCityId() == null ? null : cityMapper.selectById(scenicSpot.getCityId()); |
| | | GuideScenicConfig config = new GuideScenicConfig(); |
| | | config.setGuideId(guideId); |
| | | config.setScenicName(scenicSpot.getScenicName()); |
| | | config.setCityName(city == null ? null : city.getCityName()); |
| | | scenicConfigMapper.upsert(config); |
| | | return scenicConfigs(guideId); |
| | | } |
| | | |
| | | @Transactional |
| | | public List<GuideScenicConfigResponse> deleteScenicConfig(Long guideId, Long configId) { |
| | | findById(guideId); |
| | | GuideScenicConfig config = scenicConfigMapper.selectById(configId); |
| | | if (config == null || !guideId.equals(config.getGuideId())) { |
| | | throw new BusinessException(404, "导游景区配置不存在"); |
| | | } |
| | | scenicConfigMapper.deleteById(configId); |
| | | return scenicConfigs(guideId); |
| | | } |
| | | |
| | | private List<GuideScenicConfigResponse> scenicConfigs(Long guideId) { |
| | | return scenicConfigMapper.selectList(new LambdaQueryWrapper<GuideScenicConfig>() |
| | | .eq(GuideScenicConfig::getGuideId, guideId) |
| | | .orderByAsc(GuideScenicConfig::getId)) |
| | | .stream().map(GuideScenicConfigResponse::new).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public GuideUser findById(Long id) { |
| | |
| | | user.setIdCardBackUrl(application.getIdCardBackUrl()); |
| | | user.setGuideCertificateUrl(application.getCertificateUrl()); |
| | | user.setQualificationCertificateUrl(application.getQualificationCertificateUrl()); |
| | | user.setTeamId(application.getTeamId()); |
| | | } |
| | | |
| | | @Transactional |
| | |
| | | user.setWechatOpenId(request.getWechatOpenId()); |
| | | userMapper.updateById(user); |
| | | |
| | | scenicConfigMapper.markDeletedByGuideId(id); |
| | | if (request.getScenicConfigs() != null) { |
| | | for (GuideScenicConfigRequest scenicRequest : request.getScenicConfigs()) { |
| | | GuideScenicConfig config = new GuideScenicConfig(); |
| | | config.setGuideId(id); |
| | | config.setScenicName(scenicRequest.getScenicName()); |
| | | config.setCityName(scenicRequest.getCityName()); |
| | | scenicConfigMapper.upsert(config); |
| | | } |
| | | } |
| | | return detail(id); |
| | | } |
| | | |