|
|
@@ -1,11 +1,17 @@
|
|
|
package com.cyksj.web.controller.enterprise;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
+import com.cyksj.mapper.enterprise.EnterprisePurchaseLeadPopupRecordMapper;
|
|
|
+import com.cyksj.model.entity.EnterprisePurchaseLeadPopupRecord;
|
|
|
import com.cyksj.model.request.EnterprisePurchaseLeadSubmitReq;
|
|
|
import com.cyksj.service.enterprise.EnterprisePurchaseLeadService;
|
|
|
+import com.cyksj.web.util.StpUserUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -20,6 +26,8 @@ public class EnterprisePurchaseLeadFrontController {
|
|
|
|
|
|
private final EnterprisePurchaseLeadService enterprisePurchaseLeadService;
|
|
|
|
|
|
+ private final EnterprisePurchaseLeadPopupRecordMapper enterprisePurchaseLeadPopupRecordMapper;
|
|
|
+
|
|
|
private final HttpServletRequest request;
|
|
|
|
|
|
@PostMapping
|
|
|
@@ -28,6 +36,34 @@ public class EnterprisePurchaseLeadFrontController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(id);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 是否可以展示企业采购弹窗
|
|
|
+ */
|
|
|
+ @GetMapping("/popup/visible")
|
|
|
+ public Result<Boolean> popupVisible() {
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ Integer selectCount = enterprisePurchaseLeadPopupRecordMapper.selectCount(Wrappers.lambdaQuery(EnterprisePurchaseLeadPopupRecord.class)
|
|
|
+ .eq(EnterprisePurchaseLeadPopupRecord::getUserId, userId));
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(selectCount == 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 记录企业采购弹窗已展示
|
|
|
+ */
|
|
|
+ @PostMapping("/popup/record")
|
|
|
+ public Result<Boolean> recordPopup() {
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ EnterprisePurchaseLeadPopupRecord record = new EnterprisePurchaseLeadPopupRecord()
|
|
|
+ .setUserId(userId)
|
|
|
+ .setPopupCount(1);
|
|
|
+ try {
|
|
|
+ enterprisePurchaseLeadPopupRecordMapper.insert(record);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(true);
|
|
|
+ } catch (DuplicateKeyException e) {
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private String getClientIp() {
|
|
|
String ip = request.getHeader("X-Forwarded-For");
|
|
|
if (ip != null && !ip.isBlank()) {
|