|
@@ -13,14 +13,18 @@
|
|
package vip.xiaonuo.biz.modular.customer.controller;
|
|
package vip.xiaonuo.biz.modular.customer.controller;
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
|
+import cn.hutool.http.HttpUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+import vip.xiaonuo.biz.core.sign.utils.MD5;
|
|
import vip.xiaonuo.biz.modular.customer.param.*;
|
|
import vip.xiaonuo.biz.modular.customer.param.*;
|
|
import vip.xiaonuo.common.annotation.CommonLog;
|
|
import vip.xiaonuo.common.annotation.CommonLog;
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
@@ -30,9 +34,9 @@ import vip.xiaonuo.biz.modular.customer.service.BizCustomerService;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.validation.Valid;
|
|
import jakarta.validation.Valid;
|
|
import jakarta.validation.constraints.NotEmpty;
|
|
import jakarta.validation.constraints.NotEmpty;
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 客户控制器
|
|
* 客户控制器
|
|
@@ -40,6 +44,7 @@ import java.util.Objects;
|
|
* @author fanzherong
|
|
* @author fanzherong
|
|
* @date 2025/03/21 11:44
|
|
* @date 2025/03/21 11:44
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@Tag(name = "客户控制器")
|
|
@Tag(name = "客户控制器")
|
|
@RestController
|
|
@RestController
|
|
@Validated
|
|
@Validated
|
|
@@ -130,6 +135,53 @@ public class BizCustomerController {
|
|
return CommonResult.data(bizCustomerService.detail(bizCustomerIdParam));
|
|
return CommonResult.data(bizCustomerService.detail(bizCustomerIdParam));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ // 获取时间戳单位S
|
|
|
|
+ Long timesTamp = System.currentTimeMillis()/1000;
|
|
|
|
+ System.out.println("time == " + timesTamp);
|
|
|
|
+ Map<String, String> params = new ConcurrentHashMap<>(10);
|
|
|
|
+ String appKey = "0ol2749zps9xhid1";
|
|
|
|
+ String appSecret = "e4w9ylwk7grdsdzpbcq8kcedg7ailh1c";
|
|
|
|
+ params.put("appKey",appKey);
|
|
|
|
+ params.put("timestamp",String.valueOf(timesTamp));
|
|
|
|
+ params.put("nonce","1241455595");// 自定义随机数(只能用一次)
|
|
|
|
+ params.put("appSecret",appSecret);
|
|
|
|
+ // 调用MD5算法加密生成签名
|
|
|
|
+ String signature = generateSignature(params, appSecret);
|
|
|
|
+ // 签名加入请求参数
|
|
|
|
+ params.put("sign",signature);
|
|
|
|
+ log.info("推送sign == " + signature);
|
|
|
|
+ log.info("推送参数 == " + JSON.toJSONString(params));
|
|
|
|
+ String result = HttpUtil.createPost("http://localhost:83/thirdPart/v1/customer/yongAdd").addHeaders(params).body("{}").execute().body();
|
|
|
|
+ log.info("推送结果 == " + result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static String generateSignature(final Map<String, String> data, String key) {
|
|
|
|
+ try {
|
|
|
|
+ Set<String> keySet = data.keySet();
|
|
|
|
+ String[] keyArray = keySet.toArray(new String[keySet.size()]);
|
|
|
|
+ Arrays.sort(keyArray);
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ for (String k : keyArray) {
|
|
|
|
+ if (k.equals("sign")) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // 参数值为空,则不参与签名
|
|
|
|
+ if (data.get(k).trim().length() > 0) {
|
|
|
|
+ sb.append(k).append("=").append(data.get(k).trim()).append("&");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ System.out.printf(sb.toString());
|
|
|
|
+ return MD5.md5(sb.toString());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 用友推送客户接口
|
|
* 用友推送客户接口
|
|
*
|
|
*
|
|
@@ -138,7 +190,7 @@ public class BizCustomerController {
|
|
*/
|
|
*/
|
|
@Operation(summary = "用友推送客户接口")
|
|
@Operation(summary = "用友推送客户接口")
|
|
@CommonLog("用友推送客户接口")
|
|
@CommonLog("用友推送客户接口")
|
|
- @PostMapping("/biz/customer/yongAdd")
|
|
|
|
|
|
+ @PostMapping("/thirdPart/v1/customer/yongAdd")
|
|
public CommonResult<String> yongAdd(@RequestBody @Valid BizCustomerAddParam bizCustomerAddParam) {
|
|
public CommonResult<String> yongAdd(@RequestBody @Valid BizCustomerAddParam bizCustomerAddParam) {
|
|
bizCustomerService.add(bizCustomerAddParam);
|
|
bizCustomerService.add(bizCustomerAddParam);
|
|
return CommonResult.ok();
|
|
return CommonResult.ok();
|