main
parent
9cee33b8f8
commit
8da66d5720
|
|
@ -0,0 +1,114 @@
|
|||
package com.ruoyi.app.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import com.ruoyi.app.domain.AppUserFans;
|
||||
import com.ruoyi.app.service.IAppUserFansService;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 用户关注Controller
|
||||
*
|
||||
* @author wyh
|
||||
* @date 2024-05-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/fans")
|
||||
@Api(tags = "用户关注" , description = "用户关注")
|
||||
public class AppUserFansController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAppUserFansService appUserFansService;
|
||||
|
||||
/**
|
||||
* 查询用户关注列表
|
||||
*/
|
||||
@RequiresPermissions("app:fans:list")
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "查询用户关注", notes = "查询用户关注", httpMethod = "GET")
|
||||
public TableDataInfo list(AppUserFans appUserFans)
|
||||
{
|
||||
startPage();
|
||||
List<AppUserFans> list = appUserFansService.selectAppUserFansList(appUserFans);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户关注列表
|
||||
*/
|
||||
@RequiresPermissions("app:fans:export")
|
||||
@Log(title = "用户关注", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, AppUserFans appUserFans)
|
||||
{
|
||||
List<AppUserFans> list = appUserFansService.selectAppUserFansList(appUserFans);
|
||||
ExcelUtil<AppUserFans> util = new ExcelUtil<AppUserFans>(AppUserFans.class);
|
||||
util.exportExcel(response, list, "用户关注数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户关注详细信息
|
||||
*/
|
||||
@RequiresPermissions("app:fans:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiOperation(value = "获取用户关注详细信息", notes = "获取用户关注详细信息", httpMethod = "GET")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(appUserFansService.selectAppUserFansById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户关注
|
||||
*/
|
||||
@RequiresPermissions("app:fans:add")
|
||||
@ApiOperation(value = "新增用户关注", notes = "新增用户关注", httpMethod = "POST")
|
||||
@Log(title = "用户关注", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody AppUserFans appUserFans)
|
||||
{
|
||||
return toAjax(appUserFansService.insertAppUserFans(appUserFans));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户关注
|
||||
*/
|
||||
@RequiresPermissions("app:fans:edit")
|
||||
@ApiOperation(value = "修改用户关注", notes = "修改用户关注", httpMethod = "PUT")
|
||||
@Log(title = "用户关注", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody AppUserFans appUserFans)
|
||||
{
|
||||
return toAjax(appUserFansService.updateAppUserFans(appUserFans));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户关注
|
||||
*/
|
||||
@RequiresPermissions("app:fans:remove")
|
||||
@Log(title = "用户关注", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(appUserFansService.deleteAppUserFansByIds(ids));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
package com.ruoyi.app.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 用户关注对象 app_user_fans
|
||||
*
|
||||
* @author wyh
|
||||
* @date 2024-05-08
|
||||
*/
|
||||
public class AppUserFans extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
private Long id;
|
||||
|
||||
/** 我的id */
|
||||
@Excel(name = "我的id")
|
||||
private Long userId;
|
||||
|
||||
/** 好友id */
|
||||
@Excel(name = "好友id")
|
||||
private Long friendId;
|
||||
|
||||
/** 状态:0好友1拉黑 */
|
||||
@Excel(name = "状态:0好友1拉黑")
|
||||
private Long status;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setUserId(Long userId)
|
||||
{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getUserId()
|
||||
{
|
||||
return userId;
|
||||
}
|
||||
public void setFriendId(Long friendId)
|
||||
{
|
||||
this.friendId = friendId;
|
||||
}
|
||||
|
||||
public Long getFriendId()
|
||||
{
|
||||
return friendId;
|
||||
}
|
||||
public void setStatus(Long status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("userId", getUserId())
|
||||
.append("friendId", getFriendId())
|
||||
.append("status", getStatus())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -38,4 +38,7 @@ public class AppUserDataVo
|
|||
|
||||
@Excel(name = "行业")
|
||||
private String industry;
|
||||
|
||||
@Excel(name = "粉丝数量")
|
||||
private long fansNum;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
package com.ruoyi.app.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppUserFans;
|
||||
|
||||
/**
|
||||
* 用户关注Mapper接口
|
||||
*
|
||||
* @author wyh
|
||||
* @date 2024-05-08
|
||||
*/
|
||||
public interface AppUserFansMapper
|
||||
{
|
||||
/**
|
||||
* 查询用户关注
|
||||
*
|
||||
* @param id 用户关注主键
|
||||
* @return 用户关注
|
||||
*/
|
||||
public AppUserFans selectAppUserFansById(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户关注列表
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 用户关注集合
|
||||
*/
|
||||
public List<AppUserFans> selectAppUserFansList(AppUserFans appUserFans);
|
||||
|
||||
/**
|
||||
* 新增用户关注
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAppUserFans(AppUserFans appUserFans);
|
||||
|
||||
/**
|
||||
* 修改用户关注
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAppUserFans(AppUserFans appUserFans);
|
||||
|
||||
/**
|
||||
* 删除用户关注
|
||||
*
|
||||
* @param id 用户关注主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAppUserFansById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除用户关注
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAppUserFansByIds(Long[] ids);
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.ruoyi.app.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.app.domain.AppUserFans;
|
||||
|
||||
/**
|
||||
* 用户关注Service接口
|
||||
*
|
||||
* @author wyh
|
||||
* @date 2024-05-08
|
||||
*/
|
||||
public interface IAppUserFansService
|
||||
{
|
||||
/**
|
||||
* 查询用户关注
|
||||
*
|
||||
* @param id 用户关注主键
|
||||
* @return 用户关注
|
||||
*/
|
||||
public AppUserFans selectAppUserFansById(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户关注列表
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 用户关注集合
|
||||
*/
|
||||
public List<AppUserFans> selectAppUserFansList(AppUserFans appUserFans);
|
||||
|
||||
/**
|
||||
* 新增用户关注
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAppUserFans(AppUserFans appUserFans);
|
||||
|
||||
/**
|
||||
* 修改用户关注
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAppUserFans(AppUserFans appUserFans);
|
||||
|
||||
/**
|
||||
* 批量删除用户关注
|
||||
*
|
||||
* @param ids 需要删除的用户关注主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAppUserFansByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除用户关注信息
|
||||
*
|
||||
* @param id 用户关注主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAppUserFansById(Long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package com.ruoyi.app.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.app.mapper.AppUserFansMapper;
|
||||
import com.ruoyi.app.domain.AppUserFans;
|
||||
import com.ruoyi.app.service.IAppUserFansService;
|
||||
|
||||
/**
|
||||
* 用户关注Service业务层处理
|
||||
*
|
||||
* @author wyh
|
||||
* @date 2024-05-08
|
||||
*/
|
||||
@Service
|
||||
public class AppUserFansServiceImpl implements IAppUserFansService
|
||||
{
|
||||
@Autowired
|
||||
private AppUserFansMapper appUserFansMapper;
|
||||
|
||||
/**
|
||||
* 查询用户关注
|
||||
*
|
||||
* @param id 用户关注主键
|
||||
* @return 用户关注
|
||||
*/
|
||||
@Override
|
||||
public AppUserFans selectAppUserFansById(Long id)
|
||||
{
|
||||
return appUserFansMapper.selectAppUserFansById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户关注列表
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 用户关注
|
||||
*/
|
||||
@Override
|
||||
public List<AppUserFans> selectAppUserFansList(AppUserFans appUserFans)
|
||||
{
|
||||
return appUserFansMapper.selectAppUserFansList(appUserFans);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户关注
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAppUserFans(AppUserFans appUserFans)
|
||||
{
|
||||
appUserFans.setCreateTime(DateUtils.getNowDate());
|
||||
return appUserFansMapper.insertAppUserFans(appUserFans);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户关注
|
||||
*
|
||||
* @param appUserFans 用户关注
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAppUserFans(AppUserFans appUserFans)
|
||||
{
|
||||
appUserFans.setUpdateTime(DateUtils.getNowDate());
|
||||
return appUserFansMapper.updateAppUserFans(appUserFans);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除用户关注
|
||||
*
|
||||
* @param ids 需要删除的用户关注主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAppUserFansByIds(Long[] ids)
|
||||
{
|
||||
return appUserFansMapper.deleteAppUserFansByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户关注信息
|
||||
*
|
||||
* @param id 用户关注主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAppUserFansById(Long id)
|
||||
{
|
||||
return appUserFansMapper.deleteAppUserFansById(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.ruoyi.app.service.impl;
|
||||
|
||||
import java.security.Security;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -14,7 +14,6 @@ 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;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -161,6 +160,8 @@ public class AppUserServiceImpl implements IAppUserService
|
|||
if (schoolList.size() > limit) {
|
||||
schoolList = schoolList.subList(0, limit);
|
||||
}
|
||||
schoolList.sort(Comparator.comparingLong(AppUserDataVo::getFansNum).reversed());
|
||||
|
||||
|
||||
entity.setSchool(null);
|
||||
entity.setCompanyName(appUser.getCompanyName());
|
||||
|
|
@ -170,6 +171,7 @@ public class AppUserServiceImpl implements IAppUserService
|
|||
if (companylList.size() > limit) {
|
||||
companylList = companylList.subList(0, limit);
|
||||
}
|
||||
companylList.sort(Comparator.comparingLong(AppUserDataVo::getFansNum).reversed());
|
||||
|
||||
// 好友的好友
|
||||
List<Long> friendIds = appUserFriendMapper.selectByFriendId(ids);
|
||||
|
|
@ -184,11 +186,11 @@ public class AppUserServiceImpl implements IAppUserService
|
|||
if (friendList.size() > limit) {
|
||||
friendList = friendList.subList(0, limit);
|
||||
}
|
||||
friendList.sort(Comparator.comparingLong(AppUserDataVo::getFansNum).reversed());
|
||||
|
||||
appUserNetVo.setFriendUserList(friendList);
|
||||
appUserNetVo.setSchoolUserList(schoolList);
|
||||
appUserNetVo.setCompanyUserList(companylList);
|
||||
|
||||
// unfollowedUsers.sort(Comparator.comparingInt(User::getFollowersCount).reversed());
|
||||
return appUserNetVo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,87 @@
|
|||
<?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="com.ruoyi.app.mapper.AppUserFansMapper">
|
||||
|
||||
<resultMap type="AppUserFans" id="AppUserFansResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="friendId" column="friend_id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="updateBy" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAppUserFansVo">
|
||||
select id, user_id, friend_id, status, create_time, update_time, create_by, updateBy, remark from app_user_fans
|
||||
</sql>
|
||||
|
||||
<select id="selectAppUserFansList" parameterType="AppUserFans" resultMap="AppUserFansResult">
|
||||
<include refid="selectAppUserFansVo"/>
|
||||
<where>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="friendId != null "> and friend_id = #{friendId}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="updateBy != null and updateBy != ''"> and updateBy = #{updateBy}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAppUserFansById" parameterType="Long" resultMap="AppUserFansResult">
|
||||
<include refid="selectAppUserFansVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertAppUserFans" parameterType="AppUserFans" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into app_user_fans
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="friendId != null">friend_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">updateBy,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="friendId != null">#{friendId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateAppUserFans" parameterType="AppUserFans">
|
||||
update app_user_fans
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="friendId != null">friend_id = #{friendId},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">updateBy = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAppUserFansById" parameterType="Long">
|
||||
delete from app_user_fans where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAppUserFansByIds" parameterType="String">
|
||||
delete from app_user_fans where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
@ -139,9 +139,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="selectList" parameterType="AppUser" resultType="com.ruoyi.app.domain.vo.AppUserDataVo">
|
||||
select
|
||||
<include refid="appUserColumns"/>,
|
||||
s.name as "schoolName"
|
||||
s.name as "schoolName",
|
||||
count(f.user_id) as "fansNum"
|
||||
from app_user a
|
||||
left join app_school s on s.id = a.school
|
||||
left join app_user_fans f on f.user_id = a.id
|
||||
<where>
|
||||
<if test="isMember != null "> and a.is_member = #{isMember}</if>
|
||||
<if test="appId != null "> and a.id != #{appId}</if>
|
||||
|
|
@ -158,6 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
group by a.id
|
||||
</select>
|
||||
|
||||
<insert id="insertAppUser" parameterType="AppUser" useGeneratedKeys="true" keyProperty="id">
|
||||
|
|
|
|||
Loading…
Reference in New Issue