feat(translate): 新增阿里云翻译工具类及接口

- 添加阿里云机器翻译工具类AliyunTranslateUtil
- 实现单文本和批量翻译功能
- 配置阿里云翻译相关参数
- 创建翻译控制器TranslateController
- 支持自动检测源语言翻译
- 提供翻译结果封装响应结构
This commit is contained in:
2025-12-15 15:16:46 +08:00
parent 453bc5387e
commit d78730bbcf
12 changed files with 968 additions and 0 deletions

View File

@@ -0,0 +1,160 @@
package com.gxwebsoft.common.core.controller;
import com.gxwebsoft.common.core.utils.AliyunTranslateUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 翻译控制器
* 提供文本翻译和批量翻译功能
*/
@Slf4j
@Tag(name = "翻译管理")
@RestController
@RequestMapping("/api/translate")
public class TranslateController extends BaseController {
@Resource
private AliyunTranslateUtil translateUtil;
@Operation(summary = "单文本翻译")
@PostMapping("/text")
public ApiResult<TranslateResponse> translateText(@RequestBody TranslateRequest request) {
try {
String translated = translateUtil.translate(
request.getText(),
request.getTargetLang(),
request.getSourceLang() != null ? request.getSourceLang() : "auto"
);
TranslateResponse response = new TranslateResponse();
response.setSourceText(request.getText());
response.setTranslatedText(translated);
response.setSourceLang(request.getSourceLang());
response.setTargetLang(request.getTargetLang());
return success("翻译成功", response);
} catch (Exception e) {
log.error("翻译失败", e);
return new ApiResult<>(1, "翻译失败: " + e.getMessage());
}
}
@Operation(summary = "批量翻译")
@PostMapping("/batch")
public ApiResult<BatchTranslateResponse> batchTranslate(@RequestBody BatchTranslateRequest request) {
try {
log.info("收到批量翻译请求: {}", request);
// 参数校验
if (request.getTexts() == null || request.getTexts().isEmpty()) {
return new ApiResult<>(1, "待翻译文本列表不能为空");
}
if (request.getTargetLang() == null || request.getTargetLang().isEmpty()) {
return new ApiResult<>(1, "目标语言不能为空");
}
List<TranslateResponse> results = new ArrayList<>();
for (String text : request.getTexts()) {
if (text == null || text.trim().isEmpty()) {
continue; // 跳过空文本
}
String translated = translateUtil.translate(
text,
request.getTargetLang(),
request.getSourceLang() != null ? request.getSourceLang() : "auto"
);
TranslateResponse response = new TranslateResponse();
response.setSourceText(text);
response.setTranslatedText(translated);
response.setSourceLang(request.getSourceLang());
response.setTargetLang(request.getTargetLang());
results.add(response);
}
BatchTranslateResponse batchResponse = new BatchTranslateResponse();
batchResponse.setResults(results);
batchResponse.setTotal(results.size());
return success("批量翻译成功", batchResponse);
} catch (Exception e) {
log.error("批量翻译失败,请求参数: {}", request, e);
return new ApiResult<>(1, "批量翻译失败: " + e.getMessage());
}
}
/**
* 单文本翻译请求
*/
@Data
public static class TranslateRequest {
@Parameter(description = "待翻译文本")
private String text;
@Parameter(description = "目标语言en, zh, ja, ko")
private String targetLang;
@Parameter(description = "源语言zh, en, auto默认auto自动检测")
private String sourceLang;
}
/**
* 批量翻译请求
*/
@Data
public static class BatchTranslateRequest {
@Parameter(description = "待翻译文本列表")
private List<String> texts;
@Parameter(description = "目标语言en, zh, ja, ko")
private String targetLang;
@Parameter(description = "源语言zh, en, auto默认auto自动检测")
private String sourceLang;
}
/**
* 翻译响应
*/
@Data
public static class TranslateResponse {
@Parameter(description = "原文")
private String sourceText;
@Parameter(description = "译文")
private String translatedText;
@Parameter(description = "源语言")
private String sourceLang;
@Parameter(description = "目标语言")
private String targetLang;
}
/**
* 批量翻译响应
*/
@Data
public static class BatchTranslateResponse {
@Parameter(description = "翻译结果列表")
private List<TranslateResponse> results;
@Parameter(description = "总数")
private Integer total;
}
}

