Browse Source

Merge remote-tracking branch 'origin/master'

openHj 11 months ago
parent
commit
58d5270ff5
19 changed files with 260 additions and 35 deletions
  1. 2 1
      hx-admin/pom.xml
  2. 0 8
      hx-admin/src/main/resources/application-dev.yml
  3. 7 9
      hx-admin/src/main/resources/application-prod.yml
  4. 3 7
      hx-admin/src/main/resources/application-test.yml
  5. 13 7
      hx-admin/src/main/resources/application.yml
  6. 8 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/carousel/CarouselManagerController.java
  7. 9 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/product/ProductCategoryController.java
  8. 8 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/product/ProductInfoController.java
  9. 86 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/filter/BrowsingFilter.java
  10. 1 1
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/about/impl/AboutUsHonorServiceImpl.java
  11. 2 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/carousel/CarouselManagerService.java
  12. 13 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/carousel/impl/CarouselManagerServiceImpl.java
  13. 3 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/column/impl/ColumnArticleServiceImpl.java
  14. 2 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/ProductCategoryService.java
  15. 2 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/ProductInfoService.java
  16. 7 2
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductCategoryServiceImpl.java
  17. 8 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductInfoServiceImpl.java
  18. 85 0
      hx-xmhjc/src/main/java/com/fjhx/xmhjc/utils/NetUtils.java
  19. 1 0
      pom.xml

+ 2 - 1
hx-admin/pom.xml

@@ -67,7 +67,8 @@
                 </configuration>
             </plugin>
         </plugins>
-        <finalName>${project.artifactId}</finalName>
+<!--        <finalName>${project.artifactId}</finalName>-->
+        <finalName>hx-xmhjc-web</finalName>
     </build>
 
 </project>

+ 0 - 8
hx-admin/src/main/resources/application-dev.yml

@@ -5,14 +5,6 @@ spring:
       strict: true
       primary: base
       datasource:
-#        base:
-        #          url: jdbc:mysql://121.37.194.75:30102/bytesailing_base1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
-        #          username: xmhjc
-        #          password: 2j^q9*DF
-        #        common:
-        #          url: jdbc:mysql://121.37.194.75:30102/bytesailing_common1?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
-        #          username: xmhjc
-        #          password: 2j^q9*DF
         base:
           url: jdbc:mysql://121.37.194.75:30102/bytesailing_xmhjc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
           username: xmhjc

+ 7 - 9
hx-admin/src/main/resources/application-prod.yml

@@ -6,24 +6,20 @@ spring:
       primary: base
       datasource:
         base:
-          url: jdbc:mysql://121.37.194.75:30102/bytesailing_base?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
+          url: jdbc:mysql://172.17.0.4:3306/bytesailing_xmhjc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
           username: root
-          password: 5fWD*oa^nso@kmKa
-        common:
-          url: jdbc:mysql://121.37.194.75:30102/bytesailing_common?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
-          username: root
-          password: 5fWD*oa^nso@kmKa
+          password: PdKKy%vZ)2mGykg
 
   # redis 配置
   redis:
     # 地址
     host: 127.0.0.1
     # 端口,默认为6379
-    port: 31347
+    port: 5000
     # 数据库索引
     database: 1
     # 密码
-    password: w3G_11h4YjrsO_6P5Oi
+    password: Z?(?wpxfUke)1im
     # 连接超时时间
     timeout: 10s
     lettuce:
@@ -38,6 +34,8 @@ spring:
         max-wait: -1ms
 
 server:
+  # 服务器的HTTP端口,默认为8080
+  port: 1000
   servlet:
     context-path: /prod-api
 
@@ -47,7 +45,7 @@ mail:
   abroadUrlPrefix:
 
 hx:
-  httpUrl: http://139.159.251.109:81/prod-api/
+  httpUrl: http://haijiacheng.com/prod-api/
 
 # token配置
 token:

+ 3 - 7
hx-admin/src/main/resources/application-test.yml

