ソースを参照

增加接口调用

humuyu 3 年 前
コミット
a7abdd9af1

+ 19 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/CochainLogService.java

@@ -0,0 +1,19 @@
+package me.zhengjie.application.admin.service;
+
+
+
+
+import me.zhengjie.base.plus.AbstractService;
+import me.zhengjie.dao.mybatis.entity.CochainLogEntity;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author humuyu
+ * @since 2022-07-25
+ */
+public interface CochainLogService extends AbstractService<CochainLogEntity> {
+
+}

+ 8 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/OrderCochainService.java

@@ -0,0 +1,8 @@
+package me.zhengjie.application.admin.service;
+
+import me.zhengjie.base.plus.AbstractService;
+import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
+
+public interface OrderCochainService extends AbstractService<OrderCochainEntity>{
+
+}

+ 43 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/CochainLogServiceImpl.java

@@ -0,0 +1,43 @@
+package me.zhengjie.application.admin.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import me.zhengjie.application.admin.service.CochainLogService;
+import me.zhengjie.application.admin.service.OrderCochainService;
+import me.zhengjie.dao.mybatis.entity.CochainLogEntity;
+import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
+import me.zhengjie.dao.mybatis.mapper.ICochainLogDao;
+
+
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author humuyu
+ * @since 2022-07-25
+ */
+@Service
+public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLogEntity> implements CochainLogService {
+
+	@Autowired
+	OrderCochainService orderCochainService;
+
+	@PostConstruct
+	public void init() {
+
+		// t.set
+		QueryWrapper<OrderCochainEntity> qw = new QueryWrapper<>();
+		qw = qw.in("is_call", "0,1").orderByAsc("update_time").last("limit 1");
+
+		OrderCochainEntity cochainEntity = orderCochainService.getOne(qw);
+		System.out.println(cochainEntity);
+	}
+}

+ 20 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/OrderCochainServiceImpl.java

@@ -0,0 +1,20 @@
+package me.zhengjie.application.admin.service.impl;
+
+import org.springframework.stereotype.Service;
+import me.zhengjie.application.admin.service.OrderCochainService;
+import me.zhengjie.base.plus.AbstractServiceImpl;
+import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
+import me.zhengjie.dao.mybatis.mapper.IOrderCochainDao;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author humuyu
+ * @since 2022-07-25
+ */
+@Service
+public class OrderCochainServiceImpl extends AbstractServiceImpl<IOrderCochainDao, OrderCochainEntity>
+		implements OrderCochainService {
+}

+ 81 - 0
eladmin-system/src/main/java/me/zhengjie/base/chain/CochainService.java

@@ -0,0 +1,81 @@
+package me.zhengjie.base.chain;
+
+import java.util.Date;
+
+import org.springframework.stereotype.Component;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+
+import cn.hutool.core.codec.Base64;
+import cn.hutool.crypto.digest.HMac;
+import cn.hutool.crypto.digest.HmacAlgorithm;
+import cn.hutool.http.HttpUtil;
+import lombok.extern.slf4j.Slf4j;
+import me.zhengjie.base.util.UUIDGenerator;
+
+@Slf4j
+@Component
+public class CochainService {
+	public static final String APP_ID = "testid";
+	public static final String APP_SECRET = "80f9b2133b240c193f09fa1842ab8ef425ac735afdf9ada10f06ca33cc7e8ca7";
+
+	public static String sha1_HMAC(String message) {
+		HMac mac = new HMac(HmacAlgorithm.HmacSHA1, APP_SECRET.getBytes());
+		String macHex1 = mac.digestHex(message);
+		return macHex1;
+	}
+
+	public static void main(String[] args) {
+//	    data = {
+//	            "app_id": APP_ID,
+//	            "key": APP_ID,
+//	            "value": {
+//	                        "platCode": APP_ID,
+//	                        "bisCode": "12121333",
+//	                        "type": "file",
+//	                        "length":"5482635",
+//	                        "time":time.time(),
+//	                        "supply": {
+//	                                    "id": "123",
+//	                                    "test": "acb"
+//	                                }
+//	                    }
+//	        }
+
+		JSONObject data = new JSONObject();
+
+		JSONObject value = new JSONObject();
+		value.put("platCode", APP_ID);
+		value.put("bisCode", "123456");
+		value.put("type", "file");
+		value.put("length", "3232321");
+		value.put("time", String.valueOf(new Date().getTime()));
+		value.put("supply", new Object());
+
+		data.put("app_id", APP_ID);
+		data.put("key", UUIDGenerator.uuid());
+		data.put("value", value);
+		// 请求接口地址
+		String url = "http://221.6.10.202:10119/cochain";
+		try {
+			// 使用基本编码
+			String json = JSON.toJSONString(data);
+			String base64encodedString = Base64.encode(json);
+			System.out.println("Base64 编码字符串(基本):" + base64encodedString);
+			String sha = sha1_HMAC(base64encodedString);
+			JSONObject content = new JSONObject();
+			content.put("content", base64encodedString);
+			content.put("signature", sha);
+			String body = HttpUtil.createPost(url)
+					.contentType("application/json")
+					.body(content.toJSONString())
+					.execute().body();
+			System.out.println(body);
+		} catch (Exception e) {
+			log.error("获取训练方案失败:", e);
+			e.printStackTrace();
+		}
+
+	}
+}

