Quellcode durchsuchen

Merge branch 'master' of http://192.168.1.25:3000/lbyzx123/huimv-employment

xsh_1997 vor 2 Wochen
Ursprung
Commit
cfd7bff47f

+ 38 - 0
huimv-employment/fe-api/src/main/java/com/huimv/employment/controller/publicapi/PublicDraftController.java

@@ -0,0 +1,38 @@
1
+package com.huimv.employment.controller.publicapi;
2
+
3
+import com.huimv.employment.common.web.R;
4
+import com.huimv.employment.service.draft.DraftService;
5
+import com.huimv.employment.service.draft.dto.DraftDetailResponse;
6
+import io.swagger.v3.oas.annotations.Operation;
7
+import io.swagger.v3.oas.annotations.Parameter;
8
+import io.swagger.v3.oas.annotations.tags.Tag;
9
+import org.springframework.web.bind.annotation.GetMapping;
10
+import org.springframework.web.bind.annotation.RequestMapping;
11
+import org.springframework.web.bind.annotation.RequestParam;
12
+import org.springframework.web.bind.annotation.RestController;
13
+
14
+/**
15
+ * 用工草稿公开查询(无需 JWT)。
16
+ * <p>路径不在 {@code /api/v1/mp/**} 下,JwtAuthFilter 不会拦截。</p>
17
+ */
18
+@RestController
19
+@RequestMapping("/api/v1/public/drafts")
20
+@Tag(name = "用工草稿(公开)", description = "无需登录,按小程序码 scene 查询草稿详情")
21
+public class PublicDraftController {
22
+
23
+    private final DraftService draftService;
24
+
25
+    public PublicDraftController(DraftService draftService) {
26
+        this.draftService = draftService;
27
+    }
28
+
29
+    @GetMapping
30
+    @Operation(summary = "公开查询用工草稿详情",
31
+            description = "无需 Authorization。scene 为小程序码参数(订单编号,与 fe_registration_batch.qr_token 一致)。"
32
+                    + "返回字段与登录态详情一致(含 fields、qr_code_url)。")
33
+    public R<DraftDetailResponse> getDetail(
34
+            @Parameter(description = "小程序码 scene / 订单编号", required = true, example = "ord_123")
35
+            @RequestParam("scene") String scene) {
36
+        return R.ok(draftService.getPublicDetailByScene(scene));
37
+    }
38
+}

+ 31 - 0
huimv-employment/fe-service/src/main/java/com/huimv/employment/service/draft/DraftService.java

@@ -110,6 +110,37 @@ public class DraftService {
110 110
         return toDetail(draft, listFields(draftId));
111 111
     }
112 112
 
113
+    /**
114
+     * 公开查询草稿详情(无需登录):按小程序码 scene(订单编号)定位订单 → 草稿。
115
+     */
116
+    public DraftDetailResponse getPublicDetailByScene(String scene) {
117
+        if (!StringUtils.hasText(scene)) {
118
+            throw new BizException(ErrorCode.BAD_REQUEST, "scene 不能为空");
119
+        }
120
+        String sceneValue = scene.trim();
121
+        FeEmploymentOrder order = feEmploymentOrderMapper.selectOne(new LambdaQueryWrapper<FeEmploymentOrder>()
122
+                .eq(FeEmploymentOrder::getOrderNo, sceneValue)
123
+                .orderByDesc(FeEmploymentOrder::getId)
124
+                .last("LIMIT 1"));
125
+        if (order == null) {
126
+            FeRegistrationBatch batch = feRegistrationBatchMapper.selectOne(new LambdaQueryWrapper<FeRegistrationBatch>()
127
+                    .eq(FeRegistrationBatch::getQrToken, sceneValue)
128
+                    .orderByDesc(FeRegistrationBatch::getId)
129
+                    .last("LIMIT 1"));
130
+            if (batch != null) {
131
+                order = feEmploymentOrderMapper.selectById(batch.getOrderId());
132
+            }
133
+        }
134
+        if (order == null || order.getDraftId() == null) {
135
+            throw new BizException(ErrorCode.NOT_FOUND, "未找到对应用工信息");
136
+        }
137
+        FeEmploymentDraft draft = feEmploymentDraftMapper.selectById(order.getDraftId());
138
+        if (draft == null) {
139
+            throw new BizException(ErrorCode.NOT_FOUND, "草稿不存在");
140
+        }
141
+        return toDetail(draft, listFields(draft.getId()));
142
+    }
143
+
113 144
     @Transactional(rollbackFor = Exception.class)
114 145
     public DraftDetailResponse update(Long userId, Long draftId, DraftUpdateRequest request) {
115 146
         FeEmploymentDraft draft = requireOwned(userId, draftId);

+ 4 - 1
huimv-employment/fe-service/src/main/java/com/huimv/employment/service/order/McpOrderService.java

@@ -76,9 +76,12 @@ public class McpOrderService {
76 76
 
77 77
         LambdaQueryWrapper<FeEmploymentOrder> wrapper = new LambdaQueryWrapper<FeEmploymentOrder>()
78 78
                 .eq(FeEmploymentOrder::getEnterpriseId, conversation.getEnterpriseId())
79
-                .eq(StringUtils.hasText(status), FeEmploymentOrder::getOrderStatus, status.trim())
80 79
                 .orderByDesc(FeEmploymentOrder::getCreateTime)
81 80
                 .last("LIMIT " + resolvedLimit);
81
+        // 注意:.eq(condition, column, value) 的 value 会先求值,status 为空时勿直接 status.trim()
82
+        if (StringUtils.hasText(status)) {
83
+            wrapper.eq(FeEmploymentOrder::getOrderStatus, status.trim());
84
+        }
82 85
 
83 86
         List<FeEmploymentOrder> orders = feEmploymentOrderMapper.selectList(wrapper);
84 87
         McpOrderListResponse response = new McpOrderListResponse();