parent
f41c24f8d5
commit
ff432fd2a9
@ -0,0 +1,98 @@ |
||||
package com.ruoyi.platform.controller; |
||||
|
||||
import com.ruoyi.common.annotation.Log; |
||||
import com.ruoyi.common.core.controller.BaseController; |
||||
import com.ruoyi.common.core.domain.AjaxResult; |
||||
import com.ruoyi.common.core.page.TableDataInfo; |
||||
import com.ruoyi.common.enums.BusinessType; |
||||
import com.ruoyi.common.utils.poi.ExcelUtil; |
||||
import com.ruoyi.platform.domain.PlatformFollower; |
||||
import com.ruoyi.platform.service.IPlatformFollowerService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 粉丝Controller |
||||
* |
||||
* @author ruoyi |
||||
* @date 2023-01-13 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/platform/follower") |
||||
public class PlatformFollowerController extends BaseController { |
||||
@Autowired |
||||
private IPlatformFollowerService platformFollowerService; |
||||
|
||||
/** |
||||
* 查询粉丝列表 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('platform:follower:list')") |
||||
@GetMapping("/list/{userId}") |
||||
public TableDataInfo list(@PathVariable Long userId) { |
||||
if (userId != null) { |
||||
startPage(); |
||||
List<PlatformFollower> list = platformFollowerService.selectPlatformFollowerList(userId); |
||||
return getDataTable(list); |
||||
} else { |
||||
TableDataInfo info = new TableDataInfo(); |
||||
info.setCode(400); |
||||
info.setMsg("参数不合法,userId不能为空!"); |
||||
return info; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 导出粉丝列表 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('platform:follower:export')") |
||||
@Log(title = "粉丝", businessType = BusinessType.EXPORT) |
||||
@PostMapping("/export/{userId}") |
||||
public void export(HttpServletResponse response, @PathVariable Long userId) { |
||||
List<PlatformFollower> list = platformFollowerService.selectPlatformFollowerList(userId); |
||||
ExcelUtil<PlatformFollower> util = new ExcelUtil<>(PlatformFollower.class); |
||||
util.exportExcel(response, list, "粉丝数据"); |
||||
} |
||||
|
||||
/** |
||||
* 获取粉丝详细信息 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('platform:follower:query')") |
||||
@GetMapping(value = "/{id}") |
||||
public AjaxResult getInfo(@PathVariable("id") Long id) { |
||||
return success(platformFollowerService.selectPlatformFollowerById(id)); |
||||
} |
||||
|
||||
/** |
||||
* 新增粉丝 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('platform:follower:add')") |
||||
@Log(title = "粉丝", businessType = BusinessType.INSERT) |
||||
@PostMapping |
||||
public AjaxResult add(@RequestBody PlatformFollower platformFollower) { |
||||
return toAjax(platformFollowerService.insertPlatformFollower(platformFollower)); |
||||
} |
||||
|
||||
/** |
||||
* 修改粉丝 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('platform:follower:edit')") |
||||
@Log(title = "粉丝", businessType = BusinessType.UPDATE) |
||||
@PutMapping |
||||
public AjaxResult edit(@RequestBody PlatformFollower platformFollower) { |
||||
return toAjax(platformFollowerService.updatePlatformFollower(platformFollower)); |
||||
} |
||||
|
||||
/** |
||||
* 删除粉丝 |
||||
*/ |
||||
@PreAuthorize("@ss.hasPermi('platform:follower:remove')") |
||||
@Log(title = "粉丝", businessType = BusinessType.DELETE) |
||||
@DeleteMapping("/{ids}") |
||||
public AjaxResult remove(@PathVariable Long[] ids) { |
||||
return toAjax(platformFollowerService.deletePlatformFollowerByIds(ids)); |
||||
} |
||||
} |
@ -0,0 +1,88 @@ |
||||
package com.ruoyi.platform.domain; |
||||
|
||||
import com.ruoyi.common.annotation.Excel; |
||||
import com.ruoyi.common.core.domain.BaseEntity; |
||||
import com.ruoyi.common.core.domain.entity.SysUser; |
||||
import org.apache.commons.lang3.builder.ToStringBuilder; |
||||
import org.apache.commons.lang3.builder.ToStringStyle; |
||||
|
||||
/** |
||||
* 粉丝对象 platform_follower |
||||
* |
||||
* @author ruoyi |
||||
* @date 2023-01-13 |
||||
*/ |
||||
public class PlatformFollower extends BaseEntity { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* $column.columnComment |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 关注的人 |
||||
*/ |
||||
@Excel(name = "关注的人") |
||||
private Long following; |
||||
|
||||
/** |
||||
* 粉丝 |
||||
*/ |
||||
@Excel(name = "粉丝") |
||||
private Long follower; |
||||
|
||||
private SysUser followingUser; |
||||
|
||||
private SysUser followerUser; |
||||
|
||||
public SysUser getFollowingUser() { |
||||
return followingUser; |
||||
} |
||||
|
||||
public void setFollowingUser(SysUser followingUser) { |
||||
this.followingUser = followingUser; |
||||
} |
||||
|
||||
public SysUser getFollowerUser() { |
||||
return followerUser; |
||||
} |
||||
|
||||
public void setFollowerUser(SysUser followerUser) { |
||||
this.followerUser = followerUser; |
||||
} |
||||
|
||||
public void setId(Long id) { |
||||
this.id = id; |
||||
} |
||||
|
||||
public Long getId() { |
||||
return id; |
||||
} |
||||
|
||||
public void setFollowing(Long following) { |
||||
this.following = following; |
||||
} |
||||
|
||||
public Long getFollowing() { |
||||
return following; |
||||
} |
||||
|
||||
public void setFollower(Long follower) { |
||||
this.follower = follower; |
||||
} |
||||
|
||||
public Long getFollower() { |
||||
return follower; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
||||
.append("id", getId()) |
||||
.append("createTime", getCreateTime()) |
||||
.append("following", getFollowing()) |
||||
.append("follower", getFollower()) |
||||
.toString(); |
||||
} |
||||
} |
@ -0,0 +1,10 @@ |
||||
package com.ruoyi.platform.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.ruoyi.platform.domain.PlatformFollower; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface PlatformFollowerMapper extends BaseMapper<PlatformFollower> { |
||||
List<PlatformFollower> selectPlatformFollowerList(Long userId); |
||||
} |
@ -0,0 +1,61 @@ |
||||
package com.ruoyi.platform.service; |
||||
|
||||
import com.ruoyi.platform.domain.PlatformFollower; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 粉丝Service接口 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2023-01-13 |
||||
*/ |
||||
public interface IPlatformFollowerService { |
||||
/** |
||||
* 查询粉丝 |
||||
* |
||||
* @param id 粉丝主键 |
||||
* @return 粉丝 |
||||
*/ |
||||
public PlatformFollower selectPlatformFollowerById(Long id); |
||||
|
||||
/** |
||||
* 查询粉丝列表 |
||||
* |
||||
* @param platformFollower 粉丝 |
||||
* @return 粉丝集合 |
||||
*/ |
||||
public List<PlatformFollower> selectPlatformFollowerList(Long userId); |
||||
|
||||
/** |
||||
* 新增粉丝 |
||||
* |
||||
* @param platformFollower 粉丝 |
||||
* @return 结果 |
||||
*/ |
||||
public int insertPlatformFollower(PlatformFollower platformFollower); |
||||
|
||||
/** |
||||
* 修改粉丝 |
||||
* |
||||
* @param platformFollower 粉丝 |
||||
* @return 结果 |
||||
*/ |
||||
public int updatePlatformFollower(PlatformFollower platformFollower); |
||||
|
||||
/** |
||||
* 批量删除粉丝 |
||||
* |
||||
* @param ids 需要删除的粉丝主键集合 |
||||
* @return 结果 |
||||
*/ |
||||
public int deletePlatformFollowerByIds(Long[] ids); |
||||
|
||||
/** |
||||
* 删除粉丝信息 |
||||
* |
||||
* @param id 粉丝主键 |
||||
* @return 结果 |
||||
*/ |
||||
public int deletePlatformFollowerById(Long id); |
||||
} |
@ -0,0 +1,90 @@ |
||||
package com.ruoyi.platform.service.impl; |
||||
|
||||
import com.ruoyi.common.utils.DateUtils; |
||||
import com.ruoyi.platform.domain.PlatformFollower; |
||||
import com.ruoyi.platform.mapper.PlatformFollowerMapper; |
||||
import com.ruoyi.platform.service.IPlatformFollowerService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 粉丝Service业务层处理 |
||||
* |
||||
* @author ruoyi |
||||
* @date 2023-01-13 |
||||
*/ |
||||
@Service |
||||
public class PlatformFollowerServiceImpl implements IPlatformFollowerService { |
||||
@Autowired |
||||
private PlatformFollowerMapper platformFollowerMapper; |
||||
|
||||
/** |
||||
* 查询粉丝 |
||||
* |
||||
* @param id 粉丝主键 |
||||
* @return 粉丝 |
||||
*/ |
||||
@Override |
||||
public PlatformFollower selectPlatformFollowerById(Long id) { |
||||
return platformFollowerMapper.selectById(id); |
||||
} |
||||
|
||||
/** |
||||
* 查询粉丝列表 |
||||
* |
||||
* @param platformFollower 粉丝 |
||||
* @return 粉丝 |
||||
*/ |
||||
@Override |
||||
public List<PlatformFollower> selectPlatformFollowerList(Long userId) { |
||||
return platformFollowerMapper.selectPlatformFollowerList(userId); |
||||
} |
||||
|
||||
/** |
||||
* 新增粉丝 |
||||
* |
||||
* @param platformFollower 粉丝 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int insertPlatformFollower(PlatformFollower platformFollower) { |
||||
platformFollower.setCreateTime(DateUtils.getNowDate()); |
||||
return platformFollowerMapper.insert(platformFollower); |
||||
} |
||||
|
||||
/** |
||||
* 修改粉丝 |
||||
* |
||||
* @param platformFollower 粉丝 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int updatePlatformFollower(PlatformFollower platformFollower) { |
||||
return platformFollowerMapper.updateById(platformFollower); |
||||
} |
||||
|
||||
/** |
||||
* 批量删除粉丝 |
||||
* |
||||
* @param ids 需要删除的粉丝主键 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int deletePlatformFollowerByIds(Long[] ids) { |
||||
return platformFollowerMapper.deleteBatchIds(Arrays.asList(ids)); |
||||
} |
||||
|
||||
/** |
||||
* 删除粉丝信息 |
||||
* |
||||
* @param id 粉丝主键 |
||||
* @return 结果 |
||||
*/ |
||||
@Override |
||||
public int deletePlatformFollowerById(Long id) { |
||||
return platformFollowerMapper.deleteById(id); |
||||
} |
||||
} |
@ -0,0 +1,55 @@ |
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.ruoyi.platform.mapper.PlatformFollowerMapper"> |
||||
<resultMap type="com.ruoyi.platform.domain.PlatformFollower" id="PlatformFollowerResult"> |
||||
<id property="id" column="id"/> |
||||
<result property="following" column="following"/> |
||||
<result property="follower" column="follower"/> |
||||
<result property="createTime" column="bind_time"/> |
||||
<association property="followingUser" column="following" |
||||
javaType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserResult"/> |
||||
<association property="followerUser" column="follower" |
||||
javaType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserResult"/> |
||||
|
||||
</resultMap> |
||||
|
||||
<resultMap type="com.ruoyi.common.core.domain.entity.SysUser" id="SysUserResult"> |
||||
<id property="userId" column="user_id"/> |
||||
<result property="nickName" column="nick_name"/> |
||||
<result property="phonenumber" column="phonenumber"/> |
||||
<result property="sex" column="sex"/> |
||||
<result property="avatar" column="avatar"/> |
||||
<result property="remark" column="remark"/> |
||||
<result property="wechatNickName" column="wechat_nick_name"/> |
||||
<result property="createTime" column="create_time"/> |
||||
<result property="loginDate" column="login_date"/> |
||||
<result property="referrerId" column="referrer_id"/> |
||||
<result property="status" column="status"/> |
||||
<association property="referrerSysUser" javaType="com.ruoyi.common.core.domain.entity.SysUser"> |
||||
<result property="nickName" column="follower_referrer_nick_name"/> |
||||
</association> |
||||
</resultMap> |
||||
|
||||
<select id="selectPlatformFollowerList" parameterType="Long" resultMap="PlatformFollowerResult"> |
||||
select f.id, |
||||
f.following, |
||||
f.follower, |
||||
f.create_time as bind_time, |
||||
u2.user_id, |
||||
u2.nick_name, |
||||
u2.phonenumber, |
||||
u2.sex, |
||||
u2.avatar, |
||||
u2.wechat_nick_name, |
||||
u2.create_time, |
||||
u2.login_date, |
||||
u2.status, |
||||
u2r.nick_name as follower_referrer_nick_name |
||||
from platform_follower f |
||||
left join sys_user u1 on f.following = u1.user_id |
||||
left join sys_user u2 on f.follower = u2.user_id |
||||
left join sys_user u2r on u2.referrer_id = u2r.user_id |
||||
where f.following = #{userId} |
||||
</select> |
||||
</mapper> |
Loading…
Reference in new issue