+ 7 - 0
eladmin-system/src/main/java/me/zhengjie/base/file/FileHandle.java

@@ -50,4 +50,11 @@ public interface FileHandle {
 	 * @throws Exception
 	 */
 	public byte[] getByte(String fileId) throws Exception;
+	/**
+	 * 得到文件的大小
+	 * @param keyName
+	 * @return
+	 * @throws Exception
+	 */
+	public long getSize(String keyName)throws Exception ;
 }

+ 13 - 5
eladmin-system/src/main/java/me/zhengjie/base/file/LocalFileHandle.java

@@ -15,29 +15,37 @@ public class LocalFileHandle extends AbstractFileHandle {
 
 	@Override
 	public void uploadFileStream(FileHandleVo fileHandle) throws Exception {
-		// TODO Auto-generated method stub
+		
 
 	}
 
 	@Override
-	public void uploadfilePath(FileHandleVo fileHandle) throws Exception {}
+	public void uploadfilePath(FileHandleVo fileHandle) throws Exception {
+		
+	}
 
 	@Override
 	public InputStream getObject(String objectName) throws Exception {
-		// TODO Auto-generated method stub
+		
 		return null;
 	}
 
 	@Override
 	public String getObjectUrl(String keyName) throws Exception {
-		// TODO Auto-generated method stub
+		
 		return null;
 	}
 
 	@Override
 	public byte[] getByte(String fileId) throws Exception {
-		// TODO Auto-generated method stub
+		
 		return null;
 	}
 
+	@Override
+	public long getSize(String keyName) throws Exception {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
 }

+ 6 - 0
eladmin-system/src/main/java/me/zhengjie/base/file/MinioFileHandle.java

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Component;
 
 import cn.hutool.core.io.IoUtil;
 import io.minio.MinioClient;
+import io.minio.ObjectStat;
 import io.minio.PutObjectOptions;
 import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
@@ -119,4 +120,9 @@ public class MinioFileHandle extends AbstractFileHandle {
 		//这里已经关闭流,不需要手动关闭
 		return IoUtil.readBytes(inputStream);
 	}
+	public long getSize(String keyName)throws Exception {
+		  ObjectStat stat = minioClient.statObject(bucketName, keyName);
+		  long length =  stat.length();
+		  return length;
+	}
 }

+ 14 - 0
eladmin-system/src/main/java/me/zhengjie/base/plus/AbstractService.java

