feat:查询算法
This commit is contained in:
1 parent
9055bb29cf
commit
4875b28e45
18 files changed
+385
-74
No files matched your search
+6
@@ -23,6 +23,12 @@ public enum MemberRecentSceneEnum {
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static List<MemberRecentSceneEnum> dynamicList = Arrays.asList(DYNAMIC_RECOMMEND, DYNAMIC_NEARBY);
|
||||
|
||||
public static List<MemberRecentSceneEnum> squareList = Arrays.asList(SQUARE_SQUARE, SQUARE_NEW_TIME, SQUARE_NEW_PERSON);
|
||||
|
||||
public static List<MemberRecentSceneEnum> distanceSceneList = Arrays.asList(DYNAMIC_NEARBY, SQUARE_NEW_TIME);
|
||||
|
||||
public static boolean contains(MemberRecentOperateEnum operateEnum) {
|
||||
return Arrays.asList(values()).stream().anyMatch(v -> ObjectUtil.equals(v.type, operateEnum.getType()));
|
||||
}
|
||||
|
||||
+22
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@@ -32,6 +33,9 @@ public class RecentPageReqVO extends PageParam {
|
||||
@Schema(description = "视频")
|
||||
private String coverVideo;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "描述")
|
||||
private String describe;
|
||||
|
||||
@@ -57,4 +61,22 @@ public class RecentPageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "场景")
|
||||
private String sceneBizType;
|
||||
|
||||
/**
|
||||
* 用户tag相关
|
||||
*/
|
||||
@Schema(description = "用户tagList")
|
||||
private List<String> memberRecentTagList;
|
||||
|
||||
/**
|
||||
* 位置相关
|
||||
*/
|
||||
@Schema(description = "当前纬度")
|
||||
private Double currentLat;
|
||||
|
||||
@Schema(description = "当前经度")
|
||||
private Double currentLng;
|
||||
|
||||
}
|
||||
+7
-3
@@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.recent.RecentDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -15,15 +16,15 @@ public class RecentPageResVo extends RecentDO {
|
||||
@Schema(description = "用户相关")
|
||||
private MemberVo member;
|
||||
|
||||
@Schema(description = "距离相关")
|
||||
private LocationVo location;
|
||||
|
||||
@Schema(description = "操作统计相关")
|
||||
private OperationTotal operationTotal;
|
||||
|
||||
@Schema(description = "用户tag")
|
||||
private List<MemberTag> memberTagList;
|
||||
|
||||
@Schema(description = "距离(km)")
|
||||
private Double distance;
|
||||
|
||||
@Data
|
||||
public static class MemberVo {
|
||||
|
||||
@@ -53,6 +54,9 @@ public class RecentPageResVo extends RecentDO {
|
||||
|
||||
@Schema(description = "城市")
|
||||
private String memberCity;
|
||||
|
||||
@Schema(description = "最近登录时间")
|
||||
private LocalDateTime appRefreshDate;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
+3
@@ -46,6 +46,9 @@ public class MemberUserBaseVO {
|
||||
@Schema(description = "所在地全程", example = "上海上海市普陀区")
|
||||
private String areaName;
|
||||
|
||||
@Schema(description = "app最近刷新时间")
|
||||
private LocalDateTime appRefreshDate;
|
||||
|
||||
@Schema(description = "出生日期", example = "2023-03-12")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDateTime birthday;
|
||||
|
||||
+10
-1
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.controller.admin.recent.vo.OperationTotalG
|
||||
import cn.iocoder.yudao.module.member.controller.admin.recent.vo.RecentPageResVo;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.recent.vo.RecentSaveReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.recent.vo.*;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberRecentSceneEnum;
|
||||
import cn.iocoder.yudao.module.member.service.recent.RecentService;
|
||||
import cn.iocoder.yudao.module.member.service.recent.ViewRecordService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -36,7 +37,15 @@ public class AppRecentController {
|
||||
@Operation(summary = "快速查询朋友圈")
|
||||
public CommonResult<PageResult<RecentPageResVo>> quickPage(@Valid @RequestBody AppRecentQuickPageVO dto) {
|
||||
dto.setOperationMemberId(getLoginUserId());
|
||||
return success(recentService.quickPage(dto));
|
||||
// 动态
|
||||
if (MemberRecentSceneEnum.dynamicList.contains(dto.getScene())) {
|
||||
return success(recentService.quickPage(dto));
|
||||
}
|
||||
// 广场
|
||||
if (MemberRecentSceneEnum.squareList.contains(dto.getScene())) {
|
||||
return success(recentService.quickUserPage(dto));
|
||||
}
|
||||
return success(new PageResult());
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
|
||||
+35
@@ -83,6 +83,11 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
*/
|
||||
private LocalDateTime loginDate;
|
||||
|
||||
/**
|
||||
* app最近刷新时间
|
||||
*/
|
||||
private LocalDateTime appRefreshDate;
|
||||
|
||||
// ========== 基础信息 ==========
|
||||
|
||||
/**
|
||||
@@ -187,6 +192,36 @@ public class MemberUserDO extends TenantBaseDO {
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private Double lng;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
|
||||
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
private String district;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
private String address;
|
||||
|
||||
public String getAge() {
|
||||
if (ObjectUtil.isEmpty(birthday)) return "未知";
|
||||
|
||||
+2
-2
@@ -8,11 +8,10 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.location.LocationDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.location.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 用户位置记录 Mapper
|
||||
*
|
||||
* @author 聊天交友
|
||||
*/
|
||||
@Mapper
|
||||
public interface LocationMapper extends BaseMapperX<LocationDO> {
|
||||
@@ -30,4 +29,5 @@ public interface LocationMapper extends BaseMapperX<LocationDO> {
|
||||
.orderByDesc(LocationDO::getId));
|
||||
}
|
||||
|
||||
List<LocationDO> getLastLocationList(@Param("memberIds") List<Long> memberIds);
|
||||
}
|
||||
+5
-23
@@ -1,14 +1,12 @@
|
||||
package cn.iocoder.yudao.module.member.dal.mysql.recent;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.recent.RecentDO;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.recent.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 朋友圈 Mapper
|
||||
@@ -16,23 +14,7 @@ import cn.iocoder.yudao.module.member.controller.admin.recent.vo.*;
|
||||
@Mapper
|
||||
public interface RecentMapper extends BaseMapperX<RecentDO> {
|
||||
|
||||
default PageResult<RecentDO> selectPage(RecentPageReqVO reqVO) {
|
||||
MPJLambdaWrapper<RecentDO> queryWrapper = new MPJLambdaWrapperX<RecentDO>()
|
||||
.selectAll(RecentDO.class)
|
||||
.leftJoin(MemberUserDO.class, MemberUserDO::getId, RecentDO::getMemberId)
|
||||
.likeIfExists(MemberUserDO::getNickname, reqVO.getMemberNickname())
|
||||
.eqIfExists(RecentDO::getMemberId, reqVO.getMemberId())
|
||||
.eqIfExists(RecentDO::getDescription, reqVO.getDescribe())
|
||||
.eqIfExists(MemberUserDO::getSex, reqVO.getMemberSex())
|
||||
.likeIfExists(RecentDO::getIssueProvince, reqVO.getIssueProvince())
|
||||
.likeIfExists(RecentDO::getIssueCity, reqVO.getIssueCity())
|
||||
.likeIfExists(RecentDO::getIssueDistrict, reqVO.getIssueDistrict())
|
||||
.likeIfExists(RecentDO::getIssueAddress, reqVO.getIssueAddress());
|
||||
if (ObjectUtil.isNotEmpty(reqVO.getCreateTime())) {
|
||||
queryWrapper.between(RecentDO::getCreateTime, reqVO.getCreateTime()[0], reqVO.getCreateTime()[1]);
|
||||
}
|
||||
queryWrapper.orderByDesc(RecentDO::getId);
|
||||
return selectJoinPage(reqVO, RecentDO.class, queryWrapper);
|
||||
}
|
||||
IPage<RecentPageResVo> pageJoin(IPage<Page> page, @Param("dto") RecentPageReqVO dto);
|
||||
|
||||
IPage<RecentPageResVo> pageUserJoin(IPage<Page> page, @Param("dto") RecentPageReqVO dto);
|
||||
}
|
||||
+9
-2
@@ -11,6 +11,7 @@ import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.module.member.client.service.ChatApi;
|
||||
import cn.iocoder.yudao.module.member.client.vo.chat.user.ChatLoginReqVO;
|
||||
import cn.iocoder.yudao.module.member.client.vo.chat.user.ChatLoginRespVo;
|
||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.member.controller.app.auth.vo.*;
|
||||
import cn.iocoder.yudao.module.member.convert.auth.AuthConvert;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
@@ -36,6 +37,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@@ -309,8 +311,13 @@ public class MemberAuthServiceImpl implements MemberAuthService {
|
||||
|
||||
@Override
|
||||
public AppAuthLoginRespVO refreshToken(String refreshToken) {
|
||||
OAuth2AccessTokenRespDTO accessTokenDO = oauth2TokenApi.refreshAccessToken(refreshToken,
|
||||
OAuth2ClientConstants.CLIENT_ID_DEFAULT);
|
||||
OAuth2AccessTokenRespDTO accessTokenDO = oauth2TokenApi.refreshAccessToken(refreshToken, OAuth2ClientConstants.CLIENT_ID_DEFAULT);
|
||||
|
||||
MemberUserUpdateReqVO update = new MemberUserUpdateReqVO();
|
||||
update.setId(accessTokenDO.getUserId());
|
||||
update.setAppRefreshDate(LocalDateTime.now());
|
||||
userService.updateUser(update);
|
||||
|
||||
return AuthConvert.INSTANCE.convert(accessTokenDO, null);
|
||||
}
|
||||
|
||||
|
||||
+20
-7
@@ -5,11 +5,14 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.member.client.service.TxMapApi;
|
||||
import cn.iocoder.yudao.module.member.client.vo.txmap.geocoder.TxMapGeocoderReqVo;
|
||||
import cn.iocoder.yudao.module.member.client.vo.txmap.geocoder.TxMapGeocoderRespVo;
|
||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberErrorCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import cn.iocoder.yudao.module.member.controller.admin.location.vo.*;
|
||||
@@ -33,11 +36,14 @@ public class LocationServiceImpl implements LocationService {
|
||||
|
||||
@Resource
|
||||
private LocationMapper locationMapper;
|
||||
@Resource
|
||||
private MemberUserMapper memberUserMapper;
|
||||
|
||||
@Resource
|
||||
private TxMapApi txMapApi;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createLocation(LocationSaveReqVO dto) {
|
||||
if (!ObjectUtil.isAllNotEmpty(dto.getProvince(), dto.getCity(), dto.getDistrict())) {
|
||||
TxMapGeocoderRespVo geocoder = txMapApi.geocoder(TxMapGeocoderReqVo.builder().location(dto.getLat() + "," + dto.getLon()).build());
|
||||
@@ -55,7 +61,16 @@ public class LocationServiceImpl implements LocationService {
|
||||
// 插入
|
||||
LocationDO location = BeanUtils.toBean(dto, LocationDO.class);
|
||||
locationMapper.insert(location);
|
||||
// 返回
|
||||
// 更新用户位置信息
|
||||
MemberUserDO updateUser = new MemberUserDO();
|
||||
updateUser.setId(dto.getMemberId());
|
||||
updateUser.setLng(dto.getLon());
|
||||
updateUser.setLat(dto.getLat());
|
||||
updateUser.setProvince(dto.getProvince());
|
||||
updateUser.setCity(dto.getCity());
|
||||
updateUser.setDistrict(dto.getDistrict());
|
||||
updateUser.setAddress(dto.getAddress());
|
||||
memberUserMapper.updateById(updateUser);
|
||||
return location.getId();
|
||||
}
|
||||
|
||||
@@ -101,6 +116,9 @@ public class LocationServiceImpl implements LocationService {
|
||||
public LocationDO getCurrentUserLastLocation() {
|
||||
return locationMapper.selectOne(new LambdaQueryWrapperX<LocationDO>()
|
||||
.eq(LocationDO::getMemberId, getLoginUserId())
|
||||
.isNotNull(LocationDO::getProvince)
|
||||
.isNotNull(LocationDO::getCity)
|
||||
.isNotNull(LocationDO::getDistrict)
|
||||
.orderByDesc(LocationDO::getCreateTime)
|
||||
.orderByDesc(LocationDO::getId)
|
||||
.last(" LIMIT 1")
|
||||
@@ -112,12 +130,7 @@ public class LocationServiceImpl implements LocationService {
|
||||
*/
|
||||
@Override
|
||||
public List<LocationDO> getLastLocationList(List<Long> memberIds) {
|
||||
return locationMapper.selectList(new LambdaQueryWrapperX<LocationDO>()
|
||||
.eq(LocationDO::getMemberId, getLoginUserId())
|
||||
.orderByDesc(LocationDO::getCreateTime)
|
||||
.orderByDesc(LocationDO::getId)
|
||||
.groupBy(LocationDO::getMemberId)
|
||||
);
|
||||
return locationMapper.getLastLocationList(memberIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
@@ -60,6 +60,11 @@ public interface RecentService {
|
||||
*/
|
||||
PageResult<RecentPageResVo> quickPage(AppRecentQuickPageVO bean);
|
||||
|
||||
/**
|
||||
* 快速查询用户
|
||||
*/
|
||||
PageResult<RecentPageResVo> quickUserPage(@Valid AppRecentQuickPageVO dto);
|
||||
|
||||
/**
|
||||
* 我喜欢-分页查询
|
||||
*/
|
||||
|
||||
+66
-32
@@ -19,10 +19,13 @@ import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberErrorCode;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberRecentOperateEnum;
|
||||
import cn.iocoder.yudao.module.member.enums.MemberRecentSceneEnum;
|
||||
import cn.iocoder.yudao.module.member.enums.tag.MemberRecentTagEnum;
|
||||
import cn.iocoder.yudao.module.member.service.location.LocationService;
|
||||
import cn.iocoder.yudao.module.member.service.thirdauth.ThirdAuthService;
|
||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -231,8 +234,8 @@ public class RecentServiceImpl implements RecentService {
|
||||
*/
|
||||
@Override
|
||||
public PageResult<RecentPageResVo> getRecentPage(RecentPageReqVO pageReqVO) {
|
||||
PageResult<RecentDO> recentPageList = recentMapper.selectPage(pageReqVO);
|
||||
List<RecentPageResVo> resultList = BeanUtils.toBean(recentPageList.getList(), RecentPageResVo.class);
|
||||
IPage<RecentPageResVo> recentPageList = recentMapper.pageJoin(new Page(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
|
||||
List<RecentPageResVo> resultList = recentPageList.getRecords();
|
||||
// 为RecentPageResVo设置Member信息
|
||||
convertRecentPageResVoSetupMember(resultList);
|
||||
// 为RecentPageResVo设置OperationTotal信息
|
||||
@@ -250,30 +253,56 @@ public class RecentServiceImpl implements RecentService {
|
||||
// 查询当前用户信息
|
||||
MemberUserDO operationUser = memberUserService.getUser(bean.getOperationMemberId());
|
||||
|
||||
RecentPageReqVO result = BeanUtil.toBean(bean, RecentPageReqVO.class);
|
||||
|
||||
RecentPageReqVO resultQuery = BeanUtil.toBean(bean, RecentPageReqVO.class);
|
||||
resultQuery.setSceneBizType(bean.getScene().getType());
|
||||
// 只查询异性
|
||||
if (ObjectUtil.isNotEmpty(operationUser.getSex())) {
|
||||
SexEnum sexEnum = SexEnum.valueOfSex(operationUser.getSex());
|
||||
SexEnum targetSex = SexEnum.negation(sexEnum.getSex());
|
||||
result.setMemberSex(targetSex.getSex());
|
||||
resultQuery.setMemberSex(targetSex.getSex());
|
||||
}
|
||||
// 查询用户最新的位置
|
||||
LocationDO locationDO = locationService.getCurrentUserLastLocation();
|
||||
resultQuery.setCurrentLat(locationDO.getLat());
|
||||
resultQuery.setCurrentLng(locationDO.getLon());
|
||||
|
||||
PageResult<RecentDO> recentPageList = recentMapper.selectPage(result);
|
||||
List<RecentPageResVo> resultList = BeanUtils.toBean(recentPageList.getList(), RecentPageResVo.class);
|
||||
IPage<RecentPageResVo> recentPageList = recentMapper.pageJoin(new Page(bean.getPageNo(), bean.getPageSize()), resultQuery);
|
||||
List<RecentPageResVo> resultList = BeanUtils.toBean(recentPageList.getRecords(), RecentPageResVo.class);
|
||||
// 为RecentPageResVo设置Member信息
|
||||
convertRecentPageResVoSetupMember(resultList);
|
||||
// 查询距离的scene
|
||||
List<MemberRecentSceneEnum> locationSceneList = new ArrayList<MemberRecentSceneEnum>() {{
|
||||
add(MemberRecentSceneEnum.SQUARE_SQUARE);
|
||||
add(MemberRecentSceneEnum.SQUARE_NEW_TIME);
|
||||
add(MemberRecentSceneEnum.SQUARE_NEW_PERSON);
|
||||
}};
|
||||
if (locationSceneList.contains(bean.getScene())) {
|
||||
// 查询用户最新的位置
|
||||
LocationDO locationDO = locationService.getCurrentUserLastLocation();
|
||||
convertRecentPageResVoSetupLocation(resultList, locationDO);
|
||||
// 查询用户tag
|
||||
convertRecentPageResVoSetupTag(resultList);
|
||||
return new PageResult<>(resultList, recentPageList.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速查询用户
|
||||
*/
|
||||
@Override
|
||||
public PageResult<RecentPageResVo> quickUserPage(AppRecentQuickPageVO bean) {
|
||||
// 查询当前用户信息
|
||||
MemberUserDO operationUser = memberUserService.getUser(bean.getOperationMemberId());
|
||||
|
||||
RecentPageReqVO resultQuery = BeanUtil.toBean(bean, RecentPageReqVO.class);
|
||||
resultQuery.setSceneBizType(bean.getScene().getType());
|
||||
// 只查询异性
|
||||
if (ObjectUtil.isNotEmpty(operationUser.getSex())) {
|
||||
SexEnum sexEnum = SexEnum.valueOfSex(operationUser.getSex());
|
||||
SexEnum targetSex = SexEnum.negation(sexEnum.getSex());
|
||||
resultQuery.setMemberSex(targetSex.getSex());
|
||||
}
|
||||
// 查询用户最新的位置
|
||||
LocationDO locationDO = locationService.getCurrentUserLastLocation();
|
||||
resultQuery.setCurrentLat(locationDO.getLat());
|
||||
resultQuery.setCurrentLng(locationDO.getLon());
|
||||
// 广场-新人
|
||||
if (ObjectUtil.equals(MemberRecentSceneEnum.SQUARE_NEW_PERSON, bean.getScene())) {
|
||||
resultQuery.setMemberRecentTagList(new ArrayList<String>() {{
|
||||
add(MemberRecentTagEnum.NEW_PERSON.getType());
|
||||
}});
|
||||
}
|
||||
IPage<RecentPageResVo> recentPageList = recentMapper.pageUserJoin(new Page(bean.getPageNo(), bean.getPageSize()), resultQuery);
|
||||
List<RecentPageResVo> resultList = BeanUtils.toBean(recentPageList.getRecords(), RecentPageResVo.class);
|
||||
// 如果是新人模糊`头像`和`用户名`
|
||||
if (ObjectUtil.equals(bean.getScene(), MemberRecentSceneEnum.SQUARE_NEW_PERSON)) {
|
||||
for (RecentPageResVo v : resultList) {
|
||||
@@ -283,10 +312,13 @@ public class RecentServiceImpl implements RecentService {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 为RecentPageResVo设置Member信息
|
||||
convertRecentPageResVoSetupMember(resultList);
|
||||
// 查询用户tag
|
||||
convertRecentPageResVoSetupTag(resultList);
|
||||
return new PageResult<>(resultList, recentPageList.getTotal());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 我喜欢-分页查询
|
||||
*/
|
||||
@@ -350,9 +382,9 @@ public class RecentServiceImpl implements RecentService {
|
||||
List<RecentPageResVo> resultList = new ArrayList<>();
|
||||
|
||||
RecentPageReqVO dtoQuery = new RecentPageReqVO();
|
||||
PageResult<RecentDO> pageList = recentMapper.selectPage(dtoQuery);
|
||||
IPage<RecentPageResVo> pageList = recentMapper.pageJoin(new Page(dto.getPageNo(), dto.getPageSize()), dtoQuery);
|
||||
if (ObjectUtil.isEmpty(pageList)) return new PageResult<>();
|
||||
resultList = BeanUtil.copyToList(pageList.getList(), RecentPageResVo.class);
|
||||
resultList = BeanUtil.copyToList(pageList.getRecords(), RecentPageResVo.class);
|
||||
// 添加用户信息
|
||||
convertRecentPageResVoSetupMember(resultList);
|
||||
return new PageResult<RecentPageResVo>(resultList, pageList.getTotal());
|
||||
@@ -421,6 +453,7 @@ public class RecentServiceImpl implements RecentService {
|
||||
memberVO.setMemberHeight(member.getHeight());
|
||||
memberVO.setMemberWeight(member.getWeight());
|
||||
memberVO.setMemberSex(member.getSex());
|
||||
memberVO.setAppRefreshDate(member.getAppRefreshDate());
|
||||
entity.setMember(memberVO);
|
||||
}
|
||||
}
|
||||
@@ -523,20 +556,21 @@ public class RecentServiceImpl implements RecentService {
|
||||
*/
|
||||
private void convertRecentPageResVoSetupLocation(List<RecentPageResVo> list, LocationDO selfLocation) {
|
||||
if (ObjectUtil.isEmpty(list)) return;
|
||||
List<Long> memberIds = list.stream().map(RecentPageResVo::getMemberId).collect(Collectors.toList());
|
||||
List<Long> memberIds = list.stream().map(RecentPageResVo::getMemberId).distinct().filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
||||
List<LocationDO> LocationList = locationService.getLastLocationList(memberIds);
|
||||
Map<Long, LocationDO> LocationMap = IterUtil.toMap(LocationList, LocationDO::getId);
|
||||
Map<Long, LocationDO> LocationMap = IterUtil.toMap(LocationList, LocationDO::getMemberId);
|
||||
if (ObjectUtil.isEmpty(LocationMap)) return;
|
||||
for (RecentPageResVo entity : list) {
|
||||
// 位置相关
|
||||
if (ObjectUtil.isNotEmpty(LocationMap)) {
|
||||
LocationDO targetLocation = LocationMap.get(entity.getMemberId());
|
||||
if (ObjectUtil.isNotEmpty(targetLocation)) {
|
||||
RecentPageResVo.LocationVo locationVo = new RecentPageResVo.LocationVo();
|
||||
double distance = NumberUtils.getDistance(targetLocation.getLat(), targetLocation.getLon(), selfLocation.getLat(), selfLocation.getLon());
|
||||
locationVo.setDistance(distance);
|
||||
entity.setLocation(locationVo);
|
||||
}
|
||||
LocationDO targetLocation = LocationMap.get(entity.getMemberId());
|
||||
|
||||
RecentPageResVo.LocationVo locationVo = new RecentPageResVo.LocationVo();
|
||||
if (ObjectUtil.isEmpty(targetLocation)) {
|
||||
// entity.setLocation(locationVo);
|
||||
continue;
|
||||
}
|
||||
double distance = NumberUtils.getDistance(targetLocation.getLat(), targetLocation.getLon(), selfLocation.getLat(), selfLocation.getLon());
|
||||
locationVo.setDistance(distance);
|
||||
// entity.setLocation(locationVo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +581,7 @@ public class RecentServiceImpl implements RecentService {
|
||||
RecentPageResVo.LocationVo locationVo = new RecentPageResVo.LocationVo();
|
||||
double distance = NumberUtils.getDistance(targetLocation.getLat(), targetLocation.getLon(), selfLocation.getLat(), selfLocation.getLon());
|
||||
locationVo.setDistance(distance);
|
||||
detail.setLocation(locationVo);
|
||||
// detail.setLocation(locationVo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -142,7 +142,10 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
@Override
|
||||
public void updateUserLogin(Long id, String loginIp) {
|
||||
memberUserMapper.updateById(new MemberUserDO().setId(id)
|
||||
.setLoginIp(loginIp).setLoginDate(LocalDateTime.now()));
|
||||
.setLoginIp(loginIp)
|
||||
.setLoginDate(LocalDateTime.now())
|
||||
.setAppRefreshDate(LocalDateTime.now())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="cn.iocoder.yudao.module.member.dal.mysql.location.LocationMapper">
|
||||
|
||||
<select id="getLastLocationList" resultType="cn.iocoder.yudao.module.member.dal.dataobject.location.LocationDO">
|
||||
SELECT ml.id,
|
||||
ml.member_id,
|
||||
ml.lon,
|
||||
ml.lat,
|
||||
ml.province,
|
||||
ml.city,
|
||||
ml.district,
|
||||
ml.address,
|
||||
ml.create_time,
|
||||
ml.update_time,
|
||||
ml.creator,
|
||||
ml.updater,
|
||||
ml.deleted
|
||||
FROM member_location ml
|
||||
WHERE ml.id = (SELECT id
|
||||
FROM member_location ml2
|
||||
WHERE ml2.member_id = ml.member_id
|
||||
AND ml2.deleted = 0
|
||||
AND (ml2.province IS NOT NULL AND ml2.city IS NOT NULL AND ml2.district IS NOT NULL)
|
||||
AND ml2.tenant_id = 1
|
||||
ORDER BY ml2.create_time DESC
|
||||
LIMIT 1
|
||||
)
|
||||
AND ml.deleted = 0
|
||||
AND (ml.province IS NOT NULL
|
||||
AND ml.city IS NOT NULL
|
||||
AND ml.district IS NOT NULL)
|
||||
AND ml.tenant_id = 1
|
||||
<if test="memberIds != null and memberIds.size() != 0">
|
||||
and ml.member_id in
|
||||
<foreach collection="memberIds" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY ml.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+141
@@ -1,7 +1,148 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.member.dal.mysql.recent.RecentMapper">
|
||||
<sql id="selectA">
|
||||
select a.id,
|
||||
a.member_id,
|
||||
a.cover_pic,
|
||||
a.cover_video,
|
||||
a.description,
|
||||
a.issue_long,
|
||||
a.issue_lat,
|
||||
a.issue_province,
|
||||
a.issue_city,
|
||||
a.issue_district,
|
||||
a.issue_address,
|
||||
a.creator,
|
||||
a.create_time,
|
||||
a.updater,
|
||||
a.update_time,
|
||||
a.deleted,
|
||||
a.tenant_id
|
||||
</sql>
|
||||
|
||||
<sql id="whereA">
|
||||
a.deleted = 0
|
||||
<if test="dto.memberId != null">
|
||||
and a.member_id = #{dto.memberId}
|
||||
</if>
|
||||
<if test="dto.description != null">
|
||||
and a.description like concat('%', #{dto.description}, '%')
|
||||
</if>
|
||||
<if test="dto.issueProvince != null">
|
||||
and a.issue_province like concat('%', #{dto.issueProvince}, '%')
|
||||
</if>
|
||||
<if test="dto.issueCity != null">
|
||||
and a.issue_city like concat('%', #{dto.issueCity}, '%')
|
||||
</if>
|
||||
<if test="dto.issueDistrict != null">
|
||||
and a.issue_district like concat('%', #{dto.issueDistrict}, '%')
|
||||
</if>
|
||||
<if test="dto.issueAddress != null">
|
||||
and a.issue_address like concat('%', #{dto.issueAddress}, '%')
|
||||
</if>
|
||||
<if test="dto.createTime != null and dto.createTime.length == 2">
|
||||
and a.createTime between #{dto.createTime[0]} and #{dto.createTime[1]}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="pageJoin" resultType="cn.iocoder.yudao.module.member.controller.admin.recent.vo.RecentPageResVo">
|
||||
<include refid="selectA"/>,
|
||||
<if test="dto.currentLat != null and dto.currentLng != null ">
|
||||
(6371 * acos(
|
||||
cos(radians(#{dto.currentLat})) *
|
||||
cos(radians(a.issue_lat)) *
|
||||
cos(radians(a.issue_long) - radians(#{dto.currentLng})) +
|
||||
sin(radians(#{dto.currentLat})) *
|
||||
sin(radians(a.issue_lat))
|
||||
)) AS distance,
|
||||
</if>
|
||||
1
|
||||
from member_recent a
|
||||
left join member_user u on a.member_id = u.id
|
||||
<where>
|
||||
<include refid="whereA"/>
|
||||
<if test="dto.memberSex != null">
|
||||
and u.sex = #{dto.memberSex}
|
||||
</if>
|
||||
<if test="dto.memberRecentTagList != null and dto.memberRecentTagList.size() != 0">
|
||||
and exists (select 1
|
||||
from member_recent_tag t
|
||||
where t.deleted = 0
|
||||
and t.member_id = a.member_id
|
||||
and t.tag_biz_type in
|
||||
<foreach collection="dto.memberRecentTagList" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
<choose>
|
||||
<when test="dto.sceneBizType != null and dto.sceneBizType != ''">
|
||||
<!-- 动态-推荐 -->
|
||||
<if test="dto.sceneBizType == '1'">
|
||||
order by a.create_time desc , a.id desc
|
||||
</if>
|
||||
<!-- 动态-附近 -->
|
||||
<if test="dto.sceneBizType == '2'">
|
||||
order by a.create_time asc , distance desc
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
order by a.create_time desc , a.id desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="pageUserJoin" resultType="cn.iocoder.yudao.module.member.controller.admin.recent.vo.RecentPageResVo">
|
||||
select u.id as memberId,
|
||||
<if test="dto.currentLat != null and dto.currentLng != null ">
|
||||
(6371 * acos(
|
||||
cos(radians(#{dto.currentLat})) *
|
||||
cos(radians(u.lat)) *
|
||||
cos(radians(u.lng) - radians(#{dto.currentLng})) +
|
||||
sin(radians(#{dto.currentLat})) *
|
||||
sin(radians(u.lat))
|
||||
)) AS distance,
|
||||
</if>
|
||||
1
|
||||
from member_user u
|
||||
<where>
|
||||
u.deleted = 0
|
||||
<if test="dto.memberSex != null">
|
||||
and u.sex = #{dto.memberSex}
|
||||
</if>
|
||||
<if test="dto.memberRecentTagList != null and dto.memberRecentTagList.size() != 0">
|
||||
and exists (select 1
|
||||
from member_recent_tag t
|
||||
where t.deleted = 0
|
||||
and t.member_id = u.member_id
|
||||
and t.tag_biz_type in
|
||||
<foreach collection="dto.memberRecentTagList" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
<choose>
|
||||
<when test="dto.sceneBizType != null and dto.sceneBizType != ''">
|
||||
<!-- 广场-广场 -->
|
||||
<if test="dto.sceneBizType == '3'">
|
||||
order by u.app_refresh_date desc , u.id desc
|
||||
</if>
|
||||
<!-- 广场-最近 -->
|
||||
<if test="dto.sceneBizType == '4'">
|
||||
order by distance asc , u.id desc
|
||||
</if>
|
||||
<!-- 广场-新人 -->
|
||||
<if test="dto.sceneBizType == '5'">
|
||||
order by u.app_refresh_date desc
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
order by u.app_refresh_date desc , u.id desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -228,7 +228,8 @@ pf4j:
|
||||
pluginsDir: ${user.home}/plugins # 插件目录
|
||||
|
||||
chat:
|
||||
base-url: http://127.0.0.1:8888
|
||||
# base-url: http://127.0.0.1:8888
|
||||
base-url: http://chatsever.zianxin.com
|
||||
app-key: 4H2HkBLygMsxaQKO
|
||||
app-secret: JIizm84av3TK5xaQdsng7X5mqLPjbeQ0
|
||||
|
||||
|
||||
@@ -250,7 +250,8 @@ pf4j:
|
||||
pluginsDir: ../plugins
|
||||
|
||||
chat:
|
||||
base-url: http://127.0.0.1:8888
|
||||
# base-url: http://127.0.0.1:8888
|
||||
base-url: http://chatsever.zianxin.com
|
||||
app-key: 4H2HkBLygMsxaQKO
|
||||
app-secret: JIizm84av3TK5xaQdsng7X5mqLPjbeQ0
|
||||
|
||||
|
||||
@@ -240,7 +240,8 @@ justauth:
|
||||
timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟
|
||||
|
||||
chat:
|
||||
base-url: http://127.0.0.1:8888
|
||||
# base-url: http://127.0.0.1:8888
|
||||
base-url: http://chatsever.zianxin.com
|
||||
app-key: 4H2HkBLygMsxaQKO
|
||||
app-secret: JIizm84av3TK5xaQdsng7X5mqLPjbeQ0
|
||||
|
||||
|
||||
Reference in new issue
Block a user