TRX il y a 1 an
Parent
commit
852c9e1603
16 fichiers modifiés avec 872 ajouts et 2 suppressions
  1. 90 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipInfoModel.java
  2. 76 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipInfoParam.java
  3. 57 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipInfoSearch.java
  4. 16 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipStaticModel.java
  5. 2 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/visitor/VisitorMainSearch.java
  6. 19 0
      FullCardClient/src/main/java/com/zhongshu/card/client/type/tip/BusFunctionType.java
  7. 19 0
      FullCardClient/src/main/java/com/zhongshu/card/client/type/tip/TipType.java
  8. 127 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/visitor/TipInfoController.java
  9. 1 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/visitor/VisitorMainController.java
  10. 16 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/tip/TipInfoDao.java
  11. 20 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/tip/extend/TipInfoDaoExtend.java
  12. 116 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/tip/impl/TipInfoDaoImpl.java
  13. 1 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/school/NoticeInfo.java
  14. 93 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/tip/TipInfo.java
  15. 187 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/tip/TipInfoService.java
  16. 32 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/visitor/VisitorMainService.java

+ 90 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipInfoModel.java

@@ -0,0 +1,90 @@
+package com.zhongshu.card.client.model.tip;
+
+import com.zhongshu.card.client.model.base.SuperModel;
+import com.zhongshu.card.client.model.org.UserCountSimpleModel;
+import com.zhongshu.card.client.type.tip.BusFunctionType;
+import com.zhongshu.card.client.type.tip.TipType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author TRX
+ * @date 2025/2/19
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TipInfoModel extends SuperModel {
+
+    @Schema(description = "消息标题")
+    private String title;
+
+    @Schema(description = "消息内容")
+    private String content;
+
+    @Schema(description = "消息类型,如:系统信息、用户信息")
+    private TipType tipType;
+
+    private String tipTypeStr;
+
+    public String getTipTypeStr() {
+        if (tipType != null) {
+            return tipType.getRemark();
+        }
+        return "";
+    }
+
+    @Schema(description = "扩展信息")
+    private Map<String, Object> metaInfo = new HashMap<String, Object>();
+
+    //--------------------------那个用户发送的 start ----------------
+
+    @Schema(description = "发送用户的userId")
+    private String fromUserId;
+
+    private String fromUserName;
+
+    @Schema(description = "发送用户信息")
+    private UserCountSimpleModel fromUserAccount;
+
+    //--------------------------关于那个用户的信息 start--------------
+    private String toUserId;
+
+    private String toUserName;
+
+    @Schema(description = "接收用户信息")
+    private UserCountSimpleModel toUserAccount;
+
+    //---------------------是否阅读 start -------------
+
+    @Schema(description = "是否阅读")
+    private Boolean isRead;
+
+    @Schema(description = "阅读时间")
+    private Long readTime;
+
+    //----------------------业务参数 start -------------
+
+    @Schema(description = "关联业务数据id")
+    private String busDataId;
+
+    @Schema(description = "业务功能类型")
+    private BusFunctionType busFunctionType;
+
+    private String busFunctionTypeStr;
+
+    public String getBusFunctionTypeStr() {
+        if (busFunctionType != null) {
+            return busFunctionType.getRemark();
+        }
+        return "";
+    }
+
+    @Schema(description = "业务数据状态")
+    private String busStateStr;
+}

+ 76 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipInfoParam.java