@@ -6,13 +6,9 @@ spring:
       primary: base
       datasource:
         base:
-          url: jdbc:mysql://121.37.194.75:30102/bytesailing_base?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
-          username: root
-          password: 5fWD*oa^nso@kmKa
-        common:
-          url: jdbc:mysql://121.37.194.75:30102/bytesailing_common?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
-          username: root
-          password: 5fWD*oa^nso@kmKa
+          url: jdbc:mysql://121.37.194.75:30102/bytesailing_xmhjc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=Asia/Shanghai
+          username: xmhjc
+          password: 2j^q9*DF
 
   # redis 配置
   redis:

+ 13 - 7
hx-admin/src/main/resources/application.yml

@@ -60,9 +60,9 @@ spring:
   servlet:
     multipart:
       # 单个文件大小
-      max-file-size: 10MB
+      max-file-size: 100MB
       # 设置总上传的文件大小
-      max-request-size: 20MB
+      max-request-size: 200MB
   main:
     allow-circular-references: true
 
@@ -158,8 +158,14 @@ xss:
   urlPatterns: /system/*,/monitor/*,/tool/*
 
 obs:
-  ak: 9HNBVBHO7F3GLUCGTK5C
-  sk: ZowLEoMJrICA9tOyln0yWVm0xGSiupe0gnbsZimk
-  endPoint: obs.cn-south-1.myhuaweicloud.com
-  url: https://os.winfaster.cn/
-  bucketName: winfaster
+  #huawei / tencent
+  type: tencent
+  region: ap-shanghai
+  uploadMethod: back
+  #secretId
+  ak: AKIDmPqHhzAHM9sSwFd4dHpIm9MNBnMnIk7T
+  #secretKey
+  sk: XBjFf1Lc1VM3b1IRtHPKIRZhyCYqDf1G
+  endPoint: cos.ap-shanghai.myqcloud.com
+  url: https://xmhjc-1322241475.cos.ap-shanghai.myqcloud.com/
+  bucketName: xmhjc-1322241475

+ 8 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/carousel/CarouselManagerController.java

@@ -67,6 +67,14 @@ public class CarouselManagerController {
     }
 
     /**
+     * 轮播图管理编辑
+     */
+    @PostMapping("/changeStatus")
+    public void changeStatus(@RequestBody CarouselManagerDto carouselManagerDto) {
+        carouselManagerService.changeStatus(carouselManagerDto);
+    }
+
+    /**
      * 轮播图管理删除
      */
     @PostMapping("/delete")

+ 9 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/product/ProductCategoryController.java

@@ -1,6 +1,7 @@
 package com.fjhx.xmhjc.controller.product;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.fjhx.xmhjc.entity.product.dto.ProductInfoDto;
 import com.fjhx.xmhjc.entity.product.dto.ProductInfoSelectDto;
 import com.fjhx.xmhjc.entity.product.po.ProductInfo;
 import com.fjhx.xmhjc.entity.product.vo.ProductInfoVo;
@@ -88,4 +89,12 @@ public class ProductCategoryController {
         productCategoryService.delete(dto.getId());
     }
 
+    /**
+     * 产品信息修改状态
+     */
+    @PostMapping("/changeStatus")
+    public void changeStatus(@RequestBody ProductCategoryDto productCategoryDto) {
+        productCategoryService.changeStatus(productCategoryDto);
+    }
+
 }

+ 8 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/product/ProductInfoController.java

@@ -1,5 +1,6 @@
 package com.fjhx.xmhjc.controller.product;
 
+import com.fjhx.xmhjc.entity.carousel.dto.CarouselManagerDto;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.xmhjc.entity.product.vo.ProductInfoVo;
@@ -74,4 +75,11 @@ public class ProductInfoController {
         productInfoService.delete(dto.getId());
     }
 
