张延森 4 年 前
コミット
9303d5c65b

+ 15
- 0
src/main/java/com/huiju/estateagents/common/StringUtils.java ファイルの表示

@@ -145,4 +145,19 @@ public class StringUtils {
145 145
             return null;
146 146
         }
147 147
     }
148
+
149
+    /**
150
+     * 简易脱敏
151
+     * @param source
152
+     * @param regx
153
+     * @param repl
154
+     * @return
155
+     */
156
+    public static String simpleSensitive(String source, String regx, String repl) {
157
+        if (isEmpty(source)) {
158
+            return source;
159
+        }
160
+
161
+        return source.replaceAll(regx, repl);
162
+    }
148 163
 }

+ 42
- 3
src/main/java/com/huiju/estateagents/controller/TaPersonController.java ファイルの表示

@@ -9,14 +9,13 @@ import com.huiju.estateagents.base.BaseController;
9 9
 import com.huiju.estateagents.base.ResponseBean;
10 10
 import com.huiju.estateagents.center.taUser.entity.TaUser;
11 11
 import com.huiju.estateagents.center.taUser.service.ITaUserService;
12
-import com.huiju.estateagents.common.CommConstant;
13
-import com.huiju.estateagents.common.SMSUtils;
14
-import com.huiju.estateagents.common.StringUtils;
12
+import com.huiju.estateagents.common.*;
15 13
 import com.huiju.estateagents.common.smsService.Captcha;
16 14
 import com.huiju.estateagents.entity.TaChannel;
17 15
 import com.huiju.estateagents.entity.TaChannelPerson;
18 16
 import com.huiju.estateagents.entity.TaPerson;
19 17
 import com.huiju.estateagents.entity.TaPersonBuilding;
18
+import com.huiju.estateagents.excel.TaPersonExport;
20 19
 import com.huiju.estateagents.service.*;
21 20
 import com.huiju.estateagents.third.entity.TaThirdPartyMiniappConfig;
22 21
 import com.huiju.estateagents.third.service.ITaThirdPartyMiniappConfigService;
@@ -28,6 +27,8 @@ import org.springframework.web.bind.annotation.*;
28 27
 import org.springframework.web.client.RestTemplate;
29 28
 
30 29
 import javax.servlet.http.HttpServletRequest;
30
+import javax.servlet.http.HttpServletResponse;
31
+import java.io.IOException;
31 32
 import java.time.LocalDateTime;
32 33
 import java.util.ArrayList;
33 34
 import java.util.HashMap;
@@ -826,4 +827,42 @@ public class TaPersonController extends BaseController {
826 827
         return ResponseBean.success(result);
827 828
     }
828 829
 
830
+    @GetMapping("/admin/person-list/export")
831
+    public ResponseBean getPersonListExport(@RequestParam(value = "name", required = false) String name,
832
+                                            @RequestParam(value = "phone", required = false) String phone,
833
+                                            @RequestParam(value = "recommended", required = false) String recommended,
834
+                                            HttpServletRequest request,
835
+                                            HttpServletResponse response) {
836
+        Integer orgId = getOrgId(request);
837
+
838
+        IPage<TaPerson> page = new Page<>(1, 9999);
839
+        IPage<TaPerson> result = taPersonService.getPersonBy(page, orgId, name, phone, recommended);
840
+
841
+        List<TaPerson> personList = result.getRecords();
842
+        List<TaPersonExport> data = new ArrayList<>();
843
+        if (null != personList) {
844
+//            String senRegx = "(\\\\d{3})\\\\d{4}(\\\\d{4})";
845
+//            String senRepl = "$1****$2";
846
+            for (TaPerson person: personList) {
847
+                TaPersonExport row = new TaPersonExport();
848
+                row.setNickname(person.getNickname());
849
+//                row.setPhone(StringUtils.simpleSensitive(person.getPhone(), senRegx, senRepl));
850
+                row.setPhone(person.getPhone());
851
+                row.setSharePersonName(person.getSharePersonName());
852
+                row.setPoints(person.getPoints());
853
+                row.setCreateDate(DateUtils.format(person.getCreateDate(), "yyyy-MM-dd HH:mm"));
854
+                data.add(row);
855
+            }
856
+        }
857
+
858
+        try {
859
+            ExcelUtils.flush(response, TaPersonExport.class, data, "会员列表");
860
+        } catch (IOException e) {
861
+            e.printStackTrace();
862
+            return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
863
+        }
864
+
865
+        return null;
866
+    }
867
+
829 868
 }

+ 29
- 0
src/main/java/com/huiju/estateagents/excel/TaPersonExport.java ファイルの表示

@@ -0,0 +1,29 @@
1
+package com.huiju.estateagents.excel;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
5
+import lombok.Data;
6
+
7
+@Data
8
+public class TaPersonExport {
9
+
10
+    @ColumnWidth(20)
11
+    @ExcelProperty(value = "姓名", index = 0)
12
+    private String nickname;
13
+
14
+    @ColumnWidth(15)
15
+    @ExcelProperty(value = "电话", index = 1)
16
+    private String phone;
17
+
18
+    @ColumnWidth(20)
19
+    @ExcelProperty(value = "推荐人", index = 2)
20
+    private String sharePersonName;
21
+
22
+    @ColumnWidth(10)
23
+    @ExcelProperty(value = "总积分", index = 3)
24
+    private Integer points;
25
+
26
+    @ColumnWidth(25)
27
+    @ExcelProperty(value = "创建时间", index = 4)
28
+    private String createDate;
29
+}