From 84b5d338b610df9933d1e3158f3a090139dc545c Mon Sep 17 00:00:00 2001 From: zhoumingfa Date: Sun, 4 Aug 2024 15:37:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A1=E3=80=81=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=91=98=E5=B7=A5=E9=80=9A=E7=9F=A5=E6=97=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=B5=8F=E8=A7=88=E9=87=8F=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84=20NoticeMapper.xm?= =?UTF-8?q?l=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/oa/notice/dao/NoticeDao.java | 10 +++ .../notice/service/NoticeEmployeeService.java | 11 ++- .../employee/manager/EmployeeManager.java | 7 +- .../mapper/business/notice/NoticeMapper.xml | 69 ------------------- .../{NoticeDao.xml => NoticeMapper.xml} | 6 ++ 5 files changed, 30 insertions(+), 73 deletions(-) delete mode 100644 smart-admin-api/sa-admin/src/main/resources/mapper/business/notice/NoticeMapper.xml rename smart-admin-api/sa-admin/src/main/resources/mapper/business/oa/notice/{NoticeDao.xml => NoticeMapper.xml} (97%) diff --git a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/dao/NoticeDao.java b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/dao/NoticeDao.java index d6654a43..f6c5060f 100644 --- a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/dao/NoticeDao.java +++ b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/dao/NoticeDao.java @@ -114,4 +114,14 @@ public interface NoticeDao extends BaseMapper { */ void updateViewRecord(@Param("noticeId")Long noticeId, @Param("employeeId")Long requestEmployeeId,@Param("ip") String ip, @Param("userAgent")String userAgent); + /** + * 更新 浏览量 + * + * @param noticeId 通知 id + * @param pageViewCountIncrement 页面浏览量的增量 + * @param userViewCountIncrement 用户浏览量的增量 + */ + void updateViewCount(@Param("noticeId")Long noticeId,@Param("pageViewCountIncrement") Integer pageViewCountIncrement, @Param("userViewCountIncrement")Integer userViewCountIncrement); + + } diff --git a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/service/NoticeEmployeeService.java b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/service/NoticeEmployeeService.java index 5ac0f389..8208a74f 100644 --- a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/service/NoticeEmployeeService.java +++ b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/business/oa/notice/service/NoticeEmployeeService.java @@ -52,10 +52,10 @@ public class NoticeEmployeeService { public ResponseDTO> queryList(Long requestEmployeeId, NoticeEmployeeQueryForm noticeEmployeeQueryForm) { Page page = SmartPageUtil.convert2PageQuery(noticeEmployeeQueryForm); - //获取请求人的 部门及其子部门 List employeeDepartmentIdList = Lists.newArrayList(); EmployeeEntity employeeEntity = employeeService.getById(requestEmployeeId); - if (employeeEntity.getDepartmentId() != null) { + // 如果不是管理员 则获取请求人的 部门及其子部门 + if (!employeeEntity.getAdministratorFlag() && employeeEntity.getDepartmentId() != null) { employeeDepartmentIdList = departmentService.selfAndChildrenIdList(employeeEntity.getDepartmentId()); } @@ -106,8 +106,15 @@ public class NoticeEmployeeService { long viewCount = noticeDao.viewRecordCount(noticeId, requestEmployeeId); if (viewCount == 0) { noticeDao.insertViewRecord(noticeId, requestEmployeeId, ip, userAgent, 1); + // 该员工对于这个通知是第一次查看 页面浏览量+1 用户浏览量+1 + noticeDao.updateViewCount(noticeId, 1, 1); + noticeDetailVO.setPageViewCount(noticeDetailVO.getPageViewCount() + 1); + noticeDetailVO.setUserViewCount(noticeDetailVO.getUserViewCount() + 1); } else { noticeDao.updateViewRecord(noticeId, requestEmployeeId, ip, userAgent); + // 该员工对于这个通知不是第一次查看 页面浏览量+1 用户浏览量+0 + noticeDao.updateViewCount(noticeId, 1, 0); + noticeDetailVO.setPageViewCount(noticeDetailVO.getPageViewCount() + 1); } return ResponseDTO.ok(noticeDetailVO); diff --git a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/manager/EmployeeManager.java b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/manager/EmployeeManager.java index 2aca93bb..3495107f 100644 --- a/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/manager/EmployeeManager.java +++ b/smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/employee/manager/EmployeeManager.java @@ -60,8 +60,11 @@ public class EmployeeManager extends ServiceImpl { // 保存员工 获得id employeeDao.updateById(employee); - if (CollectionUtils.isNotEmpty(roleIdList)) { - List roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getEmployeeId())).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(roleIdList)) { + // 删除员工角色 + this.updateEmployeeRole(employee.getEmployeeId(), null); + } else { + List roleEmployeeList = roleIdList.stream().map(roleId -> new RoleEmployeeEntity(roleId, employee.getEmployeeId())).collect(Collectors.toList()); this.updateEmployeeRole(employee.getEmployeeId(), roleEmployeeList); } } diff --git a/smart-admin-api/sa-admin/src/main/resources/mapper/business/notice/NoticeMapper.xml b/smart-admin-api/sa-admin/src/main/resources/mapper/business/notice/NoticeMapper.xml deleted file mode 100644 index 580bb9b4..00000000 --- a/smart-admin-api/sa-admin/src/main/resources/mapper/business/notice/NoticeMapper.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - UPDATE t_notice - SET watch_amount = watch_amount + 1 - WHERE notice_id = #{noticeId} - - - UPDATE t_notice - SET deleted_flag = #{deletedFlag} - WHERE notice_id IN - - #{item} - - - - UPDATE t_notice - SET notice_type = #{noticeType}, - notice_belong_type = #{noticeBelongType}, - notice_title = #{noticeTitle}, - notice_content = #{noticeContent}, - link_address = #{linkAddress}, - cover_file_key = #{coverFileKey}, - accessory_file_keys = #{accessoryFileKeys}, - top_flag = #{topFlag}, - publish_time = #{publishTime}, - disabled_flag = #{disabledFlag} - WHERE notice_id = #{noticeId} - - - - \ No newline at end of file diff --git a/smart-admin-api/sa-admin/src/main/resources/mapper/business/oa/notice/NoticeDao.xml b/smart-admin-api/sa-admin/src/main/resources/mapper/business/oa/notice/NoticeMapper.xml similarity index 97% rename from smart-admin-api/sa-admin/src/main/resources/mapper/business/oa/notice/NoticeDao.xml rename to smart-admin-api/sa-admin/src/main/resources/mapper/business/oa/notice/NoticeMapper.xml index 7c623e33..b1dc8ad5 100644 --- a/smart-admin-api/sa-admin/src/main/resources/mapper/business/oa/notice/NoticeDao.xml +++ b/smart-admin-api/sa-admin/src/main/resources/mapper/business/oa/notice/NoticeMapper.xml @@ -242,5 +242,11 @@ where notice_id = #{noticeId} and employee_id = #{employeeId} + + update t_notice + set page_view_count = page_view_count + #{pageViewCountIncrement}, + user_view_count = user_view_count + #{userViewCountIncrement} + where notice_id = #{noticeId} + \ No newline at end of file