@@ -0,0 +1,76 @@
+package com.zhongshu.card.client.model.tip;
+
+import com.zhongshu.card.client.type.tip.BusFunctionType;
+import com.zhongshu.card.client.type.tip.TipType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author TRX
+ * @date 2025/2/19
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TipInfoParam {
+
+    @Schema(description = "消息标题")
+    private String title;
+
+    @Schema(description = "消息内容")
+    private String content;
+
+    @Schema(description = "消息类型,如:系统信息、用户信息")
+    private TipType tipType = TipType.System;
+
+    @Schema(description = "扩展信息")
+    private Map<String, Object> metaInfo = new HashMap<String, Object>();
+
+    //--------------------------那个用户发送的 start ----------------
+
+    @Schema(description = "发送用户的userId")
+    private String fromUserId;
+
+    @Schema(description = "名称")
+    private String fromUserName;
+
+    //--------------------------关于那个用户的信息 start--------------
+    private String toUserId;
+
+    //---------------------是否阅读 start -------------
+
+    @Schema(description = "是否阅读")
+    private Boolean isRead = Boolean.FALSE;
+
+    @Schema(description = "阅读时间")
+    private Long readTime;
+
+    @Schema(description = "阅读时间(可读)")
+    private String readTimeStr;
+
+    //----------------------业务参数 start -------------
+
+    @Schema(description = "关联业务数据id")
+    private String busDataId;
+
+    @Schema(description = "业务功能类型")
+    private BusFunctionType busFunctionType;
+
+    @Schema(description = "业务服务名称")
+    private String busServiceBeanName;
+
+    @Schema(description = "业务服务参数")
+    private Map<String, Object> bueMetaInfo = new HashMap<>();
+
+    @Schema(description = "业务数据状态")
+    private String busStateStr;
+
+    @Schema(description = "微信小程序openid")
+    private String openId;
+
+}

+ 57 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipInfoSearch.java

@@ -0,0 +1,57 @@
+package com.zhongshu.card.client.model.tip;
+
+import com.zhongshu.card.client.model.base.SuperSearch;
+import com.zhongshu.card.client.type.tip.BusFunctionType;
+import com.zhongshu.card.client.type.tip.TipType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author TRX
+ * @date 2025/2/19
+ */
+@Data
+public class TipInfoSearch extends SuperSearch {
+
+    @Schema(description = "消息标题")
+    private String title;
+
+    @Schema(description = "消息内容")
+    private String content;
+
+    @Schema(description = "消息类型,如:系统信息、用户信息")
+    private TipType tipType;
+
+    //--------------------------那个用户发送的 start ----------------
+
+    @Schema(description = "发送用户的userId")
+    private String fromUserId;
+
+    private String fromUserName;
+
+    //--------------------------关于那个用户的信息 start--------------
+    private String toUserId;
+
+    private String toUserName;
+
+    //---------------------是否阅读 start -------------
+
+    @Schema(description = "是否阅读")
+    private Boolean isRead;
+
+    //----------------------业务参数 start -------------
+
+    @Schema(description = "关联业务数据id")
+    private String busDataId;
+
+    @Schema(description = "业务功能类型")
+    private BusFunctionType busFunctionType;
+
+    @Schema(description = "业务数据状态")
+    private String busStateStr;
+
+    @Schema(description = "微信小程序openid")
+    private String openId;
+
+    private Boolean isDesen;
+}

+ 16 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/tip/TipStaticModel.java

@@ -0,0 +1,16 @@
+package com.zhongshu.card.client.model.tip;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author TRX
+ * @date 2025/2/19
+ */
+@Data
+public class TipStaticModel {
+
+    @Schema(description = "未查看的消息数量")
+    private Long unReadCount = 0L;
+
+}

+ 2 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/visitor/VisitorMainSearch.java

@@ -68,4 +68,6 @@ public class VisitorMainSearch extends SuperSearch {
     @Schema(description = "可使用的设备id集合")
     private List<String> deviceIds = new ArrayList<>();
 
+    @Schema(description = "关联用户信息是否脱敏显示")
+    private Boolean isDesen;
 }

+ 19 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/type/tip/BusFunctionType.java

@@ -0,0 +1,19 @@
+package com.zhongshu.card.client.type.tip;
+
+import lombok.Getter;
+
+/**
+ * 业务功能类型
+ */
+public enum BusFunctionType {
+    VisitorAudio("访客审核"),
+    VisitorDetail("访客信息"),
+    ;
+
+    @Getter
+    private String remark;
+
+    BusFunctionType(String remark) {
+        this.remark = remark;
+    }
+}

+ 19 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/type/tip/TipType.java

@@ -0,0 +1,19 @@
+package com.zhongshu.card.client.type.tip;
+
+import lombok.Getter;
+
+/**
+ * 提醒消息类型
+ */
+public enum TipType {
+    System("系统消息"),
+    User("用户发送的"),
+    ;
+
+    @Getter
+    private String remark;
+
+    TipType(String remark) {
+        this.remark = remark;
+    }
+}

+ 127 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/visitor/TipInfoController.java

@@ -0,0 +1,127 @@
+package com.zhongshu.card.server.core.controller.visitor;
+
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.helper.AuthHelper;
+import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.card.client.model.base.IDParam;
+import com.zhongshu.card.client.model.base.ProjectOidParam;
+import com.zhongshu.card.client.model.tip.TipInfoModel;
+import com.zhongshu.card.client.model.tip.TipInfoSearch;
+import com.zhongshu.card.server.core.service.tip.TipInfoService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.web.PageableDefault;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 提醒消息管理
+ *
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("/tipInfo")
+@Tag(name = "提醒消息管理")
+public class TipInfoController {
+
+    @Autowired
+    private TipInfoService tipInfoService;
+
+    @Autowired
+    private AuthHelper authHelper;
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除数据", description = "删除数据")
+    @RequestMapping(value = "deleteInfo", method = {RequestMethod.POST})
+    public ResultContent deleteInfo(@RequestBody IDParam param) {
+        return this.tipInfoService.deleteInfo(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "所有数据列表-分页查询", description = "数据列表-分页查询")
+    @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
+    public ResultContent<Page<TipInfoModel>> page(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) TipInfoSearch param) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        return tipInfoService.page(param, pageable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "我的消息列表-分页查询", description = "我的消息列表-分页查询")
+    @RequestMapping(value = {"myPage"}, method = {RequestMethod.POST})
+    public ResultContent<Page<TipInfoModel>> myPage(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) TipInfoSearch param) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        String toUserId = "";
+        if (authHelper.getCurrentUser() != null) {
+            toUserId = authHelper.getCurrentUser().getUserId();
+        }
+        param.setToUserId(toUserId);
+        return tipInfoService.page(param, pageable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "我的列表-分页查询(已登录的)", description = "数据列表-分页查询")
+    @RequestMapping(value = {"mySendPage"}, method = {RequestMethod.POST})
+    public ResultContent<Page<TipInfoModel>> mySendPage(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) TipInfoSearch param) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        String fromUserId = "";
+        if (authHelper.getCurrentUser() != null) {
+            fromUserId = authHelper.getCurrentUser().getUserId();
+        }
+        param.setFromUserId(fromUserId);
+        return tipInfoService.page(param, pageable);
+    }
+
+    @Operation(summary = "我的发送列表-分页查询(未登录的)", description = "我的发送列表-分页查询")
+    @RequestMapping(value = {"mySendPageUnLogin"}, method = {RequestMethod.POST})
+    public ResultContent<Page<TipInfoModel>> mySendPageUnLogin(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) TipInfoSearch param) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        Assert.hasText(param.getOpenId(), "openId不能为空");
+        param.setIsDesen(Boolean.TRUE);
+        return tipInfoService.page(param, pageable);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "提醒消息详情", description = "提醒消息详情")
+    @RequestMapping(value = "getInfo", method = {RequestMethod.POST})
+    public ResultContent getInfo(@RequestBody IDParam param) {
+        return this.tipInfoService.getInfo(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "当前用户未读的信息统计", description = "当前用户未读的信息统计")
+    @RequestMapping(value = "myUnReadCount", method = {RequestMethod.POST})
+    public ResultContent myUnReadCount(@RequestBody ProjectOidParam param) {
+        return this.tipInfoService.staticCurrentUnRead(param.getProjectOid());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "标记信息已读", description = "标记信息已读")
+    @RequestMapping(value = "markRead", method = {RequestMethod.POST})
+    public ResultContent markRead(@RequestBody IDParam param) {
+        return this.tipInfoService.markRead(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "标识所有的数据已读", description = "标识所有的数据已读")
+    @RequestMapping(value = "markCurrentAllRead", method = {RequestMethod.GET})
+    public ResultContent markCurrentAllRead() {
+        return this.tipInfoService.markCurrentAllRead();
+    }
+
+}

+ 1 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/visitor/VisitorMainController.java

@@ -89,6 +89,7 @@ public class VisitorMainController {
     public ResultContent<Page<VisitorMainModel>> myApplyPageUnLogin(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, @Parameter(required = false) VisitorMainSearch param) {
         Assert.hasText(param.getProjectOid(), "projectOid不能为空");
         Assert.hasText(param.getOpenId(), "openId不能为空");
+        param.setIsDesen(Boolean.TRUE);
         return visitorMainService.page(param, pageable);
     }
 

+ 16 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/tip/TipInfoDao.java

@@ -0,0 +1,16 @@
+package com.zhongshu.card.server.core.dao.tip;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.card.server.core.dao.tip.extend.TipInfoDaoExtend;
+import com.zhongshu.card.server.core.dao.visitor.extend.VisitorMainDaoExtend;
+import com.zhongshu.card.server.core.domain.tip.TipInfo;
+
+/**
+ * @author TRX
+ * @date 2024/3/21
+ */
+public interface TipInfoDao extends MongoDao<TipInfo>, TipInfoDaoExtend {
+
+    TipInfo findTopById(String id);
+
+}

+ 20 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/tip/extend/TipInfoDaoExtend.java

@@ -0,0 +1,20 @@
+package com.zhongshu.card.server.core.dao.tip.extend;
+
+import com.zhongshu.card.client.model.tip.TipInfoSearch;
+import com.zhongshu.card.client.model.visitor.VisitorMainSearch;
+import com.zhongshu.card.server.core.domain.tip.TipInfo;
+import com.zhongshu.card.server.core.domain.visitor.VisitorMain;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+/**
+ * @Author TRX
+ * @CreateDate: 2023/7/7
+ * @Version: 1.0
+ */
+public interface TipInfoDaoExtend {
+
+    Page<TipInfo> page(Pageable pageable, TipInfoSearch param);
+
+    Long count(TipInfoSearch param);
+}

+ 116 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/tip/impl/TipInfoDaoImpl.java

@@ -0,0 +1,116 @@
+package com.zhongshu.card.server.core.dao.tip.impl;
+
+import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
+import com.zhongshu.card.client.model.tip.TipInfoSearch;
+import com.zhongshu.card.server.core.dao.BaseImpl;
+import com.zhongshu.card.server.core.dao.tip.extend.TipInfoDaoExtend;
+import com.zhongshu.card.server.core.domain.tip.TipInfo;
+import com.zhongshu.card.server.core.domain.visitor.VisitorMain;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * @Author TRX
+ * @CreateDate: 2023/4/12
+ * @Version: 1.0
+ */
+public class TipInfoDaoImpl extends BaseImpl implements TipInfoDaoExtend {
+
+    @Autowired
+    private DBHelper dbHelper;
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @Override
+    public Page<TipInfo> page(Pageable pageable, TipInfoSearch param) {
+        Criteria criteria = buildFilterCriteria(param);
+
+        Sort sort = buildSort(param);
+        Query query = Query.query(criteria);
+        query.with(sort);
+        return dbHelper.pages(query, pageable, TipInfo.class);
+    }
+
+    @Override
+    public Long count(TipInfoSearch param) {
+        Criteria criteria = buildFilterCriteria(param);
+        Query query = Query.query(criteria);
+        return mongoTemplate.count(query, VisitorMain.class);
+    }
+
+    private Criteria buildFilterCriteria(TipInfoSearch param) {
+        Criteria criteria = buildCriteriaNotOid(param);
+
+        if (StringUtils.isNotEmpty(param.getProjectOid())) {
+            criteria.and("projectOid").is(param.getProjectOid());
+        }
+
+        if (param.getTipType() != null) {
+            criteria.and("tipType").is(param.getTipType());
+        }
+
+        if (StringUtils.isNotEmpty(param.getFromUserId())) {
+            criteria.and("fromUserId").is(param.getFromUserId());
+        }
+
+        if (StringUtils.isNotEmpty(param.getToUserId())) {
+            criteria.and("toUserId").is(param.getToUserId());
+        }
+
+        if (param.getIsRead() != null) {
+            criteria.and("isRead").is(param.getIsRead());
+        }
+
+        if (StringUtils.isNotEmpty(param.getBusDataId())) {
+            criteria.and("busDataId").is(param.getBusDataId());
+        }
+
+        if (param.getBusFunctionType() != null) {
+            criteria.and("busFunctionType").is(param.getBusFunctionType());
+        }
+
+        if (StringUtils.isNotEmpty(param.getOpenId())) {
+            criteria.and("openId").is(param.getOpenId());
+        }
+
+        if (StringUtils.isNotEmpty(param.getBusStateStr())) {
+            criteria.and("busStateStr").is(param.getBusStateStr());
+        }
+
+        // 模糊搜索
+        List<Criteria> criterias = new ArrayList<>();
+        if (StringUtils.isNotEmpty(param.getTitle())) {
+            Pattern pattern = Pattern.compile("^.*" + param.getTitle() + ".*$");
+            criterias.add(Criteria.where("title").is(pattern));
+        }
+        if (StringUtils.isNotEmpty(param.getContent())) {
+            Pattern pattern = Pattern.compile("^.*" + param.getContent() + ".*$");
+            criterias.add(Criteria.where("content").is(pattern));
+        }
+        if (StringUtils.isNotEmpty(param.getFromUserName())) {
+            Pattern pattern = Pattern.compile("^.*" + param.getFromUserName() + ".*$");
+            criterias.add(Criteria.where("fromUserName").is(pattern));
+        }
+        if (StringUtils.isNotEmpty(param.getToUserName())) {
+            Pattern pattern = Pattern.compile("^.*" + param.getToUserName() + ".*$");
+            criterias.add(Criteria.where("toUserName").is(pattern));
+        }
+        if (!CollectionUtils.isEmpty(criterias)) {
+            criteria.andOperator(criterias.toArray(new Criteria[]{}));
+        }
+        return criteria;
+    }
+
+}

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/school/NoticeInfo.java

@@ -1,7 +1,6 @@
 package com.zhongshu.card.server.core.domain.school;
 
 import com.zhongshu.card.server.core.domain.base.SuperMain;
-import com.zhongshu.card.server.core.domain.org.Role;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -21,6 +20,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
 @NoArgsConstructor
 @NonLeaked
 public class NoticeInfo extends SuperMain {
+
     @Schema(description = "标题")
     private String title;
 

+ 93 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/tip/TipInfo.java

@@ -0,0 +1,93 @@
+package com.zhongshu.card.server.core.domain.tip;
+
+import com.zhongshu.card.client.type.tip.BusFunctionType;
+import com.zhongshu.card.client.type.tip.TipType;
+import com.zhongshu.card.server.core.domain.base.SuperMain;
+import com.zhongshu.card.server.core.domain.org.UserAccount;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.checkerframework.common.aliasing.qual.NonLeaked;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 提醒消息
+ *
+ * @author TRX
+ * @date 2025/2/19
+ */
+@Data
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+@NonLeaked
+public class TipInfo extends SuperMain {
+
+    @Schema(description = "消息标题")
+    private String title;
+
+    @Schema(description = "消息内容")
+    private String content;
+
+    @Schema(description = "消息类型,如:系统信息、用户信息")
+    private TipType tipType;
+
+    @Schema(description = "扩展信息")
+    private Map<String, Object> metaInfo = new HashMap<String, Object>();
+
+    //--------------------------那个用户发送的 start ----------------
+
+    @Schema(description = "发送用户的userId")
+    private String fromUserId;
+
+    private String fromUserName;
+
+    @Schema(description = "发送用户信息")
+    @DBRef(lazy = true)
+    private UserAccount fromUserAccount;
+
+    //--------------------------关于那个用户的信息 start--------------
+    private String toUserId;
+
+    private String toUserName;
+
+    @Schema(description = "接收用户信息")
+    @DBRef(lazy = true)
+    private UserAccount toUserAccount;
+
+    //---------------------是否阅读 start -------------
+
+    @Schema(description = "是否已阅读、处理")
+    private Boolean isRead = Boolean.FALSE;
+
+    @Schema(description = "阅读时间")
+    private Long readTime;
+
+    @Schema(description = "阅读时间(可读)")
+    private String readTimeStr;
+
+    //----------------------业务参数 start -------------
+
+    @Schema(description = "关联业务数据id")
+    private String busDataId;
+
+    @Schema(description = "业务功能类型")
+    private BusFunctionType busFunctionType;
+
+    @Schema(description = "业务服务名称")
+    private String busServiceBeanName;
+
+    @Schema(description = "业务服务参数")
+    private Map<String, Object> bueMetaInfo = new HashMap<>();
+
+    @Schema(description = "业务数据状态")
+    private String busStateStr;
+
+    @Schema(description = "微信小程序openid")
+    private String openId;
+}

+ 187 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/tip/TipInfoService.java

@@ -0,0 +1,187 @@
+package com.zhongshu.card.server.core.service.tip;
+
+import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.github.microservice.net.ResultContent;
+import com.github.microservice.net.ResultMessage;
+import com.zhongshu.card.client.model.tip.TipInfoModel;
+import com.zhongshu.card.client.model.tip.TipInfoParam;
+import com.zhongshu.card.client.model.tip.TipInfoSearch;
+import com.zhongshu.card.client.model.tip.TipStaticModel;
+import com.zhongshu.card.client.utils.DateUtils;
+import com.zhongshu.card.server.core.dao.org.UserCountDao;
+import com.zhongshu.card.server.core.dao.tip.TipInfoDao;
+import com.zhongshu.card.server.core.domain.org.UserAccount;
+import com.zhongshu.card.server.core.domain.tip.TipInfo;
+import com.zhongshu.card.server.core.service.base.CommonService;
+import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author TRX
+ * @date 2025/2/19
+ */
+@Slf4j
+@Service
+public class TipInfoService extends SuperService {
+
+    @Autowired
+    private TipInfoDao tipInfoDao;
+
+    @Autowired
+    private UserAccountServiceImpl userAccountService;
+
+    @Autowired
+    private UserCountDao userCountDao;
+
+    @Autowired
+    private CommonService commonService;
+
+    /**
+     * 保存访客申请
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent saveInfo(TipInfoParam param) {
+        TipInfo entity = new TipInfo();
+        BeanUtils.copyProperties(param, entity);
+        if (StringUtils.isNotEmpty(param.getFromUserId())) {
+            UserAccount fromUserAccount = userCountDao.findTopByUserId(param.getFromUserId());
+            entity.setFromUserAccount(fromUserAccount);
+            if (ObjectUtils.isNotEmpty(fromUserAccount)) {
+                entity.setFromUserName(fromUserAccount.getName());
+            }
+        }
+        if (StringUtils.isNotEmpty(param.getFromUserId())) {
+            UserAccount toUserAccount = userCountDao.findTopByUserId(param.getToUserId());
+            entity.setToUserAccount(toUserAccount);
+            if (ObjectUtils.isNotEmpty(toUserAccount)) {
+                entity.setToUserName(toUserAccount.getName());
+            }
+        }
+        tipInfoDao.save(entity);
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent getInfo(String id) {
+        TipInfo entity = tipInfoDao.findTopById(id);
+        if (entity == null) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        return ResultContent.buildSuccess(toModel(entity));
+    }
+
+    /**
+     * 删除数据
+     *
+     * @param id
+     * @return
+     */
+    public ResultContent deleteInfo(String id) {
+        TipInfo entity = tipInfoDao.findTopById(id);
+        if (entity == null) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        tipInfoDao.delete(entity);
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 分页列表
+     *
+     * @param param
+     * @param pageable
+     * @return
+     */
+    public ResultContent<Page<TipInfoModel>> page(TipInfoSearch param, Pageable pageable) {
+        Page<TipInfo> page = tipInfoDao.page(pageable, param);
+        if (param.getIsDesen() != null && param.getIsDesen()) {
+            return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toDesenModel));
+        }
+        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
+
+    public ResultContent markRead(String id) {
+        TipInfo entity = tipInfoDao.findTopById(id);
+        if (entity == null) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        entity.setIsRead(Boolean.TRUE);
+        entity.setReadTime(System.currentTimeMillis());
+        entity.setReadTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+        return ResultContent.buildSuccess(toModel(entity));
+    }
+
+    public ResultContent markCurrentAllRead() {
+        java.util.Map<String, Object> where = new java.util.HashMap<>();
+        where.put("isRead", Boolean.FALSE);
+        where.put("toUserId", getCurrentUserId());
+
+        Map<String, Object> standardData = new HashMap<String, Object>();
+        standardData.put("isRead", Boolean.TRUE);
+        standardData.put("readTime", System.currentTimeMillis());
+        standardData.put("readTimeStr", DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+        commonService.updateData(where, standardData, TipInfo.class.getSimpleName());
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent staticCurrentUnRead(String projectOid) {
+        if (StringUtils.isEmpty(projectOid)) {
+            projectOid = getCurrentProjectOid();
+        }
+        if (StringUtils.isEmpty(projectOid)) {
+            return ResultContent.buildFail("项目oid信息为空");
+        }
+        TipInfoSearch param = new TipInfoSearch();
+        param.setProjectOid(projectOid);
+        param.setIsRead(Boolean.FALSE);
+        param.setToUserId(getCurrentUserId());
+        return staticTipCount(param);
+    }
+
+    /**
+     * 统计数量
+     *
+     * @return
+     */
+    public ResultContent staticTipCount(TipInfoSearch param) {
+        TipStaticModel model = new TipStaticModel();
+        Long unReadCount = tipInfoDao.count(param);
+        model.setUnReadCount(unReadCount);
+        return ResultContent.buildSuccess(model);
+    }
+
+    public TipInfoModel toDesenModel(TipInfo entity) {
+        TipInfoModel model = null;
+        if (ObjectUtils.isNotEmpty(entity)) {
+            model = new TipInfoModel();
+            BeanUtils.copyProperties(entity, model);
+            model.setFromUserAccount(userAccountService.toSimpleDesenModel(entity.getFromUserAccount()));
+            model.setToUserAccount(userAccountService.toSimpleDesenModel(entity.getToUserAccount()));
+        }
+        return model;
+    }
+
+    public TipInfoModel toModel(TipInfo entity) {
+        TipInfoModel model = null;
+        if (ObjectUtils.isNotEmpty(entity)) {
+            model = new TipInfoModel();
+            BeanUtils.copyProperties(entity, model);
+
+            model.setFromUserAccount(userAccountService.toSimpleModel(entity.getFromUserAccount()));
+            model.setToUserAccount(userAccountService.toSimpleModel(entity.getToUserAccount()));
+        }
+        return model;
+    }
+}

+ 32 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/visitor/VisitorMainService.java

@@ -199,7 +199,7 @@ public class VisitorMainService extends SuperPermissService {
         entity.setApplyUserId(applyUserId);
         entity.setApplyUserAccount(applyUserAccount);
         entity.setProjectOid(projectOid);
-
+        entity.setOid(projectOid);
         // 单位是小时
         Long preMinutes = visitorSetting.getMinutes();
         if (preMinutes == null) {
@@ -246,8 +246,18 @@ public class VisitorMainService extends SuperPermissService {
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 分页列表
+     *
+     * @param param
+     * @param pageable
+     * @return
+     */
     public ResultContent<Page<VisitorMainModel>> page(VisitorMainSearch param, Pageable pageable) {
         Page<VisitorMain> page = visitorMainDao.page(pageable, param);
+        if (param.getIsDesen() != null && param.getIsDesen()) {
+            return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toDesenModel));
+        }
         return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
     }
 
@@ -526,6 +536,27 @@ public class VisitorMainService extends SuperPermissService {
         }
     }
 
+    public VisitorMainModel toDesenModel(VisitorMain entity) {
+        VisitorMainModel model = null;
+        if (ObjectUtils.isNotEmpty(entity)) {
+            model = new VisitorMainModel();
+            BeanUtils.copyProperties(entity, model);
+
+            // 用户信息/被访人
+            model.setVisitorUserAccount(userAccountService.toSimpleDesenModel(entity.getVisitorUserAccount()));
+            // 申请用户
+            model.setApplyUserAccount(userAccountService.toSimpleModel(entity.getApplyUserAccount()));
+
+            // 设备信息
+            List<DeviceInfoSimpleModel> deviceInfos = new ArrayList<>();
+            if (ObjectUtils.isNotEmpty(entity.getDeviceInfos())) {
+                deviceInfos = entity.getDeviceInfos().stream().map(deviceInfoService::toSimpleModel).collect(Collectors.toList());
+            }
+            model.setDeviceInfos(deviceInfos);
+        }
+        return model;
+    }
+
     public VisitorMainModel toModel(VisitorMain entity) {
         VisitorMainModel model = null;
         if (ObjectUtils.isNotEmpty(entity)) {