diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/PlatformFollowerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/PlatformFollowerController.java new file mode 100644 index 0000000..9ca9154 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/PlatformFollowerController.java @@ -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 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 list = platformFollowerService.selectPlatformFollowerList(userId); + ExcelUtil 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)); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 003ac6b..c900b78 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -63,7 +63,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + 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} + +