View File

@@ -0,0 +1,72 @@
package com.gxwebsoft.common.core.utils;
import com.aliyun.alimt20181012.Client;
import com.aliyun.alimt20181012.models.TranslateGeneralRequest;
import com.aliyun.alimt20181012.models.TranslateGeneralResponse;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* 阿里云机器翻译工具类
*/
@Component
public class AliyunTranslateUtil {
@Value("${aliyun.translate.access-key-id:}")
private String accessKeyId;
@Value("${aliyun.translate.access-key-secret:}")
private String accessKeySecret;
@Value("${aliyun.translate.endpoint:mt.cn-hangzhou.aliyuncs.com}")
private String endpoint;
/**
* 创建客户端
*/
private Client createClient() throws Exception {
Config config = new Config()
.setAccessKeyId(accessKeyId)
.setAccessKeySecret(accessKeySecret)
.setEndpoint(endpoint);
return new Client(config);
}
/**
* 翻译文本
*
* @param text 待翻译文本
* @param targetLang 目标语言en, zh, ja, ko等
* @param sourceLang 源语言zh, en, auto等auto表示自动检测
* @return 翻译后的文本
*/
public String translate(String text, String targetLang, String sourceLang) {
try {
Client client = createClient();
TranslateGeneralRequest request = new TranslateGeneralRequest()
.setFormatType("text")
.setSourceLanguage(sourceLang)
.setTargetLanguage(targetLang)
.setSourceText(text)
.setScene("general");
TranslateGeneralResponse response = client.translateGeneral(request);
return response.getBody().getData().getTranslated();
} catch (Exception e) {
e.printStackTrace();
return text;
}
}
/**
* 翻译文本(自动检测源语言)
*
* @param text 待翻译文本
* @param targetLang 目标语言
* @return 翻译后的文本
*/
public String translate(String text, String targetLang) {
return translate(text, targetLang, "auto");
}
}

View File

