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