From abb04343603a2f6ff3090061be91a898abe90c79 Mon Sep 17 00:00:00 2001 From: 13405411873 <1994398261@qq.com> Date: Sat, 29 Mar 2025 11:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E5=91=8A=E8=AF=A6=E6=83=85=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busi/controller/BusiNoticeController.java | 17 +++ .../controller/BusiUserLoveController.java | 112 ++++++++++++++++++ .../com/ruoyi/busi/domain/BusiUserLove.java | 39 ++++++ .../ruoyi/busi/mapper/BusiNoticeMapper.java | 12 +- .../ruoyi/busi/mapper/BusiUserLoveMapper.java | 21 ++++ .../busi/service/IBusiNoticeService.java | 16 ++- .../busi/service/IBusiUserLoveService.java | 18 +++ .../service/impl/BusiNoticeServiceImpl.java | 74 ++++++++++++ .../service/impl/BusiUserLoveServiceImpl.java | 30 +++++ .../mapper/busi/BusiNoticeMapper.xml | 14 +++ .../mapper/busi/BusiUserLoveMapper.xml | 26 ++++ 11 files changed, 374 insertions(+), 5 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiUserLoveController.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiUserLove.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiUserLoveMapper.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiUserLoveService.java create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiUserLoveServiceImpl.java create mode 100644 ruoyi-admin/src/main/resources/mapper/busi/BusiUserLoveMapper.xml diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java index 85705dd..f68588a 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiNoticeController.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.busi.query.AppNoticeQuery; @@ -159,4 +161,19 @@ public class BusiNoticeController extends BaseController return success(list); } + /** + * 小程序端查询通告详细信息 + * @author 朱春云 + * @date 15:39 2025/3/29 + * @param noticeId 通告id + * @return com.ruoyi.common.core.domain.AjaxResult + **/ + @GetMapping("/appGetDetail") + @Anonymous + public AjaxResult appGetDetail(@RequestParam(name = "noticeId") String noticeId) + { + JSONObject detail = busiNoticeService.appGetDetail(noticeId); + return success(detail); + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiUserLoveController.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiUserLoveController.java new file mode 100644 index 0000000..c634068 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/controller/BusiUserLoveController.java @@ -0,0 +1,112 @@ +package com.ruoyi.busi.controller; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +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.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.busi.domain.BusiUserLove; +import com.ruoyi.busi.service.IBusiUserLoveService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 用户关注Controller + * + * @author 朱春云 + * @date 2025-03-29 + */ +@RestController +@RequestMapping("/busi/love") +public class BusiUserLoveController extends BaseController +{ + @Autowired + private IBusiUserLoveService busiUserLoveService; + + /** + * 查询用户关注列表 + */ + @PreAuthorize("@ss.hasPermi('busi:love:list')") + @GetMapping("/list") + public AjaxResult list(BusiUserLove busiUserLove, + @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) + { + Page page = new Page<>(pageNum, pageSize); + IPage list = busiUserLoveService.queryListPage(busiUserLove,page); + return success(list); + } + + /** + * 导出用户关注列表 + */ + @PreAuthorize("@ss.hasPermi('busi:love:export')") + @Log(title = "用户关注", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, BusiUserLove busiUserLove) + { + List list = busiUserLoveService.list(); + ExcelUtil util = new ExcelUtil(BusiUserLove.class); + util.exportExcel(response, list, "用户关注数据"); + } + + /** + * 获取用户关注详细信息 + */ + @PreAuthorize("@ss.hasPermi('busi:love:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(busiUserLoveService.getById(id)); + } + + /** + * 新增用户关注 + */ + @PreAuthorize("@ss.hasPermi('busi:love:add')") + @Log(title = "用户关注", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BusiUserLove busiUserLove) + { + return toAjax(busiUserLoveService.save(busiUserLove)); + } + + /** + * 修改用户关注 + */ + @PreAuthorize("@ss.hasPermi('busi:love:edit')") + @Log(title = "用户关注", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BusiUserLove busiUserLove) + { + return toAjax(busiUserLoveService.updateById(busiUserLove)); + } + + /** + * 删除用户关注 + */ + @PreAuthorize("@ss.hasPermi('busi:love:remove')") + @Log(title = "用户关注", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + List list = new ArrayList<>(Arrays.asList(ids)); + return toAjax(busiUserLoveService.removeByIds(list)); + } +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiUserLove.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiUserLove.java new file mode 100644 index 0000000..388832a --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/domain/BusiUserLove.java @@ -0,0 +1,39 @@ +package com.ruoyi.busi.domain; + +import com.ruoyi.common.annotation.Excel; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; +import com.ruoyi.common.core.domain.DlBaseEntity; + +/** + * 用户关注对象 dl_busi_user_love + * + * @author 朱春云 + * @date 2025-03-29 + */ +@TableName("dl_busi_user_love") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BusiUserLove extends DlBaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + @TableId(type = IdType.ASSIGN_UUID) + private String id; + + /** 用户主键 */ + @Excel(name = "用户主键") + private Long userId; + + /** 被关注通告主用户id */ + @Excel(name = "被关注通告主用户id") + private Long loveUserId; + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java index ea0fa9b..03953ca 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiNoticeMapper.java @@ -34,11 +34,19 @@ public interface BusiNoticeMapper extends BaseMapper { /** * 小程序端查询通告列表 - * @author vinjor-M - * @date 15:41 2025/3/25 + * @author vinjor-M + * @date 15:41 2025/3/25 * @param query TODO * @param page * @return com.baomidou.mybatisplus.core.metadata.IPage **/ IPage queryAppListPage(@Param("entity") AppNoticeQuery query, Page page); + /** + * 小程序端查询通告详细信息 + * @author 朱春云 + * @date 15:39 2025/3/29 + * @param noticeId 通告id + * @return com.ruoyi.common.core.domain.AjaxResult + **/ + BusiNoticeVo selectByIdVo(@Param("noticeId") String noticeId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiUserLoveMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiUserLoveMapper.java new file mode 100644 index 0000000..9a8fdc3 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/mapper/BusiUserLoveMapper.java @@ -0,0 +1,21 @@ +package com.ruoyi.busi.mapper; + +import java.util.List; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.busi.domain.BusiUserLove; +import org.apache.ibatis.annotations.Param; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户关注Mapper接口 + * + * @author 朱春云 + * @date 2025-03-29 + */ +@Mapper +public interface BusiUserLoveMapper extends BaseMapper +{ + IPage queryListPage(@Param("entity") BusiUserLove entity, Page page); +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java index 5e357c6..74deb69 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiNoticeService.java @@ -1,5 +1,6 @@ package com.ruoyi.busi.service; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; @@ -63,11 +64,20 @@ public interface IBusiNoticeService extends IService /** * 小程序端查询通告列表 - * @author vinjor-M - * @date 15:41 2025/3/25 + * @author vinjor-M + * @date 15:41 2025/3/25 * @param query TODO - * @param page TODO + * @param page TODO * @return com.baomidou.mybatisplus.core.metadata.IPage **/ IPage queryAppListPage(AppNoticeQuery query, Page page); + + /** + * 小程序端查询通告详细信息 + * @author 朱春云 + * @date 15:39 2025/3/29 + * @param noticeId 通告id + * @return com.ruoyi.common.core.domain.AjaxResult + **/ + JSONObject appGetDetail(String noticeId); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiUserLoveService.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiUserLoveService.java new file mode 100644 index 0000000..e341b02 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/IBusiUserLoveService.java @@ -0,0 +1,18 @@ +package com.ruoyi.busi.service; + +import java.util.List; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.busi.domain.BusiUserLove; + +/** + * 用户关注Service接口 + * + * @author 朱春云 + * @date 2025-03-29 + */ +public interface IBusiUserLoveService extends IService +{ + IPage queryListPage(BusiUserLove pageReqVO, Page page); +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java index f2cedd3..cb1b9d0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiNoticeServiceImpl.java @@ -3,11 +3,15 @@ package com.ruoyi.busi.service.impl; import java.util.*; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.base.domain.BaseCategory; import com.ruoyi.base.service.IBaseCategoryService; +import com.ruoyi.busi.domain.BusiNoticeSign; +import com.ruoyi.busi.domain.BusiUserLove; import com.ruoyi.busi.mapper.BusiNoticeSignMapper; import com.ruoyi.busi.query.AppNoticeQuery; +import com.ruoyi.busi.service.IBusiUserLoveService; import com.ruoyi.busi.vo.BusiNoticeVo; import com.ruoyi.common.core.domain.DlBaseEntity; @@ -17,10 +21,16 @@ import cn.hutool.core.date.DateUtil; import com.ruoyi.busi.utils.NoticeUtils; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.busi.query.BusiNoticeQuery; import com.ruoyi.constant.DictConstants; +import com.ruoyi.member.domain.MemberApply; +import com.ruoyi.member.service.IMemberApplyService; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.system.service.ISysDictTypeService; +import com.ruoyi.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -45,6 +55,14 @@ public class BusiNoticeServiceImpl extends ServiceImpl queryListPage(BusiNoticeQuery query, Page page) { @@ -222,6 +240,62 @@ public class BusiNoticeServiceImpl extends ServiceImpl queryWrapperMember =new LambdaQueryWrapper<>(); + queryWrapperMember.eq(MemberApply::getUserId,userDetail.getUserId()).eq(MemberApply::getApprovalStatus,1).last("limit 1"); + MemberApply memberApply = memberApplyService.getOne(queryWrapperMember); + if (null != memberApply){ + userDetailJson.put("identityType",dictDataService.selectDictLabel("dl_identity_type",memberApply.getIdentityType())); + } + res.put("userDetail",userDetailJson); + //已报名用户头像 + List signList = busiNoticeSignMapper.selectList(new LambdaQueryWrapper().eq(BusiNoticeSign::getNoticeId, noticeId)); + List signUserAvatarList = signList.stream().map(BusiNoticeSign::getAvatar).collect(Collectors.toList()); + res.put("signUserAvatarList",signUserAvatarList); + //当前用户是否已关注该通告主 + Long userId=null; + try { + userId = SecurityUtils.getUserId(); + }catch (Exception ignored){ + //未登录状态 + } + res.put("isLove",false); + res.put("isSign",false); + if (null != userId){ + LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); + queryWrapper.eq(BusiUserLove::getUserId,userId).eq(BusiUserLove::getLoveUserId,detail.getUserId()); + if(userLoveService.getOne(queryWrapper)!=null){ + //当前用户已关注通告主 + res.put("isLove",true); + } + //当前用户是否已报名该通告 + if(busiNoticeSignMapper.selectOne(new LambdaQueryWrapper().eq(BusiNoticeSign::getNoticeId, noticeId).eq(BusiNoticeSign::getUserId, userId).last("limit 1"))!=null){ + res.put("isSign",true); + } + } + + + return res; + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiUserLoveServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiUserLoveServiceImpl.java new file mode 100644 index 0000000..39c05eb --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/busi/service/impl/BusiUserLoveServiceImpl.java @@ -0,0 +1,30 @@ +package com.ruoyi.busi.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.busi.mapper.BusiUserLoveMapper; +import com.ruoyi.busi.domain.BusiUserLove; +import com.ruoyi.busi.service.IBusiUserLoveService; + +/** + * 用户关注Service业务层处理 + * + * @author 朱春云 + * @date 2025-03-29 + */ +@Service +public class BusiUserLoveServiceImpl extends ServiceImpl implements IBusiUserLoveService +{ + @Autowired + private BusiUserLoveMapper busiUserLoveMapper; + + @Override + public IPage queryListPage(BusiUserLove pageReqVO, Page page) { + return busiUserLoveMapper.queryListPage(pageReqVO, page); + } +} diff --git a/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml b/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml index 0df8c9f..65205ae 100644 --- a/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/busi/BusiNoticeMapper.xml @@ -120,5 +120,19 @@ + diff --git a/ruoyi-admin/src/main/resources/mapper/busi/BusiUserLoveMapper.xml b/ruoyi-admin/src/main/resources/mapper/busi/BusiUserLoveMapper.xml new file mode 100644 index 0000000..6dab41d --- /dev/null +++ b/ruoyi-admin/src/main/resources/mapper/busi/BusiUserLoveMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + select id, user_id, love_user_id, creator, create_time from dl_busi_user_love + + + + \ No newline at end of file