Prechádzať zdrojové kódy

增加小满配置管理

openHj 1 rok pred
rodič
commit
e781e25d9e

+ 62 - 0
hx-customer/src/main/java/com/fjhx/customer/controller/xiaoman/XiaomanConfigController.java

@@ -0,0 +1,62 @@
+package com.fjhx.customer.controller.xiaoman;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanConfigDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanConfigSelectDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerSelectDto;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanConfigVo;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanCustomerVo;
+import com.fjhx.customer.service.xiaoman.XiaomanConfigService;
+import com.fjhx.customer.service.xiaoman.XiaomanCustomerService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 小满配置表 前端控制器
+ * </p>
+ *
+ */
+@RestController
+@RequestMapping("/xiaomanConfig")
+public class XiaomanConfigController {
+
+
+    @Autowired
+    private XiaomanConfigService xiaomanConfigService;
+
+    /**
+     * 小满客户表分页
+     */
+    @PostMapping("/page")
+    public Page<XiaomanConfigVo> page(@RequestBody XiaomanConfigSelectDto dto) {
+        return xiaomanConfigService.getPage(dto);
+    }
+
+    /**
+     * 小满客户表明细
+     */
+    @PostMapping("/detail")
+    public XiaomanConfigVo detail(@RequestBody BaseSelectDto dto) {
+        return xiaomanConfigService.detail(dto.getId());
+    }
+
+
+    /**
+     * 小满客户表编辑
+     */
+    @PostMapping("/edit")
+    public void edit(@RequestBody XiaomanConfigDto xiaomanConfigDto) {
+        xiaomanConfigService.edit(xiaomanConfigDto);
+    }
+
+
+}

+ 15 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/xiaoman/dto/XiaomanConfigDto.java

@@ -0,0 +1,15 @@
+package com.fjhx.customer.entity.xiaoman.dto;
+
+import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 小满配置表表新增编辑入参实体
+ *
+ */
+@Getter
+@Setter
+public class XiaomanConfigDto extends XiaomanConfig {
+
+}

+ 15 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/xiaoman/dto/XiaomanConfigSelectDto.java

@@ -0,0 +1,15 @@
+package com.fjhx.customer.entity.xiaoman.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 小满配置表列表查询入参实体
+ *
+ */
+@Getter
+@Setter
+public class XiaomanConfigSelectDto extends BaseSelectDto {
+
+}

+ 17 - 0
hx-customer/src/main/java/com/fjhx/customer/entity/xiaoman/vo/XiaomanConfigVo.java

@@ -0,0 +1,17 @@
+package com.fjhx.customer.entity.xiaoman.vo;
+
+import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 小满配置表列表查询返回值实体
+ *
+ * @author lqh
+ * @since 2024-04-06
+ */
+@Getter
+@Setter
+public class XiaomanConfigVo extends XiaomanConfig {
+
+}

+ 13 - 1
hx-customer/src/main/java/com/fjhx/customer/initializers/XiaomanInitializers.java

@@ -2,13 +2,16 @@ package com.fjhx.customer.initializers;
 
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.HashUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.crypto.digest.DigestUtil;
 import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
 import com.fjhx.customer.entity.xiaoman.vo.XiaomanUpdateInfoVO;
 import com.fjhx.customer.handle.HandleXiaomanData;
 import com.fjhx.customer.service.xiaoman.XiaomanApiService;
 import com.fjhx.customer.service.xiaoman.XiaomanConfigService;
+import com.ruoyi.common.utils.sign.Md5Utils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
@@ -53,7 +56,7 @@ public class XiaomanInitializers {
         if(ObjectUtil.isNull(expireTime) || StrUtil.isBlank(config.getRefreshToken())) {
             xiaomanConfigService.getToken(config);
         } else {
-            //如果过期时间减去当前时间小于110分钟,则要刷新token
+            //如果过期时间减去当前时间小于等于70分钟,则要刷新token
             long between = DateUtil.between(DateUtil.date(), expireTime, DateUnit.MINUTE, false);
             if(between <= 70){
                 xiaomanConfigService.refreshToken(config);
@@ -67,4 +70,13 @@ public class XiaomanInitializers {
         xiaomanApiService.updateList(8);
     }
 
+
+    public static void main(String[] args) {
+
+        String styleBS63046 = DigestUtil.sha256Hex("StyleBS63046");
+        boolean equals = "07f204c3ae6af316afebb72972056fc2d4f2cac1d8290975c48f80bf5a8519b2".equals(styleBS63046);
+        System.out.println(styleBS63046);
+        System.out.println(equals);
+    }
+
 }

+ 16 - 0
hx-customer/src/main/java/com/fjhx/customer/mapper/xiaoman/XiaomanConfigMapper.java

@@ -1,7 +1,15 @@
 package com.fjhx.customer.mapper.xiaoman;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
+import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanConfigVo;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanCustomerVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 
 /**
@@ -11,5 +19,13 @@ import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
  *
  */
 public interface XiaomanConfigMapper extends BaseMapper<XiaomanConfig> {
+    /**
+     * 小满配置表列表
+     */
+    List<XiaomanConfigVo> getList(@Param("ew") IWrapper<XiaomanConfig> wrapper);
 
+    /**
+     * 小满配置表分页
+     */
+    Page<XiaomanConfigVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<XiaomanConfig> wrapper);
 }

+ 13 - 0
hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/XiaomanConfigService.java

@@ -1,6 +1,13 @@
 package com.fjhx.customer.service.xiaoman;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanConfigDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanConfigSelectDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerSelectDto;
 import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanConfigVo;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanCustomerVo;
 import com.ruoyi.common.core.service.BaseService;
 
 
@@ -17,4 +24,10 @@ public interface XiaomanConfigService extends BaseService<XiaomanConfig> {
     void refreshToken(XiaomanConfig config);
 
     XiaomanConfig getConfig();
+
+    Page<XiaomanConfigVo> getPage(XiaomanConfigSelectDto dto);
+
+    XiaomanConfigVo detail(Long id);
+
+    void edit(XiaomanConfigDto xiaomanConfigDto);
 }

+ 38 - 1
hx-customer/src/main/java/com/fjhx/customer/service/customer/impl/XiaomanConfigServiceImpl.java → hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/impl/XiaomanConfigServiceImpl.java

@@ -1,18 +1,28 @@
-package com.fjhx.customer.service.customer.impl;
+package com.fjhx.customer.service.xiaoman.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.crypto.digest.DigestUtil;
 import cn.hutool.http.Header;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanConfigDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanConfigSelectDto;
+import com.fjhx.customer.entity.xiaoman.dto.XiaomanCustomerDto;
 import com.fjhx.customer.entity.xiaoman.po.XiaomanConfig;
+import com.fjhx.customer.entity.xiaoman.po.XiaomanCustomer;
 import com.fjhx.customer.entity.xiaoman.vo.XiaoManTokenVO;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanConfigVo;
+import com.fjhx.customer.entity.xiaoman.vo.XiaomanCustomerVo;
 import com.fjhx.customer.mapper.xiaoman.XiaomanConfigMapper;
 import com.fjhx.customer.service.xiaoman.XiaomanConfigService;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
@@ -21,6 +31,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static com.ruoyi.common.utils.wrapper.IWrapper.getWrapper;
+
 /**
  * <p>
  * 小满配置表 服务实现类
@@ -83,6 +95,7 @@ public class XiaomanConfigServiceImpl extends ServiceImpl<XiaomanConfigMapper, X
     }
 
     public static XiaoManTokenVO getToken(XiaomanConfig config, String body, String url){
+        log.info("请求用户名{},请求密码:{}", config.getUsername(), config.getPassword());
         String s = HttpUtil.buildBasicAuth(config.getUsername(), config.getPassword(), Charset.forName("UTF-8"));
         Map<String, String> headers = new HashMap<>();
         headers.put(Header.AUTHORIZATION.getValue(), s);
@@ -111,4 +124,28 @@ public class XiaomanConfigServiceImpl extends ServiceImpl<XiaomanConfigMapper, X
         }
         return list.get(0);
     }
+
+
+    @Override
+    public Page<XiaomanConfigVo> getPage(XiaomanConfigSelectDto dto) {
+        IWrapper<XiaomanConfig> wrapper = getWrapper();
+        wrapper.orderByDesc("xc", XiaomanConfig::getId);
+        Page<XiaomanConfigVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        return page;
+    }
+
+    @Override
+    public XiaomanConfigVo detail(Long id) {
+        XiaomanConfig byId = this.getById(id);
+        return BeanUtil.copyProperties(byId, XiaomanConfigVo.class);
+    }
+
+    @Override
+    public void edit(XiaomanConfigDto xiaomanConfigDto) {
+        this.lambdaUpdate().set(XiaomanConfig::getUsername, xiaomanConfigDto.getUsername())
+                .set(XiaomanConfig::getPassword, StrUtil.isNotBlank(xiaomanConfigDto.getPassword())? DigestUtil.sha256Hex(xiaomanConfigDto.getPassword()) : DigestUtil.sha256Hex("#"))
+                .eq(XiaomanConfig::getId, xiaomanConfigDto.getId())
+                .update();
+        this.getToken(this.getConfig());
+    }
 }

+ 9 - 0
hx-customer/src/main/java/com/fjhx/customer/service/xiaoman/impl/XiaomanCustomerServiceImpl.java

@@ -85,6 +85,15 @@ public class XiaomanCustomerServiceImpl extends ServiceImpl<XiaomanCustomerMappe
     @Override
     public Page<XiaomanCustomerVo> getPage(XiaomanCustomerSelectDto dto) {
         IWrapper<XiaomanCustomer> wrapper = getWrapper();
+
+        if(ObjectUtil.isNotEmpty(dto.getKeyword())){
+            wrapper.and(q->q.like("xc",XiaomanCustomer::getCompanyId,dto.getKeyword()))
+                    .or().like("xc",XiaomanCustomer::getCustomerId,dto.getKeyword())
+                    .or().like("xc",XiaomanCustomer::getName,dto.getKeyword())
+                    .or().like("xc",XiaomanCustomer::getShortName,dto.getKeyword())
+            ;
+        }
+
         wrapper.orderByDesc("xc", XiaomanCustomer::getCompanyId);
         Page<XiaomanCustomerVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;

+ 42 - 0
hx-customer/src/main/resources/mapper/xiaoman/XiaomanConfigMapper.xml

@@ -0,0 +1,42 @@
+<?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.fjhx.customer.mapper.xiaoman.XiaomanConfigMapper">
+    <select id="getList" resultType="com.fjhx.customer.entity.xiaoman.vo.XiaomanConfigVo">
+        select
+            xc.id,
+            xc.client_id,
+            xc.client_secret,
+            xc.username,
+            xc.password,
+            xc.access_token,
+            xc.refresh_token,
+            xc.expire_time,
+            xc.last_token_time,
+            xc.scope,
+            xc.grant_type,
+            xc.token_url,
+            xc.refresh_token_url
+        from xiaoman_config xc
+            ${ew.customSqlSegment}
+    </select>
+
+    <select id="getPage" resultType="com.fjhx.customer.entity.xiaoman.vo.XiaomanConfigVo">
+        select
+            xc.id,
+            xc.client_id,
+            xc.client_secret,
+            xc.username,
+            xc.password,
+            xc.access_token,
+            xc.refresh_token,
+            xc.expire_time,
+            xc.last_token_time,
+            xc.scope,
+            xc.grant_type,
+            xc.token_url,
+            xc.refresh_token_url
+        from xiaoman_config xc
+            ${ew.customSqlSegment}
+    </select>
+
+</mapper>