+    /**
+     * 产品信息修改状态
+     */
+    @PostMapping("/changeStatus")
+    public void changeStatus(@RequestBody ProductInfoDto productInfoDto) {
+        productInfoService.changeStatus(productInfoDto);
+    }
 }

+ 86 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/filter/BrowsingFilter.java

@@ -0,0 +1,86 @@
+package com.fjhx.xmhjc.filter;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.fjhx.xmhjc.utils.NetUtils;
+import com.ruoyi.common.core.redis.RedisCache;
+import org.springframework.core.Ordered;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+import org.springframework.util.AntPathMatcher;
+import org.springframework.util.PathMatcher;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 浏览记录过滤器
+ * @author hj
+ * @date 2024年03月12日 9:47
+ */
+@Component
+public class BrowsingFilter implements Filter {
+    private static final RedisCache redisCache = SpringUtil.getBean(RedisCache.class);
+
+    private static final String[] FILTER_URL = {"/open/**"};
+
+
+
+
+    @Override
+    public void init(FilterConfig filterConfig) throws ServletException {
+        Filter.super.init(filterConfig);
+    }
+
+    @Override
+    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+        HttpServletRequest request = (HttpServletRequest) servletRequest;
+        String requestUrl = request.getRequestURI();
+
+        PathMatcher matcher = new AntPathMatcher();
+        boolean match = false;
+
+        filterChain.doFilter(servletRequest, servletResponse);
+        for(String url : FILTER_URL){
+            match = matcher.match(url, requestUrl);
+            if (match){
+                String ip = NetUtils.getIpAddress(request);
+                String key = "browsing:" + ip + "#" + DateUtil.today();
+                //判断redis中是否存在key,存在则不记录
+                if(validRedisKey(key)){
+                    filterChain.doFilter(servletRequest, servletResponse);
+                    return;
+                }
+                //TODO 记录浏览记录入库
+
+
+                break;
+            }
+        }
+    }
+
+    @Override
+    public void destroy() {
+        Filter.super.destroy();
+    }
+
+
+    /**
+     * 判断redis中是否存在key
+     * @param key
+     * @return true 存在 false 不存在
+     */
+    private synchronized boolean validRedisKey(String key){
+        String cacheObject = redisCache.getCacheObject(key);
+        if(StrUtil.isNotBlank(cacheObject)){
+            return true;
+        }
+        //不存在则记录
+        redisCache.setCacheObject(key, key, 1, TimeUnit.DAYS);
+        return false;
+    }
+}

+ 1 - 1
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/about/impl/AboutUsHonorServiceImpl.java

@@ -45,7 +45,7 @@ public class AboutUsHonorServiceImpl extends ServiceImpl<AboutUsHonorMapper, Abo
 
         IWrapper<AboutUsHonor> wrapper = getWrapper();
         wrapper.orderByAsc("auh", AboutUsHonor::getSort);
-        wrapper.keyword(dto,new SqlField("auc", AboutUsHonor::getHonorName));
+        wrapper.keyword(dto,new SqlField("auh", AboutUsHonor::getHonorName));
         Page<AboutUsHonorVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;
     }

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/carousel/CarouselManagerService.java

@@ -52,4 +52,6 @@ public interface CarouselManagerService extends BaseService<CarouselManager> {
     Page<CarouselManagerVo> pageByOpen(CarouselManagerSelectDto dto);
 
     void checkDelete(Long id);
+
+    void changeStatus(CarouselManagerDto carouselManagerDto);
 }

+ 13 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/carousel/impl/CarouselManagerServiceImpl.java

@@ -68,6 +68,13 @@ public class CarouselManagerServiceImpl extends ServiceImpl<CarouselManagerMappe
     @Override
     public void edit(CarouselManagerDto carouselManagerDto) {
         this.updateById(carouselManagerDto);
+        if ("1".equals(carouselManagerDto.getTargetType())){
+            //文章的话更新掉外链url
+            this.lambdaUpdate().set(CarouselManager::getUrl,null).eq(CarouselManager::getId,carouselManagerDto.getId()).update();
+        } else if ("2".equals(carouselManagerDto.getTargetType())){
+            //外链的话更新掉文章id
+            this.lambdaUpdate().set(CarouselManager::getArticleId,null).set(CarouselManager::getColumnId,null).eq(CarouselManager::getId,carouselManagerDto.getId()).update();
+        }
         // 保存图片
         ObsFileUtil.editFile(carouselManagerDto.getCarouselUrlList(), carouselManagerDto.getId(), 1);
     }
@@ -101,4 +108,10 @@ public class CarouselManagerServiceImpl extends ServiceImpl<CarouselManagerMappe
             throw new RuntimeException("该文章已被轮播图配置引用,无法禁用或删除!");
         }
     }
+
+    @Override
+    public void changeStatus(CarouselManagerDto carouselManagerDto) {
+        lambdaUpdate().set(CarouselManager::getStatus,carouselManagerDto.getStatus())
+                .eq(CarouselManager::getId,carouselManagerDto.getId()).update();
+    }
 }

+ 3 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/column/impl/ColumnArticleServiceImpl.java

@@ -75,6 +75,7 @@ public class ColumnArticleServiceImpl extends ServiceImpl<ColumnArticleMapper, C
             wrapper.like("ca", ColumnArticle::getTitle, dto.getTitle());
         }
         wrapper.orderByAsc("ca", ColumnArticle::getSort);
+        wrapper.orderByDesc("ca", ColumnArticle::getTime);
         List<ColumnArticleVo> list = this.baseMapper.getList(wrapper);
         return list;
     }
@@ -93,6 +94,7 @@ public class ColumnArticleServiceImpl extends ServiceImpl<ColumnArticleMapper, C
             wrapper.eq("ca", ColumnArticle::getSubId, dto.getSubId());
         }
         wrapper.orderByAsc("ca", ColumnArticle::getSort);
+        wrapper.orderByDesc("ca", ColumnArticle::getTime);
         Page<ColumnArticleVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
 
         Map<Long, String> map = columnMenuService.getList(new ColumnMenuSelectDto()).stream().collect(Collectors.toMap(ColumnMenuVo::getId, ColumnMenuVo::getName));
@@ -175,6 +177,7 @@ public class ColumnArticleServiceImpl extends ServiceImpl<ColumnArticleMapper, C
             wrapper.eq("ca", ColumnArticle::getSubId, dto.getSubId());
         }
         wrapper.orderByAsc("ca", ColumnArticle::getSort);
+        wrapper.orderByDesc("ca", ColumnArticle::getTime);
         Page<ColumnArticleVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
 
         page.getRecords().forEach(x->{

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/ProductCategoryService.java

@@ -50,4 +50,6 @@ public interface ProductCategoryService extends BaseService<ProductCategory> {
     void delete(Long id);
 
     List<ProductCategoryVo> listByOpen();
+
+    void changeStatus(ProductCategoryDto productCategoryDto);
 }

+ 2 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/ProductInfoService.java

@@ -52,4 +52,6 @@ public interface ProductInfoService extends BaseService<ProductInfo> {
     Page<ProductInfoVo> pageByOpen(Long categoryId, Long subCategoryId, ProductInfoSelectDto dto);
 
     ProductInfoVo detailByOpen(Long id);
+
+    void changeStatus(ProductInfoDto productInfoDto);
 }

+ 7 - 2
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductCategoryServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
 import com.fjhx.file.entity.FileInfoVo;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.xmhjc.entity.product.po.ProductCategory;
+import com.fjhx.xmhjc.entity.product.po.ProductInfo;
 import com.fjhx.xmhjc.entity.product.po.ProductSubCategory;
 import com.fjhx.xmhjc.entity.product.vo.ProductSubCategoryVo;
 import com.fjhx.xmhjc.mapper.product.ProductCategoryMapper;
@@ -110,8 +111,12 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
             Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(businessIdList, 1);
             x.setCategoryCoverList(fileMap.get(x.getId()));
         });
