main
parent
e0c749db5a
commit
74d9e958d6
|
|
@ -120,4 +120,11 @@ public class AppUserController extends BaseController
|
|||
{
|
||||
return toAjax(appUserService.deleteAppUserByIds(ids));
|
||||
}
|
||||
|
||||
@PostMapping("/userNetData")
|
||||
@ApiOperation(value = "好友圈", notes = "好友圈", httpMethod = "POST")
|
||||
public AjaxResult userNetData(@RequestBody AppUser appUser)
|
||||
{
|
||||
return AjaxResult.success(appUserService.userNetData(appUser));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,6 +153,14 @@ public class AppUser extends BaseEntity
|
|||
|
||||
private Integer isMember;
|
||||
|
||||
private Integer limit;
|
||||
|
||||
private List<Long> ids;
|
||||
|
||||
private List<Long> friendIds;
|
||||
|
||||
private Long appId;
|
||||
|
||||
/** 订单记录 */
|
||||
@Excel(name = "订单记录")
|
||||
private Long orderId;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.ruoyi.app.domain.vo;
|
||||
|
||||
import com.ruoyi.app.domain.AppUser;
|
||||
import com.ruoyi.app.domain.UserSkill;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* app用户对象 app_user
|
||||
*
|
||||
* @author wyh
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
public class AppUserDataVo
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String username;
|
||||
|
||||
private String avatarUrl;
|
||||
|
||||
@Excel(name = "学历")
|
||||
private String education;
|
||||
|
||||
@Excel(name = "学校")
|
||||
private String schoolName;
|
||||
|
||||
@Excel(name = "专业")
|
||||
private String major;
|
||||
|
||||
@Excel(name = "公司名称")
|
||||
private String companyName;
|
||||
|
||||
@Excel(name = "行业")
|
||||
private String industry;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.ruoyi.app.domain.vo;
|
||||
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* App用户动态对象 app_user_dynamic
|
||||
*
|
||||
* @author wyh
|
||||
* @date 2024-04-23
|
||||
*/
|
||||
@Data
|
||||
public class AppUserNetVo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
List<AppUserDataVo> schoolUserList = new ArrayList<>();
|
||||
|
||||
List<AppUserDataVo> companyUserList = new ArrayList<>();
|
||||
|
||||
List<AppUserDataVo> friendUserList = new ArrayList<>();
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.app.mapper;
|
|||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppUserFriend;
|
||||
import com.ruoyi.app.domain.vo.AppUserFriendVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 用户好友Mapper接口
|
||||
|
|
@ -27,6 +28,7 @@ public interface AppUserFriendMapper
|
|||
* @return 用户好友集合
|
||||
*/
|
||||
public List<AppUserFriend> selectAppUserFriendList(AppUserFriend appUserFriend);
|
||||
public List<Long> selectByFriendId(@Param("ids")List<Long> ids);
|
||||
public List<AppUserFriendVo> selectFriendList(AppUserFriend appUserFriend);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ruoyi.app.mapper;
|
|||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppUser;
|
||||
import com.ruoyi.app.domain.vo.AppUserDataVo;
|
||||
import com.ruoyi.app.domain.vo.AppUserNetVo;
|
||||
import com.ruoyi.app.domain.vo.AppUserVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -62,4 +64,5 @@ public interface AppUserMapper
|
|||
public int deleteAppUserByIds(Long[] ids);
|
||||
|
||||
AppUser selectAppUserByPhone(@Param("phoneNumber") String phoneNumber);
|
||||
List<AppUserDataVo> selectList(AppUser appUser);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.app.service;
|
|||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppUser;
|
||||
import com.ruoyi.app.domain.vo.AppUserNetVo;
|
||||
import com.ruoyi.app.domain.vo.AppUserVo;
|
||||
|
||||
/**
|
||||
|
|
@ -61,4 +62,6 @@ public interface IAppUserService
|
|||
public int deleteAppUserById(Long id);
|
||||
|
||||
AppUser selectAppUserByPhone(String phoneNumber);
|
||||
|
||||
public AppUserNetVo userNetData(AppUser appUser);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,16 @@ package com.ruoyi.app.service.impl;
|
|||
|
||||
import java.security.Security;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ruoyi.app.domain.AppUserFriend;
|
||||
import com.ruoyi.app.domain.UserSkill;
|
||||
import com.ruoyi.app.domain.vo.AppUserDataVo;
|
||||
import com.ruoyi.app.domain.vo.AppUserNetVo;
|
||||
import com.ruoyi.app.domain.vo.AppUserVo;
|
||||
import com.ruoyi.app.mapper.AppUserFriendMapper;
|
||||
import com.ruoyi.app.mapper.UserSkillMapper;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
|
|
@ -31,6 +37,9 @@ public class AppUserServiceImpl implements IAppUserService
|
|||
@Autowired
|
||||
private UserSkillMapper userSkillMapper;
|
||||
|
||||
@Autowired
|
||||
private AppUserFriendMapper appUserFriendMapper;
|
||||
|
||||
/**
|
||||
* 查询app用户
|
||||
*
|
||||
|
|
@ -127,4 +136,59 @@ public class AppUserServiceImpl implements IAppUserService
|
|||
public AppUser selectAppUserByPhone(String phoneNumber) {
|
||||
return appUserMapper.selectAppUserByPhone(phoneNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppUserNetVo userNetData(AppUser appUser) {
|
||||
Integer limit = appUser.getLimit() == null ? 10 : appUser.getLimit();
|
||||
AppUserNetVo appUserNetVo = new AppUserNetVo();
|
||||
if (appUser.getAppId() == null) {
|
||||
return appUserNetVo;
|
||||
}
|
||||
// 查询我的用户列表
|
||||
AppUserFriend appUserFriend = new AppUserFriend();
|
||||
appUserFriend.setUserId(appUser.getAppId());
|
||||
List<AppUserFriend> appUserFriends = appUserFriendMapper.selectAppUserFriendList(appUserFriend);
|
||||
List<Long> ids = appUserFriends.stream().map(x->x.getFriendId()).collect(Collectors.toList());
|
||||
|
||||
AppUser entity = new AppUser();
|
||||
entity.setIds(ids);
|
||||
entity.setIsMember(appUser.getIsMember());
|
||||
entity.setAppId(appUser.getAppId());
|
||||
entity.setSchool(appUser.getSchool());
|
||||
// 学校
|
||||
List<AppUserDataVo> schoolList = appUserMapper.selectList(entity);
|
||||
Collections.shuffle(schoolList);
|
||||
if (schoolList.size() > limit) {
|
||||
schoolList = schoolList.subList(0, limit);
|
||||
}
|
||||
|
||||
entity.setSchool(null);
|
||||
entity.setCompanyName(appUser.getCompanyName());
|
||||
// 公司
|
||||
List<AppUserDataVo> companylList = appUserMapper.selectList(entity);
|
||||
Collections.shuffle(companylList);
|
||||
if (companylList.size() > limit) {
|
||||
companylList = companylList.subList(0, limit);
|
||||
}
|
||||
|
||||
// 好友的好友
|
||||
List<Long> friendIds = appUserFriendMapper.selectByFriendId(ids);
|
||||
entity.setCompanyName(null);
|
||||
entity.setFriendIds(friendIds);
|
||||
List<AppUserDataVo> friendList = appUserMapper.selectList(entity);
|
||||
if (friendList == null || friendList.size() == 0) {
|
||||
entity.setFriendIds(null);
|
||||
friendList = appUserMapper.selectList(entity);
|
||||
}
|
||||
Collections.shuffle(friendList);
|
||||
if (friendList.size() > limit) {
|
||||
friendList = friendList.subList(0, limit);
|
||||
}
|
||||
appUserNetVo.setFriendUserList(friendList);
|
||||
appUserNetVo.setSchoolUserList(schoolList);
|
||||
appUserNetVo.setCompanyUserList(companylList);
|
||||
|
||||
// unfollowedUsers.sort(Comparator.comparingInt(User::getFollowersCount).reversed());
|
||||
return appUserNetVo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectByFriendId" parameterType="java.lang.Long" resultType="java.lang.Long">
|
||||
select DISTINCT(user_id) from app_user_friend
|
||||
<where>
|
||||
<if test="ids != null and ids.length > 0">
|
||||
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectFriendList" parameterType="AppUserFriend" resultType="com.ruoyi.app.domain.vo.AppUserFriendVo">
|
||||
select a.id as "id",a.user_id as "userId",a.friend_id as "friendId",a.status as "status",a.create_time as "createTime",
|
||||
u.username as "username",
|
||||
|
|
|
|||
|
|
@ -135,6 +135,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join app_school s on s.id = a.school
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectList" parameterType="AppUser" resultType="com.ruoyi.app.domain.vo.AppUserDataVo">
|
||||
select
|
||||
<include refid="appUserColumns"/>,
|
||||
s.name as "schoolName"
|
||||
from app_user a
|
||||
left join app_school s on s.id = a.school
|
||||
where a.id = #{id}
|
||||
<if test="isMember != null "> and is_member = #{isMember}</if>
|
||||
<if test="appId != null "> and id != #{appId}</if>
|
||||
<if test="school != null and school != ''"> and school = #{school}</if>
|
||||
<if test="companyName != null and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
|
||||
<if test="ids != null and ids.length > 0"> and a.id not in
|
||||
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="friendIds != null and friendIds.length > 0"> and a.id in
|
||||
<foreach collection="friendIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<insert id="insertAppUser" parameterType="AppUser" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into app_user
|
||||
|
|
|
|||
Loading…
Reference in New Issue