@@ -0,0 +1,291 @@
package com.gxwebsoft.credit.controller;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.credit.entity.CreditUser;
import com.gxwebsoft.credit.param.CreditUserImportParam;
import com.gxwebsoft.credit.param.CreditUserParam;
import com.gxwebsoft.credit.service.CreditUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
/**
* 赊账客户表控制器
*
* @author 科技小王子
* @since 2025-12-15 13:16:04
*/
@Tag(name = "赊账客户表管理")
@RestController
@RequestMapping("/api/credit/credit-user")
public class CreditUserController extends BaseController {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Resource
private CreditUserService creditUserService;
@Operation(summary = "分页查询赊账客户表")
@GetMapping("/page")
public ApiResult<PageResult<CreditUser>> page(CreditUserParam param) {
// 使用关联查询
return success(creditUserService.pageRel(param));
}
@Operation(summary = "查询全部赊账客户表")
@GetMapping()
public ApiResult<List<CreditUser>> list(CreditUserParam param) {
// 使用关联查询
return success(creditUserService.listRel(param));
}
@Operation(summary = "根据id查询赊账客户表")
@GetMapping("/{id}")
public ApiResult<CreditUser> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(creditUserService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('credit:creditUser:save')")
@OperationLog
@Operation(summary = "添加赊账客户表")
@PostMapping()
public ApiResult<?> save(@RequestBody CreditUser creditUser) {
if (creditUserService.save(creditUser)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('credit:creditUser:update')")
@OperationLog
@Operation(summary = "修改赊账客户表")
@PutMapping()
public ApiResult<?> update(@RequestBody CreditUser creditUser) {
if (creditUserService.updateById(creditUser)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('credit:creditUser:remove')")
@OperationLog
@Operation(summary = "删除赊账客户表")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (creditUserService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('credit:creditUser:save')")
@OperationLog
@Operation(summary = "批量添加赊账客户表")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<CreditUser> list) {
if (creditUserService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('credit:creditUser:update')")
@OperationLog
@Operation(summary = "批量修改赊账客户表")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<CreditUser> batchParam) {
if (batchParam.update(creditUserService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('credit:creditUser:remove')")
@OperationLog
@Operation(summary = "批量删除赊账客户表")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (creditUserService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
/**
* 批量导入赊账客户
* Excel表头格式客户名称、唯一标识、类型、企业角色、上级ID、信息类型、所在国家、所在省份、所在城市、所在辖区、街道地址、招采单位名称、中标单位名称、中标金额、备注、是否推荐、到期时间、排序、状态、用户ID、租户ID
*/
@PreAuthorize("hasAuthority('credit:creditUser:save')")
@Operation(summary = "批量导入赊账客户")
@PostMapping("/import")
public ApiResult<List<String>> importBatch(MultipartFile file) {
ImportParams importParams = new ImportParams();
List<String> errorMessages = new ArrayList<>();
int successCount = 0;
try {
List<CreditUserImportParam> list = ExcelImportUtil.importExcel(file.getInputStream(), CreditUserImportParam.class, importParams);
User loginUser = getLoginUser();
Integer currentUserId = loginUser != null ? loginUser.getUserId() : null;
for (int i = 0; i < list.size(); i++) {
CreditUserImportParam param = list.get(i);
try {
CreditUser item = convertImportParamToEntity(param);
System.out.println("item = " + item);
// 设置默认值
if (item.getUserId() == null && currentUserId != null) {
item.setUserId(currentUserId);
}
if (item.getStatus() == null) {
item.setStatus(0);
}
if (item.getRecommend() == null) {
item.setRecommend(0);
}
if (item.getType() == null) {
item.setType(0);
}
if (item.getDeleted() == null) {
item.setDeleted(0);
}
// 验证必填字段
if (item.getName() == null || item.getName().trim().isEmpty()) {
errorMessages.add("" + (i + 1) + "行:客户名称不能为空");
continue;
}
if (item.getCode() == null || item.getCode().trim().isEmpty()) {
errorMessages.add("" + (i + 1) + "行:唯一标识不能为空");
continue;
}
if (creditUserService.save(item)) {
successCount++;
} else {
errorMessages.add("" + (i + 1) + "行:保存失败");
}
} catch (Exception e) {
errorMessages.add("" + (i + 1) + "行:" + e.getMessage());
e.printStackTrace();
}
}
if (errorMessages.isEmpty()) {
return success("成功导入" + successCount + "条数据", null);
} else {
return success("导入完成,成功" + successCount + "条,失败" + errorMessages.size() + "", errorMessages);
}
} catch (Exception e) {
e.printStackTrace();
return fail("导入失败:" + e.getMessage(), null);
}
}
/**
* 下载赊账客户导入模板
*/
@Operation(summary = "下载赊账客户导入模板")
@GetMapping("/import/template")
public void downloadTemplate(HttpServletResponse response) throws IOException {
List<CreditUserImportParam> templateList = new ArrayList<>();
CreditUserImportParam example = new CreditUserImportParam();
example.setName("示例客户");
example.setCode("CUS001");
example.setType(0);
example.setRole("采购方");
example.setParentId(0);
example.setInfoType("企业");
example.setCountry("中国");
example.setProvince("广西");
example.setCity("南宁");
example.setRegion("青秀区");
example.setAddress("民族大道1号");
example.setProcurementName("示例招采单位");
example.setWinningName("示例中标单位");
example.setWinningPrice("100000");
example.setComments("这是示例数据,请删除后填入真实数据");
example.setRecommend(0);
example.setExpirationTime("2025-12-31 23:59:59");
example.setSortNumber(1);
example.setStatus(0);
example.setUserId(1);
example.setTenantId(1);
templateList.add(example);
ExportParams exportParams = new ExportParams("赊账客户导入模板", "赊账客户");
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, CreditUserImportParam.class, templateList);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment; filename=credit_user_import_template.xlsx");
workbook.write(response.getOutputStream());
workbook.close();
}
/**
* 将CreditUserImportParam转换为CreditUser实体
*/
private CreditUser convertImportParamToEntity(CreditUserImportParam param) {
CreditUser entity = new CreditUser();
entity.setName(param.getName());
entity.setCode(param.getCode());
entity.setType(param.getType());
entity.setRole(param.getRole());
entity.setParentId(param.getParentId());
entity.setInfoType(param.getInfoType());
entity.setCountry(param.getCountry());
entity.setProvince(param.getProvince());
entity.setCity(param.getCity());
entity.setRegion(param.getRegion());
entity.setAddress(param.getAddress());
entity.setProcurementName(param.getProcurementName());
entity.setWinningName(param.getWinningName());
entity.setWinningPrice(param.getWinningPrice());
entity.setComments(param.getComments());
entity.setRecommend(param.getRecommend());
entity.setSortNumber(param.getSortNumber());
entity.setStatus(param.getStatus());
entity.setUserId(param.getUserId());
entity.setTenantId(param.getTenantId());
if (param.getExpirationTime() != null && !param.getExpirationTime().trim().isEmpty()) {
try {
entity.setExpirationTime(LocalDateTime.parse(param.getExpirationTime().trim(), DATE_TIME_FORMATTER));
} catch (Exception e) {
throw new RuntimeException("到期时间格式错误应为yyyy-MM-dd HH:mm:ss");
}
}
return entity;
}
}

View File

@@ -0,0 +1,105 @@
package com.gxwebsoft.credit.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 赊账客户表
*
* @author 科技小王子
* @since 2025-12-15 13:16:03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "CreditUser对象", description = "赊账客户表")
public class CreditUser implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@Schema(description = "客户名称")
private String name;
@Schema(description = "唯一标识")
private String code;
@Schema(description = "类型, 0普通用户, 1招投标")
private Integer type;
@Schema(description = "企业角色")
private String role;
@Schema(description = "上级id, 0是顶级")
private Integer parentId;
@Schema(description = "信息类型")
private String infoType;
@Schema(description = "所在国家")
private String country;
@Schema(description = "所在省份")
private String province;
@Schema(description = "所在城市")
private String city;
@Schema(description = "所在辖区")
private String region;
@Schema(description = "街道地址")
private String address;
@Schema(description = "招采单位名称")
private String procurementName;
@Schema(description = "中标单位名称")
private String winningName;
@Schema(description = "中标单位名称")
private String winningPrice;
@Schema(description = "备注")
private String comments;
@Schema(description = "是否推荐")
private Integer recommend;
@Schema(description = "到期时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime expirationTime;
@Schema(description = "排序(数字越小越靠前)")
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@Schema(description = "用户ID")
private Integer userId;
@Schema(description = "租户id")
private Integer tenantId;
@Schema(description = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@Schema(description = "修改时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -0,0 +1,37 @@
package com.gxwebsoft.credit.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.credit.entity.CreditUser;
import com.gxwebsoft.credit.param.CreditUserParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 赊账客户表Mapper
*
* @author 科技小王子
* @since 2025-12-15 13:16:03
*/
public interface CreditUserMapper extends BaseMapper<CreditUser> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<CreditUser>
*/
List<CreditUser> selectPageRel(@Param("page") IPage<CreditUser> page,
@Param("param") CreditUserParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<CreditUser> selectListRel(@Param("param") CreditUserParam param);
}

View File

@@ -0,0 +1,102 @@
<?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.gxwebsoft.credit.mapper.CreditUserMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM credit_user a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.code != null">
AND a.code LIKE CONCAT('%', #{param.code}, '%')
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.role != null">
AND a.role LIKE CONCAT('%', #{param.role}, '%')
</if>
<if test="param.parentId != null">
AND a.parent_id = #{param.parentId}
</if>
<if test="param.infoType != null">
AND a.info_type LIKE CONCAT('%', #{param.infoType}, '%')
</if>
<if test="param.country != null">
AND a.country LIKE CONCAT('%', #{param.country}, '%')
</if>
<if test="param.province != null">
AND a.province LIKE CONCAT('%', #{param.province}, '%')
</if>
<if test="param.city != null">
AND a.city LIKE CONCAT('%', #{param.city}, '%')
</if>
<if test="param.region != null">
AND a.region LIKE CONCAT('%', #{param.region}, '%')
</if>
<if test="param.address != null">
AND a.address LIKE CONCAT('%', #{param.address}, '%')
</if>
<if test="param.procurementName != null">
AND a.procurement_name LIKE CONCAT('%', #{param.procurementName}, '%')
</if>
<if test="param.winningName != null">
AND a.winning_name LIKE CONCAT('%', #{param.winningName}, '%')
</if>
<if test="param.winningPrice != null">
AND a.winning_price LIKE CONCAT('%', #{param.winningPrice}, '%')
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.recommend != null">
AND a.recommend = #{param.recommend}
</if>
<if test="param.expirationTime != null">
AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.credit.entity.CreditUser">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.credit.entity.CreditUser">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,99 @@
package com.gxwebsoft.credit.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 赊账客户表查询参数
*
* @author 科技小王子
* @since 2025-12-15 13:16:03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "CreditUserParam对象", description = "赊账客户表查询参数")
public class CreditUserParam extends BaseParam {
private static final long serialVersionUID = 1L;
@Schema(description = "ID")
@QueryField(type = QueryType.EQ)
private Integer id;
@Schema(description = "客户名称")
private String name;
@Schema(description = "唯一标识")
private String code;
@Schema(description = "类型, 0普通用户, 1招投标")
@QueryField(type = QueryType.EQ)
private Integer type;
@Schema(description = "企业角色")
private String role;
@Schema(description = "上级id, 0是顶级")
@QueryField(type = QueryType.EQ)
private Integer parentId;
@Schema(description = "信息类型")
private String infoType;
@Schema(description = "所在国家")
private String country;
@Schema(description = "所在省份")
private String province;
@Schema(description = "所在城市")
private String city;
@Schema(description = "所在辖区")
private String region;
@Schema(description = "街道地址")
private String address;
@Schema(description = "招采单位名称")
private String procurementName;
@Schema(description = "中标单位名称")
private String winningName;
@Schema(description = "中标单位名称")
private String winningPrice;
@Schema(description = "备注")
private String comments;
@Schema(description = "是否推荐")
@QueryField(type = QueryType.EQ)
private Integer recommend;
@Schema(description = "到期时间")
private String expirationTime;
@Schema(description = "排序(数字越小越靠前)")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@Schema(description = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
@Schema(description = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
}

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.credit.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.credit.entity.CreditUser;
import com.gxwebsoft.credit.param.CreditUserParam;
import java.util.List;
/**
* 赊账客户表Service
*
* @author 科技小王子
* @since 2025-12-15 13:16:03
*/
public interface CreditUserService extends IService<CreditUser> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<CreditUser>
*/
PageResult<CreditUser> pageRel(CreditUserParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<CreditUser>
*/
List<CreditUser> listRel(CreditUserParam param);
/**
* 根据id查询
*
* @param id ID
* @return CreditUser
*/
CreditUser getByIdRel(Integer id);
}

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.credit.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.credit.mapper.CreditUserMapper;
import com.gxwebsoft.credit.service.CreditUserService;
import com.gxwebsoft.credit.entity.CreditUser;
import com.gxwebsoft.credit.param.CreditUserParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 赊账客户表Service实现
*
* @author 科技小王子
* @since 2025-12-15 13:16:03
*/
@Service
public class CreditUserServiceImpl extends ServiceImpl<CreditUserMapper, CreditUser> implements CreditUserService {
@Override
public PageResult<CreditUser> pageRel(CreditUserParam param) {
PageParam<CreditUser, CreditUserParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<CreditUser> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<CreditUser> listRel(CreditUserParam param) {
List<CreditUser> list = baseMapper.selectListRel(param);
// 排序
PageParam<CreditUser, CreditUserParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public CreditUser getByIdRel(Integer id) {
CreditUserParam param = new CreditUserParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}

View File

@@ -56,3 +56,10 @@ certificate:
private-key-file: "apiclient_key.pem"
apiclient-cert-file: "apiclient_cert.pem"
wechatpay-cert-file: "wechatpay_cert.pem"
# 阿里云翻译配置
aliyun:
translate:
access-key-id: LTAI5tEsyhW4GCKbds1qsopg
access-key-secret: zltFlQrYVAoq2KMFDWgLa3GhkMNeyO
endpoint: mt.cn-hangzhou.aliyuncs.com

View File

@@ -71,3 +71,9 @@ payment:
key-prefix: "Payment:1"
# 缓存过期时间(小时)
expire-hours: 24
# 阿里云翻译配置
aliyun:
translate:
access-key-id: LTAI5tEsyhW4GCKbds1qsopg
access-key-secret: zltFlQrYVAoq2KMFDWgLa3GhkMNeyO
endpoint: mt.cn-hangzhou.aliyuncs.com