@@ -1,6 +1,7 @@
 package me.zhengjie.base.plus;
 
 import java.lang.reflect.Field;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -218,6 +219,13 @@ public interface AbstractService<T> extends IService<T> {
 					case NE:
 						queryWrapper.ne(!ObjectUtils.isEmpty(fieldValue), fieldName, fieldValue);
 						break;
+					// 这里需要,修改为集合
+					case IN:
+						if (fieldValue != null && fieldValue.toString().contains(",")) {
+							List<String> result = Arrays.asList(fieldValue.toString().split(","));
+							queryWrapper.in(!ObjectUtils.isEmpty(fieldValue), fieldName, result);
+						}
+						break;
 					case GT:
 						queryWrapper.gt(!ObjectUtils.isEmpty(fieldValue), fieldName, fieldValue);
 						break;
@@ -242,6 +250,12 @@ public interface AbstractService<T> extends IService<T> {
 					case LIKE_RIGHT:
 						queryWrapper.likeRight(!ObjectUtils.isEmpty(fieldValue), fieldName, fieldValue);
 						break;
+					case DESC:
+						queryWrapper.orderByDesc(fieldName);
+						break;
+					case ASC:
+						queryWrapper.orderByAsc(fieldName);
+						break;
 					case RANGE:
 						// 设置开始的值和结束的值
 						String[] attribute = queryWapperAnnotation.attribute();

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/base/plus/QueryKeyword.java

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import lombok.AllArgsConstructor;
 
 /**
- * SQL 保留关键字枚举
+ * SQL 保留关键字枚举,{@link SqlKeyword}
  *
  * @author hubin
  * @since 2018-05-28

+ 194 - 0
eladmin-system/src/main/java/me/zhengjie/dao/mybatis/entity/CochainLogEntity.java

@@ -0,0 +1,194 @@
+package me.zhengjie.dao.mybatis.entity;
+
+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 lombok.ToString;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author humuyu
+ * @since 2022-07-25
+ */
+@TableName("cochain_log")
+@ToString
+public class CochainLogEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 业务编号
+     */
+    @TableField("business_no")
+    private String businessNo;
+
+    /**
+     * 业务编号
+     */
+    @TableField("order_id")
+    private String orderId;
+
+    /**
+     * 文件路径
+     */
+    @TableField("file_path")
+    private String filePath;
+
+    /**
+     * 每一条请求的流水
+     */
+    @TableField("bis_code")
+    private String bisCode;
+
+    /**
+     * 文件sha的值
+     */
+    @TableField("sha1_code")
+    private String sha1Code;
+
+    /**
+     * 请求参数
+     */
+    @TableField("req_param")
+    private String reqParam;
+
+    /**
+     * 返回的参数内容
+     */
+    @TableField("res_content")
+    private String resContent;
+
+    /**
+     * 1:图片,2:pdf,3:视频
+     */
+    @TableField("type")
+    private String type;
+
+    /**
+     * 调用成功0:是失败1:是成功
+     */
+    @TableField("is_call")
+    private String isCall;
+
+    /**
+     * 创建时间
+     */
+    @TableField("create_time")
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    @TableField("update_time")
+    private LocalDateTime updateTime;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getBusinessNo() {
+        return businessNo;
+    }
+
+    public void setBusinessNo(String businessNo) {
+        this.businessNo = businessNo;
+    }
+
+    public String getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(String orderId) {
+        this.orderId = orderId;
+    }
+
+    public String getFilePath() {
+        return filePath;
+    }
+
+    public void setFilePath(String filePath) {
+        this.filePath = filePath;
+    }
+
+    public String getBisCode() {
+        return bisCode;
+    }
+
+    public void setBisCode(String bisCode) {
+        this.bisCode = bisCode;
+    }
+
+    public String getSha1Code() {
+        return sha1Code;
+    }
+
+    public void setSha1Code(String sha1Code) {
+        this.sha1Code = sha1Code;
+    }
+
+    public String getReqParam() {
+        return reqParam;
+    }
+
+    public void setReqParam(String reqParam) {
+        this.reqParam = reqParam;
+    }
+
+    public String getResContent() {
+        return resContent;
+    }
+
+    public void setResContent(String resContent) {
+        this.resContent = resContent;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getIsCall() {
+        return isCall;
+    }
+
+    public void setIsCall(String isCall) {
+        this.isCall = isCall;
+    }
+
+    public LocalDateTime getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(LocalDateTime createTime) {
+        this.createTime = createTime;
+    }
+
+    public LocalDateTime getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(LocalDateTime updateTime) {
+        this.updateTime = updateTime;
+    }
+
+  
+}

+ 39 - 0
eladmin-system/src/main/java/me/zhengjie/dao/mybatis/entity/OrderCochainEntity.java

@@ -0,0 +1,39 @@
+package me.zhengjie.dao.mybatis.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import lombok.Getter;
+import lombok.Setter;
+import me.zhengjie.base.plus.QueryKeyword;
+import me.zhengjie.base.plus.QueryWapper;
+
+import java.io.Serializable;
+
+@Getter
+@Setter
+@TableName("order_cochain")
+public class OrderCochainEntity implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -6591819457657079267L;
+
+	@TableId(value = "id", type = IdType.AUTO)
+	private Integer id;
+
+	/**
+	 * 业务编号
+	 */
+	@TableField("business_no")
+	@QueryWapper(QueryKeyword.IN)
+	private String businessNo;
+	/**
+	 * 调用成功0:是失败1:是成功
+	 */
+	@QueryWapper(QueryKeyword.ASC)
+	
+	@TableField("is_call")
+	private String isCall;
+
+}

+ 21 - 0
eladmin-system/src/main/java/me/zhengjie/dao/mybatis/mapper/ICochainLogDao.java

@@ -0,0 +1,21 @@
+package me.zhengjie.dao.mybatis.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import me.zhengjie.dao.mybatis.entity.CochainLogEntity;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author humuyu
+ * @since 2022-07-25
+ */
+@Mapper
+public interface ICochainLogDao extends BaseMapper<CochainLogEntity> {
+
+}

+ 21 - 0
eladmin-system/src/main/java/me/zhengjie/dao/mybatis/mapper/IOrderCochainDao.java

@@ -0,0 +1,21 @@
+package me.zhengjie.dao.mybatis.mapper;
+
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author humuyu
+ * @since 2022-07-25
+ */
+@Mapper
+public interface IOrderCochainDao extends BaseMapper<OrderCochainEntity> {
+
+}

+ 1 - 1
eladmin-system/src/main/resources/config/application.yml

@@ -3,7 +3,7 @@ spring:
   freemarker:
     check-template-location: false
   profiles:
-    active: test
+    active: prod
   jackson:
     time-zone: GMT+8
   data: