luyie
3 months ago
21 changed files with 309 additions and 133 deletions
@ -0,0 +1,39 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.controller; |
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; |
||||
import com.hnac.hzims.bigmodel.zhipuai.vo.ZhipuAnalysisInfoVO; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springframework.validation.annotation.Validated; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/12 20:22 |
||||
*/ |
||||
@RestController |
||||
@Api(value = "智谱分析信息管理", tags = "智谱分析信息管理") |
||||
@RequestMapping("/zhipu/info") |
||||
@AllArgsConstructor |
||||
public class ZhipuAnalysisInfoController { |
||||
private final ZhipuAnalysisInfoService analysisInfoService; |
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation("保存智谱分析信息") |
||||
@ApiOperationSupport(order = 1) |
||||
public R<Boolean> save(@RequestBody @Validated ZhipuAnalysisInfoVO request) { |
||||
return R.status(analysisInfoService.save(request.toEntity())); |
||||
} |
||||
|
||||
@GetMapping("/remove") |
||||
@ApiOperation("批量删除智谱分析信息") |
||||
@ApiOperationSupport(order = 2) |
||||
public R<Boolean> remove (@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { |
||||
return R.status(analysisInfoService.removeByIds(Func.toLongList(",",ids))); |
||||
} |
||||
} |
@ -1,25 +1,53 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/8 15:17 |
||||
*/ |
||||
@ApiModel(value ="大模型分析信息") |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@TableName("hzims_analysis_info") |
||||
public class ZhipuAnalysisInfoEntity extends BaseEntity { |
||||
|
||||
private String resultType; |
||||
@ApiModelProperty(value = "策略编码") |
||||
@TableField("CODE") |
||||
private String code; |
||||
|
||||
@ApiModelProperty(value = "策略名称") |
||||
@TableField("NAME") |
||||
private String name; |
||||
|
||||
private String code; |
||||
|
||||
@ApiModelProperty(value = "调用模型名称") |
||||
@TableField("MODEL") |
||||
private String model; |
||||
|
||||
@ApiModelProperty(value = "模型交互内容") |
||||
@TableField("REQUEST_CONTENT") |
||||
private String requestContent; |
||||
|
||||
@ApiModelProperty(value = "结果解析策略") |
||||
@TableField("RESULT_STRATEGY") |
||||
private String resultStrategy; |
||||
|
||||
@ApiModelProperty(value = "结果类型") |
||||
@TableField("RESULT_TYPE") |
||||
private String resultType; |
||||
|
||||
@ApiModelProperty(value = "结果查询key值") |
||||
@TableField("RESULT_KEY") |
||||
private String resultKey; |
||||
|
||||
@ApiModelProperty(value = "结果对比内容") |
||||
@TableField("RESULT_CONDITION") |
||||
private String resultCondition; |
||||
|
||||
} |
||||
|
@ -0,0 +1,11 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/12 20:05 |
||||
*/ |
||||
public interface ZhipuAnalysisInfoMapper extends BaseMapper<ZhipuAnalysisInfoEntity> { |
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/12 20:03 |
||||
*/ |
||||
public interface ZhipuAnalysisInfoService extends IService<ZhipuAnalysisInfoEntity> { |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; |
||||
import com.hnac.hzims.bigmodel.zhipuai.mapper.ZhipuAnalysisInfoMapper; |
||||
import com.hnac.hzims.bigmodel.zhipuai.service.ZhipuAnalysisInfoService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/12 20:03 |
||||
*/ |
||||
@Service |
||||
public class ZhipuAnalysisInfoServiceImpl extends ServiceImpl<ZhipuAnalysisInfoMapper, ZhipuAnalysisInfoEntity> implements ZhipuAnalysisInfoService { |
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.utils; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.IOException; |
||||
import java.util.Base64; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/12 21:07 |
||||
*/ |
||||
@Slf4j |
||||
public class ZhipuUtil { |
||||
|
||||
public static byte[] getFileBytes(String filePath) { |
||||
File file = new File(filePath); |
||||
FileInputStream fileInputStream = null; |
||||
try { |
||||
fileInputStream = new FileInputStream(file); |
||||
byte[] bytes = new byte[(int) file.length()]; |
||||
fileInputStream.read(bytes); |
||||
return bytes; |
||||
} catch (Exception e) { |
||||
log.error("读取文件出错", e); |
||||
} finally { |
||||
if (null != fileInputStream) { |
||||
try { |
||||
fileInputStream.close(); |
||||
} catch (IOException ignore) { |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static String getBase64(byte[] bytes) { |
||||
return Base64.getEncoder().encodeToString(bytes); |
||||
} |
||||
|
||||
public static String getBase64(String filePath) { |
||||
return getBase64(getFileBytes(filePath)); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.hnac.hzims.bigmodel.zhipuai.vo; |
||||
|
||||
import com.hnac.hzims.bigmodel.zhipuai.entity.ZhipuAnalysisInfoEntity; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
|
||||
import javax.validation.constraints.NotNull; |
||||
|
||||
/** |
||||
* @Author: ypj |
||||
* @Date: 2024/8/8 15:17 |
||||
*/ |
||||
@ApiModel(value = "大模型分析信息") |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
public class ZhipuAnalysisInfoVO { |
||||
|
||||
@ApiModelProperty(value = "策略编码") |
||||
@NotNull |
||||
private String code; |
||||
|
||||
@ApiModelProperty(value = "策略名称") |
||||
private String name; |
||||
|
||||
@ApiModelProperty(value = "调用模型名称") |
||||
@NotNull |
||||
private String model; |
||||
|
||||
@ApiModelProperty(value = "模型交互内容") |
||||
private String requestContent; |
||||
|
||||
@ApiModelProperty(value = "结果解析策略") |
||||
private String resultStrategy; |
||||
|
||||
@ApiModelProperty(value = "结果类型") |
||||
private String resultType; |
||||
|
||||
@ApiModelProperty(value = "结果查询key值") |
||||
private String resultKey; |
||||
|
||||
@ApiModelProperty(value = "结果对比内容") |
||||
private String resultCondition; |
||||
|
||||
public ZhipuAnalysisInfoEntity toEntity() { |
||||
return BeanUtil.copy(this, ZhipuAnalysisInfoEntity.class); |
||||
} |
||||
} |
Loading…
Reference in new issue