|
|
@@ -4,8 +4,10 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
+import com.cyksj.mapper.mirrorshop.MirrorNoticeUserReviewRecordMapper;
|
|
|
import com.cyksj.mapper.mirrorshop.MirrorNoticeUserStatusRelateMapper;
|
|
|
import com.cyksj.model.entity.MirrorNotice;
|
|
|
+import com.cyksj.model.entity.MirrorNoticeUserReviewRecord;
|
|
|
import com.cyksj.model.entity.MirrorNoticeUserStatusRelate;
|
|
|
import com.cyksj.service.mange.RefreshCacheService;
|
|
|
import com.cyksj.service.sys.MirrorNoticeService;
|
|
|
@@ -15,6 +17,7 @@ import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -42,6 +45,8 @@ public class CmsUserMirrorAdvertiseController {
|
|
|
|
|
|
private final MirrorNoticeUserStatusRelateMapper MirrorNoticeUserStatusRelateMapper;
|
|
|
|
|
|
+ private final MirrorNoticeUserReviewRecordMapper mirrorNoticeUserReviewRecordMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 店铺公告列表
|
|
|
*/
|
|
|
@@ -54,6 +59,7 @@ public class CmsUserMirrorAdvertiseController {
|
|
|
} else {
|
|
|
builder.field(MirrorNotice::getUserId, 0);
|
|
|
}
|
|
|
+ builder.put("ruid", String.format(String.format(" and user_id = %s"), userId));
|
|
|
SearchResult<MirrorNotice> search = beanSearcher.search(MirrorNotice.class, builder.orderBy(MirrorNotice::getUpdateTime).desc().build());
|
|
|
search.getDataList().forEach(data -> {
|
|
|
if (data.getUserId() == 0) {
|
|
|
@@ -141,4 +147,28 @@ public class CmsUserMirrorAdvertiseController {
|
|
|
refreshCacheService.refreshUserMirrorShopAdvertiseCache(userId);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 标记公告已读
|
|
|
+ */
|
|
|
+ @PostMapping("/mark/{id}")
|
|
|
+ public Result<String> markNotice(@PathVariable Long id) {
|
|
|
+ Long userId = StpUserMirrorShopManageUser.getLoginIdAsLong();
|
|
|
+ MirrorNotice byId = mirrorNoticeService.getById(id);
|
|
|
+ MirrorNoticeUserReviewRecord mirrorNoticeUserReviewRecord = Optional.ofNullable(mirrorNoticeUserReviewRecordMapper.selectOne(Wrappers.lambdaQuery(MirrorNoticeUserReviewRecord.class)
|
|
|
+ .eq(MirrorNoticeUserReviewRecord::getNoticeId, id)
|
|
|
+ .eq(MirrorNoticeUserReviewRecord::getUserId, userId)
|
|
|
+ .last("limit 1"))).orElse(new MirrorNoticeUserReviewRecord());
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (mirrorNoticeUserReviewRecord.getId() == null) {
|
|
|
+ mirrorNoticeUserReviewRecord.setNoticeId(id);
|
|
|
+ mirrorNoticeUserReviewRecord.setUserId(userId);
|
|
|
+ mirrorNoticeUserReviewRecordMapper.insert(mirrorNoticeUserReviewRecord);
|
|
|
+ }
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
}
|