-
-
         return list;
     }
+
+    @Override
+    public void changeStatus(ProductCategoryDto productCategoryDto) {
+        lambdaUpdate().set(ProductCategory::getStatus, productCategoryDto.getStatus())
+                .eq(ProductCategory::getId, productCategoryDto.getId()).update();
+    }
 }

+ 8 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductInfoServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
 import com.fjhx.file.entity.FileInfoVo;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.tenant.service.dict.DictTenantDataService;
+import com.fjhx.xmhjc.entity.carousel.po.CarouselManager;
 import com.fjhx.xmhjc.entity.product.po.ProductInfo;
 import com.fjhx.xmhjc.mapper.product.ProductInfoMapper;
 import com.fjhx.xmhjc.service.product.ProductInfoService;
@@ -146,6 +147,13 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         return result;
     }
 
+
+    @Override
+    public void changeStatus(ProductInfoDto productInfoDto) {
+        lambdaUpdate().set(ProductInfo::getStatus, productInfoDto.getStatus())
+                .eq(ProductInfo::getId, productInfoDto.getId()).update();
+    }
+
     private void buildFile(ProductInfoVo result) {
         List<Long> businessIdList = new ArrayList<>();
         businessIdList.add(result.getId());

+ 85 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/utils/NetUtils.java

@@ -0,0 +1,85 @@
+package com.fjhx.xmhjc.utils;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.UnknownHostException;
+
+/**
+ * 网络工具类
+ *
+ */
+public class NetUtils {
+
+    /**
+     * 获取客户端 IP 地址
+     *
+     * @param request
+     * @return
+     */
+    public static String getIpAddress(HttpServletRequest request) {
+        String ip = request.getHeader("x-forwarded-for");
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+            if (ip.equals("127.0.0.1")) {
+                // 根据网卡取本机配置的 IP
+                InetAddress inet = null;
+                try {
+                    inet = InetAddress.getLocalHost();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                if (inet != null) {
+                    ip = inet.getHostAddress();
+                }
+            }
+        }
+        // 多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
+        if (ip != null && ip.length() > 15) {
+            if (ip.indexOf(",") > 0) {
+                ip = ip.substring(0, ip.indexOf(","));
+            }
+        }
+        // 本机访问
+        if ("localhost".equalsIgnoreCase(ip) || "127.0.0.1".equalsIgnoreCase(ip) || "0:0:0:0:0:0:0:1".equalsIgnoreCase(ip)){
+            // 根据网卡取本机配置的IP
+            InetAddress inet;
+            try {
+                inet = InetAddress.getLocalHost();
+                ip = inet.getHostAddress();
+            } catch (UnknownHostException e) {
+                e.printStackTrace();
+            }
+        }
+        // 如果查找不到 IP,可以返回 127.0.0.1,可以做一定的处理,但是这里不考虑
+        // if (ip == null) {
+        //     return "127.0.0.1";
+        // }
+        return ip;
+    }
+    
+  /**
+     * 获取mac地址
+     */
+    public static String getMacAddress() throws Exception {
+        // 取mac地址
+        byte[] macAddressBytes = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()).getHardwareAddress();
+        // 下面代码是把mac地址拼装成String
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < macAddressBytes.length; i++) {
+            if (i != 0) {
+                sb.append("-");
+            }
+            // mac[i] & 0xFF 是为了把byte转化为正整数
+            String s = Integer.toHexString(macAddressBytes[i] & 0xFF);
+            sb.append(s.length() == 1 ? 0 + s : s);
+        }
+        return sb.toString().trim().toUpperCase();
+    }
+}

+ 1 - 0
pom.xml

@@ -17,6 +17,7 @@
         <module>hx-xmhjc</module>
     </modules>
 
+
     <properties>
         <maven.compiler.source>8</maven.compiler.source>
         <maven.compiler.target>8</maven.compiler.target>