mitao
2025-02-25 ee2bff3a8eaaafcea4675931db3b8c6ac04c273f
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/java/com/panzhihua/sangeshenbian/service/impl/MessageNotificationServiceImpl.java
@@ -4,21 +4,31 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.service.sangeshenbian.SystemUserService;
import com.panzhihua.sangeshenbian.dao.MessageNotificationMapper;
import com.panzhihua.sangeshenbian.model.entity.MessageNotification;
import com.panzhihua.sangeshenbian.model.entity.SystemUser;
import com.panzhihua.sangeshenbian.model.query.BasePage;
import com.panzhihua.sangeshenbian.model.vo.MessageNotificationVO;
import com.panzhihua.sangeshenbian.service.IMessageNotificationService;
import com.panzhihua.sangeshenbian.service.ISystemUserService;
import com.panzhihua.sangeshenbian.warpper.MessageNotificationList;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.Objects;
import java.util.Optional;
/**
 * @author zhibing.pu
 * @Date 2025/2/23 3:04
 */
@Service
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class MessageNotificationServiceImpl extends ServiceImpl<MessageNotificationMapper, MessageNotification> implements IMessageNotificationService {
   private final ISystemUserService systemUserService;
   
   @Override
   public IPage<MessageNotification> list(MessageNotificationList query) {
@@ -35,4 +45,36 @@
      Page<MessageNotification> page = lambdaQuery().page(new Page<>(basePage.getPageNum(),basePage.getPageSize()));
      return (Page<MessageNotificationVO>) page.convert(item-> BeanUtil.copyProperties(item, MessageNotificationVO.class));
   }
   /**
    * 标记已读
    * @param loginUserInfoVO
    */
   @Override
   public void read(LoginUserInfoVO loginUserInfoVO) {
      String undertakerUserId = "";
      Optional<SystemUser> systemUserByPhone = systemUserService.getSystemUserByPhone(loginUserInfoVO.getPhone());
      if (systemUserByPhone.isPresent()) {
         SystemUser systemUser = systemUserByPhone.get();
         if (systemUser.getIsAdmin().equals(1)){
            switch (systemUser.getAccountLevel()) {
               case 1:
                  undertakerUserId = "510400";//默认市级
                  break;
               case 2:
                  undertakerUserId = systemUser.getDistrictsCode();
                  break;
               case 3:
                  undertakerUserId = systemUser.getStreetId();
                  break;
               case 4:
                  undertakerUserId = systemUser.getCommunityId().toString();
                  break;
            }
         }
      }else {
         undertakerUserId = loginUserInfoVO.getUserId().toString();
      }
      this.lambdaUpdate().eq(MessageNotification::getUndertakerUserId, undertakerUserId).set(MessageNotification::getReadStatus, 1).update();
   }
}