Browse Source

4/1 查询产品 查询产品类别 lrj

lwhhszx 1 year ago
parent
commit
b283d50f8c
27 changed files with 2823 additions and 13 deletions
  1. 12 0
      src/main/java/com/example/xiaoshiweixinback/business/common/base/Records.java
  2. 29 0
      src/main/java/com/example/xiaoshiweixinback/business/common/base/RedisConf.java
  3. 36 0
      src/main/java/com/example/xiaoshiweixinback/business/common/base/SystemFile.java
  4. 23 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/CacheUtil.java
  5. 38 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/LoginUtils.java
  6. 1325 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/RedisUtil.java
  7. 504 0
      src/main/java/com/example/xiaoshiweixinback/business/utils/StringUtils.java
  8. 31 0
      src/main/java/com/example/xiaoshiweixinback/controller/ProductCategoryController.java
  9. 30 0
      src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java
  10. 34 0
      src/main/java/com/example/xiaoshiweixinback/domain/AssoPersonCategory.java
  11. 2 1
      src/main/java/com/example/xiaoshiweixinback/domain/Product.java
  12. 2 1
      src/main/java/com/example/xiaoshiweixinback/domain/ProductCategory.java
  13. 13 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/GetProductDTO.java
  14. 0 3
      src/main/java/com/example/xiaoshiweixinback/entity/dto/LoginDTO.java
  15. 10 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductCategoryDTO.java
  16. 10 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductDTO.java
  17. 24 0
      src/main/java/com/example/xiaoshiweixinback/entity/dto/common/FMSDeleteFileDTO.java
  18. 9 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/PersonnelVO.java
  19. 56 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductCategoryVO.java
  20. 52 0
      src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductVO.java
  21. 18 0
      src/main/java/com/example/xiaoshiweixinback/mapper/AssoPersonCategoryMapper.java
  22. 6 0
      src/main/java/com/example/xiaoshiweixinback/mapper/ProductMapper.java
  23. 49 0
      src/main/java/com/example/xiaoshiweixinback/service/AssoPersonCategoryService.java
  24. 122 4
      src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java
  25. 109 4
      src/main/java/com/example/xiaoshiweixinback/service/ProductService.java
  26. 232 0
      src/main/java/com/example/xiaoshiweixinback/service/common/FileManagerService.java
  27. 47 0
      src/main/resources/mapper/ProductMapper.xml

+ 12 - 0
src/main/java/com/example/xiaoshiweixinback/business/common/base/Records.java

@@ -0,0 +1,12 @@
+package com.example.xiaoshiweixinback.business.common.base;
+
+import lombok.Data;
+
+@Data
+public class Records {
+    Object data;
+    Long total;
+    Long current;
+    Long size;
+    Integer retrieveRecordId;
+}

+ 29 - 0
src/main/java/com/example/xiaoshiweixinback/business/common/base/RedisConf.java

@@ -0,0 +1,29 @@
+package com.example.xiaoshiweixinback.business.common.base;
+
+
+/**
+ * Redis常量类
+ */
+public class RedisConf {
+
+    public static final String SYMBOL_COLON = ":";
+    public static final String SYMBOL_LINE = "-";
+    public final static String COMMON_DATA = "common-data";
+    public final static String LOGIN_USER = "login-user";
+    public final static String VERIFY_CODE = "verify-code";
+    public final static String SELECT_PATENT = "select-patent";
+    public final static String ANALYSIS_COUNT = "analysis-count";
+    public final static String AREA_LIST = "area-list";
+    public final static String USER_FIELD = "user-field";
+    public final static String FIELD_ORDER = "field-order";
+    public final static String USER_IMPORT = "user-import";
+    public final static String PROJECT_FIELD_ORDER = "project_field_order";
+    public final static String TASK_FIELD_ORDER = "task_field_order";
+    public final static String PATENT_COUNT = "patent-count";
+    public final static String TASK_FIELD_COUNT = "task_field_count";
+    public final static String PROJECT_FIELD_COUNT = "project_field_count";
+    public final static String FIELD_COUNT = "field_count";
+    public final static String PROJECT = "project";
+    public final static String PRODUCT = "product";
+    public final static String EVIDENCE_REASON = "evidence_reason";
+}

+ 36 - 0
src/main/java/com/example/xiaoshiweixinback/business/common/base/SystemFile.java

@@ -0,0 +1,36 @@
+package com.example.xiaoshiweixinback.business.common.base;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 系统文件实体类
+ *
+ * @Author xiexiang
+ * @Date 2023/6/1
+ */
+@Data
+
+public class SystemFile  {
+    /**
+     * 文件guid
+     */
+    private String guid;
+
+    /**
+     * 文件名称
+     */
+    private String fileName;
+
+    /**
+     * 原始名称
+     */
+    private String originalName;
+
+    /**
+     * 文件类型
+     */
+    private String type;
+}

+ 23 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/CacheUtil.java

@@ -0,0 +1,23 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+import cn.dev33.satoken.exception.NotLoginException;
+import com.example.xiaoshiweixinback.business.common.base.RedisConf;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CacheUtil {
+    @Resource
+    private RedisUtil redisUtil;
+
+
+    public PersonnelVO getLoginUser(Object userId) {
+        String json = redisUtil.get(RedisConf.LOGIN_USER + RedisConf.SYMBOL_COLON + userId);
+        if (StringUtils.isEmpty(json)) {
+            throw new NotLoginException("无数据", "user", "");
+        } else {
+            return com.alibaba.fastjson2.JSONObject.parseObject(json, PersonnelVO.class);
+        }
+    }
+}

+ 38 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/LoginUtils.java

@@ -0,0 +1,38 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import java.util.List;
+
+@Component
+public class LoginUtils {
+    @Resource
+    private RedisUtil redisUtil;
+
+    public static String getToken() {
+        RequestAttributes ra = RequestContextHolder.getRequestAttributes();
+        ServletRequestAttributes sra = (ServletRequestAttributes) ra;
+        HttpServletRequest httpRequest = sra.getRequest();
+        String tem = httpRequest.getHeader("Cookie");
+        List<String> lst = StringUtils.changeStringToString(tem, ";");
+        final String[] token = {null};
+        lst.forEach(item -> {
+            if (item.contains("token")) {
+                token[0] = item;
+            }
+        });
+        return token[0].replaceAll(" ", "");
+    }
+
+    public Integer getId() {
+        String oriToken = LoginUtils.getToken();
+        String q = "token:login:" + oriToken.replace("=", ":");
+        String IdS = redisUtil.get(q);
+        return Integer.parseInt(IdS);
+    }
+}

File diff suppressed because it is too large
+ 1325 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/RedisUtil.java


+ 504 - 0
src/main/java/com/example/xiaoshiweixinback/business/utils/StringUtils.java

@@ -0,0 +1,504 @@
+package com.example.xiaoshiweixinback.business.utils;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+@Slf4j
+public class StringUtils {
+
+    private final static int NUM_32 = 32;
+    //集群号
+    private static int machineId = 1;
+    /**
+     * 下划线
+     */
+    private static final char SEPARATOR = '_';
+
+    /**
+     * 下划线转驼峰命名
+     */
+    public static String toUnderScoreCase(String str) {
+        if (str == null) {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder();
+        // 前置字符是否大写
+        boolean preCharIsUpperCase = true;
+        // 当前字符是否大写
+        boolean curreCharIsUpperCase = true;
+        // 下一字符是否大写
+        boolean nexteCharIsUpperCase = true;
+        for (int i = 0; i < str.length(); i++) {
+            char c = str.charAt(i);
+            if (i > 0) {
+                preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
+            } else {
+                preCharIsUpperCase = false;
+            }
+
+            curreCharIsUpperCase = Character.isUpperCase(c);
+
+            if (i < (str.length() - 1)) {
+                nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
+            }
+
+            if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) {
+                sb.append(SEPARATOR);
+            } else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) {
+                sb.append(SEPARATOR);
+            }
+            sb.append(Character.toLowerCase(c));
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * * 判断一个对象是否非空
+     *
+     * @param object Object
+     * @return true:非空 false:空
+     */
+    public static boolean isNotNull(Object object) {
+        return !isNull(object);
+    }
+
+    public static boolean isNull(Object object) {
+        return object == null;
+    }
+
+
+    /**
+     * 把String 转换为 long
+     *
+     * @param str
+     * @param defaultData
+     * @return
+     */
+    public static long getLong(String str, Long defaultData) {
+        Long lnum = defaultData;
+
+        if (isEmpty(str)) {
+            return lnum;
+        }
+        try {
+            lnum = Long.valueOf(str.trim()).longValue();
+        } catch (NumberFormatException e) {
+            log.warn("把String 转换为 long======== " + str);
+        }
+        return lnum;
+
+    }
+
+    /**
+     * 转换成Boolean类型
+     *
+     * @param str
+     * @param defaultData
+     * @return
+     */
+    public static Boolean getBoolean(String str, Boolean defaultData) {
+        Boolean lnum = defaultData;
+
+        if (isEmpty(str)) {
+            return lnum;
+        }
+        try {
+            lnum = Boolean.valueOf(str.trim()).booleanValue();
+        } catch (NumberFormatException e) {
+            log.warn("把String 转换为 long======== " + str);
+        }
+        return lnum;
+
+    }
+
+    /**
+     * 把String转换成int数据
+     *
+     * @param str
+     * @param defaultData
+     * @return
+     */
+    public static int getInt(String str, Integer defaultData) {
+        int inum = defaultData;
+        if (isEmpty(str)) {
+            return inum;
+        }
+        try {
+            inum = Integer.valueOf(str.trim()).intValue();
+        } catch (NumberFormatException e) {
+            log.warn("把String转换成int数据========== " + str);
+        }
+        return inum;
+    }
+
+    /**
+     * 把String转换成double数据
+     *
+     * @param str
+     * @param defaultData
+     * @return
+     */
+    public static double getDouble(String str, Double defaultData) {
+        double dnum = defaultData;
+        if (isEmpty(str)) {
+            return dnum;
+        }
+        try {
+            dnum = Double.valueOf(str.trim()).doubleValue();
+        } catch (NumberFormatException e) {
+            log.error("把String转换成double数据: {}", str);
+        }
+        return dnum;
+    }
+
+    /**
+     * 把String转换成float数据
+     *
+     * @param str
+     * @param defaultData
+     * @return
+     */
+    public static float getFloat(String str, Float defaultData) {
+        float dnum = defaultData;
+        if (isEmpty(str)) {
+            return dnum;
+        }
+        try {
+            dnum = Float.valueOf(str.trim()).floatValue();
+        } catch (NumberFormatException e) {
+            log.error("把String转换成float数据: {}", str);
+        }
+        return dnum;
+    }
+
+    /**
+     * 判断字符串是否为空
+     *
+     * @param s
+     * @return
+     */
+    public static Boolean isEmpty(String s) {
+        if (s == null || s.length() <= 0) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 判断字符串是否为空
+     *
+     * @param str
+     * @return
+     */
+    public static boolean isNotEmpty(String str) {
+        return !StringUtils.isEmpty(str);
+    }
+
+    /**
+     * 按code截取字符串
+     *
+     * @return
+     */
+    public static String[] split(String str, String code) {
+        String[] split;
+        if (isEmpty(str)) {
+            split = null;
+        } else {
+            split = str.split(code);
+        }
+        return split;
+    }
+
+    /**
+     * 把字符串按code 转换为List<Long>
+     *
+     * @param str
+     * @return
+     */
+    public static List<Long> changeStringToLong(String str, String code) {
+        String[] split = split(str, code);
+        List<Long> lnums = new ArrayList<>();
+        for (String s : split) {
+            if (!isEmpty(s)) {
+                long lnum = getLong(s, 0L);
+                lnums.add(lnum);
+            }
+
+        }
+        return lnums;
+    }
+
+    /**
+     * 把字符串按code 转换为List<String>
+     *
+     * @param str
+     * @return
+     */
+    public static List<String> changeStringToString(String str, String code) {
+        String[] split = split(str, code);
+        List<String> lnums = new ArrayList<>();
+        for (String s : split) {
+            String trim = s.trim();
+            lnums.add(trim);
+        }
+        return lnums;
+    }
+
+    /**
+     * 把字符串按code 转换为List<Long>
+     *
+     * @param str
+     * @return
+     */
+    public static List<Integer> changeStringToInteger(String str, String code) {
+        if (isEmpty(str)) {
+            return new ArrayList<>();
+        }
+        String[] split = split(str, code);
+        List<Integer> inums = new ArrayList<>();
+        for (String s : split) {
+            int inum = getInt(s, 0);
+            inums.add(inum);
+        }
+        return inums;
+    }
+
+
+    /**
+     * 生成唯一订单号
+     *
+     * @return
+     */
+    public static String getOrderNumberByUUID() {
+
+        int hashCodeV = UUID.randomUUID().toString().hashCode();
+        //有可能是负数
+        if (hashCodeV < 0) {
+            hashCodeV = -hashCodeV;
+        }
+        String orderNumber = machineId + String.format("%015d", hashCodeV);
+        return orderNumber;
+    }
+
+    /**
+     * 生成唯一商户退款单号
+     *
+     * @return
+     */
+    public static String getOutRefundNoByUUID() {
+
+        int hashCodeV = UUID.randomUUID().toString().hashCode();
+        //有可能是负数
+        if (hashCodeV < 0) {
+            hashCodeV = -hashCodeV;
+        }
+        String out_refund_no = "BACK" + machineId + String.format("%015d", hashCodeV);
+        return out_refund_no;
+
+    }
+
+    /**
+     * 获取UUID,去掉了-
+     *
+     * @return
+     */
+    public static String getUUID() {
+        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+        log.debug("获取32位的UUID的调试日志-->>" + uuid);
+        return uuid;
+    }
+
+    /**
+     * 获取雪花UID
+     *
+     * @return
+     */
+//    public static Long getSnowflakeId() {
+//        SnowflakeIdWorker snowflakeIdWorker = new SnowflakeIdWorker(0, 0);
+//        return snowflakeIdWorker.nextId();
+//    }
+
+    /**
+     * list小于0的数据就过滤了
+     * 把list的数组变成1,3,4,5,6
+     *
+     * @param list
+     * @param code
+     * @return
+     */
+    public static String listToString(List<Long> list, String code) {
+        String s = "";
+        if (list == null || list.size() <= 0) {
+            return s;
+        }
+        for (Long l : list) {
+            if (l.longValue() > 0) {
+                s = s + l + code;
+            }
+        }
+        return s;
+    }
+
+    /**
+     * 按code把list的数组转换成字符串
+     *
+     * @param list
+     * @param code
+     * @return
+     */
+    public static String listTranformString(List<String> list, String code) {
+        String s = "";
+        if (list == null || list.size() <= 0) {
+            return s;
+        }
+        s = String.join(code, list);
+        return s;
+    }
+
+    /**
+     * 判断是否为非空字符串
+     *
+     * @param str
+     * @return
+     */
+    public static boolean isNotBlank(String str) {
+        return !StringUtils.isBlank(str);
+    }
+
+    /**
+     * 校验uid列表,检查里面元素是否满足限定长度为32
+     *
+     * @param collection
+     * @return
+     */
+    public static boolean checkUidList(Collection<String> collection) {
+        if (collection.size() == 0) {
+            return false;
+        }
+        for (String uid : collection) {
+            if (uid.trim().length() != NUM_32) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 判断是否为空字符串
+     *
+     * @param str
+     * @return
+     */
+    public static boolean isBlank(String str) {
+        int strLen;
+        if (str == null || (strLen = str.length()) == 0) {
+            return true;
+        }
+        for (int i = 0; i < strLen; i++) {
+            if ((Character.isWhitespace(str.charAt(i)) == false)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 判断一个字符串是否为数字
+     *
+     * @param str
+     * @return
+     */
+    public static boolean isNumeric(String str) {
+        try {
+            //把字符串强制转换为数字
+            Integer.valueOf(str);
+            //如果是数字,返回True
+            return true;
+        } catch (Exception e) {
+            //如果抛出异常,返回False
+            return false;
+        }
+    }
+
+    /**
+     * 某个子串是否在字符串内
+     *
+     * @param str
+     * @param searchChar
+     * @return
+     */
+    public static boolean contains(String str, String searchChar) {
+        if (isEmpty(str)) {
+            return false;
+        }
+        return str.indexOf(searchChar) >= 0;
+    }
+
+    /**
+     * 切割字符串
+     *
+     * @param str
+     * @param start
+     * @return
+     */
+    public static String substring(String str, int start) {
+        if (str == null) {
+            return null;
+        }
+        // handle negatives, which means last n characters
+        if (start < 0) {
+            start = str.length() + start;
+        }
+        if (start < 0) {
+            start = 0;
+        }
+        if (start > str.length()) {
+            return "";
+        }
+        return str.substring(start);
+    }
+
+    /**
+     * 判断评论是否为垃圾评论(仅通过单一字符重复出现来判断,以后可以扩展更多的检测方法)
+     *
+     * @param content
+     * @return
+     */
+    public static Boolean isCommentSpam(String content) {
+        if (content == null) {
+            return true;
+        }
+        char[] chars = content.toCharArray();
+        // 最大重复次数
+        Integer maxCount = 4;
+        for (int a = 0; a < chars.length; a++) {
+            Integer count = 1;
+            for (int b = a; b < chars.length - 1; b++) {
+                if (chars[b + 1] == chars[b]) {
+                    count++;
+                    // 判断字符重复的次数是否大于阈值
+                    if (count >= maxCount) {
+                        return true;
+                    }
+                    continue;
+                } else {
+                    break;
+                }
+            }
+        }
+        return false;
+    }
+
+    public static <T> String join(List<T> list, String separator) {
+        return org.apache.commons.lang3.StringUtils.join(list, separator);
+    }
+
+    public static <T> String join(String[] list, String separator) {
+        return org.apache.commons.lang3.StringUtils.join(list, separator);
+    }
+}

+ 31 - 0
src/main/java/com/example/xiaoshiweixinback/controller/ProductCategoryController.java

@@ -0,0 +1,31 @@
+package com.example.xiaoshiweixinback.controller;
+
+
+import com.example.xiaoshiweixinback.business.common.Constants;
+import com.example.xiaoshiweixinback.business.common.Response;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.entity.dto.ProductCategoryDTO;
+import com.example.xiaoshiweixinback.service.ProductCategoryService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/productCategory")
+@RestController
+@RequiredArgsConstructor
+public class ProductCategoryController {
+    private final ProductCategoryService productCategoryService;
+
+    @Operation(summary = "查询产品类别")
+    @PostMapping("/queryCategory")
+    private Response queryProductCategory(@RequestBody ProductCategoryDTO productCategoryDTO) {
+        Records records = productCategoryService.queryProductCategory(productCategoryDTO);
+        return Response.success(records);
+    }
+}

+ 30 - 0
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -0,0 +1,30 @@
+package com.example.xiaoshiweixinback.controller;
+
+
+import com.example.xiaoshiweixinback.business.common.Constants;
+import com.example.xiaoshiweixinback.business.common.Response;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.entity.dto.ProductDTO;
+import com.example.xiaoshiweixinback.service.ProductService;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/product")
+@RestController
+@RequiredArgsConstructor
+public class ProductController {
+private  final ProductService productService;
+    @Operation(summary = "查询爆款产品")
+    @PostMapping("/queryHotProduct")
+    public Response queryHotProduct(@RequestBody ProductDTO productDTO){
+        Records records =productService.queryHotProduct(productDTO);
+        return Response.success(records);
+    }
+
+}

+ 34 - 0
src/main/java/com/example/xiaoshiweixinback/domain/AssoPersonCategory.java

@@ -0,0 +1,34 @@
+package com.example.xiaoshiweixinback.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * 人员产品类别关联表
+ * @TableName asso_person_category
+ */
+@TableName(value ="asso_person_category")
+@Data
+public class AssoPersonCategory implements Serializable {
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     * 
+     */
+    private String personUuid;
+
+    /**
+     * 
+     */
+    private Integer productCategoryId;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 2 - 1
src/main/java/com/example/xiaoshiweixinback/domain/Product.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.util.Date;
 import lombok.Data;
+import org.joda.time.DateTime;
 
 /**
  * 产品
@@ -66,7 +67,7 @@ public class Product implements Serializable {
     /**
      * 
      */
-    private Date createTime;
+    private DateTime createTime;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;

+ 2 - 1
src/main/java/com/example/xiaoshiweixinback/domain/ProductCategory.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.util.Date;
 import lombok.Data;
+import org.joda.time.DateTime;
 
 /**
  * 产品类别
@@ -59,7 +60,7 @@ public class ProductCategory implements Serializable {
     /**
      * 
      */
-    private Date createTime;
+    private DateTime createTime;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;

+ 13 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/GetProductDTO.java

@@ -0,0 +1,13 @@
+package com.example.xiaoshiweixinback.entity.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class GetProductDTO {
+private List<Integer> categoryIds;
+private String name;
+private Long size;
+private Long current;
+}

+ 0 - 3
src/main/java/com/example/xiaoshiweixinback/entity/dto/LoginDTO.java

@@ -10,9 +10,6 @@ public class LoginDTO {
 
     private String password;
 
-    public String getUserName() {
-        return userName;
-    }
 
     public void setUserName(String userName) {
         this.userName = userName;

+ 10 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductCategoryDTO.java

@@ -0,0 +1,10 @@
+package com.example.xiaoshiweixinback.entity.dto;
+
+import lombok.Data;
+
+@Data
+public class ProductCategoryDTO {
+    private String name;
+    private Long current;
+    private Long size;
+}

+ 10 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/ProductDTO.java

@@ -0,0 +1,10 @@
+package com.example.xiaoshiweixinback.entity.dto;
+
+import lombok.Data;
+
+@Data
+public class ProductDTO {
+    private String name;
+    private Long current;
+    private Long size;
+}

+ 24 - 0
src/main/java/com/example/xiaoshiweixinback/entity/dto/common/FMSDeleteFileDTO.java

@@ -0,0 +1,24 @@
+package com.example.xiaoshiweixinback.entity.dto.common;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 调用FMS系统删除文件接口
+ *
+ * @Author xiexiang
+ * @Date 2023/8/14
+ */
+@Data
+public class FMSDeleteFileDTO {
+    /**
+     * 文件ids
+     */
+    private List<String> guids;
+
+    /**
+     * 删除类型(2物理删除 1逻辑删除)
+     */
+    private Integer type;
+}

+ 9 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/PersonnelVO.java

@@ -0,0 +1,9 @@
+package com.example.xiaoshiweixinback.entity.vo;
+
+import lombok.Data;
+
+@Data
+public class PersonnelVO {
+    private String uuid;
+    private Integer id;
+}

+ 56 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductCategoryVO.java

@@ -0,0 +1,56 @@
+package com.example.xiaoshiweixinback.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.joda.time.DateTime;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class ProductCategoryVO {
+
+    /**
+     * ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     *
+     */
+    private String name;
+
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+    /**
+     *
+     */
+    private String path;
+
+
+    /**
+     *
+     */
+    private String createName;
+
+    /**
+     *
+     */
+    private DateTime createTime;
+    private String createId;
+    @Schema(description = "文件信息")
+    private List<SystemFile> systemFileList;
+}

+ 52 - 0
src/main/java/com/example/xiaoshiweixinback/entity/vo/ProductVO.java

@@ -0,0 +1,52 @@
+package com.example.xiaoshiweixinback.entity.vo;
+
+import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class ProductVO {
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     *
+     */
+    private String name;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+
+    /**
+     * 售卖平台
+     */
+    private String sellPlatform;
+
+
+
+    /**
+     *
+     */
+    private String createName;
+
+    /**
+     *
+     */
+    private Date createTime;
+
+    @Schema(description = "文件信息")
+    private List<SystemFile> systemFileList;
+}

+ 18 - 0
src/main/java/com/example/xiaoshiweixinback/mapper/AssoPersonCategoryMapper.java

@@ -0,0 +1,18 @@
+package com.example.xiaoshiweixinback.mapper;
+
+import com.example.xiaoshiweixinback.domain.AssoPersonCategory;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author admin
+* @description 针对表【asso_person_category(人员产品类别关联表)】的数据库操作Mapper
+* @createDate 2024-04-01 14:40:55
+* @Entity xiaoshiweixinback.domain.AssoPersonCategory
+*/
+public interface AssoPersonCategoryMapper extends BaseMapper<AssoPersonCategory> {
+
+}
+
+
+
+

+ 6 - 0
src/main/java/com/example/xiaoshiweixinback/mapper/ProductMapper.java

@@ -2,6 +2,10 @@ package com.example.xiaoshiweixinback.mapper;
 
 import com.example.xiaoshiweixinback.domain.Product;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
+import com.example.xiaoshiweixinback.entity.vo.ProductVO;
+
+import java.util.List;
 
 /**
 * @author admin
@@ -11,6 +15,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 */
 public interface ProductMapper extends BaseMapper<Product> {
 
+    public List<ProductVO> getProductByCategory(GetProductDTO getProductDTO);
+    public Long getProductCount(GetProductDTO getProductDTO);
 }
 
 

+ 49 - 0
src/main/java/com/example/xiaoshiweixinback/service/AssoPersonCategoryService.java

@@ -0,0 +1,49 @@
+package com.example.xiaoshiweixinback.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
+import com.example.xiaoshiweixinback.domain.AssoPersonCategory;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.mapper.AssoPersonCategoryMapper;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+* @author admin
+* @description 针对表【asso_person_category(人员产品类别关联表)】的数据库操作Service实现
+* @createDate 2024-04-01 14:40:55
+*/
+@Service
+@RequiredArgsConstructor
+public class AssoPersonCategoryService extends ServiceImpl<AssoPersonCategoryMapper, AssoPersonCategory> {
+    private final CacheUtil cacheUtil;
+    private final LoginUtils loginUtils;
+    public List<Integer> getChoosedProductCategoryIds() {
+        List<Integer> ids = new ArrayList<>();
+        //PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
+        PersonnelVO personnelVO = new PersonnelVO();
+        personnelVO.setId(1);
+        personnelVO.setUuid("123");
+        LambdaQueryWrapper<AssoPersonCategory> queryWrapper =new LambdaQueryWrapper<>();
+        queryWrapper.eq(AssoPersonCategory::getPersonUuid,personnelVO.getUuid());
+        List<AssoPersonCategory> assoPersonCategories =this.list(queryWrapper);
+        if(assoPersonCategories.size()>0){
+            ids =assoPersonCategories.stream().map(AssoPersonCategory::getProductCategoryId).collect(Collectors.toList());
+        }
+
+        return ids;
+
+
+    }
+}
+
+
+
+

+ 122 - 4
src/main/java/com/example/xiaoshiweixinback/service/ProductCategoryService.java

@@ -1,17 +1,135 @@
 package com.example.xiaoshiweixinback.service;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
+import com.example.xiaoshiweixinback.domain.AssoCategoryFile;
+import com.example.xiaoshiweixinback.domain.AssoProductFile;
+import com.example.xiaoshiweixinback.domain.Person;
 import com.example.xiaoshiweixinback.domain.ProductCategory;
+import com.example.xiaoshiweixinback.entity.dto.ProductCategoryDTO;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.entity.vo.ProductCategoryVO;
+import com.example.xiaoshiweixinback.entity.vo.ProductVO;
 import com.example.xiaoshiweixinback.mapper.ProductCategoryMapper;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
-* @author admin
-* @description 针对表【product_category(产品类别)】的数据库操作Service实现
-* @createDate 2024-03-29 16:24:56
-*/
+ * @author admin
+ * @description 针对表【product_category(产品类别)】的数据库操作Service实现
+ * @createDate 2024-03-29 16:24:56
+ */
 @Service
+@RequiredArgsConstructor
 public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, ProductCategory> {
+    private final AssoPersonCategoryService assoPersonCategoryService;
+    private final AssoCategoryFileService assoCategoryFileService;
+    private final PersonService personService;
+    private final FileManagerService fileManagerService;
+
+    /**
+     * 查询产品类别
+     *
+     * @param productCategoryDTO
+     * @return
+     */
+    public Records queryProductCategory(ProductCategoryDTO productCategoryDTO) {
+        Records records = new Records();
+        Long size = productCategoryDTO.getSize();
+        Long current = productCategoryDTO.getCurrent();
+        records.setCurrent(current);
+        records.setSize(size);
+        String name = productCategoryDTO.getName();
+
+        LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        if (name != null && !name.trim().equals("")) {
+            queryWrapper.like(ProductCategory::getName, name);
+        }
+
+        List<ProductCategory> productCategoryList = new ArrayList<>();
+        if (size != null && current != null) {
+            IPage<ProductCategory> productCategoryIPage = this.page(new Page<>(current, size), queryWrapper);
+            productCategoryList = productCategoryIPage.getRecords();
+            records.setTotal(productCategoryIPage.getTotal());
+        } else {
+            productCategoryList = this.list(queryWrapper);
+
+        }
+
+        records.setData(productCategoryList);
+        return records;
+    }
+
+    private void loadProductCategory(List<ProductCategoryVO> productCategoryVOS) {
+        List<AssoCategoryFile> assoCategoryFiles = new ArrayList<>();
+        List<String> createIds = new ArrayList<>();
+        List<String> guids = new ArrayList<>();
+        if (productCategoryVOS == null || productCategoryVOS.size() == 0) {
+            return;
+        }
+        List<Integer> ids = productCategoryVOS.stream().map(ProductCategoryVO::getId).collect(Collectors.toList());
+        List<SystemFile> systemFiles = new ArrayList<>();
+        List<Person> personList = new ArrayList<>();
+        if (ids.size() != 0) {
+            //根据产品类别id获得产品类别与文件关联表
+            LambdaQueryWrapper<AssoCategoryFile> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(AssoCategoryFile::getCategoryId, ids);
+            assoCategoryFiles = assoCategoryFileService.list(queryWrapper);
+            guids = assoCategoryFiles.stream().map(AssoCategoryFile::getFileGuid).collect(Collectors.toList());
+
+        }
+
+        //查询创建人名称
+        if (createIds.size() != 0) {
+            LambdaQueryWrapper<Person> personLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            personLambdaQueryWrapper.in(Person::getUuid, createIds);
+            personList = personService.list(personLambdaQueryWrapper);
+        }
+        //查询文件
+        if (guids.size() != 0) {
+            try {
+                String res = fileManagerService.getSystemFileFromFMS(guids);
+                systemFiles = JSONObject.parseArray(res, SystemFile.class);
+                if (systemFiles == null) {
+                    systemFiles = new ArrayList<>();
+                }
+            } catch (Exception e) {
+            }
+
+        }
+
+        //装载登录人信息,装载
+        for (ProductCategoryVO productCategoryVO : productCategoryVOS) {
+            Person personnel = personList.stream().filter(item -> item.getUuid().toString().equals(productCategoryVO.getCreateId())).findFirst().orElse(null);
+            if (personnel != null) {
+                productCategoryVO.setCreateName(personnel.getName());
+            }
+            //装载文件信息
+            List<AssoCategoryFile> assoCategoryFilesTemp = assoCategoryFiles.stream().filter(item -> item.getCategoryId().equals(productCategoryVO.getId())).collect(Collectors.toList());
+            if (assoCategoryFilesTemp.size() != 0) {
+                List<String> guidTemp = assoCategoryFilesTemp.stream().map(AssoCategoryFile::getFileGuid).collect(Collectors.toList());
+                if (guidTemp.size() != 0) {
+                    List<SystemFile> systemFileTemp = systemFiles.stream().filter(item -> guidTemp.contains(item.getGuid())).collect(Collectors.toList());
+                    if (systemFileTemp.size() != 0) {
+                        productCategoryVO.setSystemFileList(systemFileTemp);
+                    }
+                }
+            }
+        }
+    }
 
 }
 

+ 109 - 4
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -1,18 +1,123 @@
 package com.example.xiaoshiweixinback.service;
 
+import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.common.base.Records;
+import com.example.xiaoshiweixinback.business.common.base.SystemFile;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
+import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.domain.Product;
+import com.example.xiaoshiweixinback.domain.ProductCategory;
+import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
+import com.example.xiaoshiweixinback.entity.dto.ProductDTO;
+import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
+import com.example.xiaoshiweixinback.entity.vo.ProductVO;
 import com.example.xiaoshiweixinback.mapper.ProductMapper;
+import com.example.xiaoshiweixinback.service.common.FileManagerService;
+import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
-* @author admin
-* @description 针对表【product(产品)】的数据库操作Service实现
-* @createDate 2024-03-29 16:23:21
-*/
+ * @author admin
+ * @description 针对表【product(产品)】的数据库操作Service实现
+ * @createDate 2024-03-29 16:23:21
+ */
 @Service
+@RequiredArgsConstructor
 public class ProductService extends ServiceImpl<ProductMapper, Product> {
+    private final AssoPersonCategoryService assoPersonCategoryService;
+    private final CacheUtil cacheUtil;
+    private final LoginUtils loginUtils;
+    private final AssoProductFileService assoProductFileService;
+    private final FileManagerService fileManagerService;
+
+    /**
+     * 查询爆款产品
+     *
+     * @param productDTO
+     * @return
+     */
+    public Records queryHotProduct(ProductDTO productDTO) {
+        Records records = new Records();
+        Long size = productDTO.getSize();
+        Long current = productDTO.getCurrent();
+        records.setCurrent(current);
+        records.setSize(size);
+        records.setData(new ArrayList<>());
+        records.setTotal(0L);
+        String name = productDTO.getName();
+
+        //查询登录人关联的产品类别id
+        List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
+
+        GetProductDTO getProductDTO = new GetProductDTO();
+        getProductDTO.setName(name);
+        getProductDTO.setCurrent(current);
+        getProductDTO.setSize(size);
+        getProductDTO.setCategoryIds(ids);
+        if (ids != null) {
+            List<ProductVO> productVOs = this.getBaseMapper().getProductByCategory(getProductDTO);
+            Long count = this.getBaseMapper().getProductCount(getProductDTO);
+            this.loadProduct(productVOs);
+            records.setData(productVOs);
+            records.setTotal(count);
+        }
+        return records;
+    }
+
+    private void loadProduct(List<ProductVO> productVOS) {
+        List<AssoProductFile> assoProductFiles = new ArrayList<>();
+        List<String> guids = new ArrayList<>();
+        if (productVOS == null||productVOS.size()==0) {
+            return;
+        }
+        List<Integer> ids = productVOS.stream().map(ProductVO::getId).collect(Collectors.toList());
+        List<SystemFile> systemFiles = new ArrayList<>();
+        if (ids.size() != 0) {
+            //根据产品类别id获得产品类别与文件关联表
+            LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.in(AssoProductFile::getProductId, ids);
+            assoProductFiles = assoProductFileService.list(queryWrapper);
+            guids = assoProductFiles.stream().map(AssoProductFile::getFileGuid).collect(Collectors.toList());
+
+        }
+
+        //查询文件
+        if (guids.size() != 0) {
+            try {
+                String res = fileManagerService.getSystemFileFromFMS(guids);
+                systemFiles = JSONObject.parseArray(res, SystemFile.class);
+                if (systemFiles == null) {
+                    systemFiles = new ArrayList<>();
+                }
+            } catch (Exception e) {
+            }
+
+        }
 
+        for (ProductVO productVO : productVOS) {
+//装载文件信息
+            List<AssoProductFile> assoProductFilesTemp = assoProductFiles.stream().filter(item -> item.getProductId().equals(productVO.getId())).collect(Collectors.toList());
+            if (assoProductFilesTemp.size() != 0) {
+                List<String> guidTemp = assoProductFilesTemp.stream().map(AssoProductFile::getFileGuid).collect(Collectors.toList());
+                if (guidTemp.size() != 0) {
+                    List<SystemFile> systemFileTemp = systemFiles.stream().filter(item -> guidTemp.contains(item.getGuid())).collect(Collectors.toList());
+                    if (systemFileTemp.size() != 0) {
+                        productVO.setSystemFileList(systemFileTemp);
+                    }
+                }
+            }
+        }
+    }
 }
 
 

+ 232 - 0
src/main/java/com/example/xiaoshiweixinback/service/common/FileManagerService.java

@@ -0,0 +1,232 @@
+package com.example.xiaoshiweixinback.service.common;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.example.xiaoshiweixinback.entity.dto.common.FMSDeleteFileDTO;
+import com.google.gson.Gson;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.commons.io.FileUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+
+import static cn.hutool.core.io.FileUtil.getMimeType;
+
+/**
+ * Okhttp调用FMS上传文件接口
+ *
+ * @Author xiexiang
+ * @Date 2023/8/10
+ */
+@RequiredArgsConstructor
+@Slf4j
+@Service
+public class FileManagerService {
+    @Value("${FMSUrl}")
+    private String FMSUrl;
+    @Value("${FileSource}")
+    private String FileSource;
+
+    /**
+     * 调用文件系统上传文件接口
+     *
+     * @param multipartFiles 文件
+     */
+    public String uploadFile(List<MultipartFile> multipartFiles) throws IOException {
+        List<File> files = new ArrayList<>();
+        for (MultipartFile multipartFile : multipartFiles) {
+            File file = new File(multipartFile.getOriginalFilename());
+            FileCopyUtils.copy(multipartFile.getBytes(), file);
+            files.add(file);
+        }
+        MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder()
+                .setType(MultipartBody.FORM);
+        for (File file : files) {
+            //根据文件名获取文件的MIME类型
+            String mimeType = getMimeType(file.getPath());
+            multipartBodyBuilder.addFormDataPart("files", file.getName(), RequestBody.create(MediaType.parse(mimeType), file));
+        }
+        RequestBody requestBody = multipartBodyBuilder
+                .addFormDataPart("sourceId", String.valueOf(FileSource))
+                .build();
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(FMSUrl + "/fileManager/uploadNormalFile")
+                .post(requestBody)
+                .build();
+        Response response = null;
+        response = okHttpClient.newCall(request).execute();
+        // 最后记得删除临时文件
+        for (File file : files) {
+            FileUtils.deleteQuietly(file);
+        }
+        return Objects.requireNonNull(response.body()).string();
+    }
+
+    public List<String> uploadFileGetGuid(List<MultipartFile> multipartFiles) throws IOException {
+        String res = this.uploadFile(multipartFiles);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        List<String> guids = JSONArray.parseArray(jsonObject.get("data").toString(), String.class);
+        return guids;
+    }
+
+    /**
+     * 调用文件系统取出文件接口(获得文件流)
+     *
+     * @param fieldId 文件id
+     */
+    public byte[] downloadSystemFileFromFMS(String fieldId) throws IOException {
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60000, TimeUnit.SECONDS)
+                .writeTimeout(60000, TimeUnit.SECONDS)
+                .readTimeout(60000, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(FMSUrl + "/fileManager/downloadFile?fileId=" + fieldId)
+                .get()
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).bytes();
+    }
+
+    /**
+     * 调用文件系统获取文件信息接口
+     *
+     * @param fileIds 文件ids
+     */
+    public String getSystemFileFromFMS(List<String> fileIds) throws IOException {
+        String param = new Gson().toJson(fileIds);
+        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(FMSUrl + "/fileManager/getFileData")
+                .post(requestBody)
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+    }
+
+    /**
+     * 调用文件系统删除文件接口
+     *
+     * @param ids 需要删除的文件ids
+     */
+    public String deleteFileFromFMS(List<String> ids) throws IOException {
+        FMSDeleteFileDTO fmsDeleteFileDTO = new FMSDeleteFileDTO();
+        fmsDeleteFileDTO.setGuids(ids);
+        fmsDeleteFileDTO.setType(2);
+        String param = new Gson().toJson(fmsDeleteFileDTO);
+        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), param);
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(FMSUrl + "/fileManager/deleteSystemFile")
+                .post(requestBody)
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+    }
+
+    public String uploadFileWithGuid(File file, String guid) throws IOException {
+        MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder()
+                .setType(MultipartBody.FORM);
+        //根据文件名获取文件的MIME类型
+        String mimeType = getMimeType(file.getPath());
+        multipartBodyBuilder.addFormDataPart("file", file.getName(), RequestBody.create(MediaType.parse(mimeType), file));
+        RequestBody requestBody = multipartBodyBuilder
+                .addFormDataPart("sourceId", String.valueOf(FileSource))
+                .addFormDataPart("fileGuid", guid)
+                .build();
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(FMSUrl + "/fileManager/replaceFile")
+                .post(requestBody)
+                .build();
+        Response response = null;
+        response = okHttpClient.newCall(request).execute();
+        // 最后记得删除临时文件
+        FileUtils.deleteQuietly(file);
+
+        return Objects.requireNonNull(response.body()).string();
+    }
+
+    /**
+     * 调用文件系统上传文件接口
+     */
+    public String uploadFile2(List<File> files) throws IOException {
+
+        MultipartBody.Builder multipartBodyBuilder = new MultipartBody.Builder()
+                .setType(MultipartBody.FORM);
+        for (File file : files) {
+            //根据文件名获取文件的MIME类型
+            String mimeType = getMimeType(file.getPath());
+            multipartBodyBuilder.addFormDataPart("files", file.getName(), RequestBody.create(MediaType.parse(mimeType), file));
+        }
+        RequestBody requestBody = multipartBodyBuilder
+                .addFormDataPart("sourceId", String.valueOf(FileSource))
+                .build();
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(FMSUrl + "/fileManager/uploadNormalFile")
+                .post(requestBody)
+                .build();
+        Response response = null;
+        response = okHttpClient.newCall(request).execute();
+        // 最后记得删除临时文件
+        for (File file : files) {
+            FileUtils.deleteQuietly(file);
+        }
+        return Objects.requireNonNull(response.body()).string();
+    }
+
+    public List<String> uploadFileGetGuid2(List<File> files) throws IOException {
+        String res = this.uploadFile2(files);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        List<String> guids = JSONArray.parseArray(jsonObject.get("data").toString(), String.class);
+        return guids;
+    }
+
+    /**
+     * 调用文件系统获得专利图片的guid
+     *
+     * @param appNo 申请号
+     */
+    public String getPatentPictureGuids(String appNo) throws IOException {
+        OkHttpClient okHttpClient = new OkHttpClient.Builder()
+                .connectTimeout(60, TimeUnit.SECONDS)
+                .writeTimeout(60, TimeUnit.SECONDS)
+                .readTimeout(60, TimeUnit.SECONDS)
+                .build();
+        Request request = new Request.Builder()
+                .url(FMSUrl + "/fileManager/getPatentPictureGuids?appNo=" + appNo)
+                .get()
+                .build();
+        return Objects.requireNonNull(okHttpClient.newCall(request).execute().body()).string();
+    }
+}

+ 47 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.example.xiaoshiweixinback.mapper.ProductMapper">
+
+    <select id="getProductByCategory" resultType="com.example.xiaoshiweixinback.entity.vo.ProductVO">
+        select distinct p.id as id,p.name as name,p.description as description,p.sell_platform as sellPlatform,pe.name as createName p.create_time as createTime from product as p left join
+        asso_product_category as apc on p.id =product_id
+        left join person as pe on p.create_id =pe.uuid
+        <where>
+       p.if_hot = true and p.if_show =true
+        <if test="getProductDTO.name!=null and getProductDTO.name.trim().equal('')">
+           and p.name like CONCAT('%',#{getProductDTO.name},'%')
+        </if>
+            <if test="getProductDTO.getProductByCategory!=null and getProductDTO.getProductByCategory.size()>0">
+              and  apc.product_category_id in
+                <foreach collection="getProductDTO.getProductByCategory" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="getProductDTO.current!=null and getProductDTO.size!=null">
+                limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.current*getProductDTO.size}
+            </if>
+        </where>
+
+    </select>
+
+
+    <select id="getProductCount" resultType="java.lang.Long">
+      select count(*) from (select distinct p.id as id from product as p left join
+        asso_product_category as apc on p.id =product_id
+        left join person as pe on p.create_id =pe.uuid
+        <where>
+            p.if_hot = true and p.if_show =true
+            <if test="getProductDTO.name!=null and getProductDTO.name.trim().equal('')">
+               and  p.name like CONCAT('%',#{getProductDTO.name},'%')
+            </if>
+            <if test="getProductDTO.getProductByCategory!=null and getProductDTO.getProductByCategory.size()>0">
+                and  apc.product_category_id in
+                <foreach collection="getProductDTO.getProductByCategory" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+          )  as c
+
+    </select>